Class: PageCounterIncrement

PageCounterIncrement(chunker, polisher, caller)

Handles counter-increment rules related to the page counter.

This class identifies counter-increment: page declarations that appear outside of the @page context and applies them by inserting equivalent CSS custom property rules. This allows for controlling page-based counters from regular content.

Reference: https://www.w3.org/TR/css-page-3/#page-based-counters

Constructor

new PageCounterIncrement(chunker, polisher, caller)

Constructs a PageCounterIncrement handler.

Constructs a PageCounterIncrement handler.

Parameters:
Name Type Description
chunker Object

The chunker instance used during pagination.

polisher Object

The polisher instance used for styling.

caller Object

The caller coordinating the handlers.

Source:

Members

pageCounter :Object

Tracks page counter increments and resets by selector.

Tracks page counter increments and resets by selector. Only the "page" counter is processed.

Type:
  • Object
Source:

styleSheet :CSSStyleSheet

Type:
  • CSSStyleSheet
Source:

Methods

afterParsed(_)

Hook called after parsing is complete.

Hook called after parsing is complete. Applies the processed counter-increments as CSS custom properties.

Parameters:
Name Type Description
_ *

Unused parameter (parsed content).

Source:

handleIncrement(declaration, rule) → {Object|undefined}

Parses a counter-increment declaration and determines if it's relevant.

Parses a counter-increment declaration and determines if it's relevant.

Parameters:
Name Type Description
declaration Object

The counter-increment declaration node.

rule Object

The parent rule node.

Source:
Returns:

The parsed increment object or undefined if ignored.

Type
Object | undefined

insertRule(rule)

Inserts a rule into the active stylesheet.

Inserts a rule into the active stylesheet.

Parameters:
Name Type Description
rule string

The CSS rule string to insert.

Source:

onDeclaration(declaration, dItem, dList, rule)

Handles CSS declarations during parsing.

Handles CSS declarations during parsing. Specifically looks for counter-increment: page and collects them.

Parameters:
Name Type Description
declaration Object

The CSS declaration AST node.

dItem Object

The item in the declaration list.

dList Object

The list of declarations.

rule Object

The parent rule node.

Source: