svelte-streamdown 2.2.5 → 2.2.7
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.
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TokenizerThis } from 'marked';
|
|
2
2
|
export declare function markedMath(): {
|
|
3
|
-
extensions:
|
|
3
|
+
extensions: ({
|
|
4
4
|
name: string;
|
|
5
|
-
level:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
level: string;
|
|
6
|
+
tokenizer(this: TokenizerThis, src: string): {
|
|
7
|
+
type: "math";
|
|
8
|
+
isInline: false;
|
|
9
|
+
raw: string;
|
|
10
|
+
text: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
start?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
name: string;
|
|
15
|
+
level: string;
|
|
16
|
+
start(src: string): number | undefined;
|
|
17
|
+
tokenizer(this: TokenizerThis, src: string): {
|
|
18
|
+
type: "math";
|
|
19
|
+
isInline: true;
|
|
20
|
+
raw: string;
|
|
21
|
+
text: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
})[];
|
|
9
24
|
};
|
|
10
25
|
export type MathToken = {
|
|
11
26
|
type: 'math';
|
|
12
|
-
isInline: boolean;
|
|
13
27
|
raw: string;
|
|
14
28
|
text: string;
|
|
29
|
+
isInline: boolean;
|
|
15
30
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
const inlineRuleNonStandard = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1/; // Non-standard, even if there are no spaces before and after $ or $$, try to parse
|
|
1
|
+
// Use the standard rule that requires proper spacing after math expressions
|
|
2
|
+
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/;
|
|
4
3
|
const blockRule = /^(\${1,2})\n((?:\\[\s\S]|[^\\])+?)\n\1(?:\n|$)/;
|
|
5
4
|
export function markedMath() {
|
|
6
5
|
return {
|
|
7
6
|
extensions: [
|
|
8
7
|
{
|
|
9
|
-
name: '
|
|
8
|
+
name: 'math',
|
|
10
9
|
level: 'block',
|
|
11
10
|
tokenizer(src) {
|
|
12
11
|
const match = src.match(blockRule);
|
|
@@ -21,7 +20,7 @@ export function markedMath() {
|
|
|
21
20
|
}
|
|
22
21
|
},
|
|
23
22
|
{
|
|
24
|
-
name: '
|
|
23
|
+
name: 'math',
|
|
25
24
|
level: 'inline',
|
|
26
25
|
start(src) {
|
|
27
26
|
let index;
|
|
@@ -34,7 +33,7 @@ export function markedMath() {
|
|
|
34
33
|
const f = index > -1;
|
|
35
34
|
if (f) {
|
|
36
35
|
const possibleKatex = indexSrc.substring(index);
|
|
37
|
-
if (possibleKatex.match(
|
|
36
|
+
if (possibleKatex.match(inlineRule)) {
|
|
38
37
|
return index;
|
|
39
38
|
}
|
|
40
39
|
}
|
|
@@ -42,7 +41,7 @@ export function markedMath() {
|
|
|
42
41
|
}
|
|
43
42
|
},
|
|
44
43
|
tokenizer(src) {
|
|
45
|
-
const match = src.match(
|
|
44
|
+
const match = src.match(inlineRule);
|
|
46
45
|
if (match) {
|
|
47
46
|
return {
|
|
48
47
|
type: 'math',
|
package/dist/theme.js
CHANGED
|
@@ -43,7 +43,7 @@ export const theme = {
|
|
|
43
43
|
header: 'flex items-center justify-between bg-gray-100/80 p-2 text-gray-600 text-xs',
|
|
44
44
|
button: 'cursor-pointer size-6 p-1 text-gray-600 transition-all hover:text-gray-900 rounded hover:bg-gray-100',
|
|
45
45
|
language: 'ml-1 font-mono lowercase',
|
|
46
|
-
skeleton: 'rounded-md font-mono text-transparent bg-gray-200 scale-y-90 animate-pulse whitespace-nowrap
|
|
46
|
+
skeleton: 'block rounded-md font-mono text-transparent bg-gray-200 scale-y-90 animate-pulse whitespace-nowrap',
|
|
47
47
|
pre: 'overflow-x-auto font-mono p-0 bg-gray-100/40',
|
|
48
48
|
line: 'block'
|
|
49
49
|
},
|
|
@@ -171,7 +171,7 @@ export const shadcnTheme = {
|
|
|
171
171
|
header: 'flex items-center justify-between bg-muted/80 px-2 py-1 text-muted-foreground text-xs',
|
|
172
172
|
button: 'cursor-pointer size-6 p-1 text-muted-foreground transition-all hover:text-foreground rounded hover:bg-muted',
|
|
173
173
|
language: 'ml-1 font-mono lowercase',
|
|
174
|
-
skeleton: 'rounded-md font-mono text-transparent bg-border/80 scale-y-90 w-fit animate-pulse whitespace-nowrap
|
|
174
|
+
skeleton: 'block rounded-md font-mono text-transparent bg-border/80 scale-y-90 w-fit animate-pulse whitespace-nowrap',
|
|
175
175
|
pre: 'overflow-x-auto font-mono p-0 bg-muted/40',
|
|
176
176
|
line: 'block '
|
|
177
177
|
},
|