Closed nzakas closed 1 month ago
Hey @nzakas! 👋 Commonmark specifies that spaces are significant and it would not match https://spec.commonmark.org/dingus/?text=%5Bfoo%5D%5B%20%5D%0A%0A%5Bfoo%5D%3A%20https%3A%2F%2Fexample.com
I don't see any spec changes in https://github.github.com/gfm/#link-reference-definitions to reference links This may be a bug in https://github.com/github/cmark-gfm
This seems to be https://github.com/commonmark/commonmark-spec/issues/653, which shows that most tools work differently than the spec.
I think the spec is currently saying that this is not allowed:
[ ]
in the resulting HTML, which is also not what you expected[]
”, which this is notI do consider this to be something that can improved in CM.
But I also consider this a current bug in GFM, which says it sticks to CM, so I don’t feel good about “solving” it in micromark-extension-gfm
.
To make sure I'm following, it sounds like you're saying that the spec disallows this behavior, so this is a bug in GitHub's Markdown parser?
Correct
I think that in this example, spaces and line breaks are not significant:
[foo][
bar ]
[bar
]: https://example.com
But they are significant if there are only spacing characters?
Correct. There’s indeed a “gap” between the different shortcut links and how they are defined in CM. Shortcut ([x]
), collapsed ([x][]
), vs. full ([x][y]
). Making nzakas’s case ambiguous/vague/weird.
Closing as behavior is intentional, I believe according to spec!
Hi! This was closed. Team: If this was fixed, please add phase/solved
. Otherwise, please add one of the no/*
labels.
Initial checklist
Affected packages and versions
mdast-util-from-markdown@2.0.1
Link to runnable example
https://stackblitz.com/edit/stackblitz-starters-ifpvft?file=index.js
Steps to reproduce
[]
:fromMarkdown()
Expected behavior
The returned AST should identify
[foo][ ]
as alinkReference
. (It appears that GitHub does this. I'm unsure if that's standard behavior for Markdown or not. The Micromark GFM extension exhibits the same behavior.)Actual behavior
The returned AST identifies
[foo][ ]
astext
rather than a link reference.Affected runtime and version
node@20.13.0
Affected package manager and version
No response
Affected OS and version
No response
Build and bundle tools
No response