Repository navigation
🐛 fix(markdown): stop backtick languages breaking code fences - #2153
Conversation
A backtick cannot appear in the info string of a backtick code fence. A language-* class holding one, or a Markdown.Code language holding one, was written into the fence anyway, so the opening line stopped being a fence and the code text was read as Markdown and raw HTML. Such a language is now skipped: a class token falls through to the next candidate, and a fallback holding a backtick is not written.
Merging this PR will degrade performance by 24.98%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
A
<pre>whose language class held a backtick exported to Markdown as a broken code block. 🧾 CommonMark allows a backtick fence only when its info string holds no backtick. The serializer wrote the backtick anyway, so the opening line became paragraph text, and the code that followed was read as Markdown and raw HTML. Readers of the exported Markdown could see markup where the page had code. After this change such a language is ignored, and the block keeps its fence and its text stays code.The three ways a
<pre>names its language, its own class, the class of its sole<code>child, and a styled<pre>, all go through one language lookup, so one check there covers all three. TheMarkdown.Code(language=...)fallback is checked the same way, because the application supplies it and a backtick in it breaks the fence just as well.Behavior changes
language-*class that holds a backtick names no language. The lookup moves on to the next such class, then to the<pre>'s own class, then to the fallback.Markdown.Code(language=...)value that holds a backtick is not written, so those fences carry no language.Fixes #1771.