Bug: Parsing inline code containing triple backticks injects trailing spaces into subsequent code blocks #33
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
golibs/goldmark-markdown#33
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug Report: Parsing inline code containing triple backticks injects trailing spaces into subsequent code blocks
Describe the bug
When
goldmark-markdownrenders a document containing an inline code span that encloses triple backticks (e.g., using<code>blocks or escaped backticks to represent an inline code span containing three backticks), it successfully renders that line but appears to enter a corrupted internal state. From that point forward, the renderer appends an extra trailing space to every subsequent inline code span it processes in the document.Successive renders of the same output compound this issue, recursively adding extra padding to all subsequent inline code blocks.
To Reproduce
Here is a minimal, standalone Go program that demonstrates the bug.
Expected behavior
The output should match the input markdown without injecting additional spaces into the second code block.
Actual behavior
The renderer injects a trailing space into the second inline code block.
If you take the
OUTPUTstring and pass it through the converter a second time, the trailing spaces will compound, resulting in- testcode`.Environment
1.22+goldmarkversion:v1.7.1(or relevant version)goldmark-markdownversion:v0.5.1Additional Context
This bug was encountered during the development of an automated Markdown linter and formatter using
goldmark-markdown. Because the pipeline reads, formats, and writes the Markdown back to disk, the inline triple-backtick string in our documentation caused trailing spaces to rapidly balloon across hundreds of code blocks in the document across multiple linter runs.