diff options
Diffstat (limited to 'src/build/to-html.mjs')
-rw-r--r-- | src/build/to-html.mjs | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/src/build/to-html.mjs b/src/build/to-html.mjs index 786f91d..5c08242 100644 --- a/src/build/to-html.mjs +++ b/src/build/to-html.mjs @@ -1,43 +1,43 @@ -import {unified} from 'unified'; -import remarkParse from 'remark-parse'; -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 rehypePicture from 'rehype-picture' -import rehypeKaTeX from 'rehype-katex'; -import rehypeRaw from 'rehype-raw'; -import rehypeAutolinkHeadings from 'rehype-autolink-headings'; -import rehypeStringify from 'rehype-stringify'; -import rehypeHighlight from 'rehype-highlight'; -import remarkSpecialBox from './special_box.mjs'; -import remarkRemoveFootnoteHeader from './remove-footnote-header.mjs'; -import {getTocHeading} from './i18n.mjs'; +import { unified } from "unified"; +import remarkParse from "remark-parse"; +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 rehypePicture from "rehype-picture"; +import rehypeKaTeX from "rehype-katex"; +import rehypeRaw from "rehype-raw"; +import rehypeAutolinkHeadings from "rehype-autolink-headings"; +import rehypeStringify from "rehype-stringify"; +import rehypeHighlight from "rehype-highlight"; +import remarkSpecialBox from "./special_box.mjs"; +import remarkRemoveFootnoteHeader from "./remove-footnote-header.mjs"; +import { getTocHeading } from "./i18n.mjs"; const autoLinkOption = { - behavior: 'wrap', + behavior: "wrap", properties: { tabIndex: 0, - className: 'anchor', + className: "anchor", }, }; const pictureOptions = { - 'png': {avif: 'image/avif'} -} + png: { avif: "image/avif" }, +}; const generator = unified() .use(remarkParse) .use(remarkGfm) - .use(remarkToc, {heading: getTocHeading(), tight: true, ordered: true}) + .use(remarkToc, { heading: getTocHeading(), tight: true, ordered: true }) .use(remarkMath) .use(remarkDirective) .use(remarkSpecialBox) - .use(remarkFrontmatter, {type: 'toml', marker: '-'}) - .use(remarkRehype, {allowDangerousHtml: true}) + .use(remarkFrontmatter, { type: "toml", marker: "-" }) + .use(remarkRehype, { allowDangerousHtml: true }) .use(rehypeRaw) .use(remarkRemoveFootnoteHeader) .use(rehypePicture, pictureOptions) @@ -50,14 +50,14 @@ const generator = unified() const generatorMd = unified() .use(remarkParse) .use(remarkGfm) - .use(remarkToc, {heading: getTocHeading(), tight: true, ordered: true}) + .use(remarkToc, { heading: getTocHeading(), tight: true, ordered: true }) .use(remarkMath) .use(remarkDirective) .use(remarkSpecialBox) - .use(remarkFrontmatter, {type: 'toml', marker: '-'}); + .use(remarkFrontmatter, { type: "toml", marker: "-" }); const generatorHTML = unified() - .use(remarkRehype, {allowDangerousHtml: true}) + .use(remarkRehype, { allowDangerousHtml: true }) .use(rehypeRaw) .use(remarkRemoveFootnoteHeader) .use(rehypePicture, pictureOptions) @@ -67,11 +67,13 @@ const generatorHTML = unified() .use(rehypeAutolinkHeadings, autoLinkOption) .use(rehypeStringify); -const toHtml = content => generator.processSync(content); +const toHtml = (content) => generator.processSync(content); -export const toMdRaw = content => generatorMd.runSync(generatorMd.parse(content)); -export const mdToHtmlRaw = content => generatorHTML.runSync(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 const toHtmlRaw = (content) => + generator.runSync(generator.parse(content)); +export const toString = (content) => generator.stringify(content); export default toHtml; |