1.1 --- a/moinformat/parsers/common.py Sat Nov 24 18:10:14 2018 +0100
1.2 +++ b/moinformat/parsers/common.py Sun Nov 25 16:57:15 2018 +0100
1.3 @@ -26,8 +26,9 @@
1.4 # Pattern management.
1.5
1.6 ws_excl_nl = r"[ \f\r\t\v]"
1.7 -quotes = "['" '"]' # ['"]
1.8 -dotall = r"(.|\n)"
1.9 +quotes = "['" '"]' # ['"]
1.10 +dotall = r"(.|\n)" # behave similarly to dot with DOTALL option
1.11 +dotparagraph = r"(.|\n(?!\r?\n))" # match everything within paragraphs
1.12
1.13 def choice(l):
1.14
1.15 @@ -91,6 +92,7 @@
1.16 value = value.replace(r"\N", ws_excl_nl)
1.17 value = value.replace(r"\Q", quotes)
1.18 value = value.replace(r"\E", dotall)
1.19 + value = value.replace(r"\P", dotparagraph)
1.20 patterns[name] = get_pattern(value)
1.21 return patterns
1.22
2.1 --- a/moinformat/parsers/moin.py Sat Nov 24 18:10:14 2018 +0100
2.2 +++ b/moinformat/parsers/moin.py Sun Nov 25 16:57:15 2018 +0100
2.3 @@ -508,6 +508,9 @@
2.4
2.5
2.6 def inline_patterns_for(self, name):
2.7 +
2.8 + "Return active patterns for the inline element having the given 'name'."
2.9 +
2.10 names = self.inline_pattern_names[:]
2.11 names[names.index(name)] = "%send" % name
2.12 return names
2.13 @@ -721,14 +724,34 @@
2.14 # features.
2.15
2.16 "fontstyle" : group("style", repeat("'", 2, 6)), # ''...
2.17 - "larger" : r"~\+", # ~+
2.18 - "monospace" : r"`", # `
2.19 +
2.20 + # Trivial markup balancing is done below using the end features.
2.21 +
2.22 + "larger" : join((r"~\+", # ~+
2.23 + expect(r"\P*?\+~"))), # ... +~
2.24 +
2.25 + "monospace" : join((r"`", # `
2.26 + expect(r"\P*?`"))), # ... `
2.27 +
2.28 + "smaller" : join((r"~-", # ~-
2.29 + expect(r"\P*?-~"))), # ... -~
2.30 +
2.31 + "strike" : join((r"--\(", # --(
2.32 + expect(r"\P*?\)--"))), # ... )--
2.33 +
2.34 + "sub" : join((r",,", # ,,
2.35 + expect(r"\P*?,,"))), # ... ,,
2.36 +
2.37 + "super" : join((r"\^", # ^
2.38 + expect(r"\P*?\^"))), # ... ^
2.39 +
2.40 + "underline" : join((r"__", # __
2.41 + expect(r"\P*?__"))), # ... __
2.42 +
2.43 + # Rules are treated as inline but, unlike the above, appear without
2.44 + # contents.
2.45 +
2.46 "rule" : group("rule", "-----*"), # ----...
2.47 - "smaller" : r"~-", # ~-
2.48 - "strike" : r"--\(", # --(
2.49 - "sub" : r",,", # ,,
2.50 - "super" : r"\^", # ^
2.51 - "underline" : r"__", # __
2.52
2.53 # Links and transclusions may start inline spans.
2.54
4.1 --- a/tests/test_formatting.txt Sat Nov 24 18:10:14 2018 +0100
4.2 +++ b/tests/test_formatting.txt Sun Nov 25 16:57:15 2018 +0100
4.3 @@ -17,3 +17,8 @@
4.4 Some --(deleted)-- text.
4.5
4.6 Some <<<verbatim, __not underlined__ text>>>.
4.7 +
4.8 +Some ^superscript text
4.9 +wrapped^.
4.10 +
4.11 +Some ^not superscript text.