1.1 --- a/moinformat/parsers/table.py Mon Oct 25 00:54:05 2021 +0200
1.2 +++ b/moinformat/parsers/table.py Mon Oct 25 00:55:44 2021 +0200
1.3 @@ -19,10 +19,10 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from moinformat.parsers.common import get_patterns, \
1.8 - excl, expect, group
1.9 +from moinformat.parsers.common import get_patterns, excl, group
1.10 from moinformat.parsers.moin import MoinParser
1.11 -from moinformat.tree.moin import Table, TableAttrs, TableCell, TableRow, Text
1.12 +from moinformat.tree.moin import Break, Table, TableAttrs, TableCell, \
1.13 + TableRow, Text
1.14 from moinformat.tree.table import Continuation
1.15
1.16 join = "".join
1.17 @@ -53,6 +53,7 @@
1.18 row = TableRow([cell])
1.19 table = Table([row])
1.20 self.append_node(self.region, table)
1.21 + self.new_block(cell)
1.22
1.23 while True:
1.24 self.parse_region_details(cell, self.region_pattern_names)
1.25 @@ -68,6 +69,7 @@
1.26 cell = TableCell([], leading=self.match_group("leading"),
1.27 padding=self.match_group("padding"))
1.28 row.append(cell)
1.29 + self.new_block(cell)
1.30
1.31 elif pattern == "rowsep":
1.32 row = TableRow([], leading=self.match_group("leading"),
1.33 @@ -75,6 +77,7 @@
1.34 table.append(row)
1.35 cell = TableCell([])
1.36 row.append(cell)
1.37 + self.new_block(cell)
1.38
1.39 # Parser handler methods.
1.40
1.41 @@ -83,9 +86,16 @@
1.42 "Handle continuation padding."
1.43
1.44 feature = self.match_group("feature")
1.45 - cell.append(Continuation(feature))
1.46 + self.append_inline(cell, Continuation(feature))
1.47 +
1.48 + def parse_table_attrs(self, cell):
1.49
1.50 + "Handle the start of table attributes within 'cell'."
1.51
1.52 + MoinParser.parse_table_attrs(self, cell)
1.53 +
1.54 + if isinstance(cell.node(-1), TableAttrs):
1.55 + self.new_block(cell)
1.56
1.57 # Regular expressions.
1.58
1.59 @@ -139,6 +149,7 @@
1.60 "continuation" : parse_continuation,
1.61 "rowsep" : end_region,
1.62 "regionend" : parse_table_end,
1.63 + "tableattrs" : parse_table_attrs,
1.64 })
1.65
1.66 parser = TableParser