summaryrefslogtreecommitdiff
path: root/src/build/to-html.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/build/to-html.mjs')
-rw-r--r--src/build/to-html.mjs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/build/to-html.mjs b/src/build/to-html.mjs
index a418b1f..4bc3c06 100644
--- a/src/build/to-html.mjs
+++ b/src/build/to-html.mjs
@@ -4,6 +4,7 @@ import remarkGfm from 'remark-gfm';
import remarkToc from 'remark-toc';
import remarkDirective from 'remark-directive';
import remarkMath from 'remark-math';
+import remarkFrontmatter from 'remark-frontmatter';
import remarkRehype from 'remark-rehype';
import rehypeSlug from 'rehype-slug';
import rehypeKaTeX from 'rehype-katex';
@@ -29,6 +30,26 @@ const generator = unified()
.use(remarkMath)
.use(remarkDirective)
.use(remarkSpecialBox)
+ .use(remarkFrontmatter, {type: 'toml', marker: '-'})
+ .use(remarkRehype, {allowDangerousHtml: true})
+ .use(rehypeRaw)
+ .use(remarkRemoveFootnoteHeader)
+ .use(rehypeKaTeX)
+ .use(rehypeSlug)
+ .use(rehypeHighlight)
+ .use(rehypeAutolinkHeadings, autoLinkOption)
+ .use(rehypeStringify);
+
+const generatorMd = unified()
+ .use(remarkParse)
+ .use(remarkGfm)
+ .use(remarkToc, {heading: 'Sommaire', tight: true, ordered: true})
+ .use(remarkMath)
+ .use(remarkDirective)
+ .use(remarkSpecialBox)
+ .use(remarkFrontmatter, {type: 'toml', marker: '-'});
+
+const generatorHTML = unified()
.use(remarkRehype, {allowDangerousHtml: true})
.use(rehypeRaw)
.use(remarkRemoveFootnoteHeader)
@@ -40,6 +61,9 @@ const generator = unified()
const toHtml = content => generator.processSync(content);
+export const toMdRaw = content => generatorMd.runSync(generatorMd.parse(content));
+export const mdToHtmlRaw = content => generatorHTML.runSync(content);
+
export const toHtmlRaw = content => generator.runSync(generator.parse(content));
export const toString = content => generator.stringify(content);
export default toHtml;