resolves #214 fix page counter
According to the specification the counter named page can be explicitly defined in the page context:
A counter named page is automatically created and incremented by 1 on every page of the document, unless the counter-increment property in the page context explicitly specifies a different increment for the page counter.
This merge request makes the page counter increment configurable by using a variable in the CSS counter-increment: page var(--pagedjs-page-counter-increment);
. The default value is 1.
I've created a PageCounterIncrement
to set the variable --pagedjs-page-counter-increment
when the property counter-increment
is defined in a page context for the counter named "page".
I've updated TargetCounters
to increment the value accordingly. Please note that the value can be negative (i.e. counter-increment: page -1
).
I've also fixed a potential bug (still need to create a test case) in counters.js
where number was defined as:
counter.increments[selector] = {
selector: selector,
number: number || 1
};
The issue here is that number can be 0 and 0 is falsy... so if you declare counter-increment: foo 0
it will actually increment foo by 1
const number = declaration.value.children.getSize() > 1 ? declaration.value.children.last().value : 1;
If the value is defined (i.e. declaration.value.children.getSize() > 1
is true) then use whatever the value is, otherwise, if the value is missing, use a default value of 1.
resolves #214 (closed)