[GeneralDiscussion] applied to stable: fix excerptAt to pass its test

[email protected] (stable-repo)
Newsgroups gmane.comp.web.zope.zwiki
Message-ID <20080502033901.AB758465CCD__9509.00519169426$1209699646$gmane$org@mail.joyful.com>
Thu May  1 20:38:40 PDT 2008  [email protected]
  * fix excerptAt to pass its test
diff -rN -u old-ZWiki/Utils.py new-ZWiki/Utils.py
--- old-ZWiki/Utils.py	2008-05-01 20:39:01.000000000 -0700
+++ new-ZWiki/Utils.py	2008-05-01 20:39:01.000000000 -0700
@@ -197,10 +197,12 @@
         else:
             excerpt = html_quote(toencoded(text[:size]))
         if highlight:
-            excerpt = re.sub(
-                r'(?i)'+re.escape(html_quote(toencoded(string))),
-                '<span class="hit" style="background-color:yellow;font-weight:bold;">%s</span>' % html_quote(toencoded(string)),
-                excerpt)
+            highlightstring = m and m.group() or string
+            if highlightstring:
+                excerpt = re.sub(
+                    r'(?i)'+re.escape(html_quote(toencoded(string))),
+                    '<span class="hit" style="background-color:yellow;font-weight:bold;">%s</span>' % html_quote(toencoded(highlightstring)),
+                    excerpt)
         excerpt = toencoded(excerpt)
         return excerpt
 

--
forwarded from http://zwiki.org/GeneralDiscussion#[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.