Skip to content

Commit 5264967

Browse files
authored
Switch from markdown-it to Remark.
1 parent 7201192 commit 5264967

File tree

5 files changed

+55
-61
lines changed

5 files changed

+55
-61
lines changed

webserver/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,22 @@
3737
"dset": "^3.1.3",
3838
"express": "^4.18.2",
3939
"google-auth-library": "^9.6.2",
40-
"markdown-it": "^14.0.0",
4140
"n3": "^1.17.2",
4241
"prisma": "^5.9.1",
4342
"rdf-dereference": "^2.2.0",
43+
"rehype-sanitize": "^6.0.0",
44+
"rehype-stringify": "^10.0.0",
45+
"remark-parse": "^11.0.0",
46+
"remark-rehype": "^11.1.0",
4447
"solid-js": "^1.8.13",
4548
"typescript": "^5.3.3",
49+
"unified": "^11.0.4",
4650
"zod": "^3.22.4"
4751
},
4852
"devDependencies": {
4953
"@astrojs/check": "^0.5.2",
5054
"@playwright/test": "1.41.2",
51-
"@types/markdown-it": "^13.0.7",
55+
"@types/mdast": "^4.0.3",
5256
"@types/n3": "^1.16.4",
5357
"@types/node": "^20.11.16",
5458
"dotenv-cli": "^7.3.0"

webserver/pnpm-lock.yaml

Lines changed: 33 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webserver/src/components/Markdown.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type Props = {
66
};
77
88
const { source } = Astro.props;
9+
const processed = await md.process(source);
910
---
1011

11-
<Fragment set:html={md.render(source)} />
12+
<Fragment set:html={String(processed)} />

webserver/src/components/Markdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { md } from "@lib/markdown";
2-
import { type Component, JSX, splitProps } from "solid-js";
2+
import { JSX, splitProps, type Component } from "solid-js";
33

44
export const Markdown: Component<{ source: string } & JSX.HTMLAttributes<HTMLDivElement>> = (props) => {
55
const [local, divProps] = splitProps(props, ["source"]);
6-
return <div innerHTML={md.render(local.source)} {...divProps} />;
6+
return <div innerHTML={String(md.processSync(local.source))} {...divProps} />;
77
};

webserver/src/lib/markdown.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
import MarkdownIt from "markdown-it";
21

3-
export const md = new MarkdownIt();
2+
import rehypeSanitize from 'rehype-sanitize';
3+
import rehypeStringify from 'rehype-stringify';
4+
import remarkParse from 'remark-parse';
5+
import remarkRehype from 'remark-rehype';
6+
import { unified } from 'unified';
7+
8+
export const md = unified()
9+
.use(remarkParse)
10+
.use(remarkRehype)
11+
.use(rehypeSanitize)
12+
.use(rehypeStringify)
13+
.freeze();

0 commit comments

Comments
 (0)