# HG changeset patch # User Paul Boddie # Date 1342134191 -7200 # Node ID d08ffb65157d7abf25602c72ed699338620e4809 # Parent 5440cd6c8a9e0ab7d39d3784aa5726d3e60e4c33 Prevented false recognition of line continuation markers. Improved the documentation for the line continuation syntax. diff -r 5440cd6c8a9e -r d08ffb65157d ImprovedTableParser.py --- a/ImprovedTableParser.py Fri Jul 13 00:39:56 2012 +0200 +++ b/ImprovedTableParser.py Fri Jul 13 01:03:11 2012 +0200 @@ -23,7 +23,7 @@ # Within text: "markers" : (r"([{]{3,}|[}]{3,})", re.MULTILINE | re.DOTALL), # {{{... or }}}... "columns" : (r"\|\|[ \t]*", 0), # || ws-excl-nl - "continuations" : (r"^\s*\.\.[ \t]?", re.MULTILINE), # .. ws-excl-nl + "continuations" : (r"^\s*\.\.(?!\.)[ \t]?", re.MULTILINE), # .. ws-excl-nl or .. not-dot # At start of column text: "column" : (r"^\s*<(.*?)>\s*(.*)", re.DOTALL), # ws < attributes > ws diff -r 5440cd6c8a9e -r d08ffb65157d pages/HelpOnImprovedTableParser --- a/pages/HelpOnImprovedTableParser Fri Jul 13 00:39:56 2012 +0200 +++ b/pages/HelpOnImprovedTableParser Fri Jul 13 01:03:11 2012 +0200 @@ -81,24 +81,48 @@ until the next row or the end of the table }}} +==== Indented Column Text and Line Continuation ==== + Sometimes it can be convenient to present a table in a formatted fashion, with alignment of column content even when viewed as plain text. However, this can present problems with indentation: +{{{{ +{{{#!table +First column || Second column + ...this should be part of the same paragraph, + but isn't until now. +}}} +}}}} + +The result is as follows: + {{{#!table First column || Second column - ...this should be part of - the same paragraph, but isn't + ...this should be part of the same paragraph, + but isn't until now. }}} -To achieve the desired effect, a line continuation syntax is available that prevents !MoinMoin from treating the second and subsequent lines as being indented paragraphs: +Note how !MoinMoin lost one of the dots on the second line of the second column's text. This is a feature of the Wiki text parser. + +To achieve the desired effect, a line continuation syntax is available that prevents !MoinMoin from treating the second and subsequent lines as indented paragraph text: + +{{{{ +{{{#!table +First column || Second column + .. ...this should be part of the same paragraph, and it now is, + .. as is this text. +}}} +}}}} + +Note that the `..` marker must be the first non-space characters on a line: it is not a column separator, and does not therefore provide a way of writing column content side by side. + +The result is this: {{{#!table First column || Second column - .. ...this should be part of - .. the same paragraph, but isn't + .. ...this should be part of the same paragraph, and it now is, + .. as is this text. }}} -Note that the `..` marker must be the first non-space characters on a line: it is not a column separator, and does not therefore provide a way of writing column content side by side. - ==== Styles and Formatting ==== Style and formatting options are placed at the start of a row or column inside `<` and `>` markers, with the options corresponding to HTML attributes as described for the [[HelpOnTables|default syntax for tables]] being supported. diff -r 5440cd6c8a9e -r d08ffb65157d tests/test_table.py --- a/tests/test_table.py Fri Jul 13 00:39:56 2012 +0200 +++ b/tests/test_table.py Fri Jul 13 01:03:11 2012 +0200 @@ -44,17 +44,20 @@ The first column || The second .. with the continuation of .. the text without indentation occurring. +== +A test || Of... + ...non-continuation """ attrs, rows = parse(table) -expected = 12 +expected = 13 print table print attrs print rows print len(rows) == expected, ": length is", len(rows), "==", expected print -for (row_attrs, columns), expected in zip(rows, [3, 2, 3, 3, 3, 2, 2, 2, 3, 3, 2, 2]): +for (row_attrs, columns), expected in zip(rows, [3, 2, 3, 3, 3, 2, 2, 2, 3, 3, 2, 2, 2]): print row_attrs print columns non_continuation_columns = [ @@ -71,4 +74,8 @@ text = rows[11][1][1][1] print text == expected_text, ": text is", repr(text) +expected_text = "Of...\n ...non-continuation\n" +text = rows[12][1][1][1] +print text == expected_text, ": text is", repr(text) + # vim: tabstop=4 expandtab shiftwidth=4