feat: add more validation to KaTeX in markdown

This commit is contained in:
Paul Makles
2023-06-17 16:11:22 +01:00
parent 0b276e4fb2
commit ec3129afcf
3 changed files with 98 additions and 38 deletions

View File

@@ -1,5 +1,4 @@
import "katex/dist/katex.min.css";
import rehypeKatex from "rehype-katex";
import rehypePrism from "rehype-prism";
import rehypeReact from "rehype-react";
import remarkBreaks from "remark-breaks";
@@ -14,6 +13,9 @@ import { createElement } from "preact";
import { memo } from "preact/compat";
import { useLayoutEffect, useMemo, useState } from "preact/hooks";
// @ts-expect-error no typings
import rehypeKatex from "@revoltchat/rehype-katex";
import { MarkdownProps } from "./Markdown";
import { handlers } from "./hast";
import { RenderCodeblock } from "./plugins/Codeblock";
@@ -146,6 +148,7 @@ const render = unified()
.use(rehypeKatex, {
maxSize: 10,
maxExpand: 0,
maxLength: 128,
trust: false,
strict: false,
output: "html",