Skip to content

Commit

Permalink
OPEN-2790 New filter tag to strip <p>...</p> from text
Browse files Browse the repository at this point in the history
  • Loading branch information
thriuin committed Nov 15, 2023
1 parent 206210b commit ead8245
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions search/templatetags/search_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from dateutil import parser
import json
import markdown2
import re
from search.query import url_part_unescape


Expand Down Expand Up @@ -173,6 +174,11 @@ def markdown_filter(text):
return bleach.linkify(html)


@register.filter('strip_paragraph')
def strip_paragraph(text):
return re.sub("(^<P>|</P>$)", "", text, flags=re.IGNORECASE)


@register.filter('url_part_unescape')
def url_part_unescape_filter(value: str):
return url_part_unescape(value)
Expand Down

0 comments on commit ead8245

Please sign in to comment.