diff --git a/lightrag_webui/src/utils/remarkFootnotes.ts b/lightrag_webui/src/utils/remarkFootnotes.ts index 57dd27c3..d73faa97 100644 --- a/lightrag_webui/src/utils/remarkFootnotes.ts +++ b/lightrag_webui/src/utils/remarkFootnotes.ts @@ -27,10 +27,22 @@ export const remarkFootnotes: Plugin<[], Root> = () => { }) } + // Check if there's another footnote immediately following this one + const nextIndex = startIndex + fullMatch.length + const remainingText = text.slice(nextIndex) + const hasConsecutiveFootnote = /^\[\^[^\]]+\]/.test(remainingText) + // Add footnote reference as HTML with placeholder link + const footnoteHtml = `${id}` + + // Add spacing if there's a consecutive footnote + const htmlWithSpacing = hasConsecutiveFootnote + ? footnoteHtml + ' ' + : footnoteHtml + replacements.push({ type: 'html', - value: `${id}` + value: htmlWithSpacing }) lastIndex = startIndex + fullMatch.length