- Fixes adding nodes to document by cloning the array.
- Adds a `raw_block` sigil to the document and then overrides rendering
to insert the footnotes at that point in time.
const links_section = [];
if (internalLinks.size || externalLinks.size) {
links_section.push(
const links_section = [];
if (internalLinks.size || externalLinks.size) {
links_section.push(
rawBlock`<nav id="links">`,
{
tag: "heading",
rawBlock`<nav id="links">`,
{
tag: "heading",
}
links_section.push(
rawBlock`</nav>`,
}
links_section.push(
rawBlock`</nav>`,
);
} else {
/* do nothing */
}
);
} else {
/* do nothing */
}
- e.children.push(...links_section);
+ e.children.push(
+ rawBlock`<footer>`,
+ rawBlock`${"\uFFFF"}`, // footnote placeholder
+ ...links_section,
+ rawBlock`</footer>`,
+ );
});
const renderedAST = djot.renderAST(ast);
const doc = getDOM(template);
});
const renderedAST = djot.renderAST(ast);
const doc = getDOM(template);
- const result = getDOM(`${djot.renderHTML(ast)}`);
+ const result = getDOM(djot.renderHTML(ast, {
+ overrides: {
+ raw_block: (node, context) => {
+ if (node.format == "html" && node.text == "\uFFFF") {
+ if (context.nextFootnoteIndex > 1) {
+ const result = context.renderNotes(ast.footnotes);
+ context.nextFootnoteIndex = 1;
+ return result;
+ } else {
+ return "";
+ }
+ } else {
+ return context.renderAstNodeDefault(node);
+ }
+ },
+ },
+ }));
const headElement = domutils.findOne(
(node) => node.name == "head",
doc,
const headElement = domutils.findOne(
(node) => node.name == "head",
doc,
"GitWikiWeb: Template did not include a <gitwikiweb-content> element.",
);
} else {
"GitWikiWeb: Template did not include a <gitwikiweb-content> element.",
);
} else {
- for (const node of result) {
+ for (const node of [...result]) {
domutils.prepend(contentElement, node);
}
domutils.removeElement(contentElement);
domutils.prepend(contentElement, node);
}
domutils.removeElement(contentElement);