diff --git a/src/Tokenizer.ts b/src/Tokenizer.ts index 3b2cc1ea..3cd1b8b3 100644 --- a/src/Tokenizer.ts +++ b/src/Tokenizer.ts @@ -985,7 +985,11 @@ export class _Tokenizer { title = cap[3] ? cap[3].slice(1, -1) : ''; } - href = href.trim(); + // Modern link rules already separate ASCII whitespace from the destination. + // Other whitespace is destination content and must not be trimmed. + if (this.options.pedantic) { + href = href.trim(); + } if (this.rules.other.startAngleBracket.test(href)) { if (this.options.pedantic && !(this.rules.other.endAngleBracket.test(trimmedUrl))) { // pedantic allows starting angle bracket without ending angle bracket diff --git a/test/specs/new/link_destination_unicode_whitespace.html b/test/specs/new/link_destination_unicode_whitespace.html new file mode 100644 index 00000000..57d11c87 --- /dev/null +++ b/test/specs/new/link_destination_unicode_whitespace.html @@ -0,0 +1,99 @@ +

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+
+

x

+

x

+

x

diff --git a/test/specs/new/link_destination_unicode_whitespace.md b/test/specs/new/link_destination_unicode_whitespace.md new file mode 100644 index 00000000..888e5298 --- /dev/null +++ b/test/specs/new/link_destination_unicode_whitespace.md @@ -0,0 +1,204 @@ +--- +gfm: true +renderExact: true +--- + +[x]( /url) + +--- + +[x](/url ) + +--- + +[x]( /url ) + +--- + +![x]( /url) + +--- + +![x](/url ) + +--- + +![x]( /url ) + +--- + +[x]( /url) + +--- + +[x](/url ) + +--- + +[x]( /url ) + +--- + +![x]( /url) + +--- + +![x](/url ) + +--- + +![x]( /url ) + +--- + +[x]( /url) + +--- + +[x](/url ) + +--- + +[x]( /url ) + +--- + +![x]( /url) + +--- + +![x](/url ) + +--- + +![x]( /url ) + +--- + +[x](
/url) + +--- + +[x](/url
) + +--- + +[x](
/url
) + +--- + +![x](
/url) + +--- + +![x](/url
) + +--- + +![x](
/url
) + +--- + +[x](
/url) + +--- + +[x](/url
) + +--- + +[x](
/url
) + +--- + +![x](
/url) + +--- + +![x](/url
) + +--- + +![x](
/url
) + +--- + +[x]( /url) + +--- + +[x](/url ) + +--- + +[x]( /url ) + +--- + +![x]( /url) + +--- + +![x](/url ) + +--- + +![x]( /url ) + +--- + +[x]( /url) + +--- + +[x](/url ) + +--- + +[x]( /url ) + +--- + +![x]( /url) + +--- + +![x](/url ) + +--- + +![x]( /url ) + +--- + +[x](/url) + +--- + +[x](/url) + +--- + +[x](/url) + +--- + +![x](/url) + +--- + +![x](/url) + +--- + +![x](/url) + +--- + +[x]( +/url +) + +[x](< /url > "title") + +[x]( /url  "title") diff --git a/test/specs/new/link_destination_whitespace_pedantic.html b/test/specs/new/link_destination_whitespace_pedantic.html new file mode 100644 index 00000000..6e086a99 --- /dev/null +++ b/test/specs/new/link_destination_whitespace_pedantic.html @@ -0,0 +1 @@ +

x

diff --git a/test/specs/new/link_destination_whitespace_pedantic.md b/test/specs/new/link_destination_whitespace_pedantic.md new file mode 100644 index 00000000..65f810f5 --- /dev/null +++ b/test/specs/new/link_destination_whitespace_pedantic.md @@ -0,0 +1,6 @@ +--- +pedantic: true +renderExact: true +--- + +[x]( /url )