1.1 --- a/moinformat.py Thu Apr 27 18:54:12 2017 +0200
1.2 +++ b/moinformat.py Thu Apr 27 19:05:27 2017 +0200
1.3 @@ -26,7 +26,8 @@
1.4
1.5 syntax = {
1.6 # Page regions:
1.7 - "marker" : (r"^\s*([{]{3,}|[}]{3,})", re.MULTILINE | re.DOTALL), # {{{... or }}}...
1.8 + "regionstart" : (r"^\s*([{]{3,})", re.MULTILINE | re.DOTALL), # {{{...
1.9 + "regionend" : (r"^\s*([}]{3,})", re.MULTILINE | re.DOTALL), # }}}...
1.10
1.11 # Region contents:
1.12 "header" : (r"#!(.*?)\n", 0), # #! char-excl-nl
1.13 @@ -101,9 +102,6 @@
1.14 self.level = level
1.15 self.type = type
1.16
1.17 - def have_start(self, s):
1.18 - return self.is_transparent() and s.startswith("{")
1.19 -
1.20 def have_end(self, s):
1.21 return self.level and s.startswith("}") and self.level == len(s)
1.22
1.23 @@ -334,7 +332,7 @@
1.24
1.25 # Obtain text before any marker or the end of the input.
1.26
1.27 - preceding = items.read_until(["break", "marker"])
1.28 + preceding = items.read_until(["break", "regionstart", "regionend"])
1.29 if preceding:
1.30 block.append(Text(preceding))
1.31
1.32 @@ -349,7 +347,7 @@
1.33
1.34 # Start a section if an appropriate marker is given.
1.35
1.36 - if region.have_start(feature):
1.37 + if items.matching == "regionstart":
1.38
1.39 # Define the section and parse it.
1.40
1.41 @@ -366,7 +364,7 @@
1.42 # given marker is the corresponding end marker for the current
1.43 # section.
1.44
1.45 - elif region.have_end(feature):
1.46 + elif items.matching == "regionend" and region.have_end(feature):
1.47 break
1.48
1.49 # Start a new block if a paragraph break is found.
1.50 @@ -393,7 +391,7 @@
1.51
1.52 # Obtain text before any marker or the end of the input.
1.53
1.54 - preceding = items.read_until(["marker"])
1.55 + preceding = items.read_until(["regionend"])
1.56 if preceding:
1.57 region.append(Text(preceding))
1.58