mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: allow tabs between the tag name and attributes of an html block (#4207)
This commit is contained in:
+6
-6
@@ -109,7 +109,7 @@ export const other = {
|
||||
pedanticHeadingBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}#`)),
|
||||
// a list item ends where a paragraph would be interrupted, so this mirrors the
|
||||
// html start conditions in the paragraph rule below; type 7 is excluded there
|
||||
htmlBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}(?:</?(?:${_tag})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`, 'i')),
|
||||
htmlBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}(?:</?(?:${_tag})(?:[ \\t]+|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`, 'i')),
|
||||
blockquoteBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}>`)),
|
||||
// list item and blockquote markers that open nested blocks at the start of a line, as in `- > # heading`
|
||||
nestedContainerMarkers: /^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/,
|
||||
@@ -179,12 +179,12 @@ const html = edit(
|
||||
+ '|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)' // (4)
|
||||
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)' // (5)
|
||||
+ '|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6)
|
||||
+ '|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
|
||||
+ '|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*?[ \\t]*/?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
|
||||
+ '|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag
|
||||
+ ')', 'i')
|
||||
.replace('comment', _comment)
|
||||
.replace('tag', _tag)
|
||||
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
|
||||
.replace('attribute', /[ \t]+[a-zA-Z:_][\w.:-]*(?:[ \t]*=[ \t]*"[^"\n]*"|[ \t]*=[ \t]*'[^'\n]*'|[ \t]*=[ \t]*[^\s"'=<>`]+)?/)
|
||||
.getRegex();
|
||||
|
||||
const createParagraph = (listInterrupt: RegExp) => edit(_paragraph)
|
||||
@@ -195,7 +195,7 @@ const createParagraph = (listInterrupt: RegExp) => edit(_paragraph)
|
||||
.replace('blockquote', ' {0,3}>')
|
||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)')
|
||||
.replace('list', listInterrupt)
|
||||
.replace('html', ' {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)')
|
||||
.replace('html', ' {0,3}(?:</?(?:tag)(?:[ \\t]+|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)')
|
||||
.replace('tag', _tag) // pars can be interrupted by html blocks of types (1) to (6)
|
||||
.getRegex();
|
||||
|
||||
@@ -248,7 +248,7 @@ const gfmTable = edit(
|
||||
.replace('code', '(?: {4}| {0,3}\t)[^\\n]')
|
||||
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)')
|
||||
.replace('list', ' {0,3}(?:[*+-]|1[.)])[ \\t]') // any bullet ends the table rows
|
||||
.replace('html', ' {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)')
|
||||
.replace('html', ' {0,3}(?:</?(?:tag)(?:[ \\t]+|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)')
|
||||
.replace('tag', _tag) // tables can be interrupted by html blocks of types (1) to (6)
|
||||
.getRegex();
|
||||
|
||||
@@ -264,7 +264,7 @@ const blockGfm: Record<BlockKeys, RegExp> = {
|
||||
.replace('blockquote', ' {0,3}>')
|
||||
.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', ' {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)')
|
||||
.replace('html', ' {0,3}(?:</?(?:tag)(?:[ \\t]+|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)')
|
||||
.replace('tag', _tag) // pars can be interrupted by html blocks of types (1) to (6)
|
||||
.getRegex(),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<z a>
|
||||
<z a="b">
|
||||
<z a="b" c>
|
||||
<z a = "b">
|
||||
<z />
|
||||
<p>foo</p>
|
||||
<div class="a">
|
||||
<ul>
|
||||
<li>a</li>
|
||||
</ul>
|
||||
<div b>
|
||||
@@ -0,0 +1,15 @@
|
||||
<z a>
|
||||
|
||||
<z a="b">
|
||||
|
||||
<z a="b" c>
|
||||
|
||||
<z a = "b">
|
||||
|
||||
<z />
|
||||
|
||||
foo
|
||||
<div class="a">
|
||||
|
||||
- a
|
||||
<div b>
|
||||
Reference in New Issue
Block a user