# HG changeset patch # User Paul Boddie # Date 1543161559 -3600 # Node ID 9ce079567ad8f827bde79827dcd603d3526b949e # Parent f5aac30d8a0009b1b5b6102c190b7fff6b8612fa# Parent 032af926246bf75fcd480ec5aab2c77331409259 Merged changes from the default branch. diff -r f5aac30d8a00 -r 9ce079567ad8 moinformat/parsers/common.py --- a/moinformat/parsers/common.py Wed Sep 26 23:34:52 2018 +0200 +++ b/moinformat/parsers/common.py Sun Nov 25 16:59:19 2018 +0100 @@ -26,8 +26,9 @@ # Pattern management. ws_excl_nl = r"[ \f\r\t\v]" -quotes = "['" '"]' # ['"] -dotall = r"(.|\n)" +quotes = "['" '"]' # ['"] +dotall = r"(.|\n)" # behave similarly to dot with DOTALL option +dotparagraph = r"(.|\n(?!\r?\n))" # match everything within paragraphs def choice(l): @@ -83,6 +84,7 @@ \E with a pattern for matching all characters including newlines \N with a pattern for matching whitespace excluding newlines + \P with a pattern for matching all characters within a paragraph \Q with a pattern for matching quotation marks Group names are also qualified with a pattern name prefix. @@ -94,6 +96,7 @@ value = value.replace(r"\N", ws_excl_nl) value = value.replace(r"\Q", quotes) value = value.replace(r"\E", dotall) + value = value.replace(r"\P", dotparagraph) # Add the name to group names as a prefix. diff -r f5aac30d8a00 -r 9ce079567ad8 moinformat/parsers/moin.py --- a/moinformat/parsers/moin.py Wed Sep 26 23:34:52 2018 +0200 +++ b/moinformat/parsers/moin.py Sun Nov 25 16:59:19 2018 +0100 @@ -508,6 +508,9 @@ def inline_patterns_for(self, name): + + "Return active patterns for the inline element having the given 'name'." + names = self.inline_pattern_names[:] names[names.index(name)] = "%send" % name return names @@ -721,14 +724,34 @@ # features. "fontstyle" : group("style", repeat("'", 2, 6)), # ''... - "larger" : r"~\+", # ~+ - "monospace" : r"`", # ` + + # Trivial markup balancing is done below using the end features. + + "larger" : join((r"~\+", # ~+ + expect(r"\P*?\+~"))), # ... +~ + + "monospace" : join((r"`", # ` + expect(r"\P*?`"))), # ... ` + + "smaller" : join((r"~-", # ~- + expect(r"\P*?-~"))), # ... -~ + + "strike" : join((r"--\(", # --( + expect(r"\P*?\)--"))), # ... )-- + + "sub" : join((r",,", # ,, + expect(r"\P*?,,"))), # ... ,, + + "super" : join((r"\^", # ^ + expect(r"\P*?\^"))), # ... ^ + + "underline" : join((r"__", # __ + expect(r"\P*?__"))), # ... __ + + # Rules are treated as inline but, unlike the above, appear without + # contents. + "rule" : group("rule", "-----*"), # ----... - "smaller" : r"~-", # ~- - "strike" : r"--\(", # --( - "sub" : r",,", # ,, - "super" : r"\^", # ^ - "underline" : r"__", # __ # Links and transclusions may start inline spans. diff -r f5aac30d8a00 -r 9ce079567ad8 tests/test_formatting.tree --- a/tests/test_formatting.tree Wed Sep 26 23:34:52 2018 +0200 +++ b/tests/test_formatting.tree Sun Nov 25 16:59:19 2018 +0100 @@ -96,3 +96,12 @@ Text Verbatim Text + Break + Block + Text + Superscript + Text + Text + Break + Block + Text diff -r f5aac30d8a00 -r 9ce079567ad8 tests/test_formatting.txt --- a/tests/test_formatting.txt Wed Sep 26 23:34:52 2018 +0200 +++ b/tests/test_formatting.txt Sun Nov 25 16:59:19 2018 +0100 @@ -17,3 +17,8 @@ Some --(deleted)-- text. Some <<>>. + +Some ^superscript text +wrapped^. + +Some ^not superscript text. diff -r f5aac30d8a00 -r 9ce079567ad8 tests/test_parser.py --- a/tests/test_parser.py Wed Sep 26 23:34:52 2018 +0200 +++ b/tests/test_parser.py Sun Nov 25 16:59:19 2018 +0100 @@ -49,6 +49,7 @@ # Show HTML serialisation. metadata.set("output_format", "html") + metadata.set("mapping", {"MoinMoin" : "https://moinmo.in/"}) print serialise(d, make_serialiser(metadata)) print "-" * 60