Skip to content

fix(stringify): render ordered-list start as native numbering#255

Merged
farnabaz merged 2 commits into
comarkdown:mainfrom
hendrikheil:fix/ordered-list-start-roundtrip
Jun 30, 2026
Merged

fix(stringify): render ordered-list start as native numbering#255
farnabaz merged 2 commits into
comarkdown:mainfrom
hendrikheil:fix/ordered-list-start-roundtrip

Conversation

@hendrikheil

Copy link
Copy Markdown
Contributor

Problem

An ordered list with a non-1 start round-tripped to the verbose ::ol{…} block form instead of native markdown numbering:

5. First item        ::ol{start="5"}
6. Second item   →    1. First item
7. Third item         2. Second item
                      ::

The same path means a legacy ::ol{start="…"} wrapper (e.g. one written by an older renderer) never normalizes back to a plain list — it stays an MDC component block. AST and HTML were already correct; only the Markdown round-trip was affected.

Root cause

handlers/ol.ts hardcoded the item counter to order: 1, and nothing marked start as implicit. So userBlockAttrs('ol', { start }) treated start as a genuine user attr and forced the ::ol{…} wrapper form, losing the native numbering.

Fix

  • handlers/ol.ts: seed the item counter from start (order = start >= 1 ? start : 1) so native numbering carries it.
  • stringify/attributes.ts: add ol: { drop: ['start'] } to IMPLICIT_ATTRS, so start is recognized as conveyed by the native syntax and never echoes into a wrapper.

Result (idempotent)

  • 5. 6. 7. → round-trips as native 5. 6. 7.
  • ::ol{start="3"}\n1. …\n:: → normalizes to native 3. 4. …
  • ::ol{start="undefined"}\n1. …\n:: → heals to clean 1. 2. 3.
  • ::ol{attr="value"} (a genuine non-start attr) → still wraps (unchanged)

Tests

Two new SPECs (common-mark/ordered-list-start.md, COMARK/ordered-list-start-wrapper-normalizes.md); full suite 1084 passing. The #214 attribute specs (attributes/ordered-list.md, attributes/wrapped-ol.md) stay green.

🤖 Generated with Claude Code

An ordered list with a non-1 `start` (e.g. `5. 6. 7.`) round-tripped to the
verbose `::ol{start="5"}\n1. …\n::` wrapper instead of native markdown
numbering. `ol.ts` hardcoded the item counter to `order: 1`, and nothing
marked `start` as implicit, so `userBlockAttrs('ol', …)` treated it as a real
user attr and forced the `::ol{…}` block form.

Seed the counter from `start` and add `ol: { drop: ['start'] }` to
`IMPLICIT_ATTRS` so `start` is recognized as conveyed by the native syntax.
Now `5. 6. 7.` round-trips losslessly, and a legacy `::ol{start="…"}` wrapper
normalizes to clean native numbering. Genuine non-`start` attrs still wrap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

@hendrikheil is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Jun 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

comark

npm i https://pkg.pr.new/comarkdown/comark@255

@comark/angular

npm i https://pkg.pr.new/comarkdown/comark/@comark/angular@255

@comark/ansi

npm i https://pkg.pr.new/comarkdown/comark/@comark/ansi@255

@comark/html

npm i https://pkg.pr.new/comarkdown/comark/@comark/html@255

@comark/nuxt

npm i https://pkg.pr.new/comarkdown/comark/@comark/nuxt@255

@comark/react

npm i https://pkg.pr.new/comarkdown/comark/@comark/react@255

@comark/svelte

npm i https://pkg.pr.new/comarkdown/comark/@comark/svelte@255

@comark/vue

npm i https://pkg.pr.new/comarkdown/comark/@comark/vue@255

commit: d0b3b62

@hendrikheil hendrikheil marked this pull request as ready for review June 29, 2026 15:16
@hendrikheil hendrikheil requested a review from farnabaz as a code owner June 29, 2026 15:16

@farnabaz farnabaz 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.

Thanks

@farnabaz farnabaz merged commit e5275e3 into comarkdown:main Jun 30, 2026
3 of 11 checks passed
@hendrikheil hendrikheil deleted the fix/ordered-list-start-roundtrip branch June 30, 2026 11:04
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.

2 participants