Skip to content

[css-counter-styles] Define extended CJK longhand counter styles range #12383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
restore old spec
  • Loading branch information
sakupi01 committed Jun 22, 2025
commit 908673a3fa226438a2b11f1a1779f8edaf3f8145
365 changes: 358 additions & 7 deletions css-counter-styles-3/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2056,8 +2056,9 @@ Longhand East Asian Counter Styles</h3>
████████ ████ ██ ██ ████ ██ ████████ ████████ ██████ ██████ ██ ██
-->

<h4 id='limited-japanese'>
Japanese: ''japanese-informal'' and ''japanese-formal''</h4>
<h4 id='limited-range-required'>Limited-range Implementation (required)</h4>
<h5 id='limited-japanese'>
Japanese: ''japanese-informal'' and ''japanese-formal''</h5>

<dl dfn-type="value" dfn-for="<counter-style-name>">
<dt><dfn id="japanese-informal">japanese-informal</dfn>
Expand Down Expand Up @@ -2098,8 +2099,8 @@ Japanese: ''japanese-informal'' and ''japanese-formal''</h4>
</pre>


<h4 id=limited-korean>
Korean: ''korean-hangul-formal'', ''korean-hanja-informal'', and ''korean-hanja-formal''</h4>
<h5 id=limited-korean>
Korean: ''korean-hangul-formal'', ''korean-hanja-informal'', and ''korean-hanja-formal''</h5>

<dl dfn-for="<counter-style-name>" dfn-type="value">
<dt><dfn id="korean-hangul-formal">korean-hangul-formal</dfn>
Expand Down Expand Up @@ -2154,8 +2155,8 @@ Korean: ''korean-hangul-formal'', ''korean-hanja-informal'', and ''korean-hanja-
</pre>


<h4 id='limited-chinese'>
Chinese: ''simp-chinese-informal'', ''simp-chinese-formal'', ''trad-chinese-informal'', and ''trad-chinese-formal''</h4>
<h5 id='limited-chinese'>
Chinese: ''simp-chinese-informal'', ''simp-chinese-formal'', ''trad-chinese-informal'', and ''trad-chinese-formal''</h5>

<dl dfn-type="value" dfn-for="<counter-style>">
<dt><dfn id="simp-chinese-informal">simp-chinese-informal</dfn>
Expand Down Expand Up @@ -2184,7 +2185,7 @@ Chinese: ''simp-chinese-informal'', ''simp-chinese-formal'', ''trad-chinese-info
(It exists for legacy reasons.)
</dl>

The Chinese longhand styles are defined by almost identical algorithms
The <dfn dfn>Chinese</dfn> longhand styles are defined by almost identical algorithms
(specified as a single algorithm here, with the differences called out when relevant),
but use different sets of characters,
as specified by the table following the algorithm.
Expand Down Expand Up @@ -2361,6 +2362,356 @@ Chinese: ''simp-chinese-informal'', ''simp-chinese-formal'', ''trad-chinese-info
</pre>
</div>

<h4 id='extended-range-optional'>Extended Implementation (optional)</h4>

Some counter styles described in earlier chapters have been limited to an artifically small (though still useful) range to reduce the overall complexity of the spec and the task of implementing those styles. However, some implementations might consider the extra complexity worthwhile for the additional range it offers to authors. To accomodate this, this section describes how to extend the limited counter-styles to a larger range.

This entire section is normative, but <strong>optional</strong>. User-agents may ignore it and still be conformant. If a user-agent implements some of the extended forms described in this section, they must be implemented as described here.

The Chinese longhand styles are defined out to 10k with a [=Chinese|specialized algorithm=], while the Japanese and Korean longhand styles are defined similarly as ''additive'' styles. However, these styles are defined out to 10<sup>16</sup> in common usage. The following section describes an alternative algorithm for these styles.

The Chinese and Japanese styles are defined for all numbers between -10<sup>16</sup> and 10<sup>16</sup>, exclusive; the Korean styles are defined for all non-negative numbers less than 10<sup>16</sup>. For numbers outside this range, the ''cjk-decimal'' style is used. All of the styles are defined by almost identical algorithms (specified as a single algorithm here, with the differences called out when relevant), but use different sets of characters. The list following the algorithm gives the name of each counter style using this algorithm, and the individual character sets used by each style.

<ol>
<li>If the counter value is 0, the representation is the character for 0
specified for the given counter style. Skip the rest of this algorithm.

</li><li>Initially represent the counter value as a decimal number. Starting
from the right (ones place), split the decimal number into groups of
four digits.

</li><li>For each group with a non-zero value, append the appropriate group
marker to the group. The ones group has no marker.

</li><li>Within each group, for each digit that is not 0, append the appropriate
digit marker to the digit. The ones digit of each group has no marker.

</li><li>Drop ones:
<ul>
<li>For the Chinese informal styles, for any group with a value
between ten and nineteen, remove the tens digit (leave the digit
marker).

</li><li>For the Japanese informal and Korean informal styles, if any
of the digit markers are preceded by the digit 1, and that digit
is not the first digit of the group, remove the digit (leave the
digit marker).

</li><li>For Korean informal styles, if the value of the ten-thousands
group is 1, drop the digit (leave the digit marker).
</li></ul>


</li><li>Drop zeros:
<ul>
<li>For the Japanese and Korean styles, drop all zero digits.

</li><li>For the Chinese styles, drop any trailing zeros for all
non-zero groups and collapse (across groups) each remaining
consecutive group of zeros into a single zero digit.
</li></ul>

</li><li>For the Korean styles, insert a space (" " U+0020) between each group.

</li><li>Replace the digits 0-9 with the appropriate character for the given
counter style. Return the resultant string as the representation of the
counter value.
</li></ol>

For all of these counter styles, the '@counter-style/suffix' is "、" U+3001, the '@counter-style/fallback' is ''cjk-decimal'', and the '@counter-style/negative' is given in the tables below, or else is the initial value of the descriptor. For Chinese and Japanese, the '@counter-style/range' is ''-9999999999999999 9999999999999999'' (-10<sup>16</sup>+1 and 10<sup>16</sup>-1), while for Korean it's ''0 9999999999999999'' (again, 10<sup>16</sup>-1).

The following tables define the characters used in these styles:
<table class="data">
<thead>
<tr>
<th rowspan="2" scope="col">Values
</th><th colspan="4" scope="col">Codepoints
</th></tr><tr>
<th>simp-chinese-informal
</th><th>simp-chinese-formal
</th><th>trad-chinese-informal
</th><th>trad-chinese-formal
</th></tr></thead>
<tbody>
<tr>
<th scope="row">Digit 0
</th><td>零 U+96F6
</td><td>零 U+96F6
</td><td>零 U+96F6
</td><td>零 U+96F6
</td></tr><tr>
<th scope="row">Digit 1
</th><td>一 U+4E00
</td><td>壹 U+58F9
</td><td>一 U+4E00
</td><td>壹 U+58F9
</td></tr><tr>
<th scope="row">Digit 2
</th><td>二 U+4E8C
</td><td>贰 U+8D30
</td><td>二 U+4E8C
</td><td>貳 U+8CB3
</td></tr><tr>
<th scope="row">Digit 3
</th><td>三 U+4E09
</td><td>叁 U+53C1
</td><td>三 U+4E09
</td><td>參 U+53C3
</td></tr><tr>
<th scope="row">Digit 4
</th><td>四 U+56DB
</td><td>肆 U+8086
</td><td>四 U+56DB
</td><td>肆 U+8086
</td></tr><tr>
<th scope="row">Digit 5
</th><td>五 U+4E94
</td><td>伍 U+4F0D
</td><td>五 U+4E94
</td><td>伍 U+4F0D
</td></tr><tr>
<th scope="row">Digit 6
</th><td>六 U+516D
</td><td>陆 U+9646
</td><td>六 U+516D
</td><td>陸 U+9678
</td></tr><tr>
<th scope="row">Digit 7
</th><td>七 U+4E03
</td><td>柒 U+67D2
</td><td>七 U+4E03
</td><td>柒 U+67D2
</td></tr><tr>
<th scope="row">Digit 8
</th><td>八 U+516B
</td><td>捌 U+634C
</td><td>八 U+516B
</td><td>捌 U+634C
</td></tr><tr>
<th scope="row">Digit 9
</th><td>九 U+4E5D
</td><td>玖 U+7396
</td><td>九 U+4E5D
</td><td>玖 U+7396
</td></tr><tr>
<th scope="row">Second Digit Marker
</th><td>十 U+5341
</td><td>拾 U+62FE
</td><td>十 U+5341
</td><td>拾 U+62FE
</td></tr><tr>
<th scope="row">Third Digit Marker
</th><td>百 U+767E
</td><td>佰 U+4F70
</td><td>百 U+767E
</td><td>佰 U+4F70
</td></tr><tr>
<th scope="row">Fourth Digit Marker
</th><td>千 U+5343
</td><td>仟 U+4EDF
</td><td>千 U+5343
</td><td>仟 U+4EDF
</td></tr><tr>
<th scope="row">Second Group Marker
</th><td>万 U+4E07
</td><td>万 U+4E07
</td><td>萬 U+842C
</td><td>萬 U+842C
</td></tr><tr>
<th scope="row">Third Group Marker
</th><td>亿 U+4EBF
</td><td>亿 U+4EBF
</td><td>億 U+5104
</td><td>億 U+5104
</td></tr><tr>
<th scope="row">Fourth Group Marker
</th><td>万亿 U+4E07 U+4EBF
</td><td>万亿 U+4E07 U+4EBF
</td><td>兆 U+5146
</td><td>兆 U+5146
</td></tr><tr>
<th scope="row">Negative Sign
</th><td>负 U+8D1F
</td><td>负 U+8D1F
</td><td>負 U+8CA0
</td><td>負 U+8CA0
</td></tr></tbody>
</table>

<table class="data">
<thead>
<tr>
<th rowspan="2" scope="col">Values
</th><th colspan="2" scope="col">Codepoints
</th></tr><tr>
<th>japanese-informal
</th><th>japanese-formal
</th></tr></thead>
<tbody>
<tr>
<th scope="row">Digit 0
</th><td>〇 U+3007
</td><td>零 U+96F6
</td></tr><tr>
<th scope="row">Digit 1
</th><td>一 U+4E00
</td><td>壱 U+58F1
</td></tr><tr>
<th scope="row">Digit 2
</th><td>二 U+4E8C
</td><td>弐 U+5F10
</td></tr><tr>
<th scope="row">Digit 3
</th><td>三 U+4E09
</td><td>参 U+53C2
</td></tr><tr>
<th scope="row">Digit 4
</th><td>四 U+56DB
</td><td>四 U+56DB
</td></tr><tr>
<th scope="row">Digit 5
</th><td>五 U+4E94
</td><td>伍 U+4f0D
</td></tr><tr>
<th scope="row">Digit 6
</th><td>六 U+516D
</td><td>六 U+516D
</td></tr><tr>
<th scope="row">Digit 7
</th><td>七 U+4E03
</td><td>七 U+4E03
</td></tr><tr>
<th scope="row">Digit 8
</th><td>八 U+516B
</td><td>八 U+516B
</td></tr><tr>
<th scope="row">Digit 9
</th><td>九 U+4E5D
</td><td>九 U+4E5D
</td></tr><tr>
<th scope="row">Second Digit Marker
</th><td>十 U+5341
</td><td>拾 U+62FE
</td></tr><tr>
<th scope="row">Third Digit Marker
</th><td>百 U+767E
</td><td>百 U+767E
</td></tr><tr>
<th scope="row">Fourth Digit Marker
</th><td>千 U+5343
</td><td>阡 U+9621
</td></tr><tr>
<th scope="row">Second Group Marker
</th><td>万 U+4E07
</td><td>萬 U+842C
</td></tr><tr>
<th scope="row">Third Group Marker
</th><td>億 U+5104
</td><td>億 U+5104
</td></tr><tr>
<th scope="row">Fourth Group Marker
</th><td>兆 U+5146
</td><td>兆 U+5146
</td></tr><tr>
<th scope="row">Negative Sign
</th><td colspan="2">マイナス U+30DE U+30A4 U+30CA U+30B9
</td></tr></tbody>
</table>

<table class="data">
<thead>
<tr>
<th rowspan="2" scope="col">Values
</th><th colspan="3" scope="col">Codepoints
</th></tr><tr>
<th>korean-hangul-formal
</th><th>korean-hanja-informal
</th><th>korean-hanja-formal
</th></tr></thead>
<tbody>
<tr>
<th scope="row">Digit 0
</th><td>영 U+C601
</td><td>零 U+96F6
</td><td>零 U+96F6
</td></tr><tr>
<th scope="row">Digit 1
</th><td>일 U+C77C
</td><td>一 U+4E00
</td><td>壹 U+58F9
</td></tr><tr>
<th scope="row">Digit 2
</th><td>이 U+C774
</td><td>二 U+4E8C
</td><td>貳 U+8CB3
</td></tr><tr>
<th scope="row">Digit 3
</th><td>삼 U+C0BC
</td><td>三 U+4E09
</td><td>參 U+53C3
</td></tr><tr>
<th scope="row">Digit 4
</th><td>사 U+C0AC
</td><td>四 U+56DB
</td><td>四 U+56DB
</td></tr><tr>
<th scope="row">Digit 5
</th><td>오 U+C624
</td><td>五 U+4E94
</td><td>五 U+4E94
</td></tr><tr>
<th scope="row">Digit 6
</th><td>육 U+C721
</td><td>六 U+516D
</td><td>六 U+516D
</td></tr><tr>
<th scope="row">Digit 7
</th><td>칠 U+CE60
</td><td>七 U+4E03
</td><td>七 U+4E03
</td></tr><tr>
<th scope="row">Digit 8
</th><td>팔 U+D314
</td><td>八 U+516B
</td><td>八 U+516B
</td></tr><tr>
<th scope="row">Digit 9
</th><td>구 U+AD6C
</td><td>九 U+4E5D
</td><td>九 U+4E5D
</td></tr><tr>
<th scope="row">Second Digit Marker
</th><td>십 U+C2ED
</td><td>十 U+5341
</td><td>拾 U+62FE
</td></tr><tr>
<th scope="row">Third Digit Marker
</th><td>백 U+BC31
</td><td>百 U+767E
</td><td>百 U+767E
</td></tr><tr>
<th scope="row">Fourth Digit Marker
</th><td>천 U+CC9C
</td><td>千 U+5343
</td><td>仟 U+4EDF
</td></tr><tr>
<th scope="row">Second Group Marker
</th><td>만 U+B9CC
</td><td>萬 U+842C
</td><td>萬 U+842C
</td></tr><tr>
<th scope="row">Third Group Marker
</th><td>억 U+C5B5
</td><td>億 U+5104
</td><td>億 U+5104
</td></tr><tr>
<th scope="row">Fourth Group Marker
</th><td>조 U+C870
</td><td>兆 U+5146
</td><td>兆 U+5146
</td></tr></tbody>
</table>

<!--
████████ ████████ ██ ██ ████ ███████ ████████ ████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
Expand Down