mirror of
https://github.com/markedjs/marked.git
synced 2026-12-01 16:56:16 +01:00
fix: change defaults for mangle and headerIds to false (#2890)
BREAKING CHANGE: change defaults for mangle and headerIds to false
This commit is contained in:
+2
-2
@@ -10,12 +10,12 @@ export function _getDefaults(): MarkedOptions {
|
||||
breaks: false,
|
||||
extensions: null,
|
||||
gfm: true,
|
||||
headerIds: true,
|
||||
headerIds: false,
|
||||
headerPrefix: '',
|
||||
highlight: null,
|
||||
hooks: null,
|
||||
langPrefix: 'language-',
|
||||
mangle: true,
|
||||
mangle: false,
|
||||
pedantic: false,
|
||||
renderer: null,
|
||||
sanitize: false,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<h1 id="level1">level1</h1>
|
||||
<h2 id="level2">level2</h2>
|
||||
<h3 id="level3">level3</h3>
|
||||
<h1>level1</h1>
|
||||
<h2>level2</h2>
|
||||
<h3>level3</h3>
|
||||
<ul>
|
||||
<li>foo=bar</li>
|
||||
<li>foo2=bar2</li>
|
||||
</ul>
|
||||
<h3 id="level3-1">level3</h3>
|
||||
<h3>level3</h3>
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h1 id="title">title</h1>
|
||||
<h1>title</h1>
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h1 id="title">title</h1>
|
||||
<h1>title</h1>
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
---
|
||||
headerIds: true
|
||||
---
|
||||
### Heading with <em>html</em>
|
||||
|
||||
### Heading with a [link](http://github.com/)
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
<h3 id="example-1">Example 1</h3>
|
||||
<h3>Example 1</h3>
|
||||
|
||||
<!-- comment -->
|
||||
|
||||
<h3 id="example-2">Example 2</h3>
|
||||
<h3>Example 2</h3>
|
||||
|
||||
<!---->
|
||||
|
||||
<h3 id="example-3">Example 3</h3>
|
||||
<h3>Example 3</h3>
|
||||
|
||||
<!-- -->
|
||||
|
||||
<h3 id="example-4">Example 4</h3>
|
||||
<h3>Example 4</h3>
|
||||
|
||||
<!-- - -->
|
||||
|
||||
<h3 id="example-5">Example 5</h3>
|
||||
<h3>Example 5</h3>
|
||||
|
||||
<!-- -- -->
|
||||
|
||||
<h3 id="example-6">Example 6</h3>
|
||||
<h3>Example 6</h3>
|
||||
|
||||
<!-- --->
|
||||
|
||||
<h3 id="example-7">Example 7</h3>
|
||||
<h3>Example 7</h3>
|
||||
|
||||
<!----->
|
||||
|
||||
<h3 id="example-8">Example 8</h3>
|
||||
<h3>Example 8</h3>
|
||||
|
||||
<!------>
|
||||
|
||||
<h3 id="example-9">Example 9</h3>
|
||||
<h3>Example 9</h3>
|
||||
|
||||
<!-- My favorite operators are > and <!-->
|
||||
|
||||
<h3 id="example-10">Example 10</h3>
|
||||
<h3>Example 10</h3>
|
||||
|
||||
<!-- multi
|
||||
line
|
||||
comment
|
||||
-->
|
||||
|
||||
<h3 id="example-11">Example 11</h3>
|
||||
<h3>Example 11</h3>
|
||||
|
||||
<!-- indented comment -->
|
||||
|
||||
<pre><code><!-- too much indentation -->
|
||||
</code></pre>
|
||||
|
||||
<h3 id="example-12">Example 12</h3>
|
||||
<h3>Example 12</h3>
|
||||
|
||||
<p><!--> not a comment --></p>
|
||||
|
||||
@@ -56,7 +56,7 @@ comment
|
||||
|
||||
<!-- <!-- not a comment? --> -->
|
||||
|
||||
<h3 id="example-13">Example 13</h3>
|
||||
<h3>Example 13</h3>
|
||||
|
||||
<!-- block ends at the end of the document since --!>
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
</ul>
|
||||
<hr />
|
||||
|
||||
<h2 id="heading--this-one-is-a-heading">
|
||||
<h2>
|
||||
<b>heading</b> -this one is a heading
|
||||
</h2>
|
||||
|
||||
<h2 id="heading---this-is-a-heading-too">
|
||||
<h2>
|
||||
<b>heading</b> - this is a heading too
|
||||
</h2>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<details>
|
||||
|
||||
<h2 id="heading">Heading</h2>
|
||||
<h2>Heading</h2>
|
||||
</details>
|
||||
|
||||
<h2 id="heading-1">Heading</h2>
|
||||
<h2>Heading</h2>
|
||||
<custom-tag>
|
||||
|
||||
<h2 id="heading-2">Heading</h2>
|
||||
<h2>Heading</h2>
|
||||
</custom-tag>
|
||||
|
||||
<h2 id="heading-3">Heading</h2>
|
||||
<h2>Heading</h2>
|
||||
<details>
|
||||
|
||||
<pre><code>## Heading</code></pre>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<ul>
|
||||
<li>list <h1 id="header">header</h1></li>
|
||||
<li>list <h1>header</h1></li>
|
||||
</ul>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<h1 id="header">header</h1>
|
||||
<h1>header</h1>
|
||||
|
||||
<h1 id="header1">header1</h1>
|
||||
<h1>header1</h1>
|
||||
|
||||
<h1 id="header2">header2</h1>
|
||||
<h1>header2</h1>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<p>paragraph</p>
|
||||
<ul>
|
||||
<li>
|
||||
<h1 id="heading">heading</h1>
|
||||
<h1>heading</h1>
|
||||
</li>
|
||||
</ul>
|
||||
<p>paragraph</p>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<h1 id="h1">h1</h1>
|
||||
<h1>h1</h1>
|
||||
|
||||
<h1 id="h1-1">h1</h1>
|
||||
<h1>h1</h1>
|
||||
|
||||
<h1 id="h1-">h1 #</h1>
|
||||
<h1>h1 #</h1>
|
||||
|
||||
<h1 id="h1-2">h1</h1>
|
||||
<h1>h1</h1>
|
||||
|
||||
<p># h1</p>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<p>paragraph before head with hash</p>
|
||||
<h1 id="how-are-you">how are you</h1>
|
||||
<h1>how are you</h1>
|
||||
|
||||
<p>paragraph before head with equals</p>
|
||||
<h1 id="how-are-you-again">how are you again</h1>
|
||||
<h1>how are you again</h1>
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
<h1 id="absolutization-of-rfc-3986-uris">Absolutization of RFC 3986 URIs</h1>
|
||||
<h1>Absolutization of RFC 3986 URIs</h1>
|
||||
|
||||
<h2 id="absolute-uri">Absolute URI</h2>
|
||||
<h2>Absolute URI</h2>
|
||||
|
||||
<p><a href="http://example.com/"><img src="http://example.com/logo" alt="section 4.3"></a></p>
|
||||
|
||||
<h2 id="network-path-reference">Network-path reference</h2>
|
||||
<h2>Network-path reference</h2>
|
||||
|
||||
<p><a href="//example.com/"><img src="//example.com/logo" alt="section 4.2"></a></p>
|
||||
|
||||
<h2 id="absolute-path">Absolute path</h2>
|
||||
<h2>Absolute path</h2>
|
||||
|
||||
<p><a href="/path/to/content"><img src="/path/to/img" alt="section 4.2"></a></p>
|
||||
|
||||
<h2 id="relative-path">Relative path</h2>
|
||||
<h2>Relative path</h2>
|
||||
|
||||
<p><a href="/base/content"><img src="/base/img" alt="section 4.2"></a></p>
|
||||
|
||||
<h2 id="dot-relative-path">Dot-relative path</h2>
|
||||
<h2>Dot-relative path</h2>
|
||||
|
||||
<p><a href="/base/./content"><img src="/base/./img" alt="section 3.3"></a></p>
|
||||
|
||||
<p><a href="/base/../content"><img src="/base/../img" alt="section 3.3"></a></p>
|
||||
|
||||
<h2 id="same-document-query">Same-document query</h2>
|
||||
<h2>Same-document query</h2>
|
||||
|
||||
<p><a href="?"><img src="?type=image" alt="section 4.4"></a></p>
|
||||
|
||||
<h2 id="same-document-fragment">Same-document fragment</h2>
|
||||
<h2>Same-document fragment</h2>
|
||||
|
||||
<p><a href="#"><img src="#img" alt="section 4.4"></a></p>
|
||||
|
||||
<h2 id="empty">Empty</h2>
|
||||
<h2>Empty</h2>
|
||||
|
||||
<p><a href="">section 4.2</a></p>
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
<h1 id="absolutization-of-rfc-3986-uris">Absolutization of RFC 3986 URIs</h1>
|
||||
<h1>Absolutization of RFC 3986 URIs</h1>
|
||||
|
||||
<h2 id="absolute-uri">Absolute URI</h2>
|
||||
<h2>Absolute URI</h2>
|
||||
|
||||
<p><a href="http://example.com/"><img src="http://example.com/logo" alt="section 4.3"></a></p>
|
||||
|
||||
<h2 id="network-path-reference">Network-path reference</h2>
|
||||
<h2>Network-path reference</h2>
|
||||
|
||||
<p><a href="http://example.com/"><img src="http://example.com/logo" alt="section 4.2"></a></p>
|
||||
|
||||
<h2 id="absolute-path">Absolute path</h2>
|
||||
<h2>Absolute path</h2>
|
||||
|
||||
<p><a href="http://example.com/path/to/content"><img src="http://example.com/path/to/img" alt="section 4.2"></a></p>
|
||||
|
||||
<h2 id="relative-path">Relative path</h2>
|
||||
<h2>Relative path</h2>
|
||||
|
||||
<p><a href="http://example.com/base/content"><img src="http://example.com/base/img" alt="section 4.2"></a></p>
|
||||
|
||||
<h2 id="dot-relative-path">Dot-relative path</h2>
|
||||
<h2>Dot-relative path</h2>
|
||||
|
||||
<p><a href="http://example.com/base/./content"><img src="http://example.com/base/./img" alt="section 3.3"></a></p>
|
||||
|
||||
<p><a href="http://example.com/base/../content"><img src="http://example.com/base/../img" alt="section 3.3"></a></p>
|
||||
|
||||
<h2 id="same-document-query">Same-document query</h2>
|
||||
<h2>Same-document query</h2>
|
||||
|
||||
<p><a href="?"><img src="?type=image" alt="section 4.4"></a></p>
|
||||
|
||||
<h2 id="same-document-fragment">Same-document fragment</h2>
|
||||
<h2>Same-document fragment</h2>
|
||||
|
||||
<p><a href="#"><img src="#img" alt="section 4.4"></a></p>
|
||||
|
||||
<h2 id="empty">Empty</h2>
|
||||
<h2>Empty</h2>
|
||||
|
||||
<p><a href="">section 4.2</a></p>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
pedantic: true
|
||||
headerIds: true
|
||||
---
|
||||
|
||||
Markdown: Basics
|
||||
@@ -56,7 +57,7 @@ Markdown:
|
||||
|
||||
A First Level Header
|
||||
====================
|
||||
|
||||
|
||||
A Second Level Header
|
||||
---------------------
|
||||
|
||||
@@ -66,11 +67,11 @@ Markdown:
|
||||
|
||||
The quick brown fox jumped over the lazy
|
||||
dog's back.
|
||||
|
||||
|
||||
### Header 3
|
||||
|
||||
> This is a blockquote.
|
||||
>
|
||||
>
|
||||
> This is the second paragraph in the blockquote.
|
||||
>
|
||||
> ## This is an H2 in a blockquote
|
||||
@@ -79,23 +80,23 @@ Markdown:
|
||||
Output:
|
||||
|
||||
<h1>A First Level Header</h1>
|
||||
|
||||
|
||||
<h2>A Second Level Header</h2>
|
||||
|
||||
|
||||
<p>Now is the time for all good men to come to
|
||||
the aid of their country. This is just a
|
||||
regular paragraph.</p>
|
||||
|
||||
|
||||
<p>The quick brown fox jumped over the lazy
|
||||
dog's back.</p>
|
||||
|
||||
|
||||
<h3>Header 3</h3>
|
||||
|
||||
|
||||
<blockquote>
|
||||
<p>This is a blockquote.</p>
|
||||
|
||||
|
||||
<p>This is the second paragraph in the blockquote.</p>
|
||||
|
||||
|
||||
<h2>This is an H2 in a blockquote</h2>
|
||||
</blockquote>
|
||||
|
||||
@@ -109,7 +110,7 @@ Markdown:
|
||||
|
||||
Some of these words *are emphasized*.
|
||||
Some of these words _are emphasized also_.
|
||||
|
||||
|
||||
Use two asterisks for **strong emphasis**.
|
||||
Or, if you prefer, __use two underscores instead__.
|
||||
|
||||
@@ -117,10 +118,10 @@ Output:
|
||||
|
||||
<p>Some of these words <em>are emphasized</em>.
|
||||
Some of these words <em>are emphasized also</em>.</p>
|
||||
|
||||
|
||||
<p>Use two asterisks for <strong>strong emphasis</strong>.
|
||||
Or, if you prefer, <strong>use two underscores instead</strong>.</p>
|
||||
|
||||
|
||||
|
||||
|
||||
## Lists ##
|
||||
@@ -173,7 +174,7 @@ list item text. You can create multi-paragraph list items by indenting
|
||||
the paragraphs by 4 spaces or 1 tab:
|
||||
|
||||
* A list item.
|
||||
|
||||
|
||||
With multiple paragraphs.
|
||||
|
||||
* Another item in the list.
|
||||
@@ -185,7 +186,7 @@ Output:
|
||||
<p>With multiple paragraphs.</p></li>
|
||||
<li><p>Another item in the list.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
### Links ###
|
||||
@@ -280,7 +281,7 @@ Output:
|
||||
|
||||
<p>I strongly recommend against using any
|
||||
<code><blink></code> tags.</p>
|
||||
|
||||
|
||||
<p>I wish SmartyPants used named entities like
|
||||
<code>&mdash;</code> instead of decimal-encoded
|
||||
entites like <code>&#8212;</code>.</p>
|
||||
@@ -303,7 +304,7 @@ Output:
|
||||
|
||||
<p>If you want your page to validate under XHTML 1.0 Strict,
|
||||
you've got to put paragraph tags in your blockquotes:</p>
|
||||
|
||||
|
||||
<pre><code><blockquote>
|
||||
<p>For example.</p>
|
||||
</blockquote>
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
<p>AAA<sometag> <img <sometag> src=x onerror=alert(1)BBB</p>
|
||||
|
||||
<p><a>a2<a2t>a2</a> b <c>c</c> d</p>
|
||||
<h1 id="text"><img src="URL" alt="text"></h1>
|
||||
<h1><img src="URL" alt="text"></h1>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<p>a2a2 b c d</p>
|
||||
<h1 id="text"><img src="URL" alt="text"></h1>
|
||||
<h1><img src="URL" alt="text"></h1>
|
||||
|
||||
@@ -11,7 +11,7 @@ describe('Hooks', () => {
|
||||
}
|
||||
});
|
||||
const html = marked('*text*');
|
||||
expect(html.trim()).toBe('<h1 id="preprocess">preprocess</h1>\n<p><em>text</em></p>');
|
||||
expect(html.trim()).toBe('<h1>preprocess</h1>\n<p><em>text</em></p>');
|
||||
});
|
||||
|
||||
it('should preprocess async', async() => {
|
||||
@@ -27,7 +27,7 @@ describe('Hooks', () => {
|
||||
const promise = marked('*text*');
|
||||
expect(promise).toBeInstanceOf(Promise);
|
||||
const html = await promise;
|
||||
expect(html.trim()).toBe('<h1 id="preprocess-async">preprocess async</h1>\n<p><em>text</em></p>');
|
||||
expect(html.trim()).toBe('<h1>preprocess async</h1>\n<p><em>text</em></p>');
|
||||
});
|
||||
|
||||
it('should preprocess options', () => {
|
||||
@@ -112,6 +112,6 @@ describe('Hooks', () => {
|
||||
const promise = marked('*text*');
|
||||
expect(promise).toBeInstanceOf(Promise);
|
||||
const html = await promise;
|
||||
expect(html.trim()).toBe('<h1 id="preprocess1">preprocess1</h1>\n<h1 id="preprocess2">preprocess2</h1>\n<p><em>text</em></p>\n<h1>postprocess2 async</h1>\n<h1>postprocess1</h1>');
|
||||
expect(html.trim()).toBe('<h1>preprocess1</h1>\n<h1>preprocess2</h1>\n<p><em>text</em></p>\n<h1>postprocess2 async</h1>\n<h1>postprocess1</h1>');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,7 +50,7 @@ describe('Parser', () => {
|
||||
{ type: 'text', text: 'heading' }
|
||||
]
|
||||
}],
|
||||
html: '<h1 id="heading">heading</h1>'
|
||||
html: '<h1>heading</h1>'
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('Marked', () => {
|
||||
|
||||
expect(marked1.parse('# header')).toBe('im marked1');
|
||||
expect(marked2.parse('# header')).toBe('im marked2');
|
||||
expect(marked.parse('# header')).toBe('<h1 id="header">header</h1>\n');
|
||||
expect(marked.parse('# header')).toBe('<h1>header</h1>\n');
|
||||
});
|
||||
|
||||
it('should work with use', () => {
|
||||
@@ -48,7 +48,7 @@ describe('Marked', () => {
|
||||
|
||||
expect(marked1.parse('# header')).toBe('im marked1');
|
||||
expect(marked2.parse('# header')).toBe('im marked2');
|
||||
expect(marked.parse('# header')).toBe('<h1 id="header">header</h1>\n');
|
||||
expect(marked.parse('# header')).toBe('<h1>header</h1>\n');
|
||||
});
|
||||
|
||||
it('should work with setOptions', () => {
|
||||
@@ -70,6 +70,6 @@ describe('Marked', () => {
|
||||
|
||||
expect(marked1.parse('# header')).toBe('im marked1');
|
||||
expect(marked2.parse('# header')).toBe('im marked2');
|
||||
expect(marked.parse('# header')).toBe('<h1 id="header">header</h1>\n');
|
||||
expect(marked.parse('# header')).toBe('<h1>header</h1>\n');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -755,7 +755,7 @@ paragraph
|
||||
|
||||
# heading
|
||||
`);
|
||||
expect(html).toBe('extension2 paragraph\nextension1 html\n<h1 id="heading">heading</h1>\n');
|
||||
expect(html).toBe('extension2 paragraph\nextension1 html\n<h1>heading</h1>\n');
|
||||
});
|
||||
|
||||
it('should use previous extension when returning false', () => {
|
||||
|
||||
Reference in New Issue
Block a user