Skip to content

Commit 14c48d9

Browse files
authored
Merge pull request #210 from Keyacom/Keyacom-patch0-20221026
Replace deprecated HTML in the Mediawiki format. As stated on wikipedia:WP:HTML5 [1] all instances of align="center" or align="right" must be replaced with style="text-align: center;" or style="text-align: right;", respectively, to align text. [1]: https://en.wikipedia.org/wiki/Wikipedia:HTML_5
2 parents 69dc8ed + fb9a89d commit 14c48d9

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

tabulate/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ def _pipe_line_with_colons(colwidths, colaligns):
136136
def _mediawiki_row_with_attrs(separator, cell_values, colwidths, colaligns):
137137
alignment = {
138138
"left": "",
139-
"right": 'align="right"| ',
140-
"center": 'align="center"| ',
141-
"decimal": 'align="right"| ',
139+
"right": 'style="text-align: right;"| ',
140+
"center": 'style="text-align: center;"| ',
141+
"decimal": 'style="text-align: right;"| ',
142142
}
143143
# hard-coded padding _around_ align attribute and value together
144144
# rather than padding parameter which affects only the value
@@ -1952,11 +1952,11 @@ def tabulate(
19521952
{| class="wikitable" style="text-align: left;"
19531953
|+ <!-- caption -->
19541954
|-
1955-
! strings !! align="right"| numbers
1955+
! strings !! style="text-align: right;"| numbers
19561956
|-
1957-
| spam || align="right"| 41.9999
1957+
| spam || style="text-align: right;"| 41.9999
19581958
|-
1959-
| eggs || align="right"| 451
1959+
| eggs || style="text-align: right;"| 451
19601960
|}
19611961
19621962
"html" produces HTML markup as an html.escape'd str

test/test_output.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,11 +2322,11 @@ def test_mediawiki():
23222322
'{| class="wikitable" style="text-align: left;"',
23232323
"|+ <!-- caption -->",
23242324
"|-",
2325-
'! strings !! align="right"| numbers',
2325+
'! strings !! style="text-align: right;"| numbers',
23262326
"|-",
2327-
'| spam || align="right"| 41.9999',
2327+
'| spam || style="text-align: right;"| 41.9999',
23282328
"|-",
2329-
'| eggs || align="right"| 451',
2329+
'| eggs || style="text-align: right;"| 451',
23302330
"|}",
23312331
]
23322332
)
@@ -2341,9 +2341,9 @@ def test_mediawiki_headerless():
23412341
'{| class="wikitable" style="text-align: left;"',
23422342
"|+ <!-- caption -->",
23432343
"|-",
2344-
'| spam || align="right"| 41.9999',
2344+
'| spam || style="text-align: right;"| 41.9999',
23452345
"|-",
2346-
'| eggs || align="right"| 451',
2346+
'| eggs || style="text-align: right;"| 451',
23472347
"|}",
23482348
]
23492349
)

0 commit comments

Comments
 (0)