Page MenuHomePhabricator

Table with align=center gives wrong CSS
Closed, ResolvedPublic

Description

Tables with the following (deprecated) HTML markup:

{| align=center
| ....
|}

are being given the wrong CSS. It is coming out as

<table style="text-align: center;">
...
</table>

This left aligns the table (usually) and centres the text within the able.
It should be:

<table style="margin-left:auto; margin-right:auto;">
...
</table>

The difference is that this centres the table in the page, but the alignment of the text within the table remains the same (usually left-aligned).

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I was going to say that this should be fixed at the source, but it looks like there are lots of table align attributes. And anyway, we are currently "fixing" them wrongly!

Thanks for reporting.

Yeah, there are a lot, it's unfortunate. There's a tag, Bad markup applied by the AbuseFIlter at enWS: https://en.wikisource.org/wiki/Special:RecentChanges?hidebots=1&hidecategorization=1&hideWikibase=1&tagfilter=bad_markup&limit=1000&days=30&urlversion=2

It probably doesn't catch them all. Maybe one day they can be botted out, but the fix looks good to me (not that I've tried it, I need to set up a dev environment at some point).

dom_walden subscribed.

We have changed the CSS in the epubs we export when it comes to table alignment.

For example, https://wsexport-test.wmflabs.org/?lang=beta&page=Align+test&format=epub-3&fonts=

I find the new CSS does not lead to correct alignment on Okular (the ebook reader I mostly use on GNU/Linux). See screenshot. I think it might be a bug in Okular itself. But, it does work with Apple Books and Microsoft Edge (I haven't tried any other ebook readers).

alignment_okular.png (482×1 px, 8 KB)

(This is how https://wsexport-test.wmflabs.org/?lang=beta&page=Align+test&format=epub-3&fonts= looks on Okular)

ifried subscribed.

This change is now on production, so I'm marking it as Done. As noted by some comments in this ticket, this change does not fix alignment issues for all cases (though some bugs may be due to devices, rather than specifically our work). However, the work of this ticket can improve alignment support in some cases. Furthermore, if people feel interested in exploring this issue more deeply or extending the fix to more cases, that can be done in a separate ticket. Thanks.