protected function cleanup()
 {
     parent::cleanup();
     $start = mb_strpos($this->data, $this->partToken) + mb_strlen($this->partToken);
     $end = mb_strrpos($this->data, $this->partToken);
     $this->data = mb_substr($this->data, $start, $end - $start);
 }
    </textarea>
    <!-- foobar -->
    <strong class="foobar">bar</strong>
  </body>
</html>
';
$expected = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>foobar</title></head><body><p>I am prety <h>foobar</h></p><script>
      foobar
    </script><style type="text/stylesheet">
      foobar
    </style><textarea>
      foobar
    </textarea><!-- foobar --><strong class="foobar">bar</strong></body></html>
';
$keyword = new sfLuceneHighlighterKeywordNamed(new sfLuceneHighlighterMarkerSprint('<h>%s</h>'), 'foobar');
$highlighter = new sfLuceneHighlighterHTML($xml);
$highlighter->addKeywords(array($keyword));
$highlighter->highlight();
$t->is($highlighter->export(), $expected, '->highlight() highlights only the HTML content and works with the namespace correctly');
// ********************************************
// ********************************************
$xml = '<p>I am pretty foobar</p>';
$expected = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><p>I am pretty <h>foobar</h></p></body></html>
';
$keyword = new sfLuceneHighlighterKeywordNamed(new sfLuceneHighlighterMarkerSprint('<h>%s</h>'), 'foobar');
$highlighter = new sfLuceneHighlighterHTML($xml);
$highlighter->addKeywords(array($keyword));
$highlighter->highlight();
$t->is($highlighter->export(), $expected, '->highlight() transforms and highlights the document if it is invalid HTML');