# HG changeset patch # User Paul Boddie # Date 1342132796 -7200 # Node ID 5440cd6c8a9e0ab7d39d3784aa5726d3e60e4c33 # Parent 43371b8d3dc1337d9dde62ca860d981143649595 Added line continuation syntax so that column text can be indented. diff -r 43371b8d3dc1 -r 5440cd6c8a9e ImprovedTableParser.py --- a/ImprovedTableParser.py Wed Jul 11 00:47:30 2012 +0200 +++ b/ImprovedTableParser.py Fri Jul 13 00:39:56 2012 +0200 @@ -23,6 +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 # At start of column text: "column" : (r"^\s*<(.*?)>\s*(.*)", re.DOTALL), # ws < attributes > ws @@ -124,6 +125,10 @@ for text in patterns["columns"].split(row_text): + # Replace line continuation strings. + + text = patterns["continuations"].sub("", text) + # Only create a new column when a boundary has been found. if not column_continued: diff -r 43371b8d3dc1 -r 5440cd6c8a9e README.txt --- a/README.txt Wed Jul 11 00:47:30 2012 +0200 +++ b/README.txt Fri Jul 13 00:39:56 2012 +0200 @@ -109,7 +109,8 @@ New in ImprovedTableParser 0.3 (Changes since ImprovedTableParser 0.2) ---------------------------------------------------------------------- - * Moved various functions to MoinSupport. + * Added line continuation syntax for column text. + * Moved parsing and formatting functions to MoinSupport. New in ImprovedTableParser 0.2 (Changes since ImprovedTableParser 0.1) ---------------------------------------------------------------------- diff -r 43371b8d3dc1 -r 5440cd6c8a9e pages/HelpOnImprovedTableParser --- a/pages/HelpOnImprovedTableParser Wed Jul 11 00:47:30 2012 +0200 +++ b/pages/HelpOnImprovedTableParser Fri Jul 13 00:39:56 2012 +0200 @@ -81,6 +81,24 @@ until the next row or the end of the table }}} +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 +}}} + +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: + +{{{#!table +First column || Second column + .. ...this should be part of + .. the same paragraph, but isn't +}}} + +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 43371b8d3dc1 -r 5440cd6c8a9e tests/test_table.py --- a/tests/test_table.py Wed Jul 11 00:47:30 2012 +0200 +++ b/tests/test_table.py Fri Jul 13 00:39:56 2012 +0200 @@ -40,17 +40,21 @@ 1 || 2 || 3 == 2 || 3 +== +The first column || The second + .. with the continuation of + .. the text without indentation occurring. """ attrs, rows = parse(table) -expected = 11 +expected = 12 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]): +for (row_attrs, columns), expected in zip(rows, [3, 2, 3, 3, 3, 2, 2, 2, 3, 3, 2, 2]): print row_attrs print columns non_continuation_columns = [ @@ -63,4 +67,8 @@ print len(non_continuation_columns) == expected, ": length is", len(non_continuation_columns), "==", expected print +expected_text = "The second\nwith the continuation of\nthe text without indentation occurring.\n" +text = rows[11][1][1][1] +print text == expected_text, ": text is", repr(text) + # vim: tabstop=4 expandtab shiftwidth=4