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

Bookmark label #1146

Merged
merged 6 commits into from
Sep 23, 2020
Merged

Bookmark label #1146

merged 6 commits into from
Sep 23, 2020

Conversation

Tontyna
Copy link
Contributor

@Tontyna Tontyna commented Jun 18, 2020

Incited by #1145 I started a research about how to implement bookmark-labels for the :before and :after pseudo-elements and stumbled upon page counters and target counters not being updated in bookmark-labels at all.

Of course, nobody ever will use page or target counters in her bookmark-labels...

Tontyna added 4 commits June 18, 2020 22:36
box.string_set is a pointer and is updated automatically when
parse_again() is called for page based counters and target-*.

box.bookmark_label is just a string an we must copy it explicitly
from the re-evaluated original boxes to the page's children.
@Tontyna
Copy link
Contributor Author

Tontyna commented Jun 19, 2020

To actually generate a bookmark-label the pseudo-element must not only have a bookmark-level and a bookmark-label, but also have content, e.g.:

.heading:before {
  content: '';
  bookmark-level: 1;
  bookmark-label: 'A Heading';
}

Remove duplicate bookmark-labes when pagination is finished.
The box.element helps detecting them.

Resolves Kozea#1145
@Tontyna
Copy link
Contributor Author

Tontyna commented Jun 19, 2020

@liZe Maybe there is a better way of removing the duplicates. Best thing would be not to create them at all in the first place, but I was unable to find that first place.

@Tontyna
Copy link
Contributor Author

Tontyna commented Jun 19, 2020

There is something else not feeling quite right:

div{
  bookmark-level: 1;
  bookmark-label: 'the main div';
}
div:before {
 content: 'before ';
 display:block;
 bookmark-level: 1;
 bookmark-label: 'before the div';
}

The :before-box is a child of the div's main BlockBox. Thus the main div precedes the before the div in the PDF outline. Both bookmarks target the same location in the PDF, the top left corner of the :before-box.

@liZe
Copy link
Member

liZe commented Sep 4, 2020

The :before-box is a child of the div's main BlockBox. Thus the main div precedes the before the div in the PDF outline. Both bookmarks target the same location in the PDF, the top left corner of the :before-box.

Having a pseudo-element called :before when it’s actually inside the box is the problem, and there’s nothing we can do about this 😉.

@liZe
Copy link
Member

liZe commented Sep 4, 2020

@liZe Maybe there is a better way of removing the duplicates. Best thing would be not to create them at all in the first place, but I was unable to find that first place.

We have the same problem to remove the top border of a block on the second page when it’s split. There’s a remove_decoration mechanism to change the computed value for the second part of the block (and even the first one to remove the bottom border, but we don’t care for bookmarks). But it doesn’t work for repeating table headers and footers.

I don’t know if it’s possible to do something like that for bookmarks. Otherwise, I can just merge this pull request, it’s already really good.

@Tontyna
Copy link
Contributor Author

Tontyna commented Sep 23, 2020

Otherwise, I can just merge this pull request

Yes, please merge it (and close #1145)

@liZe liZe merged commit b545239 into Kozea:master Sep 23, 2020
@liZe liZe added this to the 52 milestone Sep 23, 2020
@Tontyna Tontyna deleted the bookmark-label branch September 23, 2020 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants