Skip to content

Commit 310d94b

Browse files
fix: respect the ol start attribute
- adds support for the ol start attribute Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol#start Signed-off-by: The one with the braid <[email protected]>
1 parent 79ec194 commit 310d94b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/src/processing/lists.dart

+10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ class ListProcessing {
3838

3939
// Add the counters to ol and ul types.
4040
if (tree.name == 'ol' || tree.name == 'ul') {
41+
// respect the `start` attribute in order to begin lists at !1.
42+
final startAttribute = tree.attributes['start'];
43+
final offset =
44+
startAttribute == null ? 1 : int.tryParse(startAttribute) ?? 1;
45+
46+
tree.style.counterIncrement ??= {};
47+
// the counter starts at 1 so set to 0 in order to be correct after first
48+
// increment
49+
tree.style.counterIncrement!['list-item'] = offset - 1;
50+
4151
tree.style.counterReset ??= {};
4252
if (!tree.style.counterReset!.containsKey('list-item')) {
4353
tree.style.counterReset!['list-item'] = 0;

0 commit comments

Comments
 (0)