fix: md footnote

This commit is contained in:
Han Xiao 2025-03-19 18:46:41 +08:00
parent a3f2120885
commit 63999ba739

View File

@ -160,6 +160,17 @@ ${formatReferences(references)}
* It extracts existing footnote definitions and uses them as references
*/
export function repairMarkdownFootnotesSimple(markdownString: string): string {
// Remove outer code fence if it exists
// First trim the string to handle any extra whitespace
markdownString = markdownString.trim();
// Check if the string starts with ```markdown and ends with ```
const codeBlockRegex = /^```markdown\n([\s\S]*)\n```$/;
const codeBlockMatch = markdownString.match(codeBlockRegex);
if (codeBlockMatch) {
markdownString = codeBlockMatch[1];
}
// Extract existing footnote definitions
const footnoteDefRegex = /\[\^(\d+)]:\s*(.*?)(?=\n\[\^|$)/gs;
const references: Array<Reference> = [];