Skip to content

Commit 61e9337

Browse files
committed
Fix table plugin
ref: #118 (comment)
1 parent 76dec68 commit 61e9337

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

mistune/plugins/table.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ def _process_row(row, aligns):
9595
'text': text,
9696
'params': (aligns[i], False)
9797
})
98+
99+
if len(cells) < len(aligns):
100+
for align in aligns[len(cells):]:
101+
cells.append({
102+
'type': 'table_cell',
103+
'text': '',
104+
'params': (align, False),
105+
})
106+
98107
return {'type': 'table_row', 'children': cells}
99108

100109

tests/fixtures/table.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,30 @@ a | b
280280
</tbody>
281281
</table>
282282
````````````````````````````````
283+
284+
285+
```````````````````````````````` example
286+
| Foo | Bar |
287+
|-----|-----|
288+
| boo | baz |
289+
| faz | |
290+
.
291+
<table>
292+
<thead>
293+
<tr>
294+
<th>Foo</th>
295+
<th>Bar</th>
296+
</tr>
297+
</thead>
298+
<tbody>
299+
<tr>
300+
<td>boo</td>
301+
<td>baz</td>
302+
</tr>
303+
<tr>
304+
<td>faz</td>
305+
<td></td>
306+
</tr>
307+
</tbody>
308+
</table>
309+
````````````````````````````````

0 commit comments

Comments
 (0)