mirror of
https://github.com/one-among-us/data.git
synced 2024-11-10 13:24:50 +08:00
commit
ef97ae8bca
@ -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("<!--", "{/* ").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
|
||||
`<li id="footnote-${id}">${text}<a href="#footnote-ref-${id}">↩</a></li>` :
|
||||
// Footnote reference
|
||||
`<sup><a href="#footnote-${id}" id="footnote-ref-${id}">${id}</a></sup>`
|
||||
)
|
||||
|
||||
// Wrap the footnote definitions in an ordered list
|
||||
.replace(/(<li id="footnote.*<\/li>)/gs, '<ol>\n$1\n</ol>')
|
||||
}
|
||||
|
||||
// Copy `people/${dirname}/photos` to `dist/people/${dirname}/`.
|
||||
function copyPeopleAssets() {
|
||||
const PEOPLE_ASSETS = ["photos", "backup", "page.md"];
|
||||
|
Loading…
Reference in New Issue
Block a user