Skip to content

Commit

Permalink
Do not parse hard line breaks when doing link label blocks
Browse files Browse the repository at this point in the history
Consider this markdown:

```markdown
[x\

]: https://rust-lang.org
```

That's not a link definition, but pulldown-cmark thought it was.
The hard line break on line 1 is an inline element, and should not
prevent the paragraph break from parsing.
  • Loading branch information
notriddle committed Oct 29, 2023
1 parent 97b2141 commit 0e44799
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
11 changes: 11 additions & 0 deletions specs/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1560,3 +1560,14 @@ ISSUE xxx
</li>
</ul>
````````````````````````````````

ISSUE 753

```````````````````````````````` example
[x\

]: https://rust-lang.org
.
<p>[x\</p>
<p>]: https://rust-lang.org</p>
````````````````````````````````
4 changes: 2 additions & 2 deletions src/linklabel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use unicase::UniCase;

use crate::scanners::{is_ascii_whitespace, scan_eol};
use crate::scanners::{is_ascii_whitespace, scan_eol, is_ascii_punctuation};
use crate::strings::CowStr;

#[derive(Debug)]
Expand Down Expand Up @@ -60,7 +60,7 @@ pub(crate) fn scan_link_label_rest<'t>(
match *bytes.get(ix)? {
b'[' => return None,
b']' => break,
b'\\' => {
b'\\' if is_ascii_punctuation(*bytes.get(ix + 1)?) => {
ix += 2;
codepoints += 2;
only_white_space = false;
Expand Down
13 changes: 13 additions & 0 deletions tests/suite/regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1838,3 +1838,16 @@ fn regression_test_118() {

test_markdown_html(original, expected, false, false, false);
}

#[test]
fn regression_test_119() {
let original = r##"[x\
]: https://rust-lang.org
"##;
let expected = r##"<p>[x\</p>
<p>]: https://rust-lang.org</p>
"##;

test_markdown_html(original, expected, false, false, false);
}

0 comments on commit 0e44799

Please sign in to comment.