function highlight_keywords($text, $keywords, $sprint = '<strong class="highlight">%s</strong>')
{
    $highlighter = new sfLuceneHighlighterXHTMLPart($text);
    $highlighter->setMasterDtd(sfConfig::get('app_lucene_xhtml_dtd', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'));
    $marker = new sfLuceneHighlighterMarkerSprint($sprint);
    $harness = new sfLuceneHighlighterMarkerHarness(array($marker));
    $keywords = sfLuceneHighlighterKeywordNamedInsensitive::explode($harness, $keywords);
    $highlighter->addKeywords($keywords);
    return $highlighter->highlight()->export();
}
 * (c) 2007 - 2008 Carl Vondrick <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * @package sfLucenePlugin
 * @subpackage Test
 * @author Carl Vondrick
 * @version SVN: $Id$
 */
require dirname(__FILE__) . '/../../../bootstrap/unit.php';
$t = new limeade_test(15, limeade_output::get());
$highlighter = new sfLuceneHighlighterMarkerDry();
try {
    $kw = new sfLuceneHighlighterKeywordNamedInsensitive($highlighter, 'FOOBAR');
    $t->pass('__construct() accepts a valid highlighter and valid name');
} catch (Exception $e) {
    $t->fail('__construct() accepts a valid highlighter and valid name');
}
$t->is($kw->getHighlighter(), $highlighter, '->getHighlighter() returns the correct highlighter');
$t->is($kw->getName(), 'FOOBAR', '->getName() returns the correct name');
$t->is($kw->getLength(), 6, '->getLength() returns the correct length');
$got = $kw->tokenize('Foobar is my favorite foobar, but it needs the bar to be foobar');
$expected = array(new sfLuceneHighlighterToken($kw, 'Foobar', 0, 6), new sfLuceneHighlighterToken($kw, 'foobar', 22, 28), new sfLuceneHighlighterToken($kw, 'foobar', 57, 63));
$t->is($got, $expected, '->tokenize() returns correct positions for case-insensitivity');
$t->is_deeply($kw->tokenize('nothing interesting here.  move along!'), array(), '->tokenize() returns nothing if it does not appear in the string');
$t->is($kw->tokenize('mr foobar, where are the foobars?'), array(new sfLuceneHighlighterToken($kw, 'foobar', 3, 9)), '->tokenize() only tokenizes exact matches');
$lighters = array(new sfLuceneHighlighterMarkerUppercase(), new sfLuceneHighlighterMarkerSprint('[h]%s[/h]'));
$harness = new sfLuceneHighlighterMarkerHarness($lighters);
$keywords = sfLuceneHighlighterKeywordNamedInsensitive::generate($harness, array('a', 'b', 'c'));
 protected function prepareTerms($terms)
 {
     $highlighters = sfLuceneHighlighterMarkerSprint::generate($this->getParameter('highlight_strings'));
     return sfLuceneHighlighterKeywordNamedInsensitive::explode($highlighters, mb_strtolower($terms));
 }