diff --git a/scripts/build.ts b/scripts/build.ts index 1c19dd26..020275b9 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -120,6 +120,9 @@ function buildPeoplePages() { // Read markdown page and remove markdown meta let markdown = metadataParser(fs.readFileSync(path.join(srcPath, `page${lang}.md`), "utf-8")).content.replaceAll("", " */}"); + // Handle Footnote + markdown = handleFootnote(markdown) + // Autocorrect markdown markdown = autocorrect.formatFor(markdown, 'markdown') @@ -133,6 +136,21 @@ function buildPeoplePages() { } } +function handleFootnote(md: string) { + if (!md.includes('[^')) return md + + // Replace footnote references with HTML superscript tags + return md.replace(/\[\^(\d+)\](?::\s*(.*))?/g, (match, id, text) => text ? + // Footnote definition + `
  • ${text}
  • ` : + // Footnote reference + `${id}` + ) + + // Wrap the footnote definitions in an ordered list + .replace(/(