1.1 --- a/moinformat/parsers/moin.py Wed Aug 01 13:32:10 2018 +0200
1.2 +++ b/moinformat/parsers/moin.py Wed Aug 01 13:33:59 2018 +0200
1.3 @@ -25,7 +25,7 @@
1.4
1.5 # Parser functionality and pattern definition.
1.6
1.7 -from moinformat.parsers.common import ParserBase, get_patterns, \
1.8 +from moinformat.parsers.common import ParserBase, get_patterns, choice, \
1.9 excl, expect, group, optional, recur, \
1.10 repeat
1.11
1.12 @@ -162,9 +162,15 @@
1.13 term = DefTerm([], pad)
1.14 self.parse_region_details(term, ["deftermend", "deftermsep"])
1.15 self.add_node(region, term)
1.16 +
1.17 if self.matching_pattern() == "deftermsep":
1.18 self.parse_defitem(region)
1.19
1.20 + # Add padding from the separator to the term, there being no item.
1.21 +
1.22 + else:
1.23 + term.extra = self.match_group("pad")
1.24 +
1.25 def parse_defterm_empty(self, region):
1.26
1.27 "Handle an empty definition term within 'region'."
1.28 @@ -564,8 +570,7 @@
1.29
1.30 "defterm_empty" : join(("^",
1.31 group("pad", r"\N+"), # ws...
1.32 - expect("::\s+"))), # ::
1.33 - # ws... (optional)
1.34 + expect("::\s+"))), # :: ws...
1.35
1.36 "heading" : join(("^",
1.37 group("extra", r"\N*"), # ws... (optional)
1.38 @@ -665,9 +670,17 @@
1.39 # nl
1.40
1.41 "deftermsep" : join(("::", group("pad", r"\s+"))), # ::
1.42 - # ws... (optional)
1.43 + # ws...
1.44
1.45 - "listitemend" : r"^", # next line
1.46 + "listitemend" : join((r"^", # next line
1.47 + choice((excl(r"\N"), # without indent
1.48 + expect(r"\N+\*"), # or with ws... list-marker
1.49 + expect(r"\N+\d\."), # or with ws... decimal-marker
1.50 + expect(r"\N+[aA]\."), # or with ws... alpha-marker
1.51 + expect(r"\N+[iI]\."), # or with ws... roman-marker
1.52 + expect(r"\N+\."), # or with ws... dot-marker
1.53 + expect(r"\N+.+?::\s"), # or with ws... text :: ws (next defterm)
1.54 + expect(r"\N+::\s"))))), # or with ws... :: ws (next defitem)
1.55
1.56 # Table contents:
1.57