1.1 --- a/moinformat/parsers/moin.py Fri Jun 03 21:54:37 2022 +0200
1.2 +++ b/moinformat/parsers/moin.py Sun Dec 11 23:58:02 2022 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Moin wiki format parser.
1.6
1.7 -Copyright (C) 2017, 2018, 2019, 2020 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2017, 2018, 2019, 2020, 2022 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -38,11 +38,11 @@
1.13 from moinformat.tree.moin import Anchor, Break, Comment, DefItem, DefTerm, \
1.14 Directive, FontStyle, Heading, Larger, \
1.15 LineBreak, Link, LinkLabel, LinkParameter, \
1.16 - List, ListItem, Macro, Monospace, Region, \
1.17 - Rule, Smaller, Strikethrough, Subscript, \
1.18 - Superscript, Table, TableAttr, TableAttrs, \
1.19 - TableCell, TableRow, Text, Transclusion, \
1.20 - Underline, Verbatim
1.21 + List, ListItem, Macro, Monospace, \
1.22 + NonBreakingSpace, Region, Rule, Smaller, \
1.23 + Strikethrough, Subscript, Superscript, Table, \
1.24 + TableAttr, TableAttrs, TableCell, TableRow, \
1.25 + Text, Transclusion, Underline, Verbatim
1.26
1.27 # Link parsing.
1.28
1.29 @@ -648,6 +648,9 @@
1.30
1.31 self.root.macros.append(macro)
1.32
1.33 + def parse_nbsp(self, region):
1.34 + region.append_inline(NonBreakingSpace())
1.35 +
1.36 def parse_verbatim(self, region):
1.37 text = self.match_group("verbatim")
1.38 region.append_inline(Verbatim(text))
1.39 @@ -828,6 +831,8 @@
1.40 r"\)"))), # ) (optional)
1.41 ">>")), # >>
1.42
1.43 + "nbsp" : r"\\_", # \_
1.44 +
1.45 "verbatim" : join(("<<<", # <<<
1.46 group("verbatim", r"\P*?"), # ...
1.47 ">>>")),
1.48 @@ -924,7 +929,7 @@
1.49
1.50 inline_without_links_pattern_names = [
1.51 "anchor", "fontstyle", "larger", "linebreak", "macro",
1.52 - "monospace", "regionstart", "smaller", "strike", "sub", "super",
1.53 + "monospace", "nbsp", "regionstart", "smaller", "strike", "sub", "super",
1.54 "underline", "verbatim"
1.55 ]
1.56
1.57 @@ -989,6 +994,7 @@
1.58 "linkend" : end_region,
1.59 "linksep" : end_region,
1.60 "macro" : parse_macro,
1.61 + "nbsp" : parse_nbsp,
1.62 "listitemend" : end_region,
1.63 "listitem" : parse_listitem,
1.64 "listitem_alpha" : parse_listitem,
4.1 --- a/moinformat/tree/moin.py Fri Jun 03 21:54:37 2022 +0200
4.2 +++ b/moinformat/tree/moin.py Sun Dec 11 23:58:02 2022 +0100
4.3 @@ -3,7 +3,7 @@
4.4 """
4.5 Moin wiki format document tree nodes.
4.6
4.7 -Copyright (C) 2017, 2018, 2019, 2020, 2021 Paul Boddie <paul@boddie.org.uk>
4.8 +Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
4.9
4.10 This program is free software; you can redistribute it and/or modify it under
4.11 the terms of the GNU General Public License as published by the Free Software
4.12 @@ -778,6 +778,19 @@
4.13 def to_string(self, out):
4.14 out.linebreak()
4.15
4.16 +class NonBreakingSpace(Node):
4.17 +
4.18 + "A non-breaking space within a block."
4.19 +
4.20 + def __repr__(self):
4.21 + return "NonBreakingSpace()"
4.22 +
4.23 + def prettyprint(self, indent=""):
4.24 + return "%sNonBreakingSpace" % indent
4.25 +
4.26 + def to_string(self, out):
4.27 + out.nbsp()
4.28 +
4.29 class Rule(Node):
4.30
4.31 "A horizontal rule."