What is (or what should be) the range of indices of ordered-list items?

The CommonMark specs (0.20) says

An ordered list marker is a sequence of one of more digits (0-9), followed by either a . character or a ) character.

Is there no upper bound? As far as I know, the WC3 standard itself doesn’t specify any upper bound for those indices:

Zero or more li elements.

or for the value of the start attribute:

The ordinal value of the first list item.

However, in Safari (v8.0.6) at least, I’ve observed that

  • signed 32-bit integers seem to be used for indexing the items of ordered lists;
  • the maximum value that can be displayed (i.e. in the rendered output) is 2^31 - 1 (i.e. 2147483647);
  • the values of indices end up wrapping around (to negative 2^31) if the start number is less than or equal to 2^31 - 1;
  • the first displayed number of an ordered list is 1 if the value of the start attribute is greater than 2^31 - 1.

For instance, the following CommonMark example

2147483647. foo
2. bar
3. baz

gets rendered as

2147483647. foo
-2147483648. bar
-2147483647. baz

(You can try it for yourself by testing this example in the commonmark.js dingus.)

To avoid this “inconsistency”, shouldn’t the CommonMark specs limit the range of indices to 0,…,2^31-1?

1 Like

Firefox renders them in yet another way, so probably is better to suggest to stay in that range.

I’ve added a 9-digit limit to start numbers.

1 Like