Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"rehype-slug": "^6.0.0",
"rehype-stringify": "^10.0.1",
"rehype-unwrap-images": "^1.0.0",
"remark-cjk-friendly": "^2.3.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.1",
"remark-toc": "^9.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/lib/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import type { BuiltinLanguage } from "shiki";
import { cacheOnce } from "./utils/cache";
import rehypeShiki from "@shikijs/rehype";
import rehypeStringify from "rehype-stringify";
import remarkCjkFriendly from "remark-cjk-friendly/parseOnly";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import { unified } from "unified";

async function getProcessor(langs: BuiltinLanguage[] = []) {
return unified().use(remarkParse).use(remarkRehype).use(rehypeShiki, { theme: "vitesse-dark", langs }).use(rehypeStringify);
return unified().use(remarkParse).use(remarkCjkFriendly).use(remarkRehype).use(rehypeShiki, { theme: "vitesse-dark", langs }).use(rehypeStringify);
}

export async function renderMarkdown(text: string, langs: BuiltinLanguage[] = []) {
Expand Down
3 changes: 2 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { mdsvex } from "mdsvex";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypeSlug from "rehype-slug";
import rehypeUnwrapImages from "rehype-unwrap-images";
import remarkCjkFriendly from "remark-cjk-friendly/parseOnly";
import remarkToc from "remark-toc";

/** @type {import("mdsvex").MdsvexOptions} */
const mdsvexConfig = { extensions: [".svx"], smartypants: { dashes: "oldschool" }, remarkPlugins: [remarkToc], rehypePlugins: [rehypeUnwrapImages, rehypeSlug, [rehypeAutolinkHeadings, { behavior: "wrap" }]] };
const mdsvexConfig = { extensions: [".svx"], smartypants: { dashes: "oldschool" }, remarkPlugins: [remarkCjkFriendly, remarkToc], rehypePlugins: [rehypeUnwrapImages, rehypeSlug, [rehypeAutolinkHeadings, { behavior: "wrap" }]] };

/** @type {import('@sveltejs/kit').Config} */
const config = {
Expand Down
Loading