# HG changeset patch # User Paul Boddie # Date 1493312727 -7200 # Node ID aad3a95320c36b90fc528bf48996222adba1c5b0 # Parent 41a90c24c3979467631162181e4e1a2a1ef25118 Employ separate patterns for region start and end markers. diff -r 41a90c24c397 -r aad3a95320c3 moinformat.py --- a/moinformat.py Thu Apr 27 18:54:12 2017 +0200 +++ b/moinformat.py Thu Apr 27 19:05:27 2017 +0200 @@ -26,7 +26,8 @@ syntax = { # Page regions: - "marker" : (r"^\s*([{]{3,}|[}]{3,})", re.MULTILINE | re.DOTALL), # {{{... or }}}... + "regionstart" : (r"^\s*([{]{3,})", re.MULTILINE | re.DOTALL), # {{{... + "regionend" : (r"^\s*([}]{3,})", re.MULTILINE | re.DOTALL), # }}}... # Region contents: "header" : (r"#!(.*?)\n", 0), # #! char-excl-nl @@ -101,9 +102,6 @@ self.level = level self.type = type - def have_start(self, s): - return self.is_transparent() and s.startswith("{") - def have_end(self, s): return self.level and s.startswith("}") and self.level == len(s) @@ -334,7 +332,7 @@ # Obtain text before any marker or the end of the input. - preceding = items.read_until(["break", "marker"]) + preceding = items.read_until(["break", "regionstart", "regionend"]) if preceding: block.append(Text(preceding)) @@ -349,7 +347,7 @@ # Start a section if an appropriate marker is given. - if region.have_start(feature): + if items.matching == "regionstart": # Define the section and parse it. @@ -366,7 +364,7 @@ # given marker is the corresponding end marker for the current # section. - elif region.have_end(feature): + elif items.matching == "regionend" and region.have_end(feature): break # Start a new block if a paragraph break is found. @@ -393,7 +391,7 @@ # Obtain text before any marker or the end of the input. - preceding = items.read_until(["marker"]) + preceding = items.read_until(["regionend"]) if preceding: region.append(Text(preceding))