Skip to content

Commit

Permalink
Whitelist <markdown> and <md> as special tags
Browse files Browse the repository at this point in the history
  • Loading branch information
ang-zeyu committed Dec 30, 2020
1 parent 090dc57 commit 8f07e89
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/cli/test/functional/test_site/expected/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,22 @@ <h3 id="testing-site-nav"><span id="testing-site-nav" class="anchor"></span>Test
<div id="content-wrapper" class="fixed-header-padding">

<div class="website-content">
<p><strong>Test <code class="hljs inline no-lang" v-pre>&lt;markdown&gt;</code> and <code class="hljs inline no-lang" v-pre>&lt;md&gt;</code> elements</strong></p>
<div>
<p>This should be wrapped in a <code class="hljs inline no-lang" v-pre>&lt;p&gt;</code> tag as it uses the block-level markdown renderer</p>
</div>
<span>This should not be wrapped in a <code class="hljs inline no-lang" v-pre>&lt;p&gt;</code> tag as it uses the inline markdown renderer</span>
<div class="mt-2">
<pre><code class="hljs" v-pre><span>&lt;markdown&gt; elements allow block-level markdown without needing a leading newline.
</span><span>Hence, this html should be parsed and output as is, without any parsing errors.
</span><span>&lt;/invalidhtml&gt;
</span></code></pre>
</div>
<span>
<code class="hljs inline no-lang" v-pre>&lt;md&gt;</code> elements allow block-level markdown without needing a leading newline.
Hence, this html should be parsed and output as is, without any parsing errors.
<code class="hljs inline no-lang" v-pre>&lt;/invalid&gt;</code>.
</span>
<p><strong>Test footnotes</strong></p>
<div>
<p><strong>Normal footnotes:</strong>
Expand Down
21 changes: 21 additions & 0 deletions packages/cli/test/functional/test_site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ tags: ["tag-frontmatter-shown", "tag-included-file", "+tag-exp*", "-tag-exp-hidd

<div class="website-content">

**Test `<markdown>` and `<md>` elements**

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

<md>This should not be wrapped in a `<p>` tag as it uses the inline markdown renderer</md>

<markdown class="mt-2">
```
<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>
```
</markdown>

<md>
`<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>`.
</md>


**Test footnotes**

<include src="testFootnotes.md" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/patches/htmlparser2.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ const DEFAULT_SPECIAL_TAGS = [
'script',
'style',
'variable',
'markdown',
'md',
];

function whitespace(c) {
Expand Down

0 comments on commit 8f07e89

Please sign in to comment.