From 54972551a12fb45fd9ba9f3506f370dca73b1ee1 Mon Sep 17 00:00:00 2001 From: Laksh Agarwal <184763813+Lotion-3@users.noreply.github.com> Date: Wed, 25 Nov 2026 02:52:37 -0500 Subject: [PATCH] Allow tabs in links and link reference definitions reSpnl and reSpaceAtEndOfLine only skipped spaces, so a tab before or after a link destination stopped [a](/url) and [a](/url"t") from being links, and [a]:/url or [a]: /url from being definitions. The spec allows spaces or tabs in all of these places, and cmark skips both. --- lib/inlines.js | 4 ++-- test/regression.txt | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/inlines.js b/lib/inlines.js index ea8419a4..e7544b77 100644 --- a/lib/inlines.js +++ b/lib/inlines.js @@ -72,7 +72,7 @@ var reEmailAutolink = /^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA- var reAutolink = /^<[A-Za-z][A-Za-z0-9.+-]{1,31}:[^<>\x00-\x20]*>/i; -var reSpnl = /^ *(?:\n *)?/; +var reSpnl = /^[ \t]*(?:\n[ \t]*)?/; var reWhitespaceChar = /^[ \t\n\x0b\x0c\x0d]/; @@ -82,7 +82,7 @@ var reFinalSpace = / *$/; var reInitialSpace = /^ */; -var reSpaceAtEndOfLine = /^ *(?:\n|$)/; +var reSpaceAtEndOfLine = /^[ \t]*(?:\n|$)/; var reLinkLabel = /^\[(?:[^\\\[\]]|\\.){0,1000}\]/s; diff --git a/test/regression.txt b/test/regression.txt index 2fff1538..891376e2 100644 --- a/test/regression.txt +++ b/test/regression.txt @@ -738,3 +738,26 @@ Foo

Foo

a

```````````````````````````````` + +Tabs are allowed wherever spaces are in links and link reference +definitions. + +```````````````````````````````` example +[a]: /url→ +[b]: /url "title"→ + +[a] [b] +. +

a b

+```````````````````````````````` + +```````````````````````````````` example +[a](→/url→"title"→) + +[b]:→/url→"title" + +[b] +. +

a

+

b

+````````````````````````````````