md: emit newline before closing fence in codeBlock#358
Merged
kjk merged 1 commit intogomarkdown:masterfrom Apr 17, 2026
Merged
Conversation
The codeBlock renderer wrote the closing backtick fence directly after the node literal. When the literal did not end with a newline (as with a manually constructed ast.CodeBlock), the result was malformed markdown like 'val x : Int = 42```' on a single line. Emit a newline before the closing fence when the literal does not already end with one. Also correct the expected string in TestRenderCodeBlock to end with \n\n (matching doubleSpace semantics used by every other test in this file).
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.
Fixes #357.
Summary
md.Renderer.codeBlockused to write the closing```fence directly after the node literal. If theCodeBlock.Literaldid not already end with\n(e.g. when the AST was constructed manually), the result was malformed markdown with the closing fence glued to the last content line.TestRenderCodeBlockexercised exactly this case and has been failing as a result — it was only hidden because the CI workflow runsgo teston.,./ast,./parser,./htmland not on./md.\nbefore the closing fence when the literal does not already end with one. Literals produced by the parser end with a newline, soTestRenderCodeWithParagraphand other parser-driven tests are unaffected.TestRenderCodeBlock's expected string to end with\n\n(matching thedoubleSpace+ closing-block semantics used by every other test in the file).See #357 for the full reproduction and root-cause analysis.
Test plan
go test -v ./md— 16/16 pass (previously 15/16)go test ./...— all previously passing packages still pass;examples/still fails to build for an unrelated reason (missinggithub.com/alecthomas/chroma/stylesmodule)