Skip to content

Comments

fix: track fenced code state inside list items#354

Merged
kjk merged 1 commit intogomarkdown:masterfrom
vnykmshr:fix-346-fenced-code-in-list
Feb 17, 2026
Merged

fix: track fenced code state inside list items#354
kjk merged 1 commit intogomarkdown:masterfrom
vnykmshr:fix-346-fenced-code-in-list

Conversation

@vnykmshr
Copy link
Contributor

listItem() gatherlines loop doesn't track fenced code state, so - content inside a fence gets picked up as a new list item. Fix: track fence state inside the loop. Only indented fences count (at indent 0, fence ends the list). Abandon fence on non-indented lines so unclosed fences don't swallow later items.

5 tests covering dash content, ordered list, heading, tilde fences, and unclosed fence. go test ./... passes.

Fixes #346

Lines inside a fenced code block within a list item (e.g. `- test`
or `1. item`) were being misinterpreted as new list items or other
block-level structures. This caused the list to break incorrectly
whenever the fenced content happened to match list item syntax.

Add a fenceMarker variable to the gatherlines loop that tracks
whether we are inside a fenced code block. When inside a fence,
lines are gathered verbatim, skipping structure detection.

Only fences with indent > 0 are tracked (part of list item content).
A fence at indent 0 ends the list as before. If an unclosed fence
encounters a non-indented line, the fence state is abandoned to
prevent swallowing subsequent list items.

Fixes gomarkdown#346
@kjk kjk merged commit 9458c5e into gomarkdown:master Feb 17, 2026
1 check passed
@kjk
Copy link
Contributor

kjk commented Feb 17, 2026

thanks!

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.

When a fenced code block is on a list, a line starting from dash breaks formatting.

2 participants