svelte-streamdown 2.3.0 → 2.3.2
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.
- package/README.md +102 -87
- package/dist/Block.svelte +1 -1
- package/dist/Elements/Element.svelte +12 -2
- package/dist/Elements/index.d.ts +0 -1
- package/dist/Elements/index.js +0 -1
- package/dist/Streamdown.svelte +9 -11
- package/dist/context.svelte.d.ts +8 -2
- package/dist/context.svelte.js +4 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/marked/index.d.ts +15 -3
- package/dist/marked/index.js +21 -33
- package/dist/marked/marked-alert.d.ts +2 -8
- package/dist/marked/marked-alert.js +14 -20
- package/dist/marked/marked-br.d.ts +2 -8
- package/dist/marked/marked-br.js +15 -21
- package/dist/marked/marked-footnotes.d.ts +2 -9
- package/dist/marked/marked-footnotes.js +55 -58
- package/dist/marked/marked-hr.d.ts +2 -8
- package/dist/marked/marked-hr.js +18 -24
- package/dist/marked/marked-list.d.ts +3 -9
- package/dist/marked/marked-list.js +176 -182
- package/dist/marked/marked-math.d.ts +2 -9
- package/dist/marked/marked-math.js +110 -64
- package/dist/marked/marked-subsup.d.ts +3 -9
- package/dist/marked/marked-subsup.js +38 -43
- package/dist/marked/marked-table.d.ts +2 -9
- package/dist/marked/marked-table.js +114 -123
- package/dist/theme.js +2 -2
- package/package.json +1 -2
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export declare function markedFootnote(): {
|
|
4
|
-
extensions: {
|
|
5
|
-
name: string;
|
|
6
|
-
level: 'block' | 'inline';
|
|
7
|
-
tokenizer: TokenizerExtensionFunction;
|
|
8
|
-
}[];
|
|
9
|
-
};
|
|
1
|
+
import { type StreamdownToken, type Extension } from './index.js';
|
|
2
|
+
export declare function markedFootnote(): Extension[];
|
|
10
3
|
/**
|
|
11
4
|
* Represents a single footnote.
|
|
12
5
|
*/
|
|
@@ -26,69 +26,66 @@ export function markedFootnote() {
|
|
|
26
26
|
return streamdown.footnotes;
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
name: 'footnote',
|
|
32
|
+
level: 'block',
|
|
33
|
+
tokenizer(src) {
|
|
34
|
+
const maps = ensureMaps(this);
|
|
35
|
+
const match = /^\[\^([^\]\n]+)\]:(?:[ \t]+|[\n]*?|$)([^\n]*?(?:\n|$)(?:\n*?[ ]{4,}[^\n]*)*)/.exec(src);
|
|
36
|
+
if (match) {
|
|
37
|
+
const [raw, label, text = ''] = match;
|
|
38
|
+
let content = text.split('\n').reduce((acc, curr) => {
|
|
39
|
+
return acc + '\n' + curr.replace(/^(?:[ ]{4}|[\t])/, '');
|
|
40
|
+
}, '');
|
|
41
|
+
const contentLastLine = content.trimEnd().split('\n').pop();
|
|
42
|
+
content +=
|
|
43
|
+
// add lines after list, blockquote, codefence, and table
|
|
44
|
+
contentLastLine && /^[ \t]*?[>\-*][ ]|[`]{3,}$|^[ \t]*?[|].+[|]$/.test(contentLastLine)
|
|
45
|
+
? '\n\n'
|
|
46
|
+
: '';
|
|
47
|
+
const lines = content.split('\n');
|
|
48
|
+
const token = {
|
|
49
|
+
type: 'footnote',
|
|
50
|
+
raw,
|
|
51
|
+
label,
|
|
52
|
+
lines,
|
|
53
|
+
tokens: []
|
|
54
|
+
};
|
|
55
|
+
maps.footnotes.set(label, token);
|
|
56
|
+
const ref = maps.refs.get(label);
|
|
57
|
+
if (ref) {
|
|
58
|
+
ref.content = token;
|
|
59
|
+
}
|
|
60
|
+
return token;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'footnoteRef',
|
|
66
|
+
level: 'inline',
|
|
67
|
+
tokenizer(src) {
|
|
68
|
+
const maps = ensureMaps(this);
|
|
69
|
+
const match = /^\[\^([^\]\n]+)\]/.exec(src);
|
|
70
|
+
if (match) {
|
|
71
|
+
const [raw, label] = match;
|
|
72
|
+
const footnote = maps.footnotes.get(label);
|
|
73
|
+
const token = {
|
|
74
|
+
type: 'footnoteRef',
|
|
75
|
+
raw,
|
|
76
|
+
label,
|
|
77
|
+
content: footnote || {
|
|
51
78
|
type: 'footnote',
|
|
52
79
|
raw,
|
|
53
80
|
label,
|
|
54
|
-
lines,
|
|
81
|
+
lines: [],
|
|
55
82
|
tokens: []
|
|
56
|
-
};
|
|
57
|
-
maps.footnotes.set(label, token);
|
|
58
|
-
const ref = maps.refs.get(label);
|
|
59
|
-
if (ref) {
|
|
60
|
-
ref.content = token;
|
|
61
83
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: 'footnoteRef',
|
|
68
|
-
level: 'inline',
|
|
69
|
-
tokenizer(src) {
|
|
70
|
-
const maps = ensureMaps(this);
|
|
71
|
-
const match = /^\[\^([^\]\n]+)\]/.exec(src);
|
|
72
|
-
if (match) {
|
|
73
|
-
const [raw, label] = match;
|
|
74
|
-
const footnote = maps.footnotes.get(label);
|
|
75
|
-
const token = {
|
|
76
|
-
type: 'footnoteRef',
|
|
77
|
-
raw,
|
|
78
|
-
label,
|
|
79
|
-
content: footnote || {
|
|
80
|
-
type: 'footnote',
|
|
81
|
-
raw,
|
|
82
|
-
label,
|
|
83
|
-
lines: [],
|
|
84
|
-
tokens: []
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
maps.refs.set(label, token);
|
|
88
|
-
return token;
|
|
89
|
-
}
|
|
84
|
+
};
|
|
85
|
+
maps.refs.set(label, token);
|
|
86
|
+
return token;
|
|
90
87
|
}
|
|
91
88
|
}
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
}
|
|
90
|
+
];
|
|
94
91
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Extension } from './index.js';
|
|
2
2
|
export interface HrToken {
|
|
3
3
|
type: 'hr';
|
|
4
4
|
raw: string;
|
|
5
5
|
}
|
|
6
|
-
export declare
|
|
7
|
-
extensions: Array<{
|
|
8
|
-
name: string;
|
|
9
|
-
level: 'block';
|
|
10
|
-
tokenizer: TokenizerExtensionFunction;
|
|
11
|
-
}>;
|
|
12
|
-
};
|
|
6
|
+
export declare const markedHr: Extension;
|
package/dist/marked/marked-hr.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
};
|
|
24
|
-
}
|
|
1
|
+
export const markedHr = {
|
|
2
|
+
name: 'hr',
|
|
3
|
+
level: 'block',
|
|
4
|
+
tokenizer(src) {
|
|
5
|
+
// Match horizontal rules according to CommonMark spec:
|
|
6
|
+
// 3 or more matching -, _, or * characters, with optional spaces between
|
|
7
|
+
// Must be at start of string and match entire line
|
|
8
|
+
const match = src.match(/^[ \t]*(-[ \t]*-[ \t]*-+|_[ \t]*_[ \t]*_+|\*[ \t]*\*[ \t]*\*+)[ \t]*(?:\n|$)/);
|
|
9
|
+
if (match) {
|
|
10
|
+
const raw = match[0].replace(/\n$/, ''); // Remove trailing newline from raw
|
|
11
|
+
return {
|
|
12
|
+
type: 'hr',
|
|
13
|
+
raw: raw
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Extension, GenericToken } from './index.js';
|
|
2
2
|
export declare function letterToInt(letter: string): number;
|
|
3
3
|
export declare function romanToInt(roman: string): number;
|
|
4
4
|
export declare const romanUpper = "(?:C|XC|L?X{0,3}(?:IX|IV|V?I{0,3}))";
|
|
5
5
|
export declare const romanLower = "(?:c|xc|l?x{0,3}(?:ix|iv|v?i{0,3}))";
|
|
6
6
|
export declare const bulletPattern = "(?:[*+-]|(?:\\d{1,9}|[a-zA-Z]|(?:C|XC|L?X{0,3}(?:IX|IV|V?I{0,3}))|(?:c|xc|l?x{0,3}(?:ix|iv|v?i{0,3})))[.)])";
|
|
7
7
|
export declare const rule = "^( {0,3}(?:[*+-]|(?:\\d{1,9}|[a-zA-Z]|(?:C|XC|L?X{0,3}(?:IX|IV|V?I{0,3}))|(?:c|xc|l?x{0,3}(?:ix|iv|v?i{0,3})))[.)]))([ \\t][^\\n]*|[ \\t])?(?:\\n|$)";
|
|
8
|
-
export declare
|
|
9
|
-
extensions: Array<{
|
|
10
|
-
name: string;
|
|
11
|
-
level: 'block' | 'inline';
|
|
12
|
-
tokenizer: TokenizerExtensionFunction;
|
|
13
|
-
}>;
|
|
14
|
-
};
|
|
8
|
+
export declare const markedList: Extension;
|
|
15
9
|
export interface ListToken {
|
|
16
10
|
type: 'list';
|
|
17
11
|
raw: string;
|
|
@@ -33,5 +27,5 @@ export interface ListItemToken {
|
|
|
33
27
|
text: string;
|
|
34
28
|
value: number | null;
|
|
35
29
|
skipped: boolean;
|
|
36
|
-
tokens:
|
|
30
|
+
tokens: GenericToken[];
|
|
37
31
|
}
|
|
@@ -49,190 +49,184 @@ function finalizeList(list, lexer) {
|
|
|
49
49
|
function escapeForRegex(s) {
|
|
50
50
|
return s.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
|
|
51
51
|
}
|
|
52
|
-
export
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
52
|
+
export const markedList = {
|
|
53
|
+
name: 'list',
|
|
54
|
+
level: 'block',
|
|
55
|
+
tokenizer(src) {
|
|
56
|
+
let cap = new RegExp(rule).exec(src);
|
|
57
|
+
if (!cap)
|
|
58
|
+
return undefined;
|
|
59
|
+
const bullet = cap[1].trim();
|
|
60
|
+
const isOrdered = bullet !== '*' && bullet !== '-' && bullet !== '+';
|
|
61
|
+
let bull;
|
|
62
|
+
let type = '';
|
|
63
|
+
let expectedValue = null;
|
|
64
|
+
// Detect list type (Roman, alphabetic, numeric)
|
|
65
|
+
if (isOrdered) {
|
|
66
|
+
if (bullet.match(new RegExp(`^${romanUpper}[.)]$`))) {
|
|
67
|
+
type = 'upper-roman';
|
|
68
|
+
bull = `${romanUpper}\\${bullet.slice(-1)}`;
|
|
69
|
+
}
|
|
70
|
+
else if (bullet.match(new RegExp(`^${romanLower}[.)]$`))) {
|
|
71
|
+
type = 'lower-roman';
|
|
72
|
+
bull = `${romanLower}\\${bullet.slice(-1)}`;
|
|
73
|
+
}
|
|
74
|
+
else if (bullet.match(/^[a-z][.)]$/)) {
|
|
75
|
+
type = 'lower-alpha';
|
|
76
|
+
bull = `[a-z]\\${bullet.slice(-1)}`;
|
|
77
|
+
}
|
|
78
|
+
else if (bullet.match(/^[A-Z][.)]$/)) {
|
|
79
|
+
type = 'upper-alpha';
|
|
80
|
+
bull = `[A-Z]\\${bullet.slice(-1)}`;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
type = 'decimal';
|
|
84
|
+
bull = `\\d{1,9}\\${bullet.slice(-1)}`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
bull = this.lexer.options.pedantic ? bullet : '[*+-]';
|
|
89
|
+
bull = this.lexer.options.pedantic ? escapeForRegex(bullet) : '[*+-]';
|
|
90
|
+
}
|
|
91
|
+
const list = {
|
|
92
|
+
type: 'list',
|
|
93
|
+
raw: '',
|
|
94
|
+
ordered: isOrdered,
|
|
95
|
+
listType: isOrdered ? type : null,
|
|
96
|
+
loose: false,
|
|
97
|
+
start: undefined, // Will be set when first item is processed
|
|
98
|
+
tokens: []
|
|
99
|
+
};
|
|
100
|
+
// Get next list item
|
|
101
|
+
// Updated regex to properly handle empty list items (space after bullet, then newline)
|
|
102
|
+
const itemRegex = new RegExp(`^( {0,3}${bull})([\t ][^\\n]*|[\t ])?(?:\\n|$)`);
|
|
103
|
+
let endsWithBlankLine = false;
|
|
104
|
+
// Check if current bullet point can start a new List Item
|
|
105
|
+
while (src) {
|
|
106
|
+
let raw = '';
|
|
107
|
+
let itemContents = '';
|
|
108
|
+
let endEarly = false;
|
|
109
|
+
if (!(cap = itemRegex.exec(src)))
|
|
110
|
+
break;
|
|
111
|
+
raw = cap[0];
|
|
112
|
+
const bullet = cap[1].trim();
|
|
113
|
+
src = src.substring(raw.length);
|
|
114
|
+
const line = cap[2]
|
|
115
|
+
? cap[2].split('\n', 1)[0].replace(/^\t+/, (t) => ' '.repeat(4 * t.length))
|
|
116
|
+
: '';
|
|
117
|
+
const nextLine = src.split('\n', 1)[0];
|
|
118
|
+
const blankLine = !line.trim();
|
|
119
|
+
let indent = 0;
|
|
120
|
+
if (this.lexer.options.pedantic) {
|
|
121
|
+
indent = 2;
|
|
122
|
+
itemContents = line.trimStart();
|
|
123
|
+
}
|
|
124
|
+
else if (blankLine) {
|
|
125
|
+
indent = cap[1].length + 1;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
129
|
+
indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
|
|
130
|
+
itemContents = line.slice(indent);
|
|
131
|
+
indent += cap[1].length;
|
|
132
|
+
}
|
|
133
|
+
if (blankLine && /^[ \t]*$/.test(nextLine)) {
|
|
134
|
+
// Items begin with at most one blank line
|
|
135
|
+
raw += nextLine + '\n';
|
|
136
|
+
src = src.substring(nextLine.length + 1);
|
|
137
|
+
endEarly = true;
|
|
138
|
+
}
|
|
139
|
+
if (!endEarly) {
|
|
140
|
+
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|(?:\\d{1,9}|[a-zA-Z]|${romanUpper}|${romanLower})[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`);
|
|
141
|
+
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
|
|
142
|
+
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
|
|
143
|
+
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
|
|
144
|
+
const htmlBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}<[a-z].*>`, 'i');
|
|
145
|
+
// Check if following lines should be included in List Item
|
|
146
|
+
while (src) {
|
|
147
|
+
const rawLine = src.split('\n', 1)[0];
|
|
148
|
+
const nextLineWithoutTabs = rawLine.replace(/\t/g, ' ');
|
|
149
|
+
if (fencesBeginRegex.test(nextLineWithoutTabs) ||
|
|
150
|
+
headingBeginRegex.test(nextLineWithoutTabs) ||
|
|
151
|
+
htmlBeginRegex.test(nextLineWithoutTabs) ||
|
|
152
|
+
nextBulletRegex.test(nextLineWithoutTabs) ||
|
|
153
|
+
hrRegex.test(nextLineWithoutTabs))
|
|
154
|
+
break;
|
|
155
|
+
if (nextLineWithoutTabs.search(/[^ ]/) >= indent || !nextLineWithoutTabs.trim()) {
|
|
156
|
+
itemContents += '\n' + nextLineWithoutTabs.slice(indent);
|
|
89
157
|
}
|
|
90
158
|
else {
|
|
91
|
-
|
|
92
|
-
bull = this.lexer.options.pedantic ? escapeForRegex(bullet) : '[*+-]';
|
|
159
|
+
itemContents += '\n' + nextLineWithoutTabs;
|
|
93
160
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
raw: '',
|
|
97
|
-
ordered: isOrdered,
|
|
98
|
-
listType: isOrdered ? type : null,
|
|
99
|
-
loose: false,
|
|
100
|
-
start: undefined, // Will be set when first item is processed
|
|
101
|
-
tokens: []
|
|
102
|
-
};
|
|
103
|
-
// Get next list item
|
|
104
|
-
// Updated regex to properly handle empty list items (space after bullet, then newline)
|
|
105
|
-
const itemRegex = new RegExp(`^( {0,3}${bull})([\t ][^\\n]*|[\t ])?(?:\\n|$)`);
|
|
106
|
-
let endsWithBlankLine = false;
|
|
107
|
-
// Check if current bullet point can start a new List Item
|
|
108
|
-
while (src) {
|
|
109
|
-
let raw = '';
|
|
110
|
-
let itemContents = '';
|
|
111
|
-
let endEarly = false;
|
|
112
|
-
if (!(cap = itemRegex.exec(src)))
|
|
113
|
-
break;
|
|
114
|
-
raw = cap[0];
|
|
115
|
-
const bullet = cap[1].trim();
|
|
116
|
-
src = src.substring(raw.length);
|
|
117
|
-
const line = cap[2]
|
|
118
|
-
? cap[2].split('\n', 1)[0].replace(/^\t+/, (t) => ' '.repeat(3 * t.length))
|
|
119
|
-
: '';
|
|
120
|
-
const nextLine = src.split('\n', 1)[0];
|
|
121
|
-
const blankLine = !line.trim();
|
|
122
|
-
let indent = 0;
|
|
123
|
-
if (this.lexer.options.pedantic) {
|
|
124
|
-
indent = 2;
|
|
125
|
-
itemContents = line.trimStart();
|
|
126
|
-
}
|
|
127
|
-
else if (blankLine) {
|
|
128
|
-
indent = cap[1].length + 1;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
132
|
-
indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
|
|
133
|
-
itemContents = line.slice(indent);
|
|
134
|
-
indent += cap[1].length;
|
|
135
|
-
}
|
|
136
|
-
if (blankLine && /^[ \t]*$/.test(nextLine)) {
|
|
137
|
-
// Items begin with at most one blank line
|
|
138
|
-
raw += nextLine + '\n';
|
|
139
|
-
src = src.substring(nextLine.length + 1);
|
|
140
|
-
endEarly = true;
|
|
141
|
-
}
|
|
142
|
-
if (!endEarly) {
|
|
143
|
-
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|(?:\\d{1,9}|[a-zA-Z]|${romanUpper}|${romanLower})[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`);
|
|
144
|
-
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
|
|
145
|
-
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
|
|
146
|
-
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
|
|
147
|
-
const htmlBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}<[a-z].*>`, 'i');
|
|
148
|
-
// Check if following lines should be included in List Item
|
|
149
|
-
while (src) {
|
|
150
|
-
const rawLine = src.split('\n', 1)[0];
|
|
151
|
-
const nextLineWithoutTabs = rawLine.replace(/\t/g, ' ');
|
|
152
|
-
if (fencesBeginRegex.test(nextLineWithoutTabs) ||
|
|
153
|
-
headingBeginRegex.test(nextLineWithoutTabs) ||
|
|
154
|
-
htmlBeginRegex.test(nextLineWithoutTabs) ||
|
|
155
|
-
nextBulletRegex.test(nextLineWithoutTabs) ||
|
|
156
|
-
hrRegex.test(nextLineWithoutTabs))
|
|
157
|
-
break;
|
|
158
|
-
if (nextLineWithoutTabs.search(/[^ ]/) >= indent || !nextLineWithoutTabs.trim()) {
|
|
159
|
-
itemContents += '\n' + nextLineWithoutTabs.slice(indent);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
itemContents += '\n' + nextLineWithoutTabs;
|
|
163
|
-
}
|
|
164
|
-
raw += rawLine + '\n';
|
|
165
|
-
src = src.substring(rawLine.length + 1);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (!list.loose) {
|
|
169
|
-
// If the previous item ended with a blank line, the list is loose
|
|
170
|
-
if (endsWithBlankLine) {
|
|
171
|
-
list.loose = true;
|
|
172
|
-
}
|
|
173
|
-
else if (/\n[ \t]*\n[ \t]*$/.test(raw)) {
|
|
174
|
-
endsWithBlankLine = true;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
let isTask = null;
|
|
178
|
-
let isChecked = false;
|
|
179
|
-
// Check for task list items
|
|
180
|
-
if (this.lexer.options.gfm) {
|
|
181
|
-
isTask = /^\[[ xX]] /.exec(itemContents);
|
|
182
|
-
if (isTask) {
|
|
183
|
-
isChecked = isTask[0] !== '[ ] ';
|
|
184
|
-
itemContents = itemContents.replace(/^\[[ xX]] +/, '');
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
let value = null;
|
|
188
|
-
if (!isOrdered) {
|
|
189
|
-
// Do nothing for unordered lists
|
|
190
|
-
}
|
|
191
|
-
else if (type === 'decimal') {
|
|
192
|
-
value = parseInt(bullet.slice(0, -1), 10);
|
|
193
|
-
}
|
|
194
|
-
else if (type === 'lower-alpha' || type === 'upper-alpha') {
|
|
195
|
-
value = letterToInt(bullet.slice(0, -1));
|
|
196
|
-
}
|
|
197
|
-
else if (type === 'lower-roman' || type === 'upper-roman') {
|
|
198
|
-
value = romanToInt(bullet.slice(0, -1));
|
|
199
|
-
}
|
|
200
|
-
// Handle expectedValue initialization and validation
|
|
201
|
-
let skipped = false;
|
|
202
|
-
if (isOrdered) {
|
|
203
|
-
if (expectedValue === null) {
|
|
204
|
-
// First item: set expectedValue to this item's value (or 1 if parsing failed)
|
|
205
|
-
expectedValue = value ?? 1;
|
|
206
|
-
// Set the start property for ordered lists
|
|
207
|
-
list.start = expectedValue;
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
// Subsequent items: check if value matches expected
|
|
211
|
-
skipped = value !== null && value !== expectedValue;
|
|
212
|
-
// Increment expectedValue for next item
|
|
213
|
-
expectedValue += 1;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
list.tokens.push({
|
|
217
|
-
type: 'list_item',
|
|
218
|
-
raw,
|
|
219
|
-
task: !!isTask,
|
|
220
|
-
checked: isChecked,
|
|
221
|
-
loose: false,
|
|
222
|
-
text: itemContents,
|
|
223
|
-
value,
|
|
224
|
-
skipped,
|
|
225
|
-
tokens: []
|
|
226
|
-
});
|
|
227
|
-
list.raw += raw;
|
|
228
|
-
}
|
|
229
|
-
if (list.tokens.length === 0)
|
|
230
|
-
return null;
|
|
231
|
-
// Finalize the list
|
|
232
|
-
finalizeList(list, this.lexer);
|
|
233
|
-
return list;
|
|
161
|
+
raw += rawLine + '\n';
|
|
162
|
+
src = src.substring(rawLine.length + 1);
|
|
234
163
|
}
|
|
235
164
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
165
|
+
if (!list.loose) {
|
|
166
|
+
// If the previous item ended with a blank line, the list is loose
|
|
167
|
+
if (endsWithBlankLine) {
|
|
168
|
+
list.loose = true;
|
|
169
|
+
}
|
|
170
|
+
else if (/\n[ \t]*\n[ \t]*$/.test(raw)) {
|
|
171
|
+
endsWithBlankLine = true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
let isTask = null;
|
|
175
|
+
let isChecked = false;
|
|
176
|
+
// Check for task list items
|
|
177
|
+
if (this.lexer.options.gfm) {
|
|
178
|
+
isTask = /^\[[ xX]] /.exec(itemContents);
|
|
179
|
+
if (isTask) {
|
|
180
|
+
isChecked = isTask[0] !== '[ ] ';
|
|
181
|
+
itemContents = itemContents.replace(/^\[[ xX]] +/, '');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
let value = null;
|
|
185
|
+
if (!isOrdered) {
|
|
186
|
+
// Do nothing for unordered lists
|
|
187
|
+
}
|
|
188
|
+
else if (type === 'decimal') {
|
|
189
|
+
value = parseInt(bullet.slice(0, -1), 10);
|
|
190
|
+
}
|
|
191
|
+
else if (type === 'lower-alpha' || type === 'upper-alpha') {
|
|
192
|
+
value = letterToInt(bullet.slice(0, -1));
|
|
193
|
+
}
|
|
194
|
+
else if (type === 'lower-roman' || type === 'upper-roman') {
|
|
195
|
+
value = romanToInt(bullet.slice(0, -1));
|
|
196
|
+
}
|
|
197
|
+
// Handle expectedValue initialization and validation
|
|
198
|
+
let skipped = false;
|
|
199
|
+
if (isOrdered) {
|
|
200
|
+
if (expectedValue === null) {
|
|
201
|
+
// First item: set expectedValue to this item's value (or 1 if parsing failed)
|
|
202
|
+
expectedValue = value ?? 1;
|
|
203
|
+
// Set the start property for ordered lists
|
|
204
|
+
list.start = expectedValue;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
// Subsequent items: check if value matches expected
|
|
208
|
+
skipped = value !== null && value !== expectedValue;
|
|
209
|
+
// Increment expectedValue for next item
|
|
210
|
+
expectedValue += 1;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
list.tokens.push({
|
|
214
|
+
type: 'list_item',
|
|
215
|
+
raw,
|
|
216
|
+
task: !!isTask,
|
|
217
|
+
checked: isChecked,
|
|
218
|
+
loose: false,
|
|
219
|
+
text: itemContents,
|
|
220
|
+
value,
|
|
221
|
+
skipped,
|
|
222
|
+
tokens: []
|
|
223
|
+
});
|
|
224
|
+
list.raw += raw;
|
|
225
|
+
}
|
|
226
|
+
if (list.tokens.length === 0)
|
|
227
|
+
return undefined;
|
|
228
|
+
// Finalize the list
|
|
229
|
+
finalizeList(list, this.lexer);
|
|
230
|
+
return list;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare
|
|
3
|
-
extensions: Array<{
|
|
4
|
-
name: string;
|
|
5
|
-
level: 'block' | 'inline';
|
|
6
|
-
tokenizer: TokenizerExtensionFunction;
|
|
7
|
-
start?: TokenizerStartFunction;
|
|
8
|
-
}>;
|
|
9
|
-
};
|
|
1
|
+
import type { Extension } from './index.js';
|
|
2
|
+
export declare const markedMath: Extension[];
|
|
10
3
|
export type MathToken = {
|
|
11
4
|
type: 'math';
|
|
12
5
|
raw: string;
|