Skip to content

Commit

Permalink
Merge pull request #357 from codebykat/update/use-text-align-for-tabl…
Browse files Browse the repository at this point in the history
…e-alignment

Tables: use style=text-align for table alignment
  • Loading branch information
nicholasserra committed Jun 16, 2020
2 parents 4858c40 + e440084 commit c566064
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions lib/markdown2.py
Expand Up @@ -1013,11 +1013,11 @@ def _table_sub(self, match):
align_from_col_idx = {}
for col_idx, col in enumerate(cols):
if col[0] == ':' and col[-1] == ':':
align_from_col_idx[col_idx] = ' align="center"'
align_from_col_idx[col_idx] = ' style="text-align:center;"'
elif col[0] == ':':
align_from_col_idx[col_idx] = ' align="left"'
align_from_col_idx[col_idx] = ' style="text-align:left;"'
elif col[-1] == ':':
align_from_col_idx[col_idx] = ' align="right"'
align_from_col_idx[col_idx] = ' style="text-align:right;"'

# thead
hlines = ['<table%s>' % self._html_class_str_from_tag('table'), '<thead>', '<tr>']
Expand Down
40 changes: 20 additions & 20 deletions test/php-markdown-extra-cases/Tables.html
Expand Up @@ -133,56 +133,56 @@ <h1>One-column one-row table</h1>

<hr />

<p>Table alignement:</p>
<p>Table alignment:</p>

<table>
<thead>
<tr>
<th>Default</th>
<th align="left">Right</th>
<th align="center">Center</th>
<th align="right">Left</th>
<th style="text-align:left;">Left</th>
<th style="text-align:center;">Center</th>
<th style="text-align:right;">Right</th>
</tr>
</thead>
<tbody>
<tr>
<td>Long Cell</td>
<td align="left">Long Cell</td>
<td align="center">Long Cell</td>
<td align="right">Long Cell</td>
<td style="text-align:left;">Long Cell</td>
<td style="text-align:center;">Long Cell</td>
<td style="text-align:right;">Long Cell</td>
</tr>
<tr>
<td>Cell</td>
<td align="left">Cell</td>
<td align="center">Cell</td>
<td align="right">Cell</td>
<td style="text-align:left;">Cell</td>
<td style="text-align:center;">Cell</td>
<td style="text-align:right;">Cell</td>
</tr>
</tbody>
</table>

<p>Table alignement (alternate spacing):</p>
<p>Table alignment (alternate spacing):</p>

<table>
<thead>
<tr>
<th>Default</th>
<th align="left">Right</th>
<th align="center">Center</th>
<th align="right">Left</th>
<th style="text-align:left;">Left</th>
<th style="text-align:center;">Center</th>
<th style="text-align:right;">Right</th>
</tr>
</thead>
<tbody>
<tr>
<td>Long Cell</td>
<td align="left">Long Cell</td>
<td align="center">Long Cell</td>
<td align="right">Long Cell</td>
<td style="text-align:left;">Long Cell</td>
<td style="text-align:center;">Long Cell</td>
<td style="text-align:right;">Long Cell</td>
</tr>
<tr>
<td>Cell</td>
<td align="left">Cell</td>
<td align="center">Cell</td>
<td align="right">Cell</td>
<td style="text-align:left;">Cell</td>
<td style="text-align:center;">Cell</td>
<td style="text-align:right;">Cell</td>
</tr>
</tbody>
</table>
Expand Down
12 changes: 6 additions & 6 deletions test/php-markdown-extra-cases/Tables.text
Expand Up @@ -50,19 +50,19 @@ With leading and tailing pipes:

* * *

Table alignement:
Table alignment:

| Default | Right | Center | Left |
| Default | Left | Center | Right |
| --------- |:--------- |:---------:| ---------:|
| Long Cell | Long Cell | Long Cell | Long Cell |
| Cell | Cell | Cell | Cell |
| Cell | Cell | Cell | Cell |

Table alignement (alternate spacing):
Table alignment (alternate spacing):

| Default | Right | Center | Left |
| Default | Left | Center | Right |
| --------- | :-------- | :-------: | --------: |
| Long Cell | Long Cell | Long Cell | Long Cell |
| Cell | Cell | Cell | Cell |
| Cell | Cell | Cell | Cell |

* * *

Expand Down

0 comments on commit c566064

Please sign in to comment.