1.1 --- a/moinformat/parsers/moin.py Thu Aug 16 17:51:57 2018 +0200
1.2 +++ b/moinformat/parsers/moin.py Wed Sep 26 23:34:05 2018 +0200
1.3 @@ -42,7 +42,7 @@
1.4 Rule, Smaller, Strikethrough, Subscript, \
1.5 Superscript, Table, TableAttr, TableAttrs, \
1.6 TableCell, TableRow, Text, Transclusion, \
1.7 - Underline
1.8 + Underline, Verbatim
1.9
1.10 join = "".join
1.11
1.12 @@ -607,6 +607,10 @@
1.13
1.14 self.root.macros.append(macro)
1.15
1.16 + def parse_verbatim(self, region):
1.17 + text = self.match_group("verbatim")
1.18 + region.append_inline(Verbatim(text))
1.19 +
1.20
1.21
1.22 # Table attribute handlers.
1.23 @@ -755,6 +759,10 @@
1.24 r"\)"))), # ) (optional)
1.25 ">>")), # >>
1.26
1.27 + "verbatim" : join(("<<<", # <<<
1.28 + group("verbatim", ".*?"), # ...
1.29 + ">>>")),
1.30 +
1.31 # Ending patterns for inline features:
1.32
1.33 "largerend" : r"\+~", # +~
1.34 @@ -845,7 +853,7 @@
1.35 inline_without_links_pattern_names = [
1.36 "anchor", "fontstyle", "larger", "linebreak", "macro",
1.37 "monospace", "regionstart", "smaller", "strike", "sub", "super",
1.38 - "underline",
1.39 + "underline", "verbatim"
1.40 ]
1.41
1.42 inline_pattern_names = inline_without_links_pattern_names + [
1.43 @@ -939,6 +947,7 @@
1.44 "underline" : parse_underline,
1.45 "underlineend" : end_region,
1.46 "valign" : parse_valign,
1.47 + "verbatim" : parse_verbatim,
1.48 "width" : parse_width,
1.49 }
1.50
2.1 --- a/moinformat/serialisers/html/moin.py Thu Aug 16 17:51:57 2018 +0200
2.2 +++ b/moinformat/serialisers/html/moin.py Wed Sep 26 23:34:05 2018 +0200
2.3 @@ -305,6 +305,9 @@
2.4 def transclusion(self, target, nodes):
2.5 self._link(target, nodes, "img", "src")
2.6
2.7 + def verbatim(self, s):
2.8 + self.text(s)
2.9 +
2.10 serialiser = HTMLSerialiser
2.11
2.12 # vim: tabstop=4 expandtab shiftwidth=4
3.1 --- a/moinformat/serialisers/moin/moin.py Thu Aug 16 17:51:57 2018 +0200
3.2 +++ b/moinformat/serialisers/moin/moin.py Wed Sep 26 23:34:05 2018 +0200
3.3 @@ -228,6 +228,11 @@
3.4 node.to_string(self)
3.5 self.out("}}")
3.6
3.7 + def verbatim(self, text):
3.8 + self.out("<<<")
3.9 + self.out(text)
3.10 + self.out(">>>")
3.11 +
3.12 serialiser = MoinSerialiser
3.13
3.14 # vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/moinformat/tree/moin.py Thu Aug 16 17:51:57 2018 +0200
4.2 +++ b/moinformat/tree/moin.py Wed Sep 26 23:34:05 2018 +0200
4.3 @@ -806,4 +806,20 @@
4.4 def to_string(self, out):
4.5 out.text(self.s)
4.6
4.7 +class Verbatim(Node):
4.8 +
4.9 + "Verbatim text."
4.10 +
4.11 + def __init__(self, text):
4.12 + self.text = text
4.13 +
4.14 + def __repr__(self):
4.15 + return "Verbatim(%r)" % self.text
4.16 +
4.17 + def prettyprint(self, indent=""):
4.18 + return "%sVerbatim: text=%r" % (indent, self.text)
4.19 +
4.20 + def to_string(self, out):
4.21 + out.verbatim(self.text)
4.22 +
4.23 # vim: tabstop=4 expandtab shiftwidth=4
6.1 --- a/tests/test_formatting.txt Thu Aug 16 17:51:57 2018 +0200
6.2 +++ b/tests/test_formatting.txt Wed Sep 26 23:34:05 2018 +0200
6.3 @@ -15,3 +15,5 @@
6.4 ~+Larger...+~ and ~-smaller-~
6.5
6.6 Some --(deleted)-- text.
6.7 +
6.8 +Some <<<verbatim, __not underlined__ text>>>.