@@ -634,7 +634,7 @@ A tab will not work:
634634.
635635#→foo
636636.
637- <p># foo</p>
637+ <p>#→ foo</p>
638638.
639639
640640This is not a heading, because the first `#` is escaped:
@@ -6838,7 +6838,7 @@ There are three kinds of [reference link](@reference-link)s:
68386838and [shortcut](#shortcut-reference-link).
68396839
68406840A [full reference link](@full-reference-link)
6841- consists of a [link text], optional [whitespace], and a [link label]
6841+ consists of a [link text] immediately followed by a [link label]
68426842that [matches] a [link reference definition] elsewhere in the document.
68436843
68446844A [link label](@link-label) begins with a left bracket (`[`) and ends
@@ -7008,14 +7008,15 @@ purposes of determining matching:
70087008<p><a href="/url">Baz</a></p>
70097009.
70107010
7011- There can be [whitespace] between the [link text] and the [link label]:
7011+ No [whitespace] is allowed between the [link text] and the
7012+ [link label]:
70127013
70137014.
70147015[foo] [bar]
70157016
70167017[bar]: /url "title"
70177018.
7018- <p><a href="/url" title="title">foo </a></p>
7019+ <p>[foo] <a href="/url" title="title">bar </a></p>
70197020.
70207021
70217022.
@@ -7024,9 +7025,37 @@ There can be [whitespace] between the [link text] and the [link label]:
70247025
70257026[bar]: /url "title"
70267027.
7027- <p><a href="/url" title="title">foo</a></p>
7028+ <p>[foo]
7029+ <a href="/url" title="title">bar</a></p>
70287030.
70297031
7032+ This is a departure from John Gruber's original Markdown syntax
7033+ description, which explicitly allows whitespace between the link
7034+ text and the link label. It brings reference links in line with
7035+ [inline link]s, which (according to both original Markdown and
7036+ this spec) cannot have whitespace after the link text. More
7037+ importantly, it prevents inadvertent capture of consecutive
7038+ [shortcut reference link]s. If whitespace is allowed between the
7039+ link text and the link label, then in the following we will have
7040+ a single reference link, not two shortcut reference links, as
7041+ intended:
7042+
7043+ ``` markdown
7044+ [foo]
7045+ [bar]
7046+
7047+ [foo]: /url1
7048+ [bar]: /url2
7049+ ```
7050+
7051+ (Note that [shortcut reference link]s were introduced by Gruber
7052+ himself in a beta version of `Markdown.pl`, but never included
7053+ in the official syntax description. Without shortcut reference
7054+ links, it is harmless to allow space between the link text and
7055+ link label; but once shortcut references are introduced, it is
7056+ too dangerous to allow this, as it frequently leads to
7057+ unintended results.)
7058+
70307059When there are multiple matching [link reference definition]s,
70317060the first is used:
70327061
@@ -7127,7 +7156,7 @@ A [link label] must contain at least one [non-whitespace character]:
71277156A [collapsed reference link](@collapsed-reference-link)
71287157consists of a [link label] that [matches] a
71297158[link reference definition] elsewhere in the
7130- document, optional [whitespace], and the string `[]`.
7159+ document, followed by the string `[]`.
71317160The contents of the first link label are parsed as inlines,
71327161which are used as the link's text. The link's URI and title are
71337162provided by the matching reference link definition. Thus,
@@ -7160,16 +7189,17 @@ The link labels are case-insensitive:
71607189.
71617190
71627191
7163- As with full reference links, [whitespace] is allowed
7164- between the two sets of brackets:
7192+ As with full reference links, [whitespace] is not
7193+ allowed between the two sets of brackets:
71657194
71667195.
71677196[foo]
71687197[]
71697198
71707199[foo]: /url "title"
71717200.
7172- <p><a href="/url" title="title">foo</a></p>
7201+ <p><a href="/url" title="title">foo</a>
7202+ []</p>
71737203.
71747204
71757205A [shortcut reference link](@shortcut-reference-link)
@@ -7390,15 +7420,15 @@ My 
73907420Reference-style:
73917421
73927422.
7393- ![foo] [bar]
7423+ ![foo][bar]
73947424
73957425[bar]: /url
73967426.
73977427<p><img src="/url" alt="foo" /></p>
73987428.
73997429
74007430.
7401- ![foo] [bar]
7431+ ![foo][bar]
74027432
74037433[BAR]: /url
74047434.
@@ -7433,7 +7463,7 @@ The labels are case-insensitive:
74337463<p><img src="/url" alt="Foo" title="title" /></p>
74347464.
74357465
7436- As with full reference links, [whitespace] is allowed
7466+ As with reference links, [whitespace] is not allowed
74377467between the two sets of brackets:
74387468
74397469.
@@ -7442,7 +7472,8 @@ between the two sets of brackets:
74427472
74437473[foo]: /url "title"
74447474.
7445- <p><img src="/url" alt="foo" title="title" /></p>
7475+ <p><img src="/url" alt="foo" title="title" />
7476+ []</p>
74467477.
74477478
74487479Shortcut:
0 commit comments