-
Notifications
You must be signed in to change notification settings - Fork 756
Description
At the moment, one can define, increment and reset a counter, and then get the current value of that counter. However, it would be extremely useful to be able to get the maximum value of a counter within a certain scope.
For example, to mark lists or figures with "Item 2 of 6", or in the case of Paged Media, having sets of pages each with different page counters (such as for front matter, or multiple "articles" within a single document).
For this, I propose adding a max-counter() function, which follows the semantics of counter(), with the function that it outputs the maximum value that a counter reaches, before a counter-reset. So for example:
h1 { counter-reset: section; }
h2 { counter-increment: section; }
h2::after { content: counter(section) " of " max-counter(section); }<h1>Title</h1>
<h2>Section</h2>
<h2>Section</h2>
<h2>Section</h2>
<h1>Title</h1>
<h2>Section</h2>
<h2>Section</h2>This should output something like:
Title
Section 1 of 3
Section 2 of 3
Section 3 of 3
Title
Section 1 of 2
Section 2 of 2
In effect, when a counter increments, they should also increment the value of every max-counter() that precedes them, except for those before a counter-reset. This function should also eliminate the need for the immutable pages counter.