svelte-streamdown 2.4.2 → 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.
@@ -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, markedDt } from './marked-dl.js';
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, markedDt, ...extensions))
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
  };
@@ -1,6 +1,5 @@
1
1
  import type { Extension, GenericToken } from './index.js';
2
2
  export declare const markedDl: Extension;
3
- export declare const markedDt: Extension;
4
3
  export type DescriptionListToken = {
5
4
  type: 'descriptionList';
6
5
  raw: string;
@@ -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: match[0].trim(),
12
- tokens: this.lexer.inlineTokens(match[0].trim()).filter((t) => t.type === 'description')
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
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-streamdown",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",