fix(ansi): render subsequent paragraphs in list items on new lines - #570
Open
troclaux wants to merge 1 commit into
Open
fix(ansi): render subsequent paragraphs in list items on new lines#570troclaux wants to merge 1 commit into
troclaux wants to merge 1 commit into
Conversation
When a list item contains multiple paragraphs (loose list), only the
first paragraph was skipped (rendered inline as list item text). All
subsequent paragraphs also returned an empty Element, causing them to
be concatenated directly after the first paragraph with no separator.
Fix by returning Element{Entering: "\n"} for non-first paragraphs
inside list items, so each continuation paragraph starts on a new line.
Fixes charmbracelet#167
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.
Summary
When a list item contains multiple paragraphs (loose list syntax), glamour concatenated them without any separator, producing broken output like:
The
KindParagraphhandler skipped all paragraphs inside aKindListItemby returningElement{}. Only the first paragraph should be skipped (it's rendered inline as the list item text). Subsequent paragraphs need a newline before them.Before:
After:
Changes
ansi/elements.go: checknode.PreviousSibling() == nilin theKindParagraph/KindListItembranch; only skip the first paragraph, returnElement{Entering: "\n"}for subsequent onestestdata/issues/167.md: regression test inputansi/testdata/TestRendererIssues/167.golden: expected golden outputTesting
go test ./...passes.Fixes #167