You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Codefences closing improperly when inside GFM alert quotes blocks #1141
It seems that, when using GitHub alerts as admonitions, codefences blocks misbehave.
More specifically, they do not close correctly.
Expected Behavior
Nesting GFM alerts and codefences works as on GitHub and coherently with nesting codefences with other quote blocks (not adminitions).
To Reproduce
Examples
Try rendering the following snippet:
This works:
:::{note}
Tip
```py
"code"
```
other
```py
"other code"
```
:::
but this doesn't
> [!NOTE]
> Note
>
> ```py
> "code"
> ```
>
> other
>
> ```py
> "other code"
> ```
More in general, there is an issue with code fences not closing correctly, e.g.,
> [!NOTE]
> Note
>
> ```py
> code
> ```
For some reason the code fence extends here too, and stops only at the end of the next code fence.
```py
"other code"
```
Now I'm finally outside the code fence!
The issue only seems to affect admonitions, as regular quotes work fine:
> Quote (but not an admonition)
>
> ```py
> "code"
> ```
>
> other
>
> ```py
> "other code"
> ```
and then we are out.
GirHub rendering for reference
This works:
:::{note}
Tip
"code"
other
"other code"
:::
but this doesn't
Note
Note
"code"
other
"other code"
More in general, there is an issue with code fences not closing correctly, e.g.,
Note
Note
code
For some reason the code fence extends here too, and stops only at the end of the next code fence.
"other code"
Now I'm finally outside the code fence!
The issue only seems to affect admonitions, as regular quotes work fine:
The underlying bug was fixed upstream in markdown-it-py 4.2.0 (already the minimum version required here), and #1142 has now added a regression test covering code fences inside GFM alerts, so closing.
Activity
chrisjsewell commentedon May 20, 2026
I just added a reproducer (I believe) upstream, and this seems to be working there: executablebooks/markdown-it-py#398
TendTo commentedon May 20, 2026
I would suggest making the content of the block quote longer, something like
because, if it only contains a single fenced block, it seems it works, provided nothing else follows.
chrisjsewell commentedon Jul 12, 2026
The underlying bug was fixed upstream in markdown-it-py 4.2.0 (already the minimum version required here), and #1142 has now added a regression test covering code fences inside GFM alerts, so closing.
Generated by Claude Code
🧪 Add fence in GFM alert test (#398)