From 5ec8db1745c2bdcca3706ab8cfbbe5c11fc457c1 Mon Sep 17 00:00:00 2001 From: Seiya <20365512+seiyab@users.noreply.github.com> Date: Fri, 18 Sep 2026 06:02:50 +0900 Subject: [PATCH] [3.9.x] Markdown: Don't let Liquid objects interrupt paragraphs (#20087) Co-authored-by: fisker --- changelog_unreleased/markdown/20087.md | 17 ++ .../micromark/micromark-extension-liquid.js | 4 +- .../liquid/__snapshots__/format.test.js.snap | 157 ++++++++++++++++++ tests/format/markdown/liquid/issue-20083.md | 34 ++++ 4 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 changelog_unreleased/markdown/20087.md create mode 100644 tests/format/markdown/liquid/issue-20083.md diff --git a/changelog_unreleased/markdown/20087.md b/changelog_unreleased/markdown/20087.md new file mode 100644 index 000000000..36a8e5ea1 --- /dev/null +++ b/changelog_unreleased/markdown/20087.md @@ -0,0 +1,17 @@ +#### Don't let Liquid objects interrupt paragraphs (#20087 by @seiyab) + + +```markdown + +If `module` is not a [`WebAssembly.Module`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a +{{jsxref("TypeError")}} is thrown. + + +If `module` is not a [`WebAssembly.Module`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a + +{{jsxref("TypeError")}} is thrown. + + +If `module` is not a [`WebAssembly.Module`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a +{{jsxref("TypeError")}} is thrown. +``` diff --git a/src/language-markdown/parse/micromark/micromark-extension-liquid.js b/src/language-markdown/parse/micromark/micromark-extension-liquid.js index 45b011a28..48a7ce40f 100644 --- a/src/language-markdown/parse/micromark/micromark-extension-liquid.js +++ b/src/language-markdown/parse/micromark/micromark-extension-liquid.js @@ -77,7 +77,7 @@ function liquidSyntax() { */ function tokenize(effects, ok, nok, mode) { const isFlow = mode === "flow"; - const { interrupt, now, parser } = this; + const { now, parser } = this; /** @type {typeof codes.rightCurlyBrace | typeof codes.percentSign} */ let closingCode; @@ -97,7 +97,7 @@ function liquidSyntax() { ? codes.percentSign : codes.rightCurlyBrace; effects.consume(code); - return isFlow && interrupt ? ok : inside; + return inside; default: return nok(code); } diff --git a/tests/format/markdown/liquid/__snapshots__/format.test.js.snap b/tests/format/markdown/liquid/__snapshots__/format.test.js.snap index 75ed735b3..502830af0 100644 --- a/tests/format/markdown/liquid/__snapshots__/format.test.js.snap +++ b/tests/format/markdown/liquid/__snapshots__/format.test.js.snap @@ -511,6 +511,163 @@ Inline {{ liquid }} stays inline. ================================================================================ `; +exports[`issue-20083.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +Taken from https://github.com/mdn/content/blob/3f221b9845703eb21db70cdc321f843d5c1c072b/files/en-us/webassembly/reference/javascript_interface/module/customsections_static/index.md?plain=1#L32-L33 + +If \`module\` is not a [\`WebAssembly.Module\`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a +{{jsxref("TypeError")}} is thrown. + +--- + +text +{% comment %} here is comment {% endcomment %} + +--- + +text +{{ comment }} here is comment {{ endcomment }} + +--- + +text +{% comment %} text + +--- + +text +{{ comment }} text + +--- + +text +{{abc}} + +--- + +text +{% tag %} + +=====================================output===================================== +Taken from +https://github.com/mdn/content/blob/3f221b9845703eb21db70cdc321f843d5c1c072b/files/en-us/webassembly/reference/javascript_interface/module/customsections_static/index.md?plain=1#L32-L33 + +If \`module\` is not a +[\`WebAssembly.Module\`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) +object instance, a {{jsxref("TypeError")}} is thrown. + +--- + +text {% comment %} here is comment {% endcomment %} + +--- + +text {{ comment }} here is comment {{ endcomment }} + +--- + +text {% comment %} text + +--- + +text {{ comment }} text + +--- + +text +{{abc}} + +--- + +text +{% tag %} + +================================================================================ +`; + +exports[`issue-20083.md format 1`] = ` +====================================options===================================== +parsers: ["markdown"] + printWidth: 80 (default) | +=====================================input====================================== +Taken from https://github.com/mdn/content/blob/3f221b9845703eb21db70cdc321f843d5c1c072b/files/en-us/webassembly/reference/javascript_interface/module/customsections_static/index.md?plain=1#L32-L33 + +If \`module\` is not a [\`WebAssembly.Module\`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a +{{jsxref("TypeError")}} is thrown. + +--- + +text +{% comment %} here is comment {% endcomment %} + +--- + +text +{{ comment }} here is comment {{ endcomment }} + +--- + +text +{% comment %} text + +--- + +text +{{ comment }} text + +--- + +text +{{abc}} + +--- + +text +{% tag %} + +=====================================output===================================== +Taken from https://github.com/mdn/content/blob/3f221b9845703eb21db70cdc321f843d5c1c072b/files/en-us/webassembly/reference/javascript_interface/module/customsections_static/index.md?plain=1#L32-L33 + +If \`module\` is not a [\`WebAssembly.Module\`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a +{{jsxref("TypeError")}} is thrown. + +--- + +text +{% comment %} here is comment {% endcomment %} + +--- + +text +{{ comment }} here is comment {{ endcomment }} + +--- + +text +{% comment %} text + +--- + +text +{{ comment }} text + +--- + +text +{{abc}} + +--- + +text +{% tag %} + +================================================================================ +`; + exports[`unbalanced-mismatched-braces.md - {"proseWrap":"always"} format 1`] = ` ====================================options===================================== parsers: ["markdown"] diff --git a/tests/format/markdown/liquid/issue-20083.md b/tests/format/markdown/liquid/issue-20083.md new file mode 100644 index 000000000..2fce9bc69 --- /dev/null +++ b/tests/format/markdown/liquid/issue-20083.md @@ -0,0 +1,34 @@ +Taken from https://github.com/mdn/content/blob/3f221b9845703eb21db70cdc321f843d5c1c072b/files/en-us/webassembly/reference/javascript_interface/module/customsections_static/index.md?plain=1#L32-L33 + +If `module` is not a [`WebAssembly.Module`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a +{{jsxref("TypeError")}} is thrown. + +--- + +text +{% comment %} here is comment {% endcomment %} + +--- + +text +{{ comment }} here is comment {{ endcomment }} + +--- + +text +{% comment %} text + +--- + +text +{{ comment }} text + +--- + +text +{{abc}} + +--- + +text +{% tag %}