|
1 | | -<script> |
2 | | - import { onDestroy } from 'svelte'; |
| 1 | +<script context="module"> |
3 | 2 | import { marked } from 'marked'; |
4 | | - import { replaceTokens, processResponseContent } from '$lib/utils'; |
5 | | - import { user } from '$lib/stores'; |
6 | 3 |
|
7 | 4 | import markedExtension from '$lib/utils/marked/extension'; |
8 | 5 | import markedKatexExtension from '$lib/utils/marked/katex-extension'; |
9 | 6 | import { disableSingleTilde } from '$lib/utils/marked/strikethrough-extension'; |
10 | 7 | import { mentionExtension } from '$lib/utils/marked/mention-extension'; |
11 | 8 | import colonFenceExtension from '$lib/utils/marked/colon-fence-extension'; |
12 | | -
|
13 | | - import MarkdownTokens from './Markdown/MarkdownTokens.svelte'; |
14 | 9 | import footnoteExtension from '$lib/utils/marked/footnote-extension'; |
15 | 10 | import citationExtension from '$lib/utils/marked/citation-extension'; |
16 | 11 |
|
| 12 | + const options = { |
| 13 | + throwOnError: false, |
| 14 | + breaks: true |
| 15 | + }; |
| 16 | +
|
| 17 | + marked.use(markedKatexExtension(options)); |
| 18 | + marked.use(markedExtension(options)); |
| 19 | + marked.use(citationExtension(options)); |
| 20 | + marked.use(footnoteExtension(options)); |
| 21 | + marked.use(colonFenceExtension(options)); |
| 22 | + marked.use(disableSingleTilde); |
| 23 | + marked.use({ |
| 24 | + extensions: [ |
| 25 | + mentionExtension({ triggerChar: '@' }), |
| 26 | + mentionExtension({ triggerChar: '#' }), |
| 27 | + mentionExtension({ triggerChar: '$' }) |
| 28 | + ] |
| 29 | + }); |
| 30 | +</script> |
| 31 | + |
| 32 | +<script> |
| 33 | + import { onDestroy } from 'svelte'; |
| 34 | + import { replaceTokens, processResponseContent } from '$lib/utils'; |
| 35 | + import { user } from '$lib/stores'; |
| 36 | +
|
| 37 | + import MarkdownTokens from './Markdown/MarkdownTokens.svelte'; |
| 38 | +
|
17 | 39 | export let id = ''; |
18 | 40 | export let content; |
19 | 41 | export let done = true; |
|
40 | 62 | let lastContent = ''; |
41 | 63 | let lastParsedContent = ''; |
42 | 64 |
|
43 | | - const options = { |
44 | | - throwOnError: false, |
45 | | - breaks: true |
46 | | - }; |
47 | | -
|
48 | | - marked.use(markedKatexExtension(options)); |
49 | | - marked.use(markedExtension(options)); |
50 | | - marked.use(citationExtension(options)); |
51 | | - marked.use(footnoteExtension(options)); |
52 | | - marked.use(colonFenceExtension(options)); |
53 | | - marked.use(disableSingleTilde); |
54 | | - marked.use({ |
55 | | - extensions: [ |
56 | | - mentionExtension({ triggerChar: '@' }), |
57 | | - mentionExtension({ triggerChar: '#' }), |
58 | | - mentionExtension({ triggerChar: '$' }) |
59 | | - ] |
60 | | - }); |
61 | | -
|
62 | 65 | const parseTokens = () => { |
63 | 66 | if (content === lastContent) return; |
64 | 67 | lastContent = content; |
|
0 commit comments