Are you sure you want to highlight the words in your HTML document. This problem is complex (using a safe will not help you). Suppose your content is:
<h1>my title</h1> my content
If the custom content type is in the search box, you'll want to get something like this:
<h1>my title</h1> my <em>content</em>
But wait a minute, what if the user enters h1 in the search. If you apply the algorithm naively, you will get:
<<em>h1</em>>my title</<em>h1</em>> my content
So, to solve the problem, the marker should:
- HTML parsing.
- highlight in the analyzed document.
- Print a document.
Unfortunately, I donβt know if anyone wrote such a large liner for a haystack. But you can write your own. This explains how: http://django-haystack.readthedocs.org/en/latest/highlighting.html
source share