-
Notifications
You must be signed in to change notification settings - Fork 17
/
test_grid_tables.py
83 lines (81 loc) · 1.45 KB
/
test_grid_tables.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import markdown
markdown_table = \
"""
+-------+----------+------+
| Table Headings | Here |
+-------+----------+------+
| Sub | Headings | Too |
+=======+==========+======+
| cell | column spanning |
+ spans +----------+------+
| rows | normal | cell |
+-------+----------+------+
| multi | cells can be |
| line | *formatted* |
| | **paragraphs** |
| cells | |
| too | |
+-------+-----------------+"""[1:]
html_table = \
"""<table>
<thead>
<tr>
<th colspan="2" rowspan="1">
<p>Table Headings</p>
</th>
<th colspan="1" rowspan="1">
<p>Here</p>
</th>
</tr>
<tr>
<th colspan="1" rowspan="1">
<p>Sub</p>
</th>
<th colspan="1" rowspan="1">
<p>Headings</p>
</th>
<th colspan="1" rowspan="1">
<p>Too</p>
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="1" rowspan="2">
<p>cell
spans
rows</p>
</td>
<td colspan="2" rowspan="1">
<p>column spanning</p>
</td>
</tr>
<tr>
<td colspan="1" rowspan="1">
<p>normal</p>
</td>
<td colspan="1" rowspan="1">
<p>cell</p>
</td>
</tr>
<tr>
<td colspan="1" rowspan="1">
<p>multi
line</p>
<p>cells
too</p>
</td>
<td colspan="2" rowspan="1">
<p>cells can be
<em>formatted</em>
<strong>paragraphs</strong></p>
</td>
</tr>
</tbody>
</table>"""
md = markdown.Markdown(extensions=['grid_tables'])
result = md.convert(markdown_table)
#print result
#with open('test_grid_tables.html', 'w') as f:
# f.write(result + '<style>table, tr, td, th {border: 1px solid black;}</style>')
assert result == html_table