fix: honor ordered list start number#525
Open
yyq1025 wants to merge 2 commits into
Open
Conversation
GFM renders an ordered list starting at its first item's literal number
("3. foo" renders 3, 4, ...). md4c already reports it via
MD_BLOCK_OL_DETAIL.start, but the parser dropped it, so both renderers
restarted every list at 1.
Pass it through as a "start" attribute on the OrderedList node (set only
when != 1) and seed the item counter from it on iOS and Android.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
eszlamczyk
approved these changes
Jul 8, 2026
eszlamczyk
left a comment
Collaborator
There was a problem hiding this comment.
Hi, thanks for the quick well done job! Im gonna remove some comments and merge so we get this in next nightly release!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What/Why?
Fixes #524.
Per CommonMark/GFM, the start number of an ordered list is determined by the list number of its first item —
3. fooshould render as 3, 4, 5 (see https://spec.commonmark.org/0.31.2/#start-number). md4c already reports this viaMD_BLOCK_OL_DETAIL.start, but the shared parser dropped it, so both renderers restarted every ordered list at 1.This PR passes it through as a
startattribute on theOrderedListnode (set only when != 1, so renderers can treat absence as the default) and seeds the per-level item counter from it on iOS and Android.0.start is honored too, matching GitHub rendering. Nested-list numbering is unaffected — the counter stack works exactly as before, each level just starts from its own first item's number.Scope note: the standalone
android-enriched-markdownpackage is intentionally untouched — its renderer ignores the new attribute, so behavior there is unchanged. Happy to mirror the fix in a follow-up if useful.Testing
Added
ordered_list_start_test.yaml(basic/block_elements) with iOS + Android screenshot baselines, captured via--update-screenshotsand verified to assert clean afterwards. Existingordered_list_testandnested_ordered_list_teststill pass on both platforms (lists starting at 1 render exactly as before — the attribute isn't emitted for them).Screenshots
Input:
PR Checklist
🤖 Generated with Claude Code