You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"counter-reset: page;" doesn't work properly with web publications #522
I want to exclude book cover pages from page counter.
To do this, I tried to use web publications json and set @page :first { reset-counter: page; } to second document, because vivliostyle doesn't support named pages. however this doesn't work as I expected.
Steps to Reproduce
Open Vivliostyle with #x=http://url/to/testbook.json:
Thank you for the reporting! The page seems to be a counter of entire of a book so that it's may not acceptable for describing a document-wise page counter. In an environment of Vivliostyle, by defining the new counter which likes below works fine:
test2.html
<html><head><style>@page{size: A4;counter-increment: doc-page;@top-left{content:counter(doc-page);}}body{counter-reset: doc-page;}div{page-break-after: always;}</style></head><body><div>
C
</div><div>
D
</div></body></html>
The :first pseudo-class matches the first printed page of a document.
However, this spec is not very clear, when the document is a web publication, whether the :first matches only the first page of the web publication or matches first page of each sub-document (HTML) in the web publication.
Also it is not clear whether the Page-based counters are for a whole web publication or for each sub-document in the web publication.
(The problem is that the CSS Paged Media specification is not considered for publications composed of multiple HTML documents.)
In the Vivliostyle.js implementation, the :first matches only the first page of the web publication, and the page-based counters count consecutive pages in a whole web publication. Therefore, the page counter is not reset at the first page of the second document even when @page :first { reset-counter: page; } is specified.
changed the title [-]"reset-counter: page;" doesn't work properly with web publications json[/-][+]"reset-counter: page;" doesn't work properly with web publications[/+]on Aug 24, 2019
changed the title [-]"reset-counter: page;" doesn't work properly with web publications[/-][+]"counter-reset: page;" doesn't work properly with web publications[/+]on Feb 27, 2021
You can use @page :nth(1) { counter-reset: page; } to reset the page counter at each or a specific document in web publications (multi-document publications).
Activity
spring-raining commentedon May 19, 2019
Thank you for the reporting! The
pageseems to be a counter of entire of a book so that it's may not acceptable for describing a document-wise page counter. In an environment of Vivliostyle, by defining the new counter which likes below works fine:test2.html
Hoping this answer your question.
MurakamiShinyu commentedon May 19, 2019
Thanks @butameron for reporting the issue and @spring-raining for giving us a good workaround.
There are some problems on CSS Paged Media spec and Vivliostyle.js implementation.
In the spec, First-page pseudo-class:
:firstis defined asHowever, this spec is not very clear, when the document is a web publication, whether the
:firstmatches only the first page of the web publication or matches first page of each sub-document (HTML) in the web publication.Also it is not clear whether the Page-based counters are for a whole web publication or for each sub-document in the web publication.
(The problem is that the CSS Paged Media specification is not considered for publications composed of multiple HTML documents.)
In the Vivliostyle.js implementation, the
:firstmatches only the first page of the web publication, and the page-based counters count consecutive pages in a whole web publication. Therefore, thepagecounter is not reset at the first page of the second document even when@page :first { reset-counter: page; }is specified.butameron commentedon May 23, 2019
@spring-raining Thank you. It works
[-]"reset-counter: page;" doesn't work properly with web publications json[/-][+]"reset-counter: page;" doesn't work properly with web publications[/+][-]"reset-counter: page;" doesn't work properly with web publications[/-][+]"counter-reset: page;" doesn't work properly with web publications[/+]MurakamiShinyu commentedon Feb 27, 2021
Now, Vivliostyle.js v2.5.0 supports the
:nth()page selector.See #700 feat(core): Support the :nth() page selector
You can use
@page :nth(1) { counter-reset: page; }to reset the page counter at each or a specific document in web publications (multi-document publications).Tests:
https://raw.githack.com/vivliostyle/vivliostyle.js/master/packages/core/test/files/index.html#Nth_page_selector
(source: https://github.com/vivliostyle/vivliostyle.js/tree/master/packages/core/test/files/nth-page)
I believe this issue is now resolved.