Repository navigation
Fix fenced code blocks for languages like c# and f# - #759
Merged
nicholasserra merged 1 commit intoNov 2, 2026
Merged
Conversation
The language name after an opening fence only allowed word characters, `+` and `-`, so a fence such as ```c#, ```f# or ```vb.net was not treated as a fence. Its code was parsed as Markdown (C# `#region` lines became headers) and the closing fence opened a new code block. Also allow `#` and `.`, which Pygments uses in lexer names.
nk-batman21
force-pushed
the
fix-fenced-code-lang-with-hash
branch
from
November 1, 2026 23:09
2d1973e to
fc0ddb0
Compare
Collaborator
|
Thanks! |
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.
With the
fenced-code-blocksextra, a fence whose language name contains#or.is not treated as a fence at all.c#,f#andvb.netare Pygments lexer names, and GitHub highlights a```c#block as C#.For example:
On master this renders
<p>```c#</p>, then<h1>region Setup</h1>and<h1>endregion</h1>. The closing fence of the C# block then opens a code block that swallows "Some text here." and the```pythonline, so code and prose swap places for the rest of the document. This happens with or without Pygments installed.This adds
#and.to the characters allowed in the language name infenced_code_block_re. A fence with words after the name (```c# title) is still not a fence, and a block with no language whose first line starts with#still gets no language (#396).Ran:
make testoneon Python 3.9 and 3.14 (303 tests pass); the new fixture fails without the change.Checked:
```c#withhighlightjs-lang, with safe mode, and inside a list item and a blockquote now renders the same way as```python.