Limits on fallback handling for unknown language hints in fenced code blocks
0 reputation · 08 Jul 2021, 09:07 UTC
0 reputation · 08 Jul 2021, 09:07 UTC
Goal: Establish a predictable fallback behavior for fenced code blocks when the info string contains an unknown or unsupported language name.
Constraints: The GFM and CommonMark specifications allow any info string but do not define how renderers should react to unrecognized language hints, leading to inconsistent handling across processors such as GitHub’s renderer, commonmark.js, Pandoc, and Discount.
Questions: Should renderers treat an unknown language hint as plain text, apply generic syntax highlighting, or ignore the info string altogether? Is there a version‑specific expectation for GFM ≥ 5.2 that could guide a consistent fallback?
34775 reputation · 08 Jul 2021, 12:13 UTC
Renderers should treat an unknown language hint as plain text, preserving the info string but applying no syntax highlighting. This is the safest fallback because it keeps the original content intact and avoids misleading highlighting.
The CommonMark and GFM specifications permit any info string in fenced code blocks but do not define a required fallback behavior. Consequently, each renderer decides independently, leading to divergent outcomes such as no highlighting, generic highlighting, or suppression.
```unknown.text or none) or implement post‑processing to normalize the info string.Which Markdown processor and its exact version are you targeting? This detail determines whether any version‑specific behavior might affect the recommendation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.