aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreph <painy.eph@gmail.com>2016-08-15 22:33:55 +0800
committerWaylan Limberg <waylan.limberg@icloud.com>2016-08-15 10:33:55 -0400
commit5f358c0d580bd409279cef1404e6460e7fe2156e (patch)
tree95f65ce35781d46eb84392119a7494fd646b516a
parent655d1afbeec91ed0cbc57f36219dd1c7808ff47e (diff)
downloadmarkdown-5f358c0d580bd409279cef1404e6460e7fe2156e.tar.gz
markdown-5f358c0d580bd409279cef1404e6460e7fe2156e.tar.bz2
markdown-5f358c0d580bd409279cef1404e6460e7fe2156e.zip
Fix table alignment when seperator contains spaces (#489)
* Fix table alignment when seperator contains spaces eg. seperator like "------ | :----- | :----: | -----: | ------" * Update tests for table * Delete the newline at the end of tables.html
-rw-r--r--markdown/extensions/tables.py1
-rw-r--r--tests/extensions/extra/tables.html8
2 files changed, 5 insertions, 4 deletions
diff --git a/markdown/extensions/tables.py b/markdown/extensions/tables.py
index a19018e..8c11739 100644
--- a/markdown/extensions/tables.py
+++ b/markdown/extensions/tables.py
@@ -45,6 +45,7 @@ class TableProcessor(BlockProcessor):
# 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(':'):
diff --git a/tests/extensions/extra/tables.html b/tests/extensions/extra/tables.html
index 783c205..b5c08be 100644
--- a/tests/extensions/extra/tables.html
+++ b/tests/extensions/extra/tables.html
@@ -38,21 +38,21 @@
<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>