-
-
Notifications
You must be signed in to change notification settings - Fork 704
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
Implement counter-set #1019
Comments
Hello! It’s not a bug, it’s a feature 😉. You can open this document in other browsers, they will give you the same rendering as WeasyPrint. You have to reset a counter in a box that contains all the children that use this counter. Otherwise, the counter will only be available for the siblings (and descendants) of your child, but will be automatically reset when quitting your parent. In your example, |
Whoops, my example did indeed not reset it properly. I'll have to find another way to trigger the issue as I do properly reset everything in the document I was talking about. |
No problem! You can reopen this issue with another example. |
I tried stripping down the document that had the bug to a minimal version and this time I am able to reproduce the bug properly. <!DOCTYPE html>
<html>
<head>
<title>Counter bug</title>
<meta charset="UTF-8" />
<style type="text/css">
body {
counter-reset: h2 0 h3 0 h4 0;
}
body article h2 {
counter-increment: h2;
counter-reset: h3 0;
}
body article h2::before {
content: counter(h2) ". ";
}
body article h3 {
counter-increment: h3;
counter-reset: h4 0;
}
body article h3::before {
content: counter(h2) "." counter(h3) ". ";
}
body article h4 {
counter-increment: h4;
}
body article h4::before {
content: counter(h2) "." counter(h3) "." counter(h4) ". ";
}
</style>
</head>
<body>
<article>
<h2>1</h2>
</article>
<article>
<h2>2</h2>
</article>
<article>
<h3>2.1</h3>
<h4>2.1.1</h4>
<h4>2.1.2</h4>
<h4>2.1.3</h4>
</article>
<article>
<h3>2.2</h3>
<h4>2.2.1</h4>
</article>
<article>
<h2>3</h2>
</article>
<article>
<h3>3.1</h3>
</article>
<article>
<h3>3.2</h3>
</article>
<article>
<h2>4</h2>
<h3>4.1</h3>
<h3>4.2</h3>
<h3>4.3</h3>
</article>
</body>
</html> As you can see, after section 3 we expect 3.1 and 3.2 but instead 3.3 and 3.4 show up. |
Browsers give the same result as WeasyPrint, so I suppose WeasyPrint is right there too 😄.
You should use |
So if I understand it correctly the place where a |
You understand it correctly. The spec tells that
Have fun! |
I have a big document where the counters are not working as intended. Some counters don't reset when they should.
Unfortunately I was not able to reproduce that exact issue but I was able to get another counting issue that might be caused by the same problem. In this case the counter doesn't increment.
When converting this HTML snippet to PDF:
The result looks like this:
Using version weasyprint 51
The text was updated successfully, but these errors were encountered: