Description
*(*foo*)* is parsed incorrectly, producing a different AST than expected per the CommonMark spec.
Input
Expected behavior
Per CommonMark spec example 343, this should parse as nested emphasis:
<p><em>(<em>foo</em>)</em></p>
The CommonMark dingus confirms this interpretation.
Actual behavior
remark parses this as two separate emphasis nodes with plain text in between:
paragraph
emphasis [0..3] -> wraps "("
text "("
text "foo"
emphasis [6..9] -> wraps ")"
text ")"
Instead of:
paragraph
emphasis [0..9] -> wraps everything
text "("
emphasis [2..7] -> wraps "foo"
text "foo"
text ")"
Reproducible example
import remarkParse from "remark-parse";
import { unified } from "unified";
const tree = unified().use(remarkParse).parse("*(*foo*)*");
console.log(JSON.stringify(tree.children[0], null, 2));
Or via Prettier 3.8.1 (which uses remark):
const prettier = require("prettier");
const { ast } = await prettier.__debug.parse("*(*foo*)*", { filepath: "test.md" });
console.log(JSON.stringify(ast.children[0], null, 2));
Description
*(*foo*)*is parsed incorrectly, producing a different AST than expected per the CommonMark spec.Input
Expected behavior
Per CommonMark spec example 343, this should parse as nested emphasis:
The CommonMark dingus confirms this interpretation.
Actual behavior
remark parses this as two separate emphasis nodes with plain text in between:
Instead of:
Reproducible example
Or via Prettier 3.8.1 (which uses remark):