Skip to content

Close fences only on a marker at least as long as the opener - #109

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
iliasabk:fix/fence-length
Sep 13, 2026
Merged

ralyodio merged 1 commit into
profullstack:masterfrom
iliasabk:fix/fence-length

Conversation

@iliasabk

Copy link
Copy Markdown
Contributor

Closes #106.

A fenced block opened with four backticks ended at the first three-backtick line inside it, so the rest of the code leaked out and rendered as markup (**literal** became bold prose). The closing-fence check now requires the same marker character and at least the opening length, which is the CommonMark rule and the reason longer fences exist.

toPlainText strips fenced blocks with the same length rule so feeds and snippets agree with the renderer.

Verified: 323 tests pass, including new regression tests covering a short fence inside a long one, a longer closer for a shorter opener, and a tilde run inside a backtick fence.

A four-backtick block containing a three-backtick line ended early and
its tail rendered as markup. The closing fence now requires the same
character and at least the opening length, per CommonMark. toPlainText
strips fenced blocks with the same length rule.

Closes profullstack#106
@ralyodio
ralyodio merged commit 27b490a into profullstack:master Sep 13, 2026
4 checks passed
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.

Markdown: shorter fences prematurely close longer fenced code blocks

2 participants