Conversation
Character references such as 	 and   were trimmed as literal text, so a leading encoded tab or space left an empty first info word and dropped the language class. Decode first (matching cmark), then trim. Fixes commonmark#255
cpruijsen
force-pushed
the
fix/issue-255
branch
from
September 15, 2026 16:47
0d1fb0a to
af8c66b
Compare
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
Fenced code info strings are unescaped before they are trimmed, so a leading
	or is treated as whitespace and the first word is still used as the language class (language-js).Adds the nine examples from #255 to
test/regression.txt.Unescape, then
String.prototype.trim()(the trim already used on this line). Alternative: ASCII-only trim after unescape (as inparseInlines), or skip empty first words in the HTML renderer.The first two cases are the ones @jgm called buggy, and cmark is the cited correct behaviour: decode character references, then trim. Keeping
.trim()matches this call site instead of introducing a new whitespace rule. Can switch to the ASCII-only trim fromparseInlinesif you want only spaces and tabs removed after decode.Test plan
npm test(744 passed, including new#255example)npm run lint```	js/``` js