X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/fa9ab52217a8e6912fa4677fc7bb1da21044b470..c54df654d0d513e91167a53454c5c2fdcd166752:/apps/search/templatetags/search_tags.py diff --git a/apps/search/templatetags/search_tags.py b/apps/search/templatetags/search_tags.py index 6a2ccad44..57734c10c 100644 --- a/apps/search/templatetags/search_tags.py +++ b/apps/search/templatetags/search_tags.py @@ -46,6 +46,9 @@ def book_searched(context, result): continue snip = result.snippets[idx] # fix some formattting + snip = re.subn(r"(^[ \t\n]+|[ \t\n]+$)", u"", + re.subn(r"[ \t\n]*\n[ \t\n]*", u"\n", snip)) + snip = snip.replace("\n", "
").replace('---', '—') hit['snippet'] = snip @@ -54,6 +57,6 @@ def book_searched(context, result): 'book': book, 'main_link': book.get_absolute_url(), 'request': context.get('request'), - 'hits': zip(*hits)[1], + 'hits': hits and zip(*hits)[1] or [], 'main_link': book.get_absolute_url(), }