1.1 --- a/ImprovedTableParser.py Thu Feb 23 23:47:36 2012 +0100
1.2 +++ b/ImprovedTableParser.py Fri Feb 24 21:39:12 2012 +0100
1.3 @@ -22,7 +22,7 @@
1.4
1.5 # At start of line:
1.6 "sections" : (r"(^\s*{{{.*?^\s*}}})", re.MULTILINE | re.DOTALL), # {{{ ... }}}
1.7 - "rows" : (r"^==", re.MULTILINE), # ==
1.8 + "rows" : (r"^==(?!.*?==$)", re.MULTILINE), # == not-heading
1.9
1.10 # Within text:
1.11 "columns" : (r"\|\|[ \t]*", 0), # || ws-excl-nl
2.1 --- a/tests/test_table.py Thu Feb 23 23:47:36 2012 +0100
2.2 +++ b/tests/test_table.py Fri Feb 24 21:39:12 2012 +0100
2.3 @@ -25,6 +25,13 @@
2.4 Some preformatted text.
2.5 \\}\\}\\}
2.6 ||<colspan="2"> Preformatted text in a separate section
2.7 +==
2.8 +== Heading 2 ==
2.9 +This is in the first column.
2.10 +|| And this is in the second.
2.11 +== This, despite the == is in a new row.
2.12 +||
2.13 +And this is the second column.
2.14 """
2.15
2.16 attrs, rows = parse(table)
2.17 @@ -32,12 +39,19 @@
2.18 print table
2.19 print attrs
2.20 print rows
2.21 -print len(rows) == 6, ": length is", len(rows), "==", 6
2.22 +print len(rows) == 8, ": length is", len(rows), "==", 8
2.23 print
2.24 -for (row_attrs, columns), expected in zip(rows, [3, 2, 3, 3, 3, 2]):
2.25 +for (row_attrs, columns), expected in zip(rows, [3, 2, 3, 3, 3, 2, 2, 2]):
2.26 print row_attrs
2.27 print columns
2.28 - print len(columns) == expected, ": length is", len(columns), "==", expected
2.29 + non_continuation_columns = [
2.30 + (column_attrs, content)
2.31 + for (column_attrs, content) in columns
2.32 + if not column_attrs.has_key("colcontinuation")
2.33 + and not column_attrs.has_key("rowcontinuation")
2.34 + and not content is None
2.35 + ]
2.36 + print len(non_continuation_columns) == expected, ": length is", len(non_continuation_columns), "==", expected
2.37 print
2.38
2.39 # vim: tabstop=4 expandtab shiftwidth=4