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

Bookmarks repeat on every page #1145

Closed
arikrupnik opened this issue Jun 17, 2020 · 8 comments
Closed

Bookmarks repeat on every page #1145

arikrupnik opened this issue Jun 17, 2020 · 8 comments
Labels
bug Existing features not working as expected
Milestone

Comments

@arikrupnik
Copy link

I'm formatting an XML file. I want to generate an index, but for some reason I'm getting an entry for every section on each page. What am I doing wrong? Using Weasyprint 51 and Python 3.7.5 on Linux.

<doc>
  <section heading="1976">
    <section heading="Cemetery">
      <scene>EXT. CEMETERY -- NIGHT</scene>
      Rederik, now 28, lies behind a GRAVESTONE. He has a beard now, but is growing thinner on the top. He squints through a tree branch he's holding in front of his face.

CSS snippet:

section { bookmark-level: 1; bookmark-label: attr(heading); }
section > section { bookmark-level: 2; }
section > section > section { bookmark-level: 3; }

Screenshot_2020-06-17_12-18-50

@Tontyna
Copy link
Contributor

Tontyna commented Jun 18, 2020

Don't think you're doing anything wrong.

The level-1-section, wrapping everything, is present on every page that WeasyPrint generates -- try to give it a border or background color and you should see that decoration on each page.

Like those 'decorative' stylings, the bookmark-* properties of the section are present on each page, generating the superfluous entries in the PDF navigation.

Looks like WeasyPrint should stop propagating the bookmarks when spreading a wrapping box across pages.

@arikrupnik
Copy link
Author

Thank you for your response, @Tontyna. Is there a workaround i can use?

@arikrupnik
Copy link
Author

Maybe if I put the bookmark-level on section:before? I haven't been able to make it work, but maybe I'm missing how :before works in this context.

@Tontyna
Copy link
Contributor

Tontyna commented Jun 18, 2020

Nah, no chance. Though the spec says that the bookmark-* properties apply to all elements, WeasyPrint doesn't apply them.

Only workaround at the moment is inserting (empty) dummy elements.

@arikrupnik
Copy link
Author

Thanks.

Only workaround at the moment is inserting (empty) dummy elements.

I thought this was what :before did ;=)

Any sense if this may change in WeasyPrint in the foreseeable future?

@Tontyna
Copy link
Contributor

Tontyna commented Jun 19, 2020

BTW: Not only multi-page-boxes generate multiple bookmarks. Multi-Line Inline-Boxes do it, too:

<h1 style="display:inline; white-space:pre">
A bookmark
for every
line
</h1>

creates 4 bookmarks in the PDF outline

@arikrupnik
Copy link
Author

How about that! I guess no one would ever use more than one line in an <h1> :=)

I can test this commit with my XML this evening when I get home.

@arikrupnik
Copy link
Author

Beautiful! This fixes my problem.
Thank you!
Screenshot_2020-06-20_19-25-30

@liZe liZe added the bug Existing features not working as expected label Jul 18, 2020
@liZe liZe closed this as completed in 4c67371 Sep 23, 2020
@liZe liZe added this to the 52 milestone Sep 23, 2020
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

No branches or pull requests

3 participants