-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathMarkdown.svelte
79 lines (74 loc) · 1.94 KB
/
Markdown.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<script lang="ts">
import rehypeShikiFromHighlighter from "@shikijs/rehype/core"
import rehypeClassNames from "rehype-class-names"
import rehypeKatex from "rehype-katex"
import remarkMath from "remark-math"
import { createHighlighterCoreSync } from "shiki/core"
import { createJavaScriptRegexEngine } from "shiki/engine/javascript"
import cpp from "shiki/langs/cpp.mjs"
import csharp from "shiki/langs/csharp.mjs"
import go from "shiki/langs/go.mjs"
import html from "shiki/langs/html.mjs"
import java from "shiki/langs/java.mjs"
import json from "shiki/langs/json.mjs"
import kotlin from "shiki/langs/kotlin.mjs"
import php from "shiki/langs/php.mjs"
import python from "shiki/langs/python.mjs"
import ruby from "shiki/langs/ruby.mjs"
import rust from "shiki/langs/rust.mjs"
import shell from "shiki/langs/shell.mjs"
import svelte from "shiki/langs/svelte.mjs"
import swift from "shiki/langs/swift.mjs"
import ts from "shiki/langs/typescript.mjs"
import yaml from "shiki/langs/yaml.mjs"
import vitesseDark from "shiki/themes/vitesse-dark.mjs"
import Markdown from "svelte-exmarkdown"
import type { Plugin } from "svelte-exmarkdown"
import Pre from "./Pre.svelte"
const addClass: Plugin = {
rehypePlugin: [
rehypeClassNames,
{
pre: "p-4 rounded-md overflow-auto"
}
]
}
const shikiPlugin = {
rehypePlugin: [
rehypeShikiFromHighlighter,
createHighlighterCoreSync({
themes: [vitesseDark],
langs: [
ts,
svelte,
json,
html,
rust,
python,
java,
cpp,
csharp,
go,
ruby,
php,
kotlin,
swift,
yaml,
shell
],
engine: createJavaScriptRegexEngine()
}),
{
theme: "vitesse-dark"
}
]
} satisfies Plugin
const plugins: Plugin[] = [
shikiPlugin,
{ remarkPlugin: [remarkMath], rehypePlugin: [rehypeKatex] },
addClass,
{ renderer: { pre: Pre } }
]
let { md }: { md: string } = $props()
</script>
<Markdown {md} {plugins} />