# HG changeset patch # User Paul Boddie # Date 1493906692 -7200 # Node ID 700dd2d1431543e9b5ca74a77223a02d48c88cfc # Parent 9e46f5b6929f30aff8b873d0a360f597381db56f Use serialisation to convert ill-formed table rows back to text. diff -r 9e46f5b6929f -r 700dd2d14315 moinformat/__init__.py --- a/moinformat/__init__.py Wed May 03 18:16:06 2017 +0200 +++ b/moinformat/__init__.py Thu May 04 16:04:52 2017 +0200 @@ -19,6 +19,7 @@ this program. If not, see . """ +from moinformat.serialisers import serialise from moinformat.tree import Block, Break, DefItem, DefTerm, FontStyle, Heading, \ Larger, ListItem, Monospace, Region, Rule, Smaller, \ Subscript, Superscript, TableAttr, TableAttrs, \ @@ -478,15 +479,9 @@ # If the cell was started but not finished, convert the row into text. if not row.nodes or not cell.empty(): - region.append_inline(Text("||")) - - # Convert all cells. - for node in row.nodes: - region.append_inline_many(node.nodes) - region.append_inline(Text("||")) - - region.append_inline_many(cell.nodes) + region.append_inline(Text(serialise(node))) + region.append_inline(Text(serialise(cell))) region.append_inline(Text(trailing)) new_block(region) diff -r 9e46f5b6929f -r 700dd2d14315 moinformat/serialisers.py --- a/moinformat/serialisers.py Wed May 03 18:16:06 2017 +0200 +++ b/moinformat/serialisers.py Thu May 04 16:04:52 2017 +0200 @@ -133,16 +133,18 @@ self.out(">") def start_table_cell(self, attrs): + self.out("||") if attrs and not attrs.empty(): attrs.to_string(self) def end_table_cell(self): - self.out("||") + pass def start_table_row(self): - self.out("||") + pass def end_table_row(self, trailing): + self.out("||") self.out(trailing) def start_underline(self):