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