ietf-tools / xml2rfc

Generate RFCs and IETF drafts from document source in XML according to the IETF xml2rfc v2 and v3 vocabularies
https://ietf-tools.github.io/xml2rfc/
BSD 3-Clause "New" or "Revised" License
69 stars 39 forks source link

align attribute seems ignored in HTML and PDF rendering of artwork align="center" #834

Open alicerusso opened 2 years ago

alicerusso commented 2 years ago

In RFC 9251 (e.g., Section 9.1), XML contains artwork align="center" but the output has it left-aligned in PDF and HTML. (It's as expected in the text output.) See the first and second artworks in S9.1: https://www.rfc-editor.org/rfc/rfc9251.html#section-9.1 https://www.rfc-editor.org/rfc/rfc9251.pdf#section-9.1 https://www.rfc-editor.org/rfc/rfc9251.txt

In the prepped XML file (https://www.rfc-editor.org/rfc/rfc9251.xml), they are:

<artwork name="" type="" align="center" alt="" pn="section-9.1-2">   
<artwork name="" type="" align="center" alt="" pn="section-9.1-4">

Guessing that it's supposed to yield the same alignment in all 3 outputs. (Here's the documentation for ''align''.)

Another example: see artwork in Section 3.3.4 of RFC 9260: https://www.rfc-editor.org/rfc/rfc9260.html#section-3.3.4-7.16.3 (left aligned) vs. https://www.rfc-editor.org/rfc/rfc9260.txt (centered, as expected) (This issue occurs with other artwork elements within that document, but it's more obvious when the artwork is narrow.)

Perhaps this issue only occurs when <artwork> is not within <figure> bc there are examples where the 3 outputs match (when XML contains artwork align="center"), e.g., Figure 1 in https://www.rfc-editor.org/rfc/rfc9174.html, Figure 1 in https://www.rfc-editor.org/rfc/rfc9125.html, Figure 1 in https://www.rfc-editor.org/rfc/rfc9182.html.

kesara commented 2 years ago

This is caused by #788 and this occurs regardless of <figure> is present as a parent element. Removal of display: table; from .alignCenter > *:first-child in CSS is causing this issue.

kesara commented 2 years ago

Looks like new Weasyprint versions will play nicely with display: table. I will revert this CSS style back to display: table when Weasyprint update (#802) is complete. Reverting back should fix both this issue and #787.

martinthomson commented 2 years ago

It is possible that the right answer here is to use flexbox layout for figures, which would allow for better placement. No idea if weasyprint is able to handle that though.