1.1 --- a/MoinContentSupport.py Sun Feb 20 21:15:05 2011 +0100
1.2 +++ b/MoinContentSupport.py Sun Feb 20 22:02:35 2011 +0100
1.3 @@ -14,9 +14,10 @@
1.4 __version__ = "0.1"
1.5
1.6 # Regular expressions.
1.7 -# NOTE: These overlap with ImprovedMoinSearch.
1.8 +# NOTE: These overlap with ImprovedMoinSearch and EventAggregator.
1.9
1.10 heading_regexp = re.compile(r"^(?P<level>=+)\s*(?P<heading>.*?)\s*(?P=level)$", re.UNICODE | re.MULTILINE)
1.11 +category_membership_regexp = re.compile(ur"^\s*(?:(Category\S+)(?:\s+(Category\S+))*)\s*$", re.MULTILINE | re.UNICODE)
1.12
1.13 def getHeadingDetails(body, min_level=None, max_level=None):
1.14
1.15 @@ -41,6 +42,22 @@
1.16
1.17 return headings
1.18
1.19 +def getCategoryMembership(body):
1.20 +
1.21 + "From the given 'body', return the categories the page belongs to."
1.22 +
1.23 + match = category_membership_regexp.search(body)
1.24 + if match:
1.25 + return [x for x in match.groups() if x]
1.26 + else:
1.27 + return []
1.28 +
1.29 +def getCategoryDeclaration(categories):
1.30 +
1.31 + "Return a category declaration string for the given 'categories'."
1.32 +
1.33 + return "\n----\n%s\n" % " ".join(categories)
1.34 +
1.35 # Utility classes and associated functions.
1.36 # NOTE: These are a subset of EventAggregatorSupport.
1.37