diff options
Diffstat (limited to 'src/build/to-html.mjs')
| -rw-r--r-- | src/build/to-html.mjs | 27 |
1 files changed, 15 insertions, 12 deletions
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)); |