Skip to content

Commit 5ec8db1

Browse files
seiyabfisker
andauthored
[3.9.x] Markdown: Don't let Liquid objects interrupt paragraphs (#20087)
Co-authored-by: fisker <[email protected]>
1 parent 5b142ed commit 5ec8db1

4 files changed

Lines changed: 210 additions & 2 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#### Don't let Liquid objects interrupt paragraphs (#20087 by @seiyab)
2+
3+
<!-- prettier-ignore -->
4+
```markdown
5+
<!-- Input -->
6+
If `module` is not a [`WebAssembly.Module`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a
7+
{{jsxref("TypeError")}} is thrown.
8+
9+
<!-- Prettier stable -->
10+
If `module` is not a [`WebAssembly.Module`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a
11+
12+
{{jsxref("TypeError")}} is thrown.
13+
14+
<!-- Prettier main -->
15+
If `module` is not a [`WebAssembly.Module`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a
16+
{{jsxref("TypeError")}} is thrown.
17+
```

‎src/language-markdown/parse/micromark/micromark-extension-liquid.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function liquidSyntax() {
7777
*/
7878
function tokenize(effects, ok, nok, mode) {
7979
const isFlow = mode === "flow";
80-
const { interrupt, now, parser } = this;
80+
const { now, parser } = this;
8181
/** @type {typeof codes.rightCurlyBrace | typeof codes.percentSign} */
8282
let closingCode;
8383

@@ -97,7 +97,7 @@ function liquidSyntax() {
9797
? codes.percentSign
9898
: codes.rightCurlyBrace;
9999
effects.consume(code);
100-
return isFlow && interrupt ? ok : inside;
100+
return inside;
101101
default:
102102
return nok(code);
103103
}

‎tests/format/markdown/liquid/__snapshots__/format.test.js.snap‎

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,163 @@ Inline {{ liquid }} stays inline.
511511
================================================================================
512512
`;
513513

514+
exports[`issue-20083.md - {"proseWrap":"always"} format 1`] = `
515+
====================================options=====================================
516+
parsers: ["markdown"]
517+
proseWrap: "always"
518+
printWidth: 80 (default) |
519+
=====================================input======================================
520+
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
521+
522+
If \`module\` is not a [\`WebAssembly.Module\`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a
523+
{{jsxref("TypeError")}} is thrown.
524+
525+
---
526+
527+
text
528+
{% comment %} here is comment {% endcomment %}
529+
530+
---
531+
532+
text
533+
{{ comment }} here is comment {{ endcomment }}
534+
535+
---
536+
537+
text
538+
{% comment %} text
539+
540+
---
541+
542+
text
543+
{{ comment }} text
544+
545+
---
546+
547+
text
548+
{{abc}}
549+
550+
---
551+
552+
text
553+
{% tag %}
554+
555+
=====================================output=====================================
556+
Taken from
557+
https://github.com/mdn/content/blob/3f221b9845703eb21db70cdc321f843d5c1c072b/files/en-us/webassembly/reference/javascript_interface/module/customsections_static/index.md?plain=1#L32-L33
558+
559+
If \`module\` is not a
560+
[\`WebAssembly.Module\`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module)
561+
object instance, a {{jsxref("TypeError")}} is thrown.
562+
563+
---
564+
565+
text {% comment %} here is comment {% endcomment %}
566+
567+
---
568+
569+
text {{ comment }} here is comment {{ endcomment }}
570+
571+
---
572+
573+
text {% comment %} text
574+
575+
---
576+
577+
text {{ comment }} text
578+
579+
---
580+
581+
text
582+
{{abc}}
583+
584+
---
585+
586+
text
587+
{% tag %}
588+
589+
================================================================================
590+
`;
591+
592+
exports[`issue-20083.md format 1`] = `
593+
====================================options=====================================
594+
parsers: ["markdown"]
595+
printWidth: 80 (default) |
596+
=====================================input======================================
597+
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
598+
599+
If \`module\` is not a [\`WebAssembly.Module\`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a
600+
{{jsxref("TypeError")}} is thrown.
601+
602+
---
603+
604+
text
605+
{% comment %} here is comment {% endcomment %}
606+
607+
---
608+
609+
text
610+
{{ comment }} here is comment {{ endcomment }}
611+
612+
---
613+
614+
text
615+
{% comment %} text
616+
617+
---
618+
619+
text
620+
{{ comment }} text
621+
622+
---
623+
624+
text
625+
{{abc}}
626+
627+
---
628+
629+
text
630+
{% tag %}
631+
632+
=====================================output=====================================
633+
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
634+
635+
If \`module\` is not a [\`WebAssembly.Module\`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a
636+
{{jsxref("TypeError")}} is thrown.
637+
638+
---
639+
640+
text
641+
{% comment %} here is comment {% endcomment %}
642+
643+
---
644+
645+
text
646+
{{ comment }} here is comment {{ endcomment }}
647+
648+
---
649+
650+
text
651+
{% comment %} text
652+
653+
---
654+
655+
text
656+
{{ comment }} text
657+
658+
---
659+
660+
text
661+
{{abc}}
662+
663+
---
664+
665+
text
666+
{% tag %}
667+
668+
================================================================================
669+
`;
670+
514671
exports[`unbalanced-mismatched-braces.md - {"proseWrap":"always"} format 1`] = `
515672
====================================options=====================================
516673
parsers: ["markdown"]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
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
2+
3+
If `module` is not a [`WebAssembly.Module`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Module) object instance, a
4+
{{jsxref("TypeError")}} is thrown.
5+
6+
---
7+
8+
text
9+
{% comment %} here is comment {% endcomment %}
10+
11+
---
12+
13+
text
14+
{{ comment }} here is comment {{ endcomment }}
15+
16+
---
17+
18+
text
19+
{% comment %} text
20+
21+
---
22+
23+
text
24+
{{ comment }} text
25+
26+
---
27+
28+
text
29+
{{abc}}
30+
31+
---
32+
33+
text
34+
{% tag %}

0 commit comments

Comments
 (0)