HTML Ordered List Counter Sequence

Calculate ordered-list counters with explicit start, reversed/default-start policy and per-item integer value overrides; operates on supplied item records, not a DOM tree.

Description

Calculate ordered-list counters with explicit start, reversed/default-start policy and per-item integer value overrides; operates on supplied item records, not a DOM tree.

Ordered lists can count upward or downward, and an item value can reset the sequence. This calculator follows those declarations on supplied item records.

When to use this tool

Calculate ordered-list counters with explicit start, reversed/default-start policy and per-item integer value overrides; operates on supplied item records, not a DOM tree.

  • Prepare the supplied itemsJson, start, reversed, useDefaultStart fields for this operation.
  • Compare the complete example with the representation used by your own input before carrying the result into another step.

How to use the tool and how it works

  1. Enter itemsJson, start, reversed, useDefaultStart. Use the exact text syntax, units and index conventions explained below.
  2. Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
  3. Read result.counters, result.next. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.

Read itemsJson as objects, with optional integer value overrides. With useDefaultStart, begin at 1 or, when reversed, the item count; otherwise use start. Each override replaces the next counter before emission. Step by +1 or -1 and return counters plus the following next value.1

Input fieldMeaning and representationAccepted input
itemsJsonJSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file.Text
startstart.Integer from -1e9 to 1e9 inclusive
reversedExplicit choice for reversed; supply a boolean rather than a text label.true or false
useDefaultStartExplicit choice for use default start; supply a boolean rather than a text label.true or false

For the JSON text fields, the following decoded structures show the example records before they are serialized into input strings. Keep field names, list nesting and value types as shown.

json
[
  {
    "field": "itemsJson",
    "decoded": [
      {},
      {
        "value": 7
      },
      {},
      {}
    ]
  }
]
Output fieldInterpretation
resultObject containing the named outputs below.
result.countersThe counters list in the ordering and representation described above.
result.nextThe next value under the stated formula or text convention.
json
{
  "input": {
    "itemsJson": "[{},{\"value\":7},{},{}]",
    "start": 3,
    "reversed": true,
    "useDefaultStart": false
  },
  "output": {
    "result": {
      "counters": [
        3,
        7,
        6,
        5
      ],
      "next": 4
    }
  }
}

Limitations and assumptions

  • No DOM or CSS counters are inspected. start is required even when ignored by the default policy; declared start and overrides are bounded to plus or minus one billion.
  • All declared input fields are required and unexpected top-level fields are rejected. Numbers must be finite; lists are limited to 128 entries and ordinary text fields to 8,192 UTF-16 code units, with tighter limits where stated.
  • JSON text inputs must parse within bounded nesting and size limits. Numeric outputs outside the safe finite range are rejected; large exact integer results use decimal strings. Indexes and half-open spans are zero-based unless a rank is explicitly described as one-based.

Alternative or Complementary methods

For actual document behavior, inspect a parsed DOM and the relevant HTML algorithm. These tools transform supplied tokens, observations or coordinates; compare the browser result when parsing or layout matters.

References

  1. Tool behavior and example: HTML Ordered List Counter Sequence — tool.io

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies