Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paragraph followed by ul/ol creates wrong page-breaks #1037

Closed
Christoph-Wagner opened this issue Jan 21, 2020 · 3 comments
Closed

Paragraph followed by ul/ol creates wrong page-breaks #1037

Christoph-Wagner opened this issue Jan 21, 2020 · 3 comments
Labels
CSS Questions about how to do something with CSS

Comments

@Christoph-Wagner
Copy link

WeasyPrint version 51, Windows

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.

Gist with test files
localtest.pdf
localtest-nolines.pdf

@liZe
Copy link
Member

liZe commented Jan 24, 2020

Hello!

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.

@liZe liZe added the CSS Questions about how to do something with CSS label Jan 24, 2020
@Christoph-Wagner
Copy link
Author

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.

@liZe
Copy link
Member

liZe commented Feb 6, 2020

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.

(Somehow related to #1045.)

@liZe liZe closed this as completed Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Questions about how to do something with CSS
Projects
None yet
Development

No branches or pull requests

2 participants