mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: parse EOF backtick fences after paragraphs (#4039)
* fix: parse EOF backtick fences after paragraphs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: handle EOF tilde fence interruption Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
parent
2e21cd3554
commit
81bd750533
+3
-3
@@ -169,7 +169,7 @@ const createParagraph = (listInterrupt: RegExp) => edit(_paragraph)
|
||||
.replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
|
||||
.replace('|table', '')
|
||||
.replace('blockquote', ' {0,3}>')
|
||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n')
|
||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)')
|
||||
.replace('list', listInterrupt)
|
||||
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
||||
.replace('tag', _tag) // pars can be interrupted by type (6) html blocks
|
||||
@@ -220,7 +220,7 @@ const gfmTable = edit(
|
||||
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
||||
.replace('blockquote', ' {0,3}>')
|
||||
.replace('code', '(?: {4}| {0,3}\t)[^\\n]')
|
||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n')
|
||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)')
|
||||
.replace('list', ' {0,3}(?:[*+-]|1[.)])[ \\t]') // any bullet ends the table rows
|
||||
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
||||
.replace('tag', _tag) // tables can be interrupted by type (6) html blocks
|
||||
@@ -236,7 +236,7 @@ const blockGfm: Record<BlockKeys, RegExp> = {
|
||||
.replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
|
||||
.replace('table', gfmTable) // interrupt paragraphs with table
|
||||
.replace('blockquote', ' {0,3}>')
|
||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n')
|
||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)')
|
||||
.replace('list', ' {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]') // only non-empty lists starting from 1 can interrupt
|
||||
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
||||
.replace('tag', _tag) // pars can be interrupted by type (6) html blocks
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<p>foo</p>
|
||||
<pre><code></code></pre>
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
gfm: false
|
||||
---
|
||||
foo
|
||||
```
|
||||
@@ -0,0 +1,2 @@
|
||||
<p>foo</p>
|
||||
<pre><code></code></pre>
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
gfm: false
|
||||
---
|
||||
foo
|
||||
~~~
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
markdown: 'intro\n' + '~'.repeat(50000),
|
||||
html: `<p>intro\n${'~'.repeat(50000)}</p>\n`,
|
||||
html: '<p>intro</p>\n<pre><code>\n</code></pre>\n',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user