Interesting markdown link highlighting

I discovered this in my app and reproduced with Try CodeMirror too.

So when the content looks like this:

Both are not highlighted as links. However, if I add more content (like some spaces and random characters):

Both are links now. I couldn’t figure out a reason for this:

Is this something expected? I am trying to understand the pattern for this.

Thanks!

You can often figure out weird Markdown behavior by trying it in the CommonMark demo. Here the links become regular paragraphs when there’s whitespace in the URL, but the bracketed parts still act like link shorthands.

Thank you for the response!

This is very interesting because in cmark-gfm, [^1]: is a footnote label: Footnotes now supported in Markdown fields - GitHub Changelog and right now it behaves differently w/ and w/o spaces.

@lezer/markdown does not have support for that extension so it obviously won’t parse it in that way.