X-Git-Url: https://git.ladys.computer/GitWikiWeb/blobdiff_plain/ec82c7286badf5d109dec2a0f6bc71b3d4e3ef64..06d2bfe7fc9b1319467b9d71151dc8b5362f7384:/build.js?ds=inline
diff --git a/build.js b/build.js
index b50fe3d..0eb61fd 100644
--- a/build.js
+++ b/build.js
@@ -147,8 +147,8 @@ const logErrorsAndCollectResults = (results) =>
});
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",
@@ -235,7 +235,6 @@ class GitWikiWebPage {
const links_section = [];
if (internalLinks.size || externalLinks.size) {
links_section.push(
- rawBlock``,
);
} else {
/* do nothing */
}
- e.children.push(...links_section);
+ e.children.push(
+ rawBlock``,
+ );
},
},
hard_break: {
@@ -328,7 +331,7 @@ class GitWikiWebPage {
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(
@@ -921,8 +924,25 @@ class GitWikiWebPage {
},
};
});
+ 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,
@@ -962,7 +982,7 @@ class GitWikiWebPage {
"GitWikiWeb: Template did not include a element.",
);
} else {
- for (const node of result) {
+ for (const node of [...result]) {
domutils.prepend(contentElement, node);
}
domutils.removeElement(contentElement);
@@ -979,6 +999,13 @@ class GitWikiWebPage {
{ createNew: true },
),
);
+ promises.push(
+ Deno.writeTextFile(
+ `${DESTINATION}/${pageRef}/index.ast`,
+ renderedAST,
+ { createNew: true },
+ ),
+ );
promises.push(
Deno.writeTextFile(
`${DESTINATION}/${pageRef}/source.djot`,