# HG changeset patch # User Paul Boddie # Date 1537997692 -7200 # Node ID f5aac30d8a0009b1b5b6102c190b7fff6b8612fa # Parent cf512c95f3d43bf788a3b21a1af05e44c8b838fc# Parent 20e4d2fb3f9c7e01670aa1778d5f4176b8b794fd Merged changes from the default branch. diff -r cf512c95f3d4 -r f5aac30d8a00 moinformat/parsers/moin.py --- a/moinformat/parsers/moin.py Thu Aug 16 17:52:17 2018 +0200 +++ b/moinformat/parsers/moin.py Wed Sep 26 23:34:52 2018 +0200 @@ -42,7 +42,7 @@ Rule, Smaller, Strikethrough, Subscript, \ Superscript, Table, TableAttr, TableAttrs, \ TableCell, TableRow, Text, Transclusion, \ - Underline + Underline, Verbatim join = "".join @@ -607,6 +607,10 @@ self.root.macros.append(macro) + def parse_verbatim(self, region): + text = self.match_group("verbatim") + region.append_inline(Verbatim(text)) + # Table attribute handlers. @@ -755,6 +759,10 @@ r"\)"))), # ) (optional) ">>")), # >> + "verbatim" : join(("<<<", # <<< + group("verbatim", ".*?"), # ... + ">>>")), + # Ending patterns for inline features: "largerend" : r"\+~", # +~ @@ -845,7 +853,7 @@ inline_without_links_pattern_names = [ "anchor", "fontstyle", "larger", "linebreak", "macro", "monospace", "regionstart", "smaller", "strike", "sub", "super", - "underline", + "underline", "verbatim" ] inline_pattern_names = inline_without_links_pattern_names + [ @@ -939,6 +947,7 @@ "underline" : parse_underline, "underlineend" : end_region, "valign" : parse_valign, + "verbatim" : parse_verbatim, "width" : parse_width, } diff -r cf512c95f3d4 -r f5aac30d8a00 moinformat/serialisers/html/moin.py --- a/moinformat/serialisers/html/moin.py Thu Aug 16 17:52:17 2018 +0200 +++ b/moinformat/serialisers/html/moin.py Wed Sep 26 23:34:52 2018 +0200 @@ -305,6 +305,9 @@ def transclusion(self, target, nodes): self._link(target, nodes, "img", "src") + def verbatim(self, s): + self.text(s) + serialiser = HTMLSerialiser # vim: tabstop=4 expandtab shiftwidth=4 diff -r cf512c95f3d4 -r f5aac30d8a00 moinformat/serialisers/moin/moin.py --- a/moinformat/serialisers/moin/moin.py Thu Aug 16 17:52:17 2018 +0200 +++ b/moinformat/serialisers/moin/moin.py Wed Sep 26 23:34:52 2018 +0200 @@ -228,6 +228,11 @@ node.to_string(self) self.out("}}") + def verbatim(self, text): + self.out("<<<") + self.out(text) + self.out(">>>") + serialiser = MoinSerialiser # vim: tabstop=4 expandtab shiftwidth=4 diff -r cf512c95f3d4 -r f5aac30d8a00 moinformat/tree/moin.py --- a/moinformat/tree/moin.py Thu Aug 16 17:52:17 2018 +0200 +++ b/moinformat/tree/moin.py Wed Sep 26 23:34:52 2018 +0200 @@ -806,4 +806,20 @@ def to_string(self, out): out.text(self.s) +class Verbatim(Node): + + "Verbatim text." + + def __init__(self, text): + self.text = text + + def __repr__(self): + return "Verbatim(%r)" % self.text + + def prettyprint(self, indent=""): + return "%sVerbatim: text=%r" % (indent, self.text) + + def to_string(self, out): + out.verbatim(self.text) + # vim: tabstop=4 expandtab shiftwidth=4 diff -r cf512c95f3d4 -r f5aac30d8a00 tests/test_formatting.tree --- a/tests/test_formatting.tree Thu Aug 16 17:52:17 2018 +0200 +++ b/tests/test_formatting.tree Wed Sep 26 23:34:52 2018 +0200 @@ -91,3 +91,8 @@ Strikethrough Text Text + Break + Block + Text + Verbatim + Text diff -r cf512c95f3d4 -r f5aac30d8a00 tests/test_formatting.txt --- a/tests/test_formatting.txt Thu Aug 16 17:52:17 2018 +0200 +++ b/tests/test_formatting.txt Wed Sep 26 23:34:52 2018 +0200 @@ -15,3 +15,5 @@ ~+Larger...+~ and ~-smaller-~ Some --(deleted)-- text. + +Some <<>>.