1.1 --- a/moinformat/parsers/moin.py Mon Oct 25 00:54:05 2021 +0200
1.2 +++ b/moinformat/parsers/moin.py Mon Oct 25 00:55:44 2021 +0200
1.3 @@ -455,8 +455,8 @@
1.4 else:
1.5 # Add the attributes as a node, also recording their presence.
1.6
1.7 - cell.append(attrs)
1.8 cell.attrs = attrs
1.9 + self.add_node(cell, attrs)
1.10 return
1.11
1.12 # Invalid nodes were found: serialise the attributes as text.
1.13 @@ -519,7 +519,7 @@
1.14
1.15 # Add the row to the table and any new table to the region.
1.16
1.17 - table.add(row)
1.18 + self.add_node(table, row)
1.19 if new_table:
1.20 self.add_node(region, new_table)
1.21
2.1 --- a/moinformat/parsers/table.py Mon Oct 25 00:54:05 2021 +0200
2.2 +++ b/moinformat/parsers/table.py Mon Oct 25 00:55:44 2021 +0200
2.3 @@ -19,10 +19,10 @@
2.4 this program. If not, see <http://www.gnu.org/licenses/>.
2.5 """
2.6
2.7 -from moinformat.parsers.common import get_patterns, \
2.8 - excl, expect, group
2.9 +from moinformat.parsers.common import get_patterns, excl, group
2.10 from moinformat.parsers.moin import MoinParser
2.11 -from moinformat.tree.moin import Table, TableAttrs, TableCell, TableRow, Text
2.12 +from moinformat.tree.moin import Break, Table, TableAttrs, TableCell, \
2.13 + TableRow, Text
2.14 from moinformat.tree.table import Continuation
2.15
2.16 join = "".join
2.17 @@ -53,6 +53,7 @@
2.18 row = TableRow([cell])
2.19 table = Table([row])
2.20 self.append_node(self.region, table)
2.21 + self.new_block(cell)
2.22
2.23 while True:
2.24 self.parse_region_details(cell, self.region_pattern_names)
2.25 @@ -68,6 +69,7 @@
2.26 cell = TableCell([], leading=self.match_group("leading"),
2.27 padding=self.match_group("padding"))
2.28 row.append(cell)
2.29 + self.new_block(cell)
2.30
2.31 elif pattern == "rowsep":
2.32 row = TableRow([], leading=self.match_group("leading"),
2.33 @@ -75,6 +77,7 @@
2.34 table.append(row)
2.35 cell = TableCell([])
2.36 row.append(cell)
2.37 + self.new_block(cell)
2.38
2.39 # Parser handler methods.
2.40
2.41 @@ -83,9 +86,16 @@
2.42 "Handle continuation padding."
2.43
2.44 feature = self.match_group("feature")
2.45 - cell.append(Continuation(feature))
2.46 + self.append_inline(cell, Continuation(feature))
2.47 +
2.48 + def parse_table_attrs(self, cell):
2.49
2.50 + "Handle the start of table attributes within 'cell'."
2.51
2.52 + MoinParser.parse_table_attrs(self, cell)
2.53 +
2.54 + if isinstance(cell.node(-1), TableAttrs):
2.55 + self.new_block(cell)
2.56
2.57 # Regular expressions.
2.58
2.59 @@ -139,6 +149,7 @@
2.60 "continuation" : parse_continuation,
2.61 "rowsep" : end_region,
2.62 "regionend" : parse_table_end,
2.63 + "tableattrs" : parse_table_attrs,
2.64 })
2.65
2.66 parser = TableParser
3.1 --- a/moinformat/themes/default/css/all.css Mon Oct 25 00:54:05 2021 +0200
3.2 +++ b/moinformat/themes/default/css/all.css Mon Oct 25 00:55:44 2021 +0200
3.3 @@ -7,3 +7,7 @@
3.4 border: 1px solid #000;
3.5 padding: 0.5em;
3.6 }
3.7 +
3.8 +td p {
3.9 + margin: inherit;
3.10 +}
4.1 --- a/moinformat/themes/mercurial/css/all.css Mon Oct 25 00:54:05 2021 +0200
4.2 +++ b/moinformat/themes/mercurial/css/all.css Mon Oct 25 00:55:44 2021 +0200
4.3 @@ -52,6 +52,10 @@
4.4 border: 1pt solid #ADB9CC;
4.5 }
4.6
4.7 +td p {
4.8 + margin: inherit;
4.9 +}
4.10 +
4.11 /* Preformatted text. */
4.12
4.13 pre {
7.1 --- a/tests/test_table_parser.txt Mon Oct 25 00:54:05 2021 +0200
7.2 +++ b/tests/test_table_parser.txt Mon Oct 25 00:55:44 2021 +0200
7.3 @@ -18,3 +18,24 @@
7.4 <style="vertical-align: bottom"> Bottom
7.5 ||<style="vertical-align: top"> Top
7.6 }}}
7.7 +
7.8 +
7.9 +{{{#!table
7.10 +
7.11 +Padded, no break
7.12 +
7.13 +||
7.14 +
7.15 +Padded, no break
7.16 +
7.17 +==
7.18 +
7.19 +No preceding break
7.20 +|| No succeeding break
7.21 +
7.22 +==
7.23 +
7.24 +No preceding break
7.25 +
7.26 +Separated by break || Some text
7.27 +}}}