mirror of
https://github.com/one-among-us/data.git
synced 2024-11-10 13:24:50 +08:00
[O] Handle footnote
This commit is contained in:
parent
047926b5bd
commit
496363eaa0
@ -120,6 +120,9 @@ function buildPeoplePages() {
|
|||||||
// Read markdown page and remove markdown meta
|
// Read markdown page and remove markdown meta
|
||||||
let markdown = metadataParser(fs.readFileSync(path.join(srcPath, `page${lang}.md`), "utf-8")).content.replaceAll("<!--", "{/* ").replaceAll("-->", " */}");
|
let markdown = metadataParser(fs.readFileSync(path.join(srcPath, `page${lang}.md`), "utf-8")).content.replaceAll("<!--", "{/* ").replaceAll("-->", " */}");
|
||||||
|
|
||||||
|
// Handle Footnote
|
||||||
|
markdown = handleFootnote(markdown)
|
||||||
|
|
||||||
// Autocorrect markdown
|
// Autocorrect markdown
|
||||||
markdown = autocorrect.formatFor(markdown, 'markdown')
|
markdown = autocorrect.formatFor(markdown, 'markdown')
|
||||||
|
|
||||||
@ -133,6 +136,50 @@ function buildPeoplePages() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleFootnote(md: string) {
|
||||||
|
const data = md.split('')
|
||||||
|
let result = ''
|
||||||
|
let footnote = false
|
||||||
|
let ol = false
|
||||||
|
|
||||||
|
for (let i = 0; i < data.length; i += 1) {
|
||||||
|
if ((data[i] == '[') && (i != data.length - 1)) {
|
||||||
|
if (data[i + 1] == '^') {
|
||||||
|
footnote = true;
|
||||||
|
i += 1
|
||||||
|
let id = ''
|
||||||
|
while (data[++i] != ']') id += data[i]
|
||||||
|
if (data[i + 1] == ':') {
|
||||||
|
if (!ol) {
|
||||||
|
ol = !ol;
|
||||||
|
result += '<ol>\n'
|
||||||
|
}
|
||||||
|
//<li id="fn1">message <a href="#fnref1">↩</a></li>
|
||||||
|
result += `<li id=\"fn${id}\">`
|
||||||
|
let message = ''
|
||||||
|
while (data[i] != '\n') {
|
||||||
|
if (i < data.length - 1) ++i
|
||||||
|
else break
|
||||||
|
message += data[i]
|
||||||
|
}
|
||||||
|
result += message
|
||||||
|
result += `<a href=\"#fnref${id}\">↩</a></li>`
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//<sup><a href="#fn1" id="fnref1">1</a></sup>
|
||||||
|
result += `<sup><a href=\"#fn${id}\" id=\"fnref${id}\">${id}</a></sup>`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else result += data[i]
|
||||||
|
}
|
||||||
|
else result += data[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (footnote) result += '\n</ol>\n'
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
// Copy `people/${dirname}/photos` to `dist/people/${dirname}/`.
|
// Copy `people/${dirname}/photos` to `dist/people/${dirname}/`.
|
||||||
function copyPeopleAssets() {
|
function copyPeopleAssets() {
|
||||||
const PEOPLE_ASSETS = ["photos", "backup", "page.md"];
|
const PEOPLE_ASSETS = ["photos", "backup", "page.md"];
|
||||||
|
Loading…
Reference in New Issue
Block a user