# HG changeset patch # User Paul Boddie # Date 1635116144 -7200 # Node ID e269a9f0104069129b94d639b2d9d11e57d18691 # Parent bc2834224ef70c3d829a09ddd142cb5c4505646c Introduced block nodes inside tables produced by the table parser. This requires changes to any styling of the HTML output to avoid unwanted margins. diff -r bc2834224ef7 -r e269a9f01040 moinformat/parsers/moin.py --- a/moinformat/parsers/moin.py Mon Oct 25 00:54:05 2021 +0200 +++ b/moinformat/parsers/moin.py Mon Oct 25 00:55:44 2021 +0200 @@ -455,8 +455,8 @@ else: # Add the attributes as a node, also recording their presence. - cell.append(attrs) cell.attrs = attrs + self.add_node(cell, attrs) return # Invalid nodes were found: serialise the attributes as text. @@ -519,7 +519,7 @@ # Add the row to the table and any new table to the region. - table.add(row) + self.add_node(table, row) if new_table: self.add_node(region, new_table) diff -r bc2834224ef7 -r e269a9f01040 moinformat/parsers/table.py --- a/moinformat/parsers/table.py Mon Oct 25 00:54:05 2021 +0200 +++ b/moinformat/parsers/table.py Mon Oct 25 00:55:44 2021 +0200 @@ -19,10 +19,10 @@ this program. If not, see . """ -from moinformat.parsers.common import get_patterns, \ - excl, expect, group +from moinformat.parsers.common import get_patterns, excl, group from moinformat.parsers.moin import MoinParser -from moinformat.tree.moin import Table, TableAttrs, TableCell, TableRow, Text +from moinformat.tree.moin import Break, Table, TableAttrs, TableCell, \ + TableRow, Text from moinformat.tree.table import Continuation join = "".join @@ -53,6 +53,7 @@ row = TableRow([cell]) table = Table([row]) self.append_node(self.region, table) + self.new_block(cell) while True: self.parse_region_details(cell, self.region_pattern_names) @@ -68,6 +69,7 @@ cell = TableCell([], leading=self.match_group("leading"), padding=self.match_group("padding")) row.append(cell) + self.new_block(cell) elif pattern == "rowsep": row = TableRow([], leading=self.match_group("leading"), @@ -75,6 +77,7 @@ table.append(row) cell = TableCell([]) row.append(cell) + self.new_block(cell) # Parser handler methods. @@ -83,9 +86,16 @@ "Handle continuation padding." feature = self.match_group("feature") - cell.append(Continuation(feature)) + self.append_inline(cell, Continuation(feature)) + + def parse_table_attrs(self, cell): + "Handle the start of table attributes within 'cell'." + MoinParser.parse_table_attrs(self, cell) + + if isinstance(cell.node(-1), TableAttrs): + self.new_block(cell) # Regular expressions. @@ -139,6 +149,7 @@ "continuation" : parse_continuation, "rowsep" : end_region, "regionend" : parse_table_end, + "tableattrs" : parse_table_attrs, }) parser = TableParser diff -r bc2834224ef7 -r e269a9f01040 moinformat/themes/default/css/all.css --- a/moinformat/themes/default/css/all.css Mon Oct 25 00:54:05 2021 +0200 +++ b/moinformat/themes/default/css/all.css Mon Oct 25 00:55:44 2021 +0200 @@ -7,3 +7,7 @@ border: 1px solid #000; padding: 0.5em; } + +td p { + margin: inherit; +} diff -r bc2834224ef7 -r e269a9f01040 moinformat/themes/mercurial/css/all.css --- a/moinformat/themes/mercurial/css/all.css Mon Oct 25 00:54:05 2021 +0200 +++ b/moinformat/themes/mercurial/css/all.css Mon Oct 25 00:55:44 2021 +0200 @@ -52,6 +52,10 @@ border: 1pt solid #ADB9CC; } +td p { + margin: inherit; +} + /* Preformatted text. */ pre { diff -r bc2834224ef7 -r e269a9f01040 tests/test_continuation.tree --- a/tests/test_continuation.tree Mon Oct 25 00:54:05 2021 +0200 +++ b/tests/test_continuation.tree Mon Oct 25 00:55:44 2021 +0200 @@ -3,21 +3,25 @@ Table TableRow TableCell - FontStyle - Text + Block + FontStyle + Text TableCell - FontStyle - Text + Block + FontStyle + Text TableRow TableCell - Text + Block + Text TableCell - Link - LinkLabel - Text - Continuation - Link - LinkLabel - Text - Text + Block + Link + LinkLabel + Text + Continuation + Link + LinkLabel + Text + Text Block diff -r bc2834224ef7 -r e269a9f01040 tests/test_table_parser.tree --- a/tests/test_table_parser.tree Mon Oct 25 00:54:05 2021 +0200 +++ b/tests/test_table_parser.tree Mon Oct 25 00:55:44 2021 +0200 @@ -6,15 +6,19 @@ Table TableRow TableCell - FontStyle + Block + FontStyle + Text + TableCell + Block + Text + TableRow + TableCell + Block Text TableCell - Text - TableRow - TableCell - Text - TableCell - Text + Block + Text Break Block Text @@ -25,18 +29,51 @@ TableCell TableAttrs TableAttr - Text + Block + Text TableCell TableAttrs TableAttr - Text + Block + Text TableRow TableCell TableAttrs TableAttr - Text + Block + Text TableCell TableAttrs TableAttr - Text + Block + Text + Break + Break + Region + Table + TableRow + TableCell + Break + Block + Text + TableCell + Block + Text + TableRow + TableCell + Block + Text + TableCell + Block + Text + TableRow + TableCell + Block + Text + Break + Block + Text + TableCell + Block + Text Block diff -r bc2834224ef7 -r e269a9f01040 tests/test_table_parser.txt --- a/tests/test_table_parser.txt Mon Oct 25 00:54:05 2021 +0200 +++ b/tests/test_table_parser.txt Mon Oct 25 00:55:44 2021 +0200 @@ -18,3 +18,24 @@ Bottom || Top }}} + + +{{{#!table + +Padded, no break + +|| + +Padded, no break + +== + +No preceding break +|| No succeeding break + +== + +No preceding break + +Separated by break || Some text +}}}