From 4b9de9ff088f887c1a5633c598a013d61774c78b Mon Sep 17 00:00:00 2001 From: The one with the braid Date: Tue, 31 Dec 2024 15:56:54 +0100 Subject: [PATCH] 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 --- lib/src/processing/lists.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/src/processing/lists.dart b/lib/src/processing/lists.dart index d52403f060..ea00d56c12 100644 --- a/lib/src/processing/lists.dart +++ b/lib/src/processing/lists.dart @@ -38,6 +38,16 @@ class ListProcessing { // Add the counters to ol and ul types. if (tree.name == 'ol' || tree.name == 'ul') { + // respect the `start` attribute in order to begin lists at !1. + final startAttribute = tree.attributes['start']; + final offset = + startAttribute == null ? 1 : int.tryParse(startAttribute) ?? 1; + + tree.style.counterIncrement ??= {}; + // the counter starts at 1 so set to 0 in order to be correct after first + // increment + tree.style.counterIncrement!['list-item'] = offset - 1; + tree.style.counterReset ??= {}; if (!tree.style.counterReset!.containsKey('list-item')) { tree.style.counterReset!['list-item'] = 0;