-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
fix: running element page counter incorrect #1327
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you for the fix! I will check tomorrow. |
and target-counter in running element equally incorrect🙋🙋🙋 |
let value = arr[0]; | ||
if (arr[1]) { | ||
value = arr[1]; | ||
} | ||
return format(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let value = arr[0]; | |
if (arr[1]) { | |
value = arr[1]; | |
} | |
return format(value); | |
return format(arr[arr.length - 1]); |
value = arr[1]
is not good when counter-reset: page
happens multiple times, for example:
@page :nth(2) {
counter-reset: page 20;
}
@page :nth(3) {
counter-reset: page 30;
}
I found the problem in vivliostyle.js/packages/core/src/vivliostyle/counters.ts Lines 877 to 886 in 126436b
In this code, the "pages" counter value is obtained from the "page" counter value at the last page: const pages = this.currentPageCounters["page"][0]; It doesn't work when In the CSS Paged Media spec, the definition of the Suggested change: const pages = viewport.contentContainer.childElementCount; |
With the last commit f5083bb the test result seems good except the last page with "??" remaining. |
@EnochGao Thanks for the fix and the test case "counter_in_running.html". The fix seems almost good, but I found a problem that it does not work when a page-based |
Thanks. The fix 72fa5bc is good for custom page-based counter, but still has a problem with element-based counter. I made a test case which tests element-based counter in addition to custom page-based counter: The "(Section 11)" in the page header is wrong. It should be "(Section 2)". I found this problem is caused by the following code in const transformedId = node.getAttribute(TARGET_PAGE_COUNTER_ID_ATTR);
const expr = this.targetPageCounterExprs.find(
(o) => o.transformedId === transformedId,
); There are multiple target counter expressions with the same const key = node.getAttribute(TARGET_PAGE_COUNTER_ATTR);
const expr = this.targetPageCounterExprs.find((o) => o.expr.key === key); If this change is ok, the Also the naming Please check the proposed changes in the following diff: |
I see. Thanks for the correction. |
<div class="reset-page">reset page</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This <div class="reset-page">reset page</div>
element is not used for resetting page counter. So I think this should be removed.
<div class="reset-page">reset page</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM 💯
Thanks for the correction. Made me know more about this place |
#1325
I'm not sure if this modification is elegant, but the result seems to be correct. I'm not sure how to handle the total number of pages