Skip to content

Commit 3145751

Browse files
committed
[css-counter-styles-3] Make all algorithms capable of rendering negatives. Describe how to handle the 'width' descriptor. Make all the descriptors use <symbol> rather than <string>.
1 parent 4ae9f29 commit 3145751

File tree

2 files changed

+78
-79
lines changed

2 files changed

+78
-79
lines changed

css-counter-styles-3/Overview.html

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,28 @@ <h2 id=counter-styles><span class=secno>2. </span> Counter Styles</h2>
409409
<ol>
410410
<li> If the counter value is outside the <a href="#range"><i
411411
title=counter-range>range</i></a> of the counter style, exit this
412-
algorithm and instead <i title=generate-a-counter>generate a counter
413-
representation</i> using the counter style's fallback style and the same
414-
counter value.
412+
algorithm and instead <a
413+
href="#generate-a-counter-representation"><i>generate a counter
414+
representation</i></a> using the counter style's fallback style and the
415+
same counter value.
415416

416417
<li> Using the counter value and the <a href="#algorithm"><i
417418
title=counter-algorithm>counter algorithm</i></a> for the counter style,
418-
generate an initial representation for the counter value.
419+
generate an initial representation for the counter value. If the counter
420+
value is negative, instead generate an initial representation using the
421+
absolute value of it.
422+
423+
<li> If the representation uses less symbols than specified in the counter
424+
style's ‘<a href="#descdef-width"><code
425+
class=property>width</code></a>’ descriptor, prepend symbols to the
426+
representation as specified in the ‘<a href="#descdef-width"><code
427+
class=property>width</code></a>’ descriptor.
428+
429+
<li> If the counter value is negative, wrap the representation in the
430+
counter style's <a href="#negative-sign"><i
431+
title=counter-negative>negative sign</i></a> as specified in the ‘<a
432+
href="#descdef-negative"><code class=property>negative</code></a>
433+
descriptor.
419434

420435
<li> Return the representation.
421436
</ol>
@@ -863,19 +878,14 @@ <h4 id=numeric-system><span class=secno>3.1.5. </span> Positional Numerals:
863878

864879
<p> Let <var>N</var> be the length of the list of <i>counter symbols</i>,
865880
<var>value</var> initially be the counter value, <var>S</var> initially be
866-
the empty string, <a href="#descdef-negative"><var>negative</var></a> be a
867-
boolean flag that is initially false, and <var>symbol(n)</var> be the nth
868-
<a href="#counter-symbol"><i>counter symbol</i></a> in the list of
869-
<i>counter symbols</i> (0-indexed).
881+
the empty string, and <var>symbol(n)</var> be the nth <a
882+
href="#counter-symbol"><i>counter symbol</i></a> in the list of <i>counter
883+
symbols</i> (0-indexed).
870884

871885
<ol>
872886
<li>If <var>value</var> is 0, append <var>symbol(0)</var> to <var>S</var>
873887
and return <var>S</var>.
874888

875-
<li>If <var>value</var> is negative, run the next step of this algorithm
876-
with <var>value</var> being the absolute value of <var>value</var>
877-
instead.
878-
879889
<li>While <var>value</var> is not equal to 0:
880890
<ol>
881891
<li>Prepend <var>symbol( <var>value</var> mod <var>N</var> )</var> to
@@ -885,11 +895,6 @@ <h4 id=numeric-system><span class=secno>3.1.5. </span> Positional Numerals:
885895
)</code>.
886896
</ol>
887897

888-
<li>If <var>value</var> was originally negative, wrap <var>S</var> in the
889-
counter style's <a href="#negative-sign"><i
890-
title=counter-negative>negative sign</i></a>, as specified in the section
891-
for the <a href="#counter-style-negative">negative descriptor</a>.
892-
893898
<li>Return <var>S</var>.
894899
</ol>
895900

@@ -950,10 +955,6 @@ <h4 id=additive-system><span class=secno>3.1.6. </span> Accumulating
950955
append that tuple's <a href="#counter-symbol"><i>counter symbol</i></a>
951956
to S and return S.
952957

953-
<li>If <var>value</var> is negative, run the next step of this algorithm
954-
with <var>value</var> being the absolute value of <var>value</var>
955-
instead.
956-
957958
<li>While <var>value</var> is greater than 0 and there are elements left
958959
in the <var>symbol list</var>:
959960
<ol>
@@ -973,11 +974,6 @@ <h4 id=additive-system><span class=secno>3.1.6. </span> Accumulating
973974
tuple</i></a> was appended to <var>S</var> in the previous step. </var>
974975
</ol>
975976

976-
<li>If <var>value</var> was originally negative, wrap <var>S</var> in the
977-
counter style's <a href="#negative-sign"><i
978-
title=counter-negative>negative sign</i></a>, as specified in the section
979-
for the <a href="#counter-style-negative">negative descriptor</a>.
980-
981977
<li>If the loop ended because <var>value</var> is 0, return S. Otherwise,
982978
the given counter value cannot be represented by this counter style, and
983979
must instead be represented by the fallback counter style.
@@ -1026,7 +1022,8 @@ <h3 id=counter-style-negative><span class=secno>3.2. </span> Formatting
10261022
<tr>
10271023
<th>Value:
10281024

1029-
<td>&lt;string> &lt;string>?
1025+
<td><a href="#ltsymbol"><var>&lt;symbol></var></a> <a
1026+
href="#ltsymbol"><var>&lt;symbol></var></a>?
10301027

10311028
<tr>
10321029
<th>Initial:
@@ -1036,11 +1033,11 @@ <h3 id=counter-style-negative><span class=secno>3.2. </span> Formatting
10361033

10371034
<p>The ‘<a href="#descdef-negative"><code
10381035
class=property>negative</code></a>’ descriptor defines how to alter the
1039-
representation when the counter value is negative. Not all counter systems
1040-
can render negative numbers.
1036+
representation when the counter value is negative.
10411037

1042-
<p>The first string in the value is prepended to the representation when
1043-
the counter value is negative. The second string, if specified, is
1038+
<p>The first <a href="#ltsymbol"><var>&lt;symbol></var></a> in the value is
1039+
prepended to the representation when the counter value is negative. The
1040+
second <a href="#ltsymbol"><var>&lt;symbol></var></a>, if specified, is
10441041
appended to the representation when the counter value is negative.
10451042

10461043
<div class=example>
@@ -1063,7 +1060,7 @@ <h3 id=counter-style-prefix><span class=secno>3.3. </span> Symbols before
10631060
<tr>
10641061
<th>Value:
10651062

1066-
<td>&lt;string>
1063+
<td><a href="#ltsymbol"><var>&lt;symbol></var></a>
10671064

10681065
<tr>
10691066
<th>Initial:
@@ -1072,9 +1069,10 @@ <h3 id=counter-style-prefix><span class=secno>3.3. </span> Symbols before
10721069
</table>
10731070

10741071
<p>The ‘<a href="#descdef-prefix"><code
1075-
class=property>prefix</code></a>’ descripter specifies a string that is
1076-
prepended to the marker representation. Prefixes are only added by the
1077-
algorithm for constructing the default contents of the ‘<code
1072+
class=property>prefix</code></a>’ descripter specifies a <a
1073+
href="#ltsymbol"><var>&lt;symbol></var></a> that is prepended to the
1074+
marker representation. Prefixes are only added by the algorithm for
1075+
constructing the default contents of the ‘<code
10781076
class=css>::marker</code>’ pseudo-element; the prefix is not added
10791077
automatically when the counter() or counters() functions are used.
10801078
Prefixes come before any negative sign.
@@ -1093,7 +1091,7 @@ <h3 id=counter-style-suffix><span class=secno>3.4. </span> Symbols after
10931091
<tr>
10941092
<th>Value:
10951093

1096-
<td>&lt;string>
1094+
<td><a href="#ltsymbol"><var>&lt;symbol></var></a>
10971095

10981096
<tr>
10991097
<th>Initial:
@@ -1102,12 +1100,13 @@ <h3 id=counter-style-suffix><span class=secno>3.4. </span> Symbols after
11021100
</table>
11031101

11041102
<p>The ‘<a href="#descdef-suffix"><code
1105-
class=property>suffix</code></a>’ descripter specifies a string that is
1106-
appended to the marker representation. Suffixes are only added by the
1107-
algorithm for constructing the default contents of the ‘<code
1108-
class=css>::marker</code>’ pseudo-element; the suffix is not added
1109-
automatically when the counter() or counters() functions are used.
1110-
Suffixes are added to the representation after negative signs.
1103+
class=property>suffix</code></a>’ descripter specifies a <a
1104+
href="#ltsymbol"><var>&lt;symbol></var></a> that is appended to the marker
1105+
representation. Suffixes are only added by the algorithm for constructing
1106+
the default contents of the ‘<code class=css>::marker</code>
1107+
pseudo-element; the suffix is not added automatically when the counter()
1108+
or counters() functions are used. Suffixes are added to the representation
1109+
after negative signs.
11111110

11121111
<h3 id=counter-style-range><span class=secno>3.5. </span> Limiting the
11131112
counter scope: the ‘<a href="#descdef-range"><code
@@ -1202,7 +1201,8 @@ <h3 id=counter-style-width><span class=secno>3.6. </span> Constant-width
12021201
<p> The ‘<a href="#descdef-width"><code
12031202
class=property>width</code></a>’ descriptor allows an author to specify
12041203
a "fixed-width" counter style, where representations shorter than the
1205-
width are padded with a particular character.
1204+
width are padded with a particular character. Representations larger than
1205+
the specified width are constructed as normal.
12061206

12071207
<dl>
12081208
<dt>auto
@@ -1216,14 +1216,14 @@ <h3 id=counter-style-width><span class=secno>3.6. </span> Constant-width
12161216
counter representations must reach. If a counter representation would be
12171217
generated using less <a href="#ltsymbol"><var>&lt;symbol></var></a>s than
12181218
the specified <var>&lt;integer></var> (before adding
1219-
prefixes/suffixes/negatives), pad the front of the representation with
1220-
copies of the specified <a href="#ltsymbol"><var>&lt;symbol></var></a>
1221-
until the number of symbols reaches the specified width.
1222-
<p> If the counter value is negative, reduce the width by one or two,
1223-
depending on whether the second <var>&lt;string></var> value is omitted
1224-
or provided, respectively, in the ‘<a href="#descdef-negative"><code
1225-
class=property>negative</code></a>descriptor for the given counter
1226-
style.
1219+
prefixes/suffixes/negatives), prepend copies of the specified <a
1220+
href="#ltsymbol"><var>&lt;symbol></var></a> to the representation until
1221+
the number of symbols reaches the specified width.
1222+
<p> If the counter value is negative, reduce the width by one or two when
1223+
determining how many copies to prepend, depending on whether the <a
1224+
href="#descdef-negative"><code class=property>negative</code></a>
1225+
descriptor's value is one or two <a
1226+
href="#ltsymbol"><var>&lt;symbol></var></a>s.
12271227
</dl>
12281228

12291229
<div class=example> The most common example of "fixed-width" numbering is
@@ -3683,14 +3683,14 @@ <h2 class=no-num id=descriptor-index>Descriptor index</h2>
36833683
<tr>
36843684
<th><a class=property href="#descdef-negative">negative</a>
36853685

3686-
<td>&lt;string> &lt;string>?
3686+
<td>&lt;symbol> &lt;symbol>?
36873687

36883688
<td>"\2D" ("-" hyphen-minus)
36893689

36903690
<tr>
36913691
<th><a class=property href="#descdef-prefix">prefix</a>
36923692

3693-
<td>&lt;string>
3693+
<td>&lt;symbol>
36943694

36953695
<td>"" (the empty string)
36963696

@@ -3711,7 +3711,7 @@ <h2 class=no-num id=descriptor-index>Descriptor index</h2>
37113711
<tr>
37123712
<th><a class=property href="#descdef-suffix">suffix</a>
37133713

3714-
<td>&lt;string>
3714+
<td>&lt;symbol>
37153715

37163716
<td>"\2E" ("." full stop)
37173717

css-counter-styles-3/Overview.src.html

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,23 @@ <h2 id='counter-styles'>
145145
<ol>
146146
<li>
147147
If the counter value is outside the <i title='counter-range'>range</i> of the counter style,
148-
exit this algorithm and instead <i title='generate-a-counter'>generate a counter representation</i>
148+
exit this algorithm and instead <i>generate a counter representation</i>
149149
using the counter style's fallback style and the same counter value.
150150

151151
<li>
152152
Using the counter value and the <i title='counter-algorithm'>counter algorithm</i> for the counter style,
153153
generate an initial representation for the counter value.
154+
If the counter value is negative,
155+
instead generate an initial representation using the absolute value of it.
156+
157+
<li>
158+
If the representation uses less symbols than specified in the counter style's 'width' descriptor,
159+
prepend symbols to the representation as specified in the 'width' descriptor.
160+
161+
<li>
162+
If the counter value is negative,
163+
wrap the representation in the counter style's <i title='counter-negative'>negative sign</i>
164+
as specified in the 'negative' descriptor.
154165

155166
<li>
156167
Return the representation.
@@ -557,15 +568,12 @@ <h4 id="numeric-system">
557568
Let <var>N</var> be the length of the list of <i>counter symbols</i>,
558569
<var>value</var> initially be the counter value,
559570
<var>S</var> initially be the empty string,
560-
<var>negative</var> be a boolean flag that is initially false,
561571
and <var>symbol(n)</var> be the nth <i>counter symbol</i> in the list of <i>counter symbols</i> (0-indexed).
562572

563573
<ol>
564574
<li>If <var>value</var> is 0, append <var>symbol(0)</var> to
565575
<var>S</var> and return <var>S</var>.
566576

567-
<li>If <var>value</var> is negative, run the next step of this algorithm with <var>value</var> being the absolute value of <var>value</var> instead.
568-
569577
<li>While <var>value</var> is not equal to 0:
570578

571579
<ol>
@@ -574,9 +582,6 @@ <h4 id="numeric-system">
574582

575583
<li>Set <var>value</var> to <code>floor( <var>value</var> / <var>N</var> )</code>.
576584
</ol>
577-
578-
579-
<li>If <var>value</var> was originally negative, wrap <var>S</var> in the counter style's <i title='counter-negative'>negative sign</i>, as specified in the section for the <a href='#counter-style-negative'>negative descriptor</a>.
580585

581586
<li>Return <var>S</var>.
582587
</ol>
@@ -635,8 +640,6 @@ <h4 id="additive-system">
635640
<ol>
636641
<li>If <var>value</var> is initially 0, and there is an <i>additive tuple</i> with a weight of 0, append that tuple's <i>counter symbol</i> to S and return S.
637642

638-
<li>If <var>value</var> is negative, run the next step of this algorithm with <var>value</var> being the absolute value of <var>value</var> instead.
639-
640643
<li>While <var>value</var> is greater than 0 and there are elements left in the <var>symbol list</var>:
641644

642645
<ol>
@@ -651,9 +654,6 @@ <h4 id="additive-system">
651654
by the number of times the <i>current tuple</i> was appended to <var>S</var>
652655
in the previous step.
653656
</ol>
654-
655-
656-
<li>If <var>value</var> was originally negative, wrap <var>S</var> in the counter style's <i title='counter-negative'>negative sign</i>, as specified in the section for the <a href='#counter-style-negative'>negative descriptor</a>.
657657

658658
<li>If the loop ended because <var>value</var> is 0, return S. Otherwise, the given counter value cannot be represented by this counter style, and must instead be represented by the fallback counter style.
659659
</ol>
@@ -693,18 +693,17 @@ <h3 id='counter-style-negative'>
693693
<td><dfn id="descdef-negative">negative</dfn>
694694
<tr>
695695
<th>Value:
696-
<td>&lt;string> &lt;string>?
696+
<td><var>&lt;symbol></var> <var>&lt;symbol></var>?
697697
<tr>
698698
<th>Initial:
699699
<td>"\2D" ("-" hyphen-minus)
700700
</table>
701701

702702
<p>The 'negative' descriptor defines how to alter the representation when
703-
the counter value is negative. Not all counter systems can render negative
704-
numbers.
703+
the counter value is negative.
705704

706-
<p>The first string in the value is prepended to the representation when the
707-
counter value is negative. The second string, if specified, is appended
705+
<p>The first <var>&lt;symbol></var> in the value is prepended to the representation when the
706+
counter value is negative. The second <var>&lt;symbol></var>, if specified, is appended
708707
to the representation when the counter value is negative.
709708

710709
<div class='example'>
@@ -723,13 +722,13 @@ <h3 id='counter-style-prefix'>
723722
<td><dfn id="descdef-prefix">prefix</dfn>
724723
<tr>
725724
<th>Value:
726-
<td>&lt;string>
725+
<td><var>&lt;symbol></var>
727726
<tr>
728727
<th>Initial:
729728
<td>"" (the empty string)
730729
</table>
731730

732-
<p>The 'prefix' descripter specifies a string that is prepended to the
731+
<p>The 'prefix' descripter specifies a <var>&lt;symbol></var> that is prepended to the
733732
marker representation. Prefixes are only added by the algorithm for constructing
734733
the default contents of the ''::marker'' pseudo-element; the prefix is not
735734
added automatically when the counter() or counters() functions are used.
@@ -745,13 +744,13 @@ <h3 id='counter-style-suffix'>
745744
<td><dfn id="descdef-suffix">suffix</dfn>
746745
<tr>
747746
<th>Value:
748-
<td>&lt;string>
747+
<td><var>&lt;symbol></var>
749748
<tr>
750749
<th>Initial:
751750
<td>"\2E" ("." full stop)
752751
</table>
753752

754-
<p>The 'suffix' descripter specifies a string that is appended to the
753+
<p>The 'suffix' descripter specifies a <var>&lt;symbol></var> that is appended to the
755754
marker representation. Suffixes are only added by the algorithm for constructing
756755
the default contents of the ''::marker'' pseudo-element; the suffix is not
757756
added automatically when the counter() or counters() functions are used.
@@ -806,6 +805,7 @@ <h3 id='counter-style-width'>
806805
<p>
807806
The 'width' descriptor allows an author to specify a "fixed-width" counter style,
808807
where representations shorter than the width are padded with a particular character.
808+
Representations larger than the specified width are constructed as normal.
809809

810810
<dl>
811811
<dt>auto
@@ -817,14 +817,13 @@ <h3 id='counter-style-width'>
817817
The <var>&lt;integer></var> specifies a minimum width that all counter representations must reach.
818818
If a counter representation would be generated using less <var>&lt;symbol></var>s than the specified <var>&lt;integer></var>
819819
(before adding prefixes/suffixes/negatives),
820-
pad the front of the representation with copies of the specified <var>&lt;symbol></var>
820+
prepend copies of the specified <var>&lt;symbol></var> to the representation
821821
until the number of symbols reaches the specified width.
822822

823823
<p>
824824
If the counter value is negative,
825-
reduce the width by one or two,
826-
depending on whether the second <var>&lt;string></var> value is omitted or provided, respectively,
827-
in the 'negative' descriptor for the given counter style.
825+
reduce the width by one or two when determining how many copies to prepend,
826+
depending on whether the 'negative' descriptor's value is one or two <var>&lt;symbol></var>s.
828827
</dl>
829828

830829
<div class='example'>

0 commit comments

Comments
 (0)