1 #!/usr/bin/env python 2 3 from ImprovedTableParser import parse 4 5 table = """<tablestyle="border: 2px solid red; border-collapse: collapse;" rowstyle="background-color: #f77;"> 6 Test||Outcome||Comments 7 == 8 Colspan 9 ||<colspan="2"> Test a column with attributes 10 == 11 Normal || <style=" 12 text-align: center" colspan=1> Three columns || Adjacent column 13 == 14 Split 15 || Three columns 16 || Separate lines 17 == 18 * Item #1 19 * Item #2 20 || 21 * Item #A 22 || Not a list 23 == 24 \\{\\{\\{ 25 Some preformatted text. 26 \\}\\}\\} 27 ||<colspan="2"> Preformatted text in a separate section 28 """ 29 30 attrs, rows = parse(table) 31 32 print table 33 print attrs 34 print rows 35 print len(rows) == 6, ": length is", len(rows), "==", 6 36 print 37 for (row_attrs, columns), expected in zip(rows, [3, 2, 3, 3, 3, 2]): 38 print row_attrs 39 print columns 40 print len(columns) == expected, ": length is", len(columns), "==", expected 41 print 42 43 # vim: tabstop=4 expandtab shiftwidth=4