Skip to content

Codefences closing improperly when inside GFM alert quotes blocks #1141

@TendTo

Description

@TendTo

What version of myst-parser are you using?

5.1.0

What version dependencies are you using?

  • Sphinx : 9.1.0
  • docutils: 0.22.4

What operating system are you using?

Linux

Describe the Bug

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:

Quote (but not an admonition)

"code"

other

"other code"

and then we are out.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions