Skip to content
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

fix: respect the ol start attribute #1456

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/src/processing/lists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@

// 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;

Check warning on line 44 in lib/src/processing/lists.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/processing/lists.dart#L44

Added line #L44 was not covered by tests

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;
Expand Down