});
const getReferenceFromPath = (path) =>
- /Sources\/([A-Z][0-9A-Za-z]*\/[A-Z][0-9A-Za-z]*)\.djot$/u.exec(path)
- ?.[1]?.replace?.("/", ":");
+ /Sources\/([A-Z][0-9A-Za-z]*(?:\/[A-Z][0-9A-Za-z]*)+)\.djot$/u
+ .exec(path)?.[1]?.replace?.("/", ":"); // only replaces first slash
const listOfInternalLinks = (references, wrapper = ($) => $) => ({
tag: "bullet_list",
const links_section = [];
if (internalLinks.size || externalLinks.size) {
links_section.push(
- rawBlock`<footer>`,
rawBlock`<nav id="links">`,
{
tag: "heading",
}
links_section.push(
rawBlock`</nav>`,
- rawBlock`</footer>`,
);
} else {
/* do nothing */
}
- e.children.push(...links_section);
+ e.children.push(
+ rawBlock`<footer>`,
+ rawBlock`${"\uFFFF"}`, // footnote placeholder
+ ...links_section,
+ rawBlock`</footer>`,
+ );
},
},
hard_break: {
e.attributes ??= {};
const { attributes, reference, destination } = e;
if (
- /^(?:[A-Z][0-9A-Za-z]*|[@#])?:(?:[A-Z][0-9A-Za-z]*)?$/u
+ /^(?:[A-Z][0-9A-Za-z]*|[@#])?:(?:[A-Z][0-9A-Za-z]*(?:\/[A-Z][0-9A-Za-z]*)*)?$/u
.test(reference ?? "")
) {
const [namespacePrefix, pageName] = splitReference(
});
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,
"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);