1.1 --- a/ImprovedTableParser.py Wed Jul 11 00:47:30 2012 +0200
1.2 +++ b/ImprovedTableParser.py Fri Jul 13 00:39:56 2012 +0200
1.3 @@ -23,6 +23,7 @@
1.4 # Within text:
1.5 "markers" : (r"([{]{3,}|[}]{3,})", re.MULTILINE | re.DOTALL), # {{{... or }}}...
1.6 "columns" : (r"\|\|[ \t]*", 0), # || ws-excl-nl
1.7 + "continuations" : (r"^\s*\.\.[ \t]?", re.MULTILINE), # .. ws-excl-nl
1.8
1.9 # At start of column text:
1.10 "column" : (r"^\s*<(.*?)>\s*(.*)", re.DOTALL), # ws < attributes > ws
1.11 @@ -124,6 +125,10 @@
1.12
1.13 for text in patterns["columns"].split(row_text):
1.14
1.15 + # Replace line continuation strings.
1.16 +
1.17 + text = patterns["continuations"].sub("", text)
1.18 +
1.19 # Only create a new column when a boundary has been found.
1.20
1.21 if not column_continued:
2.1 --- a/README.txt Wed Jul 11 00:47:30 2012 +0200
2.2 +++ b/README.txt Fri Jul 13 00:39:56 2012 +0200
2.3 @@ -109,7 +109,8 @@
2.4 New in ImprovedTableParser 0.3 (Changes since ImprovedTableParser 0.2)
2.5 ----------------------------------------------------------------------
2.6
2.7 - * Moved various functions to MoinSupport.
2.8 + * Added line continuation syntax for column text.
2.9 + * Moved parsing and formatting functions to MoinSupport.
2.10
2.11 New in ImprovedTableParser 0.2 (Changes since ImprovedTableParser 0.1)
2.12 ----------------------------------------------------------------------
3.1 --- a/pages/HelpOnImprovedTableParser Wed Jul 11 00:47:30 2012 +0200
3.2 +++ b/pages/HelpOnImprovedTableParser Fri Jul 13 00:39:56 2012 +0200
3.3 @@ -81,6 +81,24 @@
3.4 until the next row or the end of the table
3.5 }}}
3.6
3.7 +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:
3.8 +
3.9 +{{{#!table
3.10 +First column || Second column
3.11 + ...this should be part of
3.12 + the same paragraph, but isn't
3.13 +}}}
3.14 +
3.15 +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:
3.16 +
3.17 +{{{#!table
3.18 +First column || Second column
3.19 + .. ...this should be part of
3.20 + .. the same paragraph, but isn't
3.21 +}}}
3.22 +
3.23 +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.
3.24 +
3.25 ==== Styles and Formatting ====
3.26
3.27 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.
4.1 --- a/tests/test_table.py Wed Jul 11 00:47:30 2012 +0200
4.2 +++ b/tests/test_table.py Fri Jul 13 00:39:56 2012 +0200
4.3 @@ -40,17 +40,21 @@
4.4 <rowspan=2> 1 || 2 || 3
4.5 ==
4.6 <rowstyle="background-color: #f33"> 2 || 3
4.7 +==
4.8 +The first column || The second
4.9 + .. with the continuation of
4.10 + .. the text without indentation occurring.
4.11 """
4.12
4.13 attrs, rows = parse(table)
4.14 -expected = 11
4.15 +expected = 12
4.16
4.17 print table
4.18 print attrs
4.19 print rows
4.20 print len(rows) == expected, ": length is", len(rows), "==", expected
4.21 print
4.22 -for (row_attrs, columns), expected in zip(rows, [3, 2, 3, 3, 3, 2, 2, 2, 3, 3, 2]):
4.23 +for (row_attrs, columns), expected in zip(rows, [3, 2, 3, 3, 3, 2, 2, 2, 3, 3, 2, 2]):
4.24 print row_attrs
4.25 print columns
4.26 non_continuation_columns = [
4.27 @@ -63,4 +67,8 @@
4.28 print len(non_continuation_columns) == expected, ": length is", len(non_continuation_columns), "==", expected
4.29 print
4.30
4.31 +expected_text = "The second\nwith the continuation of\nthe text without indentation occurring.\n"
4.32 +text = rows[11][1][1][1]
4.33 +print text == expected_text, ": text is", repr(text)
4.34 +
4.35 # vim: tabstop=4 expandtab shiftwidth=4