mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: allow one more level of nested brackets in a link label (#4064)
This commit is contained in:
+8
-1
@@ -441,7 +441,14 @@ const tag = edit(
|
||||
.replace('attribute', /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/)
|
||||
.getRegex();
|
||||
|
||||
const _inlineLabel = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
|
||||
// One matched pair of brackets, holding no bracket of its own.
|
||||
const _inlineLabelBrackets = /\[(?:\\[\s\S]|[^\[\]\\])*\]/;
|
||||
// CommonMark lets the brackets in a link label nest to any depth, which a regex
|
||||
// cannot follow, so it stops at a fixed one. Two levels is what the spec suite
|
||||
// asks for: a third and a fourth flip no further example.
|
||||
const _inlineLabel = edit(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/)
|
||||
.replace('brackets', _inlineLabelBrackets)
|
||||
.getRegex();
|
||||
|
||||
const link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/)
|
||||
.replace('label', _inlineLabel)
|
||||
|
||||
@@ -4096,8 +4096,7 @@
|
||||
"example": 512,
|
||||
"start_line": 7840,
|
||||
"end_line": 7844,
|
||||
"section": "Links",
|
||||
"shouldFail": true
|
||||
"section": "Links"
|
||||
},
|
||||
{
|
||||
"markdown": "[link] bar](/uri)\n",
|
||||
@@ -4161,8 +4160,7 @@
|
||||
"example": 520,
|
||||
"start_line": 7900,
|
||||
"end_line": 7904,
|
||||
"section": "Links",
|
||||
"shouldFail": true
|
||||
"section": "Links"
|
||||
},
|
||||
{
|
||||
"markdown": "*[foo*](/uri)\n",
|
||||
@@ -4228,8 +4226,7 @@
|
||||
"example": 528,
|
||||
"start_line": 8004,
|
||||
"end_line": 8010,
|
||||
"section": "Links",
|
||||
"shouldFail": true
|
||||
"section": "Links"
|
||||
},
|
||||
{
|
||||
"markdown": "[link \\[bar][ref]\n\n[ref]: /uri\n",
|
||||
|
||||
@@ -4096,8 +4096,7 @@
|
||||
"example": 512,
|
||||
"start_line": 7840,
|
||||
"end_line": 7844,
|
||||
"section": "Links",
|
||||
"shouldFail": true
|
||||
"section": "Links"
|
||||
},
|
||||
{
|
||||
"markdown": "[link] bar](/uri)\n",
|
||||
@@ -4161,8 +4160,7 @@
|
||||
"example": 520,
|
||||
"start_line": 7900,
|
||||
"end_line": 7904,
|
||||
"section": "Links",
|
||||
"shouldFail": true
|
||||
"section": "Links"
|
||||
},
|
||||
{
|
||||
"markdown": "*[foo*](/uri)\n",
|
||||
@@ -4228,8 +4226,7 @@
|
||||
"example": 528,
|
||||
"start_line": 8004,
|
||||
"end_line": 8010,
|
||||
"section": "Links",
|
||||
"shouldFail": true
|
||||
"section": "Links"
|
||||
},
|
||||
{
|
||||
"markdown": "[link \\[bar][ref]\n\n[ref]: /uri\n",
|
||||
|
||||
Reference in New Issue
Block a user