diff --git a/markdown_it/helpers/parse_link_destination.py b/markdown_it/helpers/parse_link_destination.py index c98323c0..e4859fbb 100644 --- a/markdown_it/helpers/parse_link_destination.py +++ b/markdown_it/helpers/parse_link_destination.py @@ -56,7 +56,10 @@ def parseLinkDestination(string: str, pos: int, maximum: int) -> _Result: if code == 0x5C and pos + 1 < maximum: if charCodeAt(string, pos + 1) == 0x20: - break + # a backslash before a space is a literal backslash, + # and the space then ends the destination + pos += 1 + continue pos += 2 continue diff --git a/tests/test_port/fixtures/commonmark_extras.md b/tests/test_port/fixtures/commonmark_extras.md index 98ce1ad5..88b22588 100644 --- a/tests/test_port/fixtures/commonmark_extras.md +++ b/tests/test_port/fixtures/commonmark_extras.md @@ -324,6 +324,21 @@ Escaped space is not allowed in link destination, commonmark/CommonMark#493.

[link](a\ b)

. +Backslash before a space in a link destination is a literal backslash, and the space ends the destination (CommonMark 0.31.2 6.3) +. +[a](/url\ ) + +[b](/url\ "title") + +[c] + +[c]: /url\ "title" +. +

a

+

b

+

c

+. + Link destination cannot contain '<' . []()