-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bug: Nested fenced code blocks (4 backticks) are corrupted #8109
Description
Lexical version: indirect dependency (version not exposed by Sveltia CMS)
Steps To Reproduce
- Create or edit a markdown document in the Sveltia CMS editor.
- Switch to markdown view.
- Add nested fenced code blocks using 4 backticks to wrap content that contains a 3-backtick code block, e.g.:
````markdown
## Development Setup
After cloning, run:
```bash
pip install pre-commit
pre-commit install
```
````- Save the markdown content.
- Close the editor.
- Reopen the same markdown document in the editor.
- Observe the malformed markdown output.
Click the Convert from Markdown button
The current behavior
When reopening a document that contains nested fenced code blocks (4 backticks wrapping a 3-backtick fenced block), the editor corrupts the structure: it misinterprets and breaks the nesting boundaries, leading to malformed markdown where code blocks are opened/closed incorrectly.
The expected behavior
The nested fenced code block structure should be preserved exactly as it was entered, with the outer 4-backtick fence correctly containing the inner 3-backtick code block, following CommonMark rules for nested fences.
Impact of fix
Severity: High for users documenting examples of code within markdown (e.g., docs, tutorials).
Frequency: Happens whenever nested code fences are used and the document is reopened.
Who would benefit: Content authors using advanced markdown features; anyone relying on accurate editing of code examples.
Metrics (if known): Affects all markdown fields in the CMS editor where nested code blocks are used.