Open mail2nnv opened 1 year ago
Try separating footnotes and citations by one line.
Try separating footnotes and citations by one line.
Nothing changed.
I'm sure this needs a more thorough look from someone familiar with the parser, but a quick check suggests that this behavior is the result of a conflict between how reference links are parsed and how link definitions are parsed.
Specifically, link definitions are explicitly not recognized if the reference name starts with a caret. (Note the (?!\^)
.)
Conversely, reference links aren't subject to that exclusion. (Called out here as the "link def".)
As a result, footnotes appear to be interpreted as [shorthand]
-style reference links which simply happen to start with a caret. But because the matching footnote definition isn't recognized as a link definition, the language service sees this as a link without a definition.
By my read, a fix for this could be as simple as removing (?!\^)
from definitionPattern
. Unless there's something else in the way, that should allow the parser to find the link definition. It'll still think the footnote is a link, though, and I don't know whether that could cause other issues.
Just for additional context, even though most people's use case for this is footnotes, the following minimal example is parsed fine by commonmark.js (see here)
[^1]
[^1]: /url
However, vscode complains with
No link definition found: '^1'(link.no-such-reference)
footnotes are often used in rich documentation sites powered by mkdocs and the likes. Would be great to see this fixed
a few examples with footnotes that are not captured as a link in the current vscode markdown lsp:
[`Makefile`][makefile][^1]
`make`[^4]
[`text`](url)[^5]
Does this issue occur when all extensions are disabled?: Yes/No Yes
Steps to Reproduce: