Reference links followed by space-only pair of brackets

Consider this example:



Or, equivalently, this one:


[foo][ ]

It seems ambiguous from the commonmark spec whether there’s a link here or not

  • commonmark-hs, commonmark-js, and markdown-it all say that there isn’t a link. They render: [foo][ ]
  • pulldown-cmark and goldmark both say that there is. They render: foo[ ]

I’m pretty sure the reference implementation justifies this choice by example 570, which is annotated like this:

Here [foo] is not parsed as a shortcut reference, because it is followed by a link label (even though [bar] is not defined):


[baz]: /url1
[foo]: /url2

However, [ ] cannot actually be a valid label, because it contains only whitespace.

Interestingly enough, the rule is definitely not “collapsed links can’t be followed by [.” If I drop the last line, making it like this, I get a link: