Skip to content

Commit f3d21af

Browse files
amanjhacodes55amanclaude
authored
fix: do not allow a blank line inside a link reference definition label (#4165)
Co-authored-by: aman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 1d4d8fe commit f3d21af

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎src/rules.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const lheadingGfm = edit(lheadingCore)
148148
.getRegex();
149149
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
150150
const blockText = /^[^\n]+/;
151-
const _blockLabel = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
151+
const _blockLabel = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/;
152152
const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/)
153153
.replace('label', _blockLabel)
154154
// An escaped delimiter is part of the title, so a backslash must consume the
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<p>[foo</p>
2+
3+
<p>bar]: /url</p>
4+
5+
<p>[foo</p>
6+
7+
<p>bar]</p>
8+
9+
<p><a href="/url">baz
10+
qux</a></p>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[foo
2+
3+
bar]: /url
4+
5+
[foo
6+
7+
bar]
8+
9+
[baz
10+
qux]: /url
11+
12+
[baz
13+
qux]

0 commit comments

Comments
 (0)