From 6435ac98896212b4f117b024cccd4c7e186a8b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krassowski?= <5832902+krassowski@users.noreply.github.com> Date: Thu, 20 May 2021 14:42:45 +0100 Subject: [PATCH] fix: Fix indented markdown in html (#2052) Co-authored-by: Tony Brix --- src/rules.js | 6 +++--- test/specs/new/indented_details.html | 24 ++++++++++++++++++++++++ test/specs/new/indented_details.md | 24 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 test/specs/new/indented_details.html create mode 100644 test/specs/new/indented_details.md diff --git a/src/rules.js b/src/rules.js index d3175e8ba0..a06bdb6892 100644 --- a/src/rules.js +++ b/src/rules.js @@ -21,9 +21,9 @@ const block = { + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3) + '|\\n*|$)' // (4) + '|\\n*|$)' // (5) - + '|)[\\s\\S]*?(?:\\n{2,}|$)' // (6) - + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag - + '|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag + + '|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6) + + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag + + '|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag + ')', def: /^ {0,3}\[(label)\]: *\n? *]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/, nptable: noopTest, diff --git a/test/specs/new/indented_details.html b/test/specs/new/indented_details.html new file mode 100644 index 0000000000..910ff957c1 --- /dev/null +++ b/test/specs/new/indented_details.html @@ -0,0 +1,24 @@ +
+ +

Heading

+
+ +

Heading

+ + +

Heading

+
+ +

Heading

+
+ +
## Heading
+
+ +
## Heading
+ + +
## Heading
+
+ +
## Heading
diff --git a/test/specs/new/indented_details.md b/test/specs/new/indented_details.md new file mode 100644 index 0000000000..5b838ca17b --- /dev/null +++ b/test/specs/new/indented_details.md @@ -0,0 +1,24 @@ +
+ + ## Heading +
+ + ## Heading + + + ## Heading + + + ## Heading +
+ + ## Heading +
+ + ## Heading + + + ## Heading + + + ## Heading