Skip to content

Commit

Permalink
fix: Fix cases where both the chapter and part page counters are set
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-raining committed Sep 8, 2024
1 parent 5b9a7e6 commit 22b8286
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-socks-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vivliostyle/theme-base": patch
---

Fix cases where both the chapter and part page counters are set
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,13 @@
*/
--vs-document-root-counter-reset: ;
--vs-first-page-counter-reset: ;

/**
* Counter increments
* It is used for incrementing CSS counters on a first page of a document
* Caution: Don't set counter-reset directly otherwise all other counters will be ignored.
* OK: :root { --vs-document-first-page-counter-increment: foo bar; }
* NG: @page :nth(1) { counter-increment: foo bar; }
*/
--vs-document-first-page-counter-increment: ;
}
37 changes: 23 additions & 14 deletions packages/@vivliostyle/theme-base/css/partial/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -426,22 +426,37 @@
* document counters
*/

html.chapter,
body.chapter {
page: chapter-document;
}

html.part,
body.part,
[role='doc-part'] {
page: part;
body.part {
page: part-document;
}

html.part.chapter,
body.part.chapter {
page: part-chapter-document;
}

@page :nth(1) {
counter-increment: vs-counter-doc;
counter-increment: var(--vs-page--doc-counter-increment, vs-counter-doc)
var(--vs-document-first-page-counter-increment,);
}

@page part:nth(1) {
counter-increment: vs-counter-doc vs-counter-part;
@page chapter-document {
--vs-page--doc-counter-increment: vs-counter-doc vs-counter-chapter;
}

@page chapter:nth(1) {
counter-increment: vs-counter-doc vs-counter-chapter;
@page part-document {
--vs-page--doc-counter-increment: vs-counter-doc vs-counter-part;
}

@page part-chapter-document {
--vs-page--doc-counter-increment: vs-counter-doc vs-counter-part
vs-counter-chapter;
}

/*
Expand Down Expand Up @@ -489,12 +504,6 @@ body.bibliography,
page: bibliography;
}

html.chapter,
body.chapter,
[role='doc-chapter'] {
page: chapter;
}

html.conclusion,
body.conclusion,
[role='doc-conclusion'] {
Expand Down

0 comments on commit 22b8286

Please sign in to comment.