Skip to content

Commit b006595

Browse files
committed
Do not parse markdown footnotes as references
Resolves #2991
1 parent 2118cc2 commit b006595

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ title: Changelog
77
### Bug Fixes
88

99
- Fixed inconsistent anchors on module pages for re-exports, #2990.
10+
- Markdown references which appear to be footnotes will no longer be checked for links, #2991.
1011

1112
## v0.28.9 (2025-08-01)
1213

src/lib/converter/comments/textParser.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,13 @@ function checkReference(data: TextParserData): RelativeLink | undefined {
258258
while (/[ \t]/.test(token.text[lookahead])) {
259259
++lookahead;
260260
}
261-
if (token.text[lookahead] === "[") {
261+
// #2991, we check that this reference also doesn't look like a footnote reference
262+
// as it is unlikely that someone uses that syntax without intending for footnote behavior.
263+
// This introduces a problem if someone has an [^ref] and doesn't intend for that to
264+
// be interpreted as a footnote, but as a reference, but we can't have it both ways,
265+
// and having people rename their reference to not be confused with a footnote isn't a
266+
// horrible workaround.
267+
if (token.text[lookahead] === "[" && token.text[lookahead + 1] !== "^") {
262268
while (
263269
lookahead < token.text.length &&
264270
/[^\n\]]/.test(token.text[lookahead])

src/test/comments.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,7 @@ describe("Comment Parser", () => {
15581558
* [2]:<./example with space>
15591559
* [3]: https://example.com
15601560
* [4]: #hash
1561+
* [^footnote]: ./example.md
15611562
*/`);
15621563

15631564
equal(
@@ -1579,7 +1580,7 @@ describe("Comment Parser", () => {
15791580
},
15801581
{
15811582
kind: "text",
1582-
text: "\n[3]: https://example.com\n[4]: #hash",
1583+
text: "\n[3]: https://example.com\n[4]: #hash\n[^footnote]: ./example.md",
15831584
},
15841585
] satisfies CommentDisplayPart[],
15851586
);

0 commit comments

Comments
 (0)