fix: handle empty markdown string and footnote content

This commit is contained in:
Han Xiao 2025-06-13 09:57:05 -07:00
parent 6c3ed9ba6d
commit 1d531ceffe

View File

@ -164,6 +164,7 @@ ${formatReferences(references)}
* It extracts existing footnote definitions and uses them as references
*/
export function repairMarkdownFootnotesOuter(markdownString: string): string {
if (!markdownString) return '';
// First trim the string to handle any extra whitespace
markdownString = markdownString.trim();
@ -203,6 +204,7 @@ export function repairMarkdownFootnotesOuter(markdownString: string): string {
let footnoteMatch;
while ((footnoteMatch = footnoteDefRegex.exec(footnotesPart)) !== null) {
// The footnote content
if (!footnoteMatch[2]) continue;
let content = footnoteMatch[2].trim();
// Extract URL and title if present