summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2026-06-04 06:14:49 +0200
committerache <ache@ache.one>2026-06-04 06:14:49 +0200
commitfea0ab5cad22341e1bf87a36239a7b3aa737e5fa (patch)
tree568f6b8dfca8d95658204f16b96adbbc71c199ff
parentFix style in article (diff)
Fix footnotes i18n
-rw-r--r--src/build/i18n.mjs2
-rw-r--r--src/build/loadMD.mjs4
-rw-r--r--src/build/remove-footnote-header.mjs14
-rw-r--r--src/build/to-html.mjs27
4 files changed, 29 insertions, 18 deletions
diff --git a/src/build/i18n.mjs b/src/build/i18n.mjs
index b65c0a9..280c354 100644
--- a/src/build/i18n.mjs
+++ b/src/build/i18n.mjs
@@ -45,6 +45,7 @@ const i18n = {
like_title: "Si vous avez aimez cet article cliquez sur le cƓur !",
like_text:
'Vous pouvez mĂȘme envoyez plusieurs cƓurs ! <br><span class="likesNotes">Le dĂ©lais d\'attente entre deux cƓurs double Ă  chaque fois.</span>',
+ footnotes_title: "Notes de bas de page",
},
en: {
intro: {
@@ -85,6 +86,7 @@ const i18n = {
like_title: "If you liked this article click on the heart!",
like_text:
'You can even send multiple hearts! <br><span class="likesNotes">The waiting time between two hearts doubles each time.</span>',
+ footnotes_title: "Footnotes",
},
};
diff --git a/src/build/loadMD.mjs b/src/build/loadMD.mjs
index 8675e42..0861e9d 100644
--- a/src/build/loadMD.mjs
+++ b/src/build/loadMD.mjs
@@ -18,9 +18,9 @@ const loadMD = (listFile, dirSuffix, pathLinkSuffix, lang) => {
const mdRaw = toMdRaw(content);
const tomlStringValue = mdRaw.children[0].value;
const metaData = toml.parse(tomlStringValue);
- const newHTML = mdToHtmlRaw(mdRaw);
-
const langR = lang || metaData.lang;
+ const newHTML = mdToHtmlRaw(mdRaw, langR);
+
const linkSuffix = pathLinkSuffix || dirSuffix;
const htmlContent = newHTML;
diff --git a/src/build/remove-footnote-header.mjs b/src/build/remove-footnote-header.mjs
index 95f481b..37f3af9 100644
--- a/src/build/remove-footnote-header.mjs
+++ b/src/build/remove-footnote-header.mjs
@@ -4,12 +4,18 @@ import { visit } from "unist-util-visit";
// It’s informative but rather useless.
// See below for others examples.
/** @type {import('unified').Plugin<[], import('mdast').Root>} */
-export default function specialBox() {
+export default function specialBox(opt) {
return (tree) => {
- visit(tree, (node) => {
+ visit(tree, (node, _, parent) => {
if (node?.tagName === "h2" && node?.properties?.id === "footnote-label") {
- node.tagName = "hr";
- node.children = []; // Exposure of children, Roman's way
+ node.tagName = "h4";
+ node.children = [{ type: "text", value: opt?.title || "Footnote" }];
+
+ parent.children.unshift({
+ type: "element",
+ tagName: "hr",
+ children: [],
+ });
}
});
};
diff --git a/src/build/to-html.mjs b/src/build/to-html.mjs
index db417a1..97eb3f6 100644
--- a/src/build/to-html.mjs
+++ b/src/build/to-html.mjs
@@ -17,6 +17,7 @@ import rehypeHighlight from "rehype-highlight";
import remarkSpecialBox from "./special_box.mjs";
import remarkRemoveFootnoteHeader from "./remove-footnote-header.mjs";
import { getTocHeading } from "./i18n.mjs";
+import i18n from "./i18n.mjs";
// Support for more highlight syntaxes
import arduino from "highlight.js/lib/languages/arduino";
@@ -132,22 +133,24 @@ const generatorMd = unified()
.use(remarkCaptions, captionsOptions)
.use(remarkFrontmatter, { type: "toml", marker: "-" });
-const generatorHTML = unified()
- .use(remarkRehype, { allowDangerousHtml: true })
- .use(rehypeRaw)
- .use(remarkRemoveFootnoteHeader)
- .use(rehypePicture, pictureOptions)
- .use(rehypeKaTeX)
- .use(rehypeSlug)
- .use(rehypeHighlight, { languages: highlightLanguages })
- .use(rehypeAutolinkHeadings, autoLinkOption)
- .use(rehypeStringify);
-
const toHtml = (content) => generator.processSync(content);
export const toMdRaw = (content) =>
generatorMd.runSync(generatorMd.parse(content));
-export const mdToHtmlRaw = (content) => generatorHTML.runSync(content);
+export const mdToHtmlRaw = (content, lang) => {
+ const generatorHTML = unified()
+ .use(remarkRehype, { allowDangerousHtml: true })
+ .use(rehypeRaw)
+ .use(remarkRemoveFootnoteHeader, { title: i18n[lang]["footnotes_title"] })
+ .use(rehypePicture, pictureOptions)
+ .use(rehypeKaTeX)
+ .use(rehypeSlug)
+ .use(rehypeHighlight, { languages: highlightLanguages })
+ .use(rehypeAutolinkHeadings, autoLinkOption)
+ .use(rehypeStringify);
+
+ return generatorHTML.runSync(content);
+};
export const toHtmlRaw = (content) =>
generator.runSync(generator.parse(content));