1.1 --- a/MoinContentSupport.py Mon Feb 21 01:55:43 2011 +0100
1.2 +++ b/MoinContentSupport.py Sat Feb 26 21:45:56 2011 +0100
1.3 @@ -17,7 +17,10 @@
1.4 # NOTE: These overlap with ImprovedMoinSearch and EventAggregator.
1.5
1.6 heading_regexp = re.compile(r"^(?P<level>=+)\s*(?P<heading>.*?)\s*(?P=level)$", re.UNICODE | re.MULTILINE)
1.7 -category_membership_regexp = re.compile(ur"^\s*(?:(Category\S+)(?:\s+(Category\S+))*)\s*$", re.MULTILINE | re.UNICODE)
1.8 +
1.9 +category_membership_str = ur"^\s*(?:(Category\S+)(?:\s+(Category\S+))*)\s*$"
1.10 +category_membership_regexp = re.compile(category_membership_str, re.MULTILINE | re.UNICODE)
1.11 +category_declarations_regexp = re.compile("^----$\s*" + category_membership_str, re.MULTILINE | re.UNICODE)
1.12
1.13 def getHeadingDetails(body, min_level=None, max_level=None):
1.14
1.15 @@ -52,7 +55,17 @@
1.16 else:
1.17 return []
1.18
1.19 -def getCategoryDeclaration(categories):
1.20 +def getCategoryDeclarations(body):
1.21 +
1.22 + """
1.23 + From the given 'body', return the category declaration sections in the page
1.24 + in the form of a list of tuples, each containing a list of categories, the
1.25 + start of the declaration region and the end of the region.
1.26 + """
1.27 +
1.28 + return [([x for x in match.groups() if x], match.span()) for match in category_declarations_regexp.finditer(body)]
1.29 +
1.30 +def makeCategoryDeclaration(categories):
1.31
1.32 "Return a category declaration string for the given 'categories'."
1.33