Skip to content

fix: honor ordered list start number#525

Open
yyq1025 wants to merge 2 commits into
software-mansion:mainfrom
yyq1025:fix/ordered-list-start
Open

fix: honor ordered list start number#525
yyq1025 wants to merge 2 commits into
software-mansion:mainfrom
yyq1025:fix/ordered-list-start

Conversation

@yyq1025

@yyq1025 yyq1025 commented Jul 8, 2026

Copy link
Copy Markdown

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. foo should render as 3, 4, 5 (see https://spec.commonmark.org/0.31.2/#start-number). md4c already reports this via MD_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 start attribute on the OrderedList node (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-markdown package 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-screenshots and verified to assert clean afterwards. Existing ordered_list_test and nested_ordered_list_test still pass on both platforms (lists starting at 1 render exactly as before — the attribute isn't emitted for them).

Screenshots

Input:

3. Add eggs and vanilla extract
4. Pour into a greased tin
5. Bake for 30 minutes
iOS Android

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes
  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

🤖 Generated with Claude Code

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 eszlamczyk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the quick well done job! Im gonna remove some comments and merge so we get this in next nightly release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ordered lists ignore the start number of the first item

2 participants