changeset 3506:6b6851d0a3c8

search: match categories even if there are comment lines
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 14 Apr 2008 23:00:59 +0200
parents cd43bbf56c33
children 792fd08a05b6 87c26058d9c0
files MoinMoin/search/queryparser.py
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/queryparser.py	Mon Apr 14 18:47:57 2008 +0200
+++ b/MoinMoin/search/queryparser.py	Mon Apr 14 23:00:59 2008 +0200
@@ -747,9 +747,20 @@
         self._tag = 'category:'
 
     def _build_re(self, pattern, **kwargs):
+        """ match categories like this:
+            ... some page text ...
+            ----
+            ## optionally some comments, e.g. about possible categories:
+            ## CategoryFoo
+            CategoryTheRealAndOnly
+
+            Note: there might be multiple comment lines, but all real categories
+                  must be on a single line either directly below the ---- or
+                  directly below some comment lines.
+        """
         kwargs['use_re'] = True
         TextSearch._build_re(self,
-                r'(----(-*)(\r)?\n)(.*)\b%s\b' % pattern, **kwargs)
+                r'(?m)(^-----*\r?\n)(^##.*\r?\n)*^(?!##)(.*)\b%s\b' % pattern, **kwargs)
 
     def costs(self):
         return 5000 # cheaper than a TextSearch