Open kesara opened 1 month ago
This is a non-issue when the sup
is not present in the first line.
Screenshot:
Thanks a lot for the bug report and the examples.
This bug appears because in WeasyPrint, markers are absolutely positioned boxes: vertically they are positioned to be on the left of the content of the li
box, and horizontally to be aligned with the top of the content box of the li
box.
Both positions are wrong in some cases. Horizontally, it’s explained in #1557, padding breaks the assumption. And vertically, well … you’ve just found the bug.
Subscript doesn’t break the rendering because we still want to put the marker at the top of the li
box in this case.
The clean solution would be to position markers manually, not using some dirty hidden CSS rules. We can actually do what we want, as "CSS does not specify the precise location of the marker box or its position in the painting order", but we should try to manually do what other browsers do.
A workaround is to add line-height: 0
to superscript text, it works well with rather high line-height values. It should be the default in my opinion, otherwise lines with superscript are taller than other lines. But that’s not what other browsers do, so we’re stuck with this.
@liZe Thanks for the explanation and workaround.
The marker position for
li
differs whensup
(superscript) is present. There are no such issues withsub
(subscript).Example screenshots:
Test HTML:
Sample PDF generated with WeasyPrint
62.3
: li.pdf