svelte-streamdown 2.4.1 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -72,8 +72,11 @@
|
|
|
72
72
|
</div>
|
|
73
73
|
<div style="height: fit-content; width: 100%;" class={streamdown.theme.code.container}>
|
|
74
74
|
{#if highlighter.isReady(streamdown.shikiTheme, token.lang)}
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
<pre class={streamdown.theme.code.pre}><code
|
|
76
|
+
>{@render Tokens(
|
|
77
|
+
highlighter.highlightCode(token.text, token.lang, streamdown.shikiTheme)
|
|
78
|
+
)}</code
|
|
79
|
+
></pre>
|
|
77
80
|
{:else}
|
|
78
81
|
<pre class={streamdown.theme.code.pre}><code>{@render Skeleton(token.text.split('\n'))}</code
|
|
79
82
|
></pre>
|
|
@@ -81,10 +84,10 @@
|
|
|
81
84
|
</div>
|
|
82
85
|
</div>
|
|
83
86
|
|
|
84
|
-
{#snippet Tokens(
|
|
85
|
-
{#each
|
|
87
|
+
{#snippet Tokens(lines: ThemedToken[][])}
|
|
88
|
+
{#each lines as tokens}
|
|
86
89
|
<span class={streamdown.theme.code.line}>
|
|
87
|
-
{#each
|
|
90
|
+
{#each tokens as token}
|
|
88
91
|
<span
|
|
89
92
|
style={streamdown.isMounted ? streamdown.animationTextStyle : ''}
|
|
90
93
|
style:color={token.color}
|
|
@@ -99,10 +102,7 @@
|
|
|
99
102
|
|
|
100
103
|
{#snippet Skeleton(lines: string[])}
|
|
101
104
|
{#each lines as line}
|
|
102
|
-
<span
|
|
103
|
-
style={streamdown.isMounted ? streamdown.animationTextStyle : ''}
|
|
104
|
-
class={streamdown.theme.code.skeleton}
|
|
105
|
-
>
|
|
105
|
+
<span class={streamdown.theme.code.skeleton}>
|
|
106
106
|
{line.trim().length > 0 ? line : '\u200B'}
|
|
107
107
|
</span>
|
|
108
108
|
{/each}
|
|
@@ -97,7 +97,6 @@
|
|
|
97
97
|
{@attach clickOutside.attachment}
|
|
98
98
|
{@attach popoverAttachment}
|
|
99
99
|
open
|
|
100
|
-
popover="auto"
|
|
101
100
|
class={`${streamdown.theme.footnotePopover.base}`}
|
|
102
101
|
>
|
|
103
102
|
{#each token.content.lines as line}
|
|
@@ -107,22 +106,24 @@
|
|
|
107
106
|
</Slot>
|
|
108
107
|
{/if}
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
<button
|
|
117
|
-
style={streamdown.animationBlockStyle}
|
|
118
|
-
bind:this={reference}
|
|
119
|
-
class={streamdown.theme.footnoteRef.base}
|
|
120
|
-
onclick={() => (isOpen = !isOpen)}
|
|
121
|
-
aria-expanded={isOpen}
|
|
122
|
-
aria-haspopup="dialog"
|
|
123
|
-
aria-controls={'footnote-popover-' + id}
|
|
124
|
-
{@attach clickOutside.attachment}
|
|
109
|
+
{#if token.label !== 'streamdown:footnote'}
|
|
110
|
+
<Slot
|
|
111
|
+
props={{
|
|
112
|
+
token
|
|
113
|
+
}}
|
|
114
|
+
render={streamdown.snippets.footnoteRef}
|
|
125
115
|
>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
116
|
+
<button
|
|
117
|
+
style={streamdown.animationBlockStyle}
|
|
118
|
+
bind:this={reference}
|
|
119
|
+
class={streamdown.theme.footnoteRef.base}
|
|
120
|
+
onclick={() => (isOpen = !isOpen)}
|
|
121
|
+
aria-expanded={isOpen}
|
|
122
|
+
aria-haspopup="dialog"
|
|
123
|
+
aria-controls={'footnote-popover-' + id}
|
|
124
|
+
{@attach clickOutside.attachment}
|
|
125
|
+
>
|
|
126
|
+
{token.label.replace('^', '')}
|
|
127
|
+
</button>
|
|
128
|
+
</Slot>
|
|
129
|
+
{/if}
|
package/dist/marked/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { markedList } from './marked-list.js';
|
|
|
7
7
|
import { markedBr } from './marked-br.js';
|
|
8
8
|
import { markedHr } from './marked-hr.js';
|
|
9
9
|
import { markedTable } from './marked-table.js';
|
|
10
|
-
import { markedDl
|
|
10
|
+
import { markedDl } from './marked-dl.js';
|
|
11
11
|
const parseExtensions = (...extensions) => {
|
|
12
12
|
const options = {
|
|
13
13
|
gfm: true,
|
|
@@ -41,7 +41,7 @@ const parseExtensions = (...extensions) => {
|
|
|
41
41
|
return options;
|
|
42
42
|
};
|
|
43
43
|
export const lex = (markdown, extensions = []) => {
|
|
44
|
-
return new Lexer(parseExtensions(markedHr, markedTable, ...markedFootnote(), markedAlert, ...markedMath, markedSub, markedSup, markedList, markedBr, markedDl,
|
|
44
|
+
return new Lexer(parseExtensions(markedHr, markedTable, ...markedFootnote(), markedAlert, ...markedMath, markedSub, markedSup, markedList, markedBr, markedDl, ...extensions))
|
|
45
45
|
.lex(markdown)
|
|
46
46
|
.filter((token) => token.type !== 'space' && token.type !== 'footnote');
|
|
47
47
|
};
|
package/dist/marked/marked-dl.js
CHANGED
|
@@ -5,41 +5,40 @@ export const markedDl = {
|
|
|
5
5
|
const rule = /^(?:[ \t]*:[^:\n]+:[ \t]?[^\n]*(?:\n|$))+/;
|
|
6
6
|
const match = rule.exec(src);
|
|
7
7
|
if (match) {
|
|
8
|
+
const text = match[0].trim();
|
|
9
|
+
const tokens = [];
|
|
10
|
+
// Parse each line as a description
|
|
11
|
+
const lines = text.split('\n');
|
|
12
|
+
for (const line of lines) {
|
|
13
|
+
const lineMatch = /^\s*:([^:\n]+):([^:\n]*)(?:\n|$)/.exec(line);
|
|
14
|
+
if (lineMatch) {
|
|
15
|
+
const term = lineMatch[1].trim();
|
|
16
|
+
const detail = lineMatch[2].trim();
|
|
17
|
+
tokens.push({
|
|
18
|
+
type: 'description',
|
|
19
|
+
raw: lineMatch[0],
|
|
20
|
+
tokens: [
|
|
21
|
+
{
|
|
22
|
+
type: 'descriptionTerm',
|
|
23
|
+
raw: term,
|
|
24
|
+
tokens: this.lexer.inlineTokens(term)
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'descriptionDetail',
|
|
28
|
+
raw: detail,
|
|
29
|
+
tokens: this.lexer.inlineTokens(detail)
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
8
35
|
const token = {
|
|
9
36
|
type: 'descriptionList',
|
|
10
37
|
raw: match[0],
|
|
11
|
-
text:
|
|
12
|
-
tokens:
|
|
38
|
+
text: text,
|
|
39
|
+
tokens: tokens
|
|
13
40
|
};
|
|
14
41
|
return token;
|
|
15
42
|
}
|
|
16
43
|
}
|
|
17
44
|
};
|
|
18
|
-
export const markedDt = {
|
|
19
|
-
name: 'description',
|
|
20
|
-
level: 'inline',
|
|
21
|
-
tokenizer(src) {
|
|
22
|
-
const rule = /^\s*:([^:\n]+):([^:\n]*)(?:\n|$)/;
|
|
23
|
-
const match = rule.exec(src);
|
|
24
|
-
if (match) {
|
|
25
|
-
const term = match[1].trim();
|
|
26
|
-
const detail = match[2].trim();
|
|
27
|
-
return {
|
|
28
|
-
type: 'description',
|
|
29
|
-
raw: match[0],
|
|
30
|
-
tokens: [
|
|
31
|
-
{
|
|
32
|
-
type: 'descriptionTerm',
|
|
33
|
-
raw: term,
|
|
34
|
-
tokens: this.lexer.inlineTokens(term)
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: 'descriptionDetail',
|
|
38
|
-
raw: detail,
|
|
39
|
-
tokens: this.lexer.inlineTokens(detail)
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|