Skip to content

Commit

Permalink
Fix table plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Apr 25, 2022
1 parent 76dec68 commit 61e9337
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mistune/plugins/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ def _process_row(row, aligns):
'text': text,
'params': (aligns[i], False)
})

if len(cells) < len(aligns):
for align in aligns[len(cells):]:
cells.append({
'type': 'table_cell',
'text': '',
'params': (align, False),
})

return {'type': 'table_row', 'children': cells}


Expand Down
27 changes: 27 additions & 0 deletions tests/fixtures/table.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,30 @@ a | b
</tbody>
</table>
````````````````````````````````


```````````````````````````````` example
| Foo | Bar |
|-----|-----|
| boo | baz |
| faz | |
.
<table>
<thead>
<tr>
<th>Foo</th>
<th>Bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>boo</td>
<td>baz</td>
</tr>
<tr>
<td>faz</td>
<td></td>
</tr>
</tbody>
</table>
````````````````````````````````

0 comments on commit 61e9337

Please # to comment.