You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a paragraph is followed by an ul or ol element, it seems that weasyprint somehow calculates the list as part of the paragraph for the purpose of breaking into a new page. This results in the paragraph breaking early even though there is more than enough space to finish it.
Note that the problem happens when the code is </p><ul></ul> as well as for </p><div><ul></ul><div> but not for </p>X<ul></ul> so my personal workaround is to add a zero-width-joiner before the list.
I added both files used to create the pdfs, one pdf with debug-borders, and one where only the otherwise invisible ul has a blue border.
The problem is caused by WeasyPrint’s default stylesheet that avoids page breaks before ol and ul tags. It’s usually really useful when you don’t have lists with forced heights, as in your example.
If you want to avoid this behavior, you can use the ol, ul { break-before: auto } in your stylesheet.
Oh wow, I didn’t even think that would be a thing. Thank you. I feel like it should be mentioned in the docs somewhere, but I don’t know if "Tips & Tricks" or the "Features" section is more appropriate.
The default stylesheet is full of little details that are "normal" for generic cases, but may be strange when the content is somehow different (like your really high li tags). It’s hard to document that, because many people may need information on different parts of the stylesheet, and we would end up with a huge article full of tips that nobody would read 😞.
I’m currently thinking of a new organization for the documentation, it may be easier to find a place for this kind of content.
WeasyPrint version 51, Windows
When a paragraph is followed by an
ul
orol
element, it seems that weasyprint somehow calculates the list as part of the paragraph for the purpose of breaking into a new page. This results in the paragraph breaking early even though there is more than enough space to finish it.Note that the problem happens when the code is
</p><ul></ul>
as well as for</p><div><ul></ul><div>
but not for</p>X<ul></ul>
so my personal workaround is to add a zero-width-joiner before the list.I added both files used to create the pdfs, one pdf with debug-borders, and one where only the otherwise invisible
ul
has a blue border.Gist with test files
localtest.pdf
localtest-nolines.pdf
The text was updated successfully, but these errors were encountered: