From 683bbe9364491a2c12e83392dae8723f508cc1a5 Mon Sep 17 00:00:00 2001 From: yangdx Date: Fri, 26 Sep 2025 10:20:45 +0800 Subject: [PATCH] Fix footnote spacing and anchor links in markdown processing - Add spacing between consecutive footnotes - Fix anchor href to use footnote ID - Detect adjacent footnote patterns - Improve footnote reference formatting - Add non-breaking space for readability --- lightrag_webui/src/utils/remarkFootnotes.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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