Skip to content
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

Tables: use style=text-align for table alignment #357

Merged
merged 1 commit into from Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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