Skip to content

Commit

Permalink
Fix table alignment when seperator contains spaces (Python-Markdown#489)
Browse files Browse the repository at this point in the history
* Fix table alignment when seperator contains spaces

eg. seperator like "------ |  :----- | :----: | -----: | ------"

* Update tests for table

* Delete the newline at the end of tables.html
  • Loading branch information
painyeph authored and waylan committed Aug 15, 2016
1 parent 655d1af commit 5f358c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions markdown/extensions/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def run(self, parent, blocks):
# Get alignment of columns
align = []
for c in self._split_row(seperator, border):
c = c.strip()
if c.startswith(':') and c.endswith(':'):
align.append('center')
elif c.startswith(':'):
Expand Down
8 changes: 4 additions & 4 deletions tests/extensions/extra/tables.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ <h2>Table Tests</h2>
<table>
<thead>
<tr>
<th>Item</th>
<th align="left">Item</th>
<th align="right">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Computer</td>
<td align="left">Computer</td>
<td align="right">$1600</td>
</tr>
<tr>
<td>Phone</td>
<td align="left">Phone</td>
<td align="right">$12</td>
</tr>
<tr>
<td>Pipe</td>
<td align="left">Pipe</td>
<td align="right">$1</td>
</tr>
</tbody>
Expand Down

0 comments on commit 5f358c0

Please sign in to comment.