enh: summary tag support

This commit is contained in:
Timothy J. Baek
2024-09-30 12:50:53 +02:00
parent d255251e5f
commit ffd598c5d7
3 changed files with 82 additions and 2 deletions

View File

@@ -1,9 +1,11 @@
<script>
import { marked } from 'marked';
import markedKatex from '$lib/utils/marked/katex-extension';
import { replaceTokens, processResponseContent } from '$lib/utils';
import { user } from '$lib/stores';
import markedExtension from '$lib/utils/marked/extension';
import markedKatexExtension from '$lib/utils/marked/katex-extension';
import MarkdownTokens from './Markdown/MarkdownTokens.svelte';
export let id;
@@ -16,7 +18,8 @@
throwOnError: false
};
marked.use(markedKatex(options));
marked.use(markedKatexExtension(options));
marked.use(markedExtension(options));
$: (async () => {
if (content) {

View File

@@ -8,6 +8,7 @@
import MarkdownInlineTokens from '$lib/components/chat/Messages/Markdown/MarkdownInlineTokens.svelte';
import KatexRenderer from './KatexRenderer.svelte';
import { WEBUI_BASE_URL } from '$lib/constants';
import { stringify } from 'postcss';
export let id: string;
export let tokens: Token[];
@@ -94,6 +95,12 @@
{/each}
</ul>
{/if}
{:else if token.type === 'details'}
<details>
<summary>{token.summary}</summary>
<svelte:self id={`${id}-${tokenIdx}-d`} tokens={marked.lexer(token.text)} />
</details>
{:else if token.type === 'html'}
{@const html = DOMPurify.sanitize(token.text)}
{#if html && html.includes('<video')}