-
-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Last cell of table missing if blank #118
Comments
The above fix doesn't cover the case where the table is the very last thing in the file this needs the re to be changed to |
s |
Could you add a test case, and send the patch as a pull request? |
OK will do On 25 September 2016 at 04:42, Hsiaoming Yang [email protected]
|
A simple fix for the problem would be def parse_table(self, m):
item = self._process_table(m)
cols = len(item['header']) #added
cells = re.sub(r'(?: *\| *)?\n$', '', m.group(3))
cells = cells.split('\n')
for i, v in enumerate(cells):
v = re.sub(r'^ *\| *| *\| *$', '', v)
cells[i] = re.split(r' *(?<!\\)\| *', v)
#
# The header row must match the delimiter row in the number of cells.
# If not, a table will not be recognized. The remainder of the table’s
# rows may vary in the number of cells. If there are a number of cells
# fewer than the number of cells in the header row, empty cells are
# inserted. See https://github.github.com/gfm/#example-203
while len(cells[i]) < cols: #added
cells[i].append('')
# If there are greater, the excess is ignored
# see https://github.github.com/gfm/#example-203
del cells[i][cols:] #added
item['cells'] = self._process_cells(cells)
self.tokens.append(item) |
please try v2.0.0a1 |
This issue appears to still be a problem in v2.0.2. Here's a test case: import mistune
s = '''
| Foo | Bar |
|-----|-----|
| boo | baz |
| faz | |
'''
print(mistune.html(s)) which yields the following output: <table>
<thead>
<tr>
<th>Foo</th>
<th>Bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>boo</td>
<td>baz</td>
</tr>
<tr>
<td>faz</td>
</tr>
</tbody>
</table> The expected output is: <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> Please re-open this issue. |
@lifton just fixed in master code. |
If the last table of a cell is blank then it is missing in the rendered HTML.
This appears to be because the last pipe is removed to avoid an extra row being created if by the split function.
A crude fix to this would look something like
The text was updated successfully, but these errors were encountered: