svelte-streamdown 2.2.6 → 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 { TokenizerExtensionFunction, TokenizerStartFunction } from 'marked';
1
+ import type { TokenizerThis } from 'marked';
2
2
  export declare function markedMath(): {
3
- extensions: Array<{
3
+ extensions: ({
4
4
  name: string;
5
- level: 'block' | 'inline';
6
- start?: TokenizerStartFunction;
7
- tokenizer: TokenizerExtensionFunction;
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
- // const inlineRule =
2
- // /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/;
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: 'block-math',
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: 'inline-math',
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(inlineRuleNonStandard)) {
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(inlineRuleNonStandard);
44
+ const match = src.match(inlineRule);
46
45
  if (match) {
47
46
  return {
48
47
  type: 'math',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-streamdown",
3
- "version": "2.2.6",
3
+ "version": "2.2.7",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",