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

"reset-counter: page;" doesn't work properly with web publications json #522

Open
butameron opened this issue May 18, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@butameron
Copy link

commented May 18, 2019

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:

testbook.json

{
    "@context": [
        "https://schema.org",
        "https://www.w3.org/ns/wp-context"
    ],
    "type": "Book",
    "dateModified": "",
    "readingOrder": [
        "./test.html",
        "./test2.html"
    ]
}

test.html

<html>
    <head>
        <style>
            @page {
                size: A4;
                            
                @top-left {
                    content: counter(page);
                }

            }
            div { page-break-after: always; }
        </style>
    </head>
    <body>
        <div>
            A
        </div>
        <div>
            B
        </div>
    </body>
</html>

test2.html

<html>
    <head>
        <style>
            @page {
                size: A4;
                            
                @top-left {
                    content: counter(page);
                }

            }
            @page :first {
                counter-reset: page;
            }

            div { page-break-after: always; }
        </style>
    </head>
    <body>
        <div>
            C
        </div>
        <div>
            D
        </div>
    </body>
</html>

Expected result

Page A: page counter value = 1
Page B: page counter value = 2
Page C: page counter value = 1
Page D: page counter value = 2

Actual result

Page A: page counter value = 1
Page B: page counter value = 2
Page C: page counter value = 3
Page D: page counter value = 4

@spring-raining

This comment has been minimized.

Copy link
Member

commented May 19, 2019

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>

Hoping this answer your question.

@MurakamiShinyu

This comment has been minimized.

Copy link
Member

commented 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: :first is defined as

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.

@butameron

This comment has been minimized.

Copy link
Author

commented May 23, 2019

@spring-raining Thank you. It works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.