donteatfriedrice
2025-04-18 02:44:21 +00:00
parent dd51180acb
commit a555df0200
8 changed files with 44 additions and 62 deletions
@@ -29,13 +29,23 @@ export const markdownFootnoteReferenceToDeltaMatcher =
const footnoteReference = FootNoteReferenceParamsSchema.parse(
footnoteDefinitionJson
);
// If the footnote reference is an attachment, and the file type is not set,
// Try to infer the file type from the file name.
const { type: referenceType, fileName, fileType } = footnoteReference;
if (referenceType === 'attachment' && fileName && !fileType) {
const ext = fileName.split('.').pop()?.toLowerCase();
if (ext) {
footnoteReference.fileType = ext;
}
}
const footnote = {
label: ast.identifier,
reference: footnoteReference,
};
return [{ insert: ' ', attributes: { footnote } }];
} catch (error) {
console.warn('Error parsing footnote reference', error);
} catch {
return [];
}
},