From: Marcin Koziej Date: Mon, 10 Sep 2012 13:03:18 +0000 (+0200) Subject: snippet format fixs X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/d6c2be651d0cc889b1dbc5b73c7659a8a2ff7704?ds=inline snippet format fixs --- diff --git a/apps/search/templatetags/search_tags.py b/apps/search/templatetags/search_tags.py index 555edd2fe..a167f024d 100644 --- a/apps/search/templatetags/search_tags.py +++ b/apps/search/templatetags/search_tags.py @@ -34,7 +34,7 @@ def book_searched(context, result): hits = filter(lambda (idx, h): result.snippets[idx] is not None or 'fragment' in h, enumerate(result.hits)) - print "[tmpl: from %d hits selected %d]" % (len(result.hits), len(hits)) + # print "[tmpl: from %d hits selected %d]" % (len(result.hits), len(hits)) for (idx, hit) in hits: # currently we generate one snipper per hit though. @@ -43,7 +43,7 @@ def book_searched(context, result): 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)) + re.subn(r"[ \t\n]*\n[ \t\n]*", u"\n", snip)[0])[0] snip = snip.replace("\n", "
").replace('---', '—') hit['snippet'] = snip