Skip to content

Commit 9bccc4e

Browse files
authored
fix: prevent duplicate footnotes for identical external links (#998)
close #981
1 parent cf821d7 commit 9bccc4e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/core/src/renderer/renderer-impl.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ export function initRenderer(opts: IOpts): RendererAPI {
169169
}
170170

171171
function addFootnote(title: string, link: string): number {
172+
// 检查是否已经存在相同的链接
173+
const existingFootnote = footnotes.find(([, , existingLink]) => existingLink === link)
174+
if (existingFootnote) {
175+
return existingFootnote[0] // 返回已存在的脚注索引
176+
}
177+
178+
// 如果不存在,创建新的脚注
172179
footnotes.push([++footnoteIndex, title, link])
173180
return footnoteIndex
174181
}

0 commit comments

Comments
 (0)