mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: allow escaped newline in link text (#3752)
* fix: allow ecaped newline in link text * use [\s\S]
This commit is contained in:
+4
-4
@@ -106,7 +106,7 @@ const lheadingGfm = edit(lheadingCore)
|
||||
.getRegex();
|
||||
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
||||
const blockText = /^[^\n]+/;
|
||||
const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
||||
const _blockLabel = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
||||
const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/)
|
||||
.replace('label', _blockLabel)
|
||||
.replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/)
|
||||
@@ -267,7 +267,7 @@ const _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
|
||||
const _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
|
||||
|
||||
// sequences em should skip over [title](link), `code`, <html>
|
||||
const blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g;
|
||||
const blockSkip = /\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g;
|
||||
|
||||
const emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
|
||||
|
||||
@@ -336,7 +336,7 @@ const tag = edit(
|
||||
.replace('attribute', /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/)
|
||||
.getRegex();
|
||||
|
||||
const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
||||
const _inlineLabel = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`[^`]*`|[^\[\]\\`])*?/;
|
||||
|
||||
const link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/)
|
||||
.replace('label', _inlineLabel)
|
||||
@@ -412,7 +412,7 @@ const inlineGfm: Record<InlineKeys, RegExp> = {
|
||||
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
|
||||
.getRegex(),
|
||||
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
||||
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
|
||||
del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
|
||||
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/,
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<p>
|
||||
<a href="https://example.com">foo<br />
|
||||
bar</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="https://example2.com">foo2<br />
|
||||
bar2</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="https://example.com">foo3<br />
|
||||
bar3</a>
|
||||
</p>
|
||||
@@ -0,0 +1,12 @@
|
||||
[foo\
|
||||
bar]
|
||||
|
||||
[foo\
|
||||
bar]: https://example.com
|
||||
|
||||
[foo2\
|
||||
bar2](https://example2.com)
|
||||
|
||||
[foo3\
|
||||
bar3][foo\
|
||||
bar]
|
||||
Reference in New Issue
Block a user