From 8f07e8901e964f51cf7d7e75a4b624479ea0c33a Mon Sep 17 00:00:00 2001 From: Ze Yu Date: Wed, 30 Dec 2020 20:00:27 +0800 Subject: [PATCH] Whitelist and as special tags --- .../functional/test_site/expected/index.html | 16 ++++++++++++++ .../cli/test/functional/test_site/index.md | 21 +++++++++++++++++++ .../markdown-it-escape-special-tags.js | 2 +- packages/core/src/patches/htmlparser2.js | 2 ++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/cli/test/functional/test_site/expected/index.html b/packages/cli/test/functional/test_site/expected/index.html index 6b13f87a3e..3c12bf9fd8 100644 --- a/packages/cli/test/functional/test_site/expected/index.html +++ b/packages/cli/test/functional/test_site/expected/index.html @@ -180,6 +180,22 @@

Test
+

Test <markdown> and <md> elements

+
+

This should be wrapped in a <p> tag as it uses the block-level markdown renderer

+
+ This should not be wrapped in a <p> tag as it uses the inline markdown renderer +
+
<markdown> elements allow block-level markdown without needing a leading newline.
+Hence, this html should be parsed and output as is, without any parsing errors.
+</invalidhtml>
+
+
+ + <md> elements allow block-level markdown without needing a leading newline. + Hence, this html should be parsed and output as is, without any parsing errors. + </invalid>. +

Test footnotes

Normal footnotes: diff --git a/packages/cli/test/functional/test_site/index.md b/packages/cli/test/functional/test_site/index.md index a85f3562a5..466726db00 100644 --- a/packages/cli/test/functional/test_site/index.md +++ b/packages/cli/test/functional/test_site/index.md @@ -10,6 +10,27 @@ tags: ["tag-frontmatter-shown", "tag-included-file", "+tag-exp*", "-tag-exp-hidd

+**Test `` and `` elements** + +This should be wrapped in a `

` tag as it uses the block-level markdown renderer + +This should not be wrapped in a `

` tag as it uses the inline markdown renderer + + +``` + elements allow block-level markdown without needing a leading newline. +Hence, this html should be parsed and output as is, without any parsing errors. + +``` + + + +`` elements allow block-level markdown without needing a leading newline. +Hence, this html should be parsed and output as is, without any parsing errors. +``. + + + **Test footnotes** diff --git a/packages/core/src/lib/markdown-it/markdown-it-escape-special-tags.js b/packages/core/src/lib/markdown-it/markdown-it-escape-special-tags.js index 23f191461d..a65b3475ba 100644 --- a/packages/core/src/lib/markdown-it/markdown-it-escape-special-tags.js +++ b/packages/core/src/lib/markdown-it/markdown-it-escape-special-tags.js @@ -10,7 +10,7 @@ function escape_plugin(md, tagsToIgnore) { const HTML_OPEN_CLOSE_TAG_RE = require('markdown-it/lib/common/html_re').HTML_OPEN_CLOSE_TAG_RE; const specialTagsRegex = Array.from(tagsToIgnore) - .concat(['script|pre|style|variable|site-nav']) + .concat(['script|pre|style|variable|site-nav|markdown|md']) .join('|'); // attr_name, unquoted ... attribute patterns adapted from markdown-it/lib/common/html_re diff --git a/packages/core/src/patches/htmlparser2.js b/packages/core/src/patches/htmlparser2.js index e7726da87b..aa62707d1b 100644 --- a/packages/core/src/patches/htmlparser2.js +++ b/packages/core/src/patches/htmlparser2.js @@ -142,6 +142,8 @@ const DEFAULT_SPECIAL_TAGS = [ 'script', 'style', 'variable', + 'markdown', + 'md', ]; function whitespace(c) {