diff --git a/src/colab/utils/highlighting.py b/src/colab/utils/highlighting.py index 353d84b..8f41b7c 100644 --- a/src/colab/utils/highlighting.py +++ b/src/colab/utils/highlighting.py @@ -1,8 +1,15 @@ from haystack.utils import Highlighter from django.conf import settings +from django.utils.html import escape, strip_tags class ColabHighlighter(Highlighter): + def highlight(self, text_block): + self.text_block = escape(strip_tags(text_block)) + highlight_locations = self.find_highlightable_words() + start_offset, end_offset = self.find_window(highlight_locations) + return self.render_html(highlight_locations, start_offset, end_offset) + def find_window(self, highlight_locations): """Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting to find how many characters before the first word found should -- libgit2 0.21.2