refactor: restructure directories

This commit is contained in:
JoniVR 2021-12-11 14:51:29 +01:00
parent aff98e59f0
commit 6d31e0f1ad
No known key found for this signature in database
GPG key ID: 3C8F6B8A7809ACDA
16 changed files with 0 additions and 0 deletions

View file

@ -1,42 +0,0 @@
const footnoteMatch = /^\[\^([^\]]+)\]:([\s\S]*)$/;
const referenceMatch = /\[\^([^\]]+)\](?!\()/g;
const referencePrefix = "fnref";
const footnotePrefix = "fn";
const footnoteTemplate = (ref, text) => {
return `<p id="${footnotePrefix}:${ref}">${ref}. ${text}</p>`;
};
const footnoteContainerTemplate = (text) => {
return `<h3>Footnotes</h3>${text}`
}
const referenceTemplate = ref => {
return `<sup id="${referencePrefix}:${ref}"><a href="#${footnotePrefix}:${ref}">[${ref}]</a></sup>`;
};
const interpolateReferences = (text) => {
return text.replace(referenceMatch, (_, ref) => {
return referenceTemplate(ref);
});
}
const interpolateFootnotes = (text) => {
const found = text.match(footnoteMatch)
if (found) {
const replacedText = text.replace(footnoteMatch, (_, value, text) => {
return footnoteTemplate(value, text);
});
return footnoteContainerTemplate(replacedText)
}
return text
}
const renderer = {
paragraph(text) {
return marked.Renderer.prototype.paragraph.apply(null, [
interpolateReferences(interpolateFootnotes(text))
]);
},
text(text) {
return marked.Renderer.prototype.text.apply(null, [
interpolateReferences(interpolateFootnotes(text))
]);
}
};
marked.use({ renderer });

File diff suppressed because one or more lines are too long