fix: track fenced code state inside list items#354
Merged
kjk merged 1 commit intogomarkdown:masterfrom Feb 17, 2026
Merged
Conversation
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
Contributor
|
thanks! |
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.
listItem()gatherlines loop doesn't track fenced code state, so- contentinside 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