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

fix: don't output footnotes before their call sites #1566

Merged
merged 1 commit into from
Feb 13, 2022

Conversation

aschmitz
Copy link
Contributor

If a footnote has been output but we then decide to cancel the line it was output on, we should cancel the output of the footnote itself.

This requires a bit of extra bookkeeping, so we know which footnotes are relevant, but otherwise largely works using the existing remove_placeholders code.

Includes a minor refactor of footnote area management in LayoutContext, and a new testing utility: tree_position.

Closes #1564.

If a footnote has been output but we then decide to cancel the line it
was output on, we should cancel the output of the footnote itself.

This requires a bit of extra bookkeeping, so we know which footnotes are
relevant, but otherwise largely works using the existing
remove_placeholders code.

Includes a minor refactor of footnote area management in LayoutContext,
and a new testing utility: `tree_position`.

Closes Kozea#1564.
@aschmitz
Copy link
Contributor Author

I'm certainly conscious of the fact that this PR is one of the more wide-reaching ones I've submitted. Definitely feel free to push back on any parts of it if you'd like them done different ways: I'm trying to fit things into the conventions I've seen elsewhere in the code, but clearly I haven't seen everything. 😅

@liZe liZe merged commit 0214311 into Kozea:master Feb 13, 2022
@liZe
Copy link
Member

liZe commented Feb 13, 2022

Thanks a lot for this pull request. It’s a very good idea to use remove_placeholders to remove footnotes. Your code is always clean, always tested… 💜

@liZe liZe added this to the 55.0 milestone Feb 13, 2022
@liZe liZe added the bug Existing features not working as expected label Feb 13, 2022
aschmitz added a commit to aschmitz/WeasyPrint that referenced this pull request Feb 14, 2022
This fixes a bug accidentally introduced in Kozea#1566, where we would try to
unlayout a footnote that had not yet been laid out, if the algorithm
decided that there would be insufficient space on a page before laying
out a further footnote.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Footnotes are sometimes placed on the page before the corresponding footnote call
2 participants