Private betav0.3.0
DocsSign in
Format developer documentation

NumberingRule

A selector bound to a counter operation, applied to every match in document order.

A NumberingRule binds a selector to a counter operation and applies it to every match in document order. One rule numbers a chapter scheme or a figure counter. A CounterDef with resetEach provides restarts and a scope provides nesting, so a rule itself only advances and inserts.

Fields

selectorRequiredType stringCSS selector for the elements to number, such as h2 or tr.step. Matches flowing content, excluding surrounding scaffolding. If <main> wraps the Flow, use h2, not main h2. Ancestor selectors work when the ancestor is part of the flowing content.
counterType stringThe counter this rule advances. Defaults to the selector.
incrementType integerHow much to advance the counter on each match. Defaults to 1. Set it to 0 to insert a counter's value without advancing it.
setType integerWhen set, set the counter to this value instead of advancing it.
formatType stringThe text inserted into each match, with {counter} placeholders.
counterStyleType stringThe counter style for the format placeholders. Defaults to the document's numbering style, or decimal.
insertType InsertDefault beforeWhere the formatted number goes relative to the match. Defaults to before.

Example

A two-level chapter scheme that replaces the default heading numbers: each h1 advances the chapter, a <CounterDef> restarts the figure count under it, and each <figure> reads the chapter alongside its own number.

<Numbering defaultHeadings={false}>
  <CounterDef name="figure" resetEach="chapter" />
  <NumberingRule match="h1" counter="chapter" format="{chapter}. " />
  <NumberingRule match="figure" counter="figure" format="Figure {chapter}.{figure}: " />
</Numbering>
<Numbering :default-headings="false">
  <CounterDef name="figure" reset-each="chapter" />
  <NumberingRule match="h1" counter="chapter" format="{chapter}. " />
  <NumberingRule match="figure" counter="figure" format="Figure {chapter}.{figure}: " />
</Numbering>
<template data-type="numbering" data-default-headings="false">
  <template data-type="counter-def" data-name="figure" data-reset-each="chapter"></template>
  <template data-type="numbering-rule" data-match="h1" data-counter="chapter" data-format="{chapter}. "></template>
  <template data-type="numbering-rule" data-match="figure" data-counter="figure" data-format="Figure {chapter}.{figure}: "></template>
</template>

Usage

A rule fires for every element its match selector hits, in document order. The format text is inserted into each match, with {counter} placeholders that read the named counters; a placeholder can carry a style after a colon, as in {chapter:upper-roman}. Set increment to 0 to insert a counter's value without advancing it. A <CounterDef> with resetEach provides restarts, and a data-scope marker provides nesting, so a rule itself only advances and inserts. Rules add to the default heading scheme, so a rule that numbers headings needs defaultHeadings set to false on its <Numbering>. Author rules as <NumberingRule> children of <Numbering>.

Was this page helpful?