markdown support
This commit is contained in:
parent
8e8872b2d2
commit
ce5f9b1b2e
3 changed files with 26 additions and 5 deletions
6
chatsbt/deno.lock
generated
6
chatsbt/deno.lock
generated
|
|
@ -4,6 +4,7 @@
|
||||||
"npm:@sveltejs/vite-plugin-svelte@6": "6.1.0_svelte@5.36.8__acorn@8.15.0_vite@7.0.5__picomatch@4.0.3",
|
"npm:@sveltejs/vite-plugin-svelte@6": "6.1.0_svelte@5.36.8__acorn@8.15.0_vite@7.0.5__picomatch@4.0.3",
|
||||||
"npm:@tailwindcss/vite@^4.1.11": "4.1.11_vite@7.0.5__picomatch@4.0.3",
|
"npm:@tailwindcss/vite@^4.1.11": "4.1.11_vite@7.0.5__picomatch@4.0.3",
|
||||||
"npm:daisyui@^5.0.46": "5.0.46",
|
"npm:daisyui@^5.0.46": "5.0.46",
|
||||||
|
"npm:marked@^16.1.1": "16.1.1",
|
||||||
"npm:svelte@^5.35.5": "5.36.8_acorn@8.15.0",
|
"npm:svelte@^5.35.5": "5.36.8_acorn@8.15.0",
|
||||||
"npm:tailwindcss@^4.1.11": "4.1.11",
|
"npm:tailwindcss@^4.1.11": "4.1.11",
|
||||||
"npm:vite@^7.0.4": "7.0.5_picomatch@4.0.3"
|
"npm:vite@^7.0.4": "7.0.5_picomatch@4.0.3"
|
||||||
|
|
@ -639,6 +640,10 @@
|
||||||
"@jridgewell/sourcemap-codec"
|
"@jridgewell/sourcemap-codec"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"marked@16.1.1": {
|
||||||
|
"integrity": "sha512-ij/2lXfCRT71L6u0M29tJPhP0bM5shLL3u5BePhFwPELj2blMJ6GDtD7PfJhRLhJ/c2UwrK17ySVcDzy2YHjHQ==",
|
||||||
|
"bin": true
|
||||||
|
},
|
||||||
"minipass@7.1.2": {
|
"minipass@7.1.2": {
|
||||||
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw=="
|
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw=="
|
||||||
},
|
},
|
||||||
|
|
@ -789,6 +794,7 @@
|
||||||
"npm:@sveltejs/vite-plugin-svelte@6",
|
"npm:@sveltejs/vite-plugin-svelte@6",
|
||||||
"npm:@tailwindcss/vite@^4.1.11",
|
"npm:@tailwindcss/vite@^4.1.11",
|
||||||
"npm:daisyui@^5.0.46",
|
"npm:daisyui@^5.0.46",
|
||||||
|
"npm:marked@^16.1.1",
|
||||||
"npm:svelte@^5.35.5",
|
"npm:svelte@^5.35.5",
|
||||||
"npm:tailwindcss@^4.1.11",
|
"npm:tailwindcss@^4.1.11",
|
||||||
"npm:vite@^7.0.4"
|
"npm:vite@^7.0.4"
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
||||||
"@tailwindcss/vite": "^4.1.11",
|
"@tailwindcss/vite": "^4.1.11",
|
||||||
"daisyui": "^5.0.46",
|
"daisyui": "^5.0.46",
|
||||||
|
"marked": "^16.1.1",
|
||||||
"svelte": "^5.35.5",
|
"svelte": "^5.35.5",
|
||||||
"tailwindcss": "^4.1.11",
|
"tailwindcss": "^4.1.11",
|
||||||
"vite": "^7.0.4"
|
"vite": "^7.0.4"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,23 @@
|
||||||
<script>
|
<script>
|
||||||
export let m; // { text, me }
|
import { marked } from 'marked';
|
||||||
|
export let m; // { text, me, sender }
|
||||||
|
|
||||||
|
/* optional: allow HTML inside the markdown (default is escaped) */
|
||||||
|
marked.setOptions({ breaks: true, gfm: true });
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="chat {m.me ? 'chat-end' : 'chat-start'}">
|
{#if m.me}
|
||||||
<div class="chat-bubble {m.me ? 'chat-bubble-primary' : 'chat-bubble'} {m.sender === 'error' ? 'text-error' : ''}">
|
<div class="chat chat-end">
|
||||||
{m.text}
|
<div class="chat-bele chat-bubble chat-bubble-primary">
|
||||||
|
{m.text}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{:else}
|
||||||
|
<div class="chat chat-start">
|
||||||
|
<div class="chat-bele chat-bubble {m.sender === 'error' ? 'text-error' : ''} prose prose-sm max-w-none" >
|
||||||
|
<!-- eslint-disable svelte/no-at-html-tags -->
|
||||||
|
{@html marked(m.text)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue