diff options
| author | Adam <[email protected]> | 2025-10-03 09:04:28 -0500 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-10-03 09:04:28 -0500 |
| commit | 3fa280d21878ae391674a21758199df3d2d8c3b5 (patch) | |
| tree | f70c6ecafffeecc8e7a59dc9acef66c59a9ea54a /packages/desktop/src/components/markdown.tsx | |
| parent | 1d58b5548287a3e32ffce3abdcf0f2db08fdb155 (diff) | |
| download | opencode-3fa280d21878ae391674a21758199df3d2d8c3b5.tar.gz opencode-3fa280d21878ae391674a21758199df3d2d8c3b5.zip | |
chore: app -> desktop
Diffstat (limited to 'packages/desktop/src/components/markdown.tsx')
| -rw-r--r-- | packages/desktop/src/components/markdown.tsx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/desktop/src/components/markdown.tsx b/packages/desktop/src/components/markdown.tsx new file mode 100644 index 000000000..a60fad149 --- /dev/null +++ b/packages/desktop/src/components/markdown.tsx @@ -0,0 +1,23 @@ +import { useMarked } from "@/context" +import { createResource } from "solid-js" + +function strip(text: string): string { + const wrappedRe = /^\s*<([A-Za-z]\w*)>\s*([\s\S]*?)\s*<\/\1>\s*$/ + const match = text.match(wrappedRe) + return match ? match[2] : text +} +export function Markdown(props: { text: string; class?: string }) { + const marked = useMarked() + const [html] = createResource( + () => strip(props.text), + async (markdown) => { + return marked.parse(markdown) + }, + ) + return ( + <div + class={`min-w-0 max-w-full text-xs overflow-auto no-scrollbar prose ${props.class ?? ""}`} + innerHTML={html()} + /> + ) +} |
