-
-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and discussions and couldn’t find anything (or linked relevant results below)
Affected package
Steps to reproduce
When using remark-directive with containerDirective, nested directives inside fenced code blocks cause incorrect parsing. Specifically, the parser treats the inner ::: (inside a code block) as the closing marker for the outer container directive, leading to broken syntax trees and invalid output.
One way to solve it is to use a higher level outer container directive (for example, use four colons). However, the directiveToMarkdown plugin seems not able to recognize this problem and will produce three colons only, which will break the structure.
Actual behavior
Consider using this chain to parse markdown source code and stringify the mdast (which often used in code formatting):
unified()
.use(remarkParse)
.use(remarkDirective)
.use(remarkStringify, { bullet: '-', rule: '-' })
.process(content)The input:
::::block
```markdown
:::block
some code
:::
```
::::After processing, the output becomes:
:::block
```markdown
:::block
some code
:::
```
:::This leads to incorrect rendering and broken nesting.
Expected behavior
Either parse the code block in the container directive properly, or produce proper result after using remarkStringify.
After processing and stringifying, the Markdown source should remain structurally unchanged.
::::block
```markdown
:::block
some code
:::
```
::::Runtime
No response
Package manager
No response
Operating system
No response
Build and bundle tools
No response