satorigear 0.0.3 → 0.0.5
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 +21 -21
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +237 -286
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ Benchmarked against Sätteri and Remark, which also produce MDAST, with feature
|
|
|
68
68
|
|
|
69
69
|
<!-- benchmark:start environment -->
|
|
70
70
|
|
|
71
|
-
> Median of 5 isolated mean-time runs at commit [`
|
|
71
|
+
> Median of 5 isolated mean-time runs at commit [`cc6e5c9`](https://github.com/KazariEX/satorigear/commit/cc6e5c9ffc8545c591e4f51cbd904e144d36c20f) on Apple M3, node 26.5.0, arm64-darwin. SatoriGear and Sätteri run in paired AB/BA order; comparisons are normalized to SatoriGear (↑ faster, ↓ slower). Lower time and higher throughput are better.
|
|
72
72
|
|
|
73
73
|
<!-- benchmark:end -->
|
|
74
74
|
|
|
@@ -83,17 +83,17 @@ Benchmarked against Sätteri and Remark, which also produce MDAST, with feature
|
|
|
83
83
|
|
|
84
84
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
85
85
|
| --- | ---: | ---: | ---: |
|
|
86
|
-
| **SatoriGear** | 2.
|
|
87
|
-
| Sätteri | 1.12 ms | ↑
|
|
88
|
-
| Remark |
|
|
86
|
+
| **SatoriGear** | 2.16 ms | baseline | 90.7 MiB/s |
|
|
87
|
+
| Sätteri | 1.12 ms | ↑ 1.91× | 174 MiB/s |
|
|
88
|
+
| Remark | 61.8 ms | ↓ 28.91× | 3.16 MiB/s |
|
|
89
89
|
|
|
90
90
|
##### CommonMark 0.31.2 examples, 14919 bytes, 652 documents
|
|
91
91
|
|
|
92
92
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
93
93
|
| --- | ---: | ---: | ---: |
|
|
94
|
-
| **SatoriGear** |
|
|
95
|
-
| Sätteri | 2.
|
|
96
|
-
| Remark | 26.
|
|
94
|
+
| **SatoriGear** | 971 µs | baseline | 14.7 MiB/s |
|
|
95
|
+
| Sätteri | 2.66 ms | ↓ 2.74× | 5.34 MiB/s |
|
|
96
|
+
| Remark | 26.5 ms | ↓ 27.16× | 0.54 MiB/s |
|
|
97
97
|
|
|
98
98
|
#### Built-in features
|
|
99
99
|
|
|
@@ -101,15 +101,15 @@ Benchmarked against Sätteri and Remark, which also produce MDAST, with feature
|
|
|
101
101
|
|
|
102
102
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
103
103
|
| --- | ---: | ---: | ---: |
|
|
104
|
-
| **SatoriGear** |
|
|
105
|
-
| Sätteri | 26.
|
|
104
|
+
| **SatoriGear** | 20.3 ms | baseline | 42.8 MiB/s |
|
|
105
|
+
| Sätteri | 26.6 ms | ↓ 1.31× | 32.6 MiB/s |
|
|
106
106
|
|
|
107
107
|
##### Public APIs README, 232580 bytes, 1 document
|
|
108
108
|
|
|
109
109
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
110
110
|
| --- | ---: | ---: | ---: |
|
|
111
|
-
| **SatoriGear** |
|
|
112
|
-
| Sätteri | 2.
|
|
111
|
+
| **SatoriGear** | 4.65 ms | baseline | 47.7 MiB/s |
|
|
112
|
+
| Sätteri | 2.41 ms | ↑ 1.93× | 92.0 MiB/s |
|
|
113
113
|
|
|
114
114
|
</details>
|
|
115
115
|
|
|
@@ -126,17 +126,17 @@ Benchmarked against Sätteri and Remark, which also produce MDAST, with feature
|
|
|
126
126
|
|
|
127
127
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
128
128
|
| --- | ---: | ---: | ---: |
|
|
129
|
-
| **SatoriGear** | 2.
|
|
130
|
-
| Sätteri | 5.
|
|
131
|
-
| Remark |
|
|
129
|
+
| **SatoriGear** | 2.15 ms | baseline | 91.0 MiB/s |
|
|
130
|
+
| Sätteri | 5.52 ms | ↓ 2.57× | 35.4 MiB/s |
|
|
131
|
+
| Remark | 60.5 ms | ↓ 28.08× | 3.23 MiB/s |
|
|
132
132
|
|
|
133
133
|
##### CommonMark 0.31.2 examples, 14919 bytes, 652 documents
|
|
134
134
|
|
|
135
135
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
136
136
|
| --- | ---: | ---: | ---: |
|
|
137
|
-
| **SatoriGear** |
|
|
138
|
-
| Sätteri | 5.
|
|
139
|
-
| Remark | 26.
|
|
137
|
+
| **SatoriGear** | 989 µs | baseline | 14.4 MiB/s |
|
|
138
|
+
| Sätteri | 5.95 ms | ↓ 5.98× | 2.39 MiB/s |
|
|
139
|
+
| Remark | 26.5 ms | ↓ 26.84× | 0.54 MiB/s |
|
|
140
140
|
|
|
141
141
|
#### Built-in features
|
|
142
142
|
|
|
@@ -144,15 +144,15 @@ Benchmarked against Sätteri and Remark, which also produce MDAST, with feature
|
|
|
144
144
|
|
|
145
145
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
146
146
|
| --- | ---: | ---: | ---: |
|
|
147
|
-
| **SatoriGear** |
|
|
148
|
-
| Sätteri | 79.
|
|
147
|
+
| **SatoriGear** | 21.0 ms | baseline | 41.2 MiB/s |
|
|
148
|
+
| Sätteri | 79.3 ms | ↓ 3.78× | 10.9 MiB/s |
|
|
149
149
|
|
|
150
150
|
##### Public APIs README, 232580 bytes, 1 document
|
|
151
151
|
|
|
152
152
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
153
153
|
| --- | ---: | ---: | ---: |
|
|
154
|
-
| **SatoriGear** | 5.
|
|
155
|
-
| Sätteri |
|
|
154
|
+
| **SatoriGear** | 5.02 ms | baseline | 44.2 MiB/s |
|
|
155
|
+
| Sätteri | 20.9 ms | ↓ 4.14× | 10.6 MiB/s |
|
|
156
156
|
|
|
157
157
|
</details>
|
|
158
158
|
|
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -143,6 +143,69 @@ function isSetEqual(foo, bar) {
|
|
|
143
143
|
return true;
|
|
144
144
|
}
|
|
145
145
|
//#endregion
|
|
146
|
+
//#region src/block/profile.ts
|
|
147
|
+
function compileBlockProfile(features) {
|
|
148
|
+
const decorators = [];
|
|
149
|
+
const fallbacks = [];
|
|
150
|
+
const interrupts = [];
|
|
151
|
+
const ruleByKind = [];
|
|
152
|
+
const rules = [];
|
|
153
|
+
const restarts = [];
|
|
154
|
+
const starts = [];
|
|
155
|
+
const lazyContinuationUnwrappers = [];
|
|
156
|
+
for (const feature of features) {
|
|
157
|
+
if (feature.decorators) decorators.push(...feature.decorators);
|
|
158
|
+
if (feature.fallbacks) fallbacks.push(...feature.fallbacks);
|
|
159
|
+
if (feature.restart) restarts.push(feature.restart);
|
|
160
|
+
if (feature.starts) for (const registration of feature.starts) {
|
|
161
|
+
if (registration.unwrapLazyContinuation) lazyContinuationUnwrappers.push(registration.unwrapLazyContinuation);
|
|
162
|
+
for (const code of registration.codes) {
|
|
163
|
+
(starts[code] ??= []).push(registration.start);
|
|
164
|
+
if (registration.interrupt) (interrupts[code] ??= []).push(registration.interrupt);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (feature.rules) for (const registration of feature.rules) {
|
|
168
|
+
const syntax = registration.syntax;
|
|
169
|
+
const rule = {
|
|
170
|
+
block: syntax.kind === "block" || syntax.kind === "leaf",
|
|
171
|
+
close: syntax.kind === "block" || syntax.kind === "frame" ? syntax.close : 0,
|
|
172
|
+
definitionKey: registration.definitionKey,
|
|
173
|
+
inlineContent: registration.inlineContent === true,
|
|
174
|
+
rule: registration.rule,
|
|
175
|
+
build: registration.build,
|
|
176
|
+
syntaxKind: syntax.kind === "block" || syntax.kind === "frame" ? 0 : syntax.kind === "group" ? 1 : 2
|
|
177
|
+
};
|
|
178
|
+
rules[registration.rule] = rule;
|
|
179
|
+
if (syntax.kind === "block" || syntax.kind === "frame") {
|
|
180
|
+
const opens = typeof syntax.open === "number" ? [syntax.open] : syntax.open;
|
|
181
|
+
for (const open of opens) ruleByKind[open] = rule;
|
|
182
|
+
} else if (syntax.kind === "group") for (const token of syntax.tokens) ruleByKind[token] = rule;
|
|
183
|
+
else if (syntax.kind === "leaf") ruleByKind[syntax.token] = rule;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for (const registration of decorators) {
|
|
187
|
+
const rule = rules[registration.rule];
|
|
188
|
+
const build = rule?.build;
|
|
189
|
+
if (!build) throw new Error(`Cannot decorate unknown block rule ${registration.rule}`);
|
|
190
|
+
rule.build = registration.decorate(build);
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
fallbacks,
|
|
194
|
+
interrupts,
|
|
195
|
+
lazyContinuationUnwrappers,
|
|
196
|
+
restart(source, lines, changedStart, changedEnd) {
|
|
197
|
+
let result;
|
|
198
|
+
for (const restart of restarts) {
|
|
199
|
+
const candidate = restart(source, lines, changedStart, changedEnd);
|
|
200
|
+
if (candidate !== void 0 && (result === void 0 || candidate < result)) result = candidate;
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
203
|
+
},
|
|
204
|
+
schema: { ruleByKind },
|
|
205
|
+
starts
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
146
209
|
//#region src/block/tokens.ts
|
|
147
210
|
const blockTokenStride = 4;
|
|
148
211
|
var BlockTokenStream = class {
|
|
@@ -185,18 +248,17 @@ var BlockTokenStream = class {
|
|
|
185
248
|
const closes = [];
|
|
186
249
|
for (let index = 0; index < this.length; index++) {
|
|
187
250
|
const kind = this.kind(index);
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
251
|
+
const rule = schema.ruleByKind[kind];
|
|
252
|
+
if (rule?.syntaxKind === 0) {
|
|
190
253
|
opens.push(index);
|
|
191
|
-
closes.push(
|
|
254
|
+
closes.push(rule.close);
|
|
192
255
|
continue;
|
|
193
256
|
}
|
|
194
|
-
|
|
195
|
-
if (groupedRule) {
|
|
257
|
+
if (rule?.syntaxKind === 1) {
|
|
196
258
|
const start = index;
|
|
197
259
|
do
|
|
198
260
|
index++;
|
|
199
|
-
while (index < this.length && schema.
|
|
261
|
+
while (index < this.length && schema.ruleByKind[this.kind(index)] === rule);
|
|
200
262
|
fields[start * blockTokenStride + 3] = index - start;
|
|
201
263
|
index--;
|
|
202
264
|
continue;
|
|
@@ -207,7 +269,7 @@ var BlockTokenStream = class {
|
|
|
207
269
|
fields[open * blockTokenStride + 3] = index - open + 1;
|
|
208
270
|
continue;
|
|
209
271
|
}
|
|
210
|
-
if (
|
|
272
|
+
if (rule?.syntaxKind === 2) fields[index * blockTokenStride + 3] = 1;
|
|
211
273
|
}
|
|
212
274
|
if (opens.length > 0) throw new Error(`Block token stream did not close token ${this.kind(opens.at(-1))}`);
|
|
213
275
|
}
|
|
@@ -650,7 +712,6 @@ var BlockScanner = class {
|
|
|
650
712
|
};
|
|
651
713
|
//#endregion
|
|
652
714
|
//#region src/block/structure.ts
|
|
653
|
-
const noBlockEntry = Number.MIN_SAFE_INTEGER;
|
|
654
715
|
var BlockStructure = class {
|
|
655
716
|
#records = [];
|
|
656
717
|
#schema;
|
|
@@ -709,17 +770,6 @@ var BlockStructure = class {
|
|
|
709
770
|
}
|
|
710
771
|
return records;
|
|
711
772
|
}
|
|
712
|
-
firstChild(tokenStart) {
|
|
713
|
-
return ~tokenStart;
|
|
714
|
-
}
|
|
715
|
-
nextChild(tokenStart, entry) {
|
|
716
|
-
const next = entry < 0 ? ~entry + 1 : entry + this.#tokens.nodeLength(entry);
|
|
717
|
-
if (next >= tokenStart + this.#tokens.nodeLength(tokenStart)) return noBlockEntry;
|
|
718
|
-
return this.#tokens.nodeLength(next) > 0 ? next : ~next;
|
|
719
|
-
}
|
|
720
|
-
leafToken(entry) {
|
|
721
|
-
return ~entry;
|
|
722
|
-
}
|
|
723
773
|
lenOf(tokenStart) {
|
|
724
774
|
const end = tokenStart + this.#tokens.nodeLength(tokenStart);
|
|
725
775
|
return this.#tokens.end(end - 1) - this.#tokens.start(tokenStart);
|
|
@@ -732,7 +782,7 @@ var BlockStructure = class {
|
|
|
732
782
|
}
|
|
733
783
|
ruleOf(tokenStart) {
|
|
734
784
|
const kind = this.#tokens.kind(tokenStart);
|
|
735
|
-
const rule = this.#schema.
|
|
785
|
+
const rule = this.#schema.ruleByKind[kind];
|
|
736
786
|
if (!rule) throw new Error(`Block token ${tokenStart} does not begin a semantic node`);
|
|
737
787
|
return rule;
|
|
738
788
|
}
|
|
@@ -826,15 +876,16 @@ function appendPhrasing(target, value) {
|
|
|
826
876
|
function appendInlineGap(output, context, start, end) {
|
|
827
877
|
output.gapStart = -1;
|
|
828
878
|
output.gapEnd = -1;
|
|
829
|
-
|
|
830
|
-
appendText(output.children, context.decodeText(context.view.text.slice(start, end).replace(/[\r\n]/g, "")), gapSpan.start, gapSpan.end);
|
|
879
|
+
appendText(output.children, context.view.text.slice(start, end), context.view.mapPoint(start), context.view.mapPoint(end));
|
|
831
880
|
}
|
|
832
881
|
function appendInline(output, context, value) {
|
|
833
882
|
const target = output.children;
|
|
834
883
|
const nextLineOffset = value.position.start;
|
|
835
884
|
const newline = value.type === "text" && value.value.startsWith("\n");
|
|
836
885
|
if (output.gapStart >= 0) {
|
|
837
|
-
|
|
886
|
+
const gapStart = output.gapStart;
|
|
887
|
+
const gapEnd = newline ? lineEndingStart(context.view.text, output.gapEnd) : output.gapEnd;
|
|
888
|
+
if (gapEnd > gapStart) appendInlineGap(output, context, gapStart, gapEnd);
|
|
838
889
|
else {
|
|
839
890
|
output.gapStart = -1;
|
|
840
891
|
output.gapEnd = -1;
|
|
@@ -871,7 +922,7 @@ function appendInlineRange(startToken, endToken, context, output, closeKind) {
|
|
|
871
922
|
while (index < endToken) {
|
|
872
923
|
if (inlineTokenKind(context.tokens, index) === closeKind) break;
|
|
873
924
|
const childOffset = inlineTokenStart(context.tokens, index);
|
|
874
|
-
if (
|
|
925
|
+
if (childOffset > output.cursor) {
|
|
875
926
|
output.gapStart = output.cursor;
|
|
876
927
|
output.gapEnd = childOffset;
|
|
877
928
|
}
|
|
@@ -882,10 +933,10 @@ function appendInlineRange(startToken, endToken, context, output, closeKind) {
|
|
|
882
933
|
if (!childEmitted) continue;
|
|
883
934
|
output.cursor = childEnd;
|
|
884
935
|
}
|
|
885
|
-
if (closeKind !== void 0 && index < endToken
|
|
936
|
+
if (closeKind !== void 0 && index < endToken) {
|
|
886
937
|
const contentEnd = inlineTokenStart(context.tokens, index);
|
|
887
938
|
if (contentEnd > output.cursor) appendInlineGap(output, context, output.cursor, contentEnd);
|
|
888
|
-
}
|
|
939
|
+
} else if (closeKind === void 0 && context.view.text.length > output.cursor) appendInlineGap(output, context, output.cursor, context.view.text.length);
|
|
889
940
|
return index;
|
|
890
941
|
}
|
|
891
942
|
function buildInlineSemantic(openToken, endToken, output, context) {
|
|
@@ -938,7 +989,7 @@ function buildInlineFragment(tokenStart, context) {
|
|
|
938
989
|
};
|
|
939
990
|
const result = {
|
|
940
991
|
children: [],
|
|
941
|
-
cursor:
|
|
992
|
+
cursor: 0,
|
|
942
993
|
gapEnd: -1,
|
|
943
994
|
gapStart: -1
|
|
944
995
|
};
|
|
@@ -985,8 +1036,14 @@ const buildBlockNode = (tokenStart, context) => {
|
|
|
985
1036
|
};
|
|
986
1037
|
const buildBlockChildren = (tokenStart, context) => {
|
|
987
1038
|
const structure = context.structure;
|
|
1039
|
+
const tokens = structure.tokens;
|
|
988
1040
|
const children = [];
|
|
989
|
-
|
|
1041
|
+
const tokenEnd = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
1042
|
+
for (let child = tokenStart + 1; child < tokenEnd;) {
|
|
1043
|
+
const length = tokens.nodeLength(child);
|
|
1044
|
+
if (length > 0 && structure.isBlock(child)) children.push(buildBlockNode(child, context));
|
|
1045
|
+
child += length || 1;
|
|
1046
|
+
}
|
|
990
1047
|
return children;
|
|
991
1048
|
};
|
|
992
1049
|
//#endregion
|
|
@@ -1516,76 +1573,6 @@ var DocumentImpl = class {
|
|
|
1516
1573
|
}
|
|
1517
1574
|
};
|
|
1518
1575
|
//#endregion
|
|
1519
|
-
//#region src/block/profile.ts
|
|
1520
|
-
function compileBlockProfile(features) {
|
|
1521
|
-
const decorators = [];
|
|
1522
|
-
const fallbacks = [];
|
|
1523
|
-
const frameByOpen = [];
|
|
1524
|
-
const groupedRuleByToken = [];
|
|
1525
|
-
const interrupts = [];
|
|
1526
|
-
const ruleByLeaf = [];
|
|
1527
|
-
const rules = [];
|
|
1528
|
-
const restarts = [];
|
|
1529
|
-
const starts = [];
|
|
1530
|
-
const lazyContinuationUnwrappers = [];
|
|
1531
|
-
for (const feature of features) {
|
|
1532
|
-
if (feature.decorators) decorators.push(...feature.decorators);
|
|
1533
|
-
if (feature.fallbacks) fallbacks.push(...feature.fallbacks);
|
|
1534
|
-
if (feature.restart) restarts.push(feature.restart);
|
|
1535
|
-
if (feature.starts) for (const registration of feature.starts) {
|
|
1536
|
-
if (registration.unwrapLazyContinuation) lazyContinuationUnwrappers.push(registration.unwrapLazyContinuation);
|
|
1537
|
-
for (const code of registration.codes) {
|
|
1538
|
-
(starts[code] ??= []).push(registration.start);
|
|
1539
|
-
if (registration.interrupt) (interrupts[code] ??= []).push(registration.interrupt);
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
if (feature.rules) for (const registration of feature.rules) {
|
|
1543
|
-
const syntax = registration.syntax;
|
|
1544
|
-
const rule = {
|
|
1545
|
-
block: syntax.kind === "block" || syntax.kind === "leaf",
|
|
1546
|
-
definitionKey: registration.definitionKey,
|
|
1547
|
-
inlineContent: registration.inlineContent === true,
|
|
1548
|
-
rule: registration.rule,
|
|
1549
|
-
build: registration.build
|
|
1550
|
-
};
|
|
1551
|
-
rules[registration.rule] = rule;
|
|
1552
|
-
if (syntax.kind === "block" || syntax.kind === "frame") {
|
|
1553
|
-
const opens = typeof syntax.open === "number" ? [syntax.open] : syntax.open;
|
|
1554
|
-
for (const open of opens) frameByOpen[open] = {
|
|
1555
|
-
close: syntax.close,
|
|
1556
|
-
rule
|
|
1557
|
-
};
|
|
1558
|
-
} else if (syntax.kind === "group") for (const token of syntax.tokens) groupedRuleByToken[token] = rule;
|
|
1559
|
-
else if (syntax.kind === "leaf") ruleByLeaf[syntax.token] = rule;
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
for (const registration of decorators) {
|
|
1563
|
-
const rule = rules[registration.rule];
|
|
1564
|
-
const build = rule?.build;
|
|
1565
|
-
if (!build) throw new Error(`Cannot decorate unknown block rule ${registration.rule}`);
|
|
1566
|
-
rule.build = registration.decorate(build);
|
|
1567
|
-
}
|
|
1568
|
-
return {
|
|
1569
|
-
fallbacks,
|
|
1570
|
-
interrupts,
|
|
1571
|
-
lazyContinuationUnwrappers,
|
|
1572
|
-
restart(source, lines, changedStart, changedEnd) {
|
|
1573
|
-
let result;
|
|
1574
|
-
for (const restart of restarts) {
|
|
1575
|
-
const candidate = restart(source, lines, changedStart, changedEnd);
|
|
1576
|
-
if (candidate !== void 0 && (result === void 0 || candidate < result)) result = candidate;
|
|
1577
|
-
}
|
|
1578
|
-
return result;
|
|
1579
|
-
},
|
|
1580
|
-
schema: {
|
|
1581
|
-
frameByOpen,
|
|
1582
|
-
groupedRuleByToken,
|
|
1583
|
-
ruleByLeaf
|
|
1584
|
-
},
|
|
1585
|
-
starts
|
|
1586
|
-
};
|
|
1587
|
-
}
|
|
1588
|
-
//#endregion
|
|
1589
1576
|
//#region src/inline/delimiter.ts
|
|
1590
1577
|
const whitespace = /\s/u;
|
|
1591
1578
|
const punctuation = /[\p{P}\p{S}]/u;
|
|
@@ -1610,13 +1597,13 @@ function flanking(source, start, end, config) {
|
|
|
1610
1597
|
const afterPunctuation = punctuation.test(after);
|
|
1611
1598
|
const left = !afterWhitespace && (!afterPunctuation || beforeWhitespace || beforePunctuation);
|
|
1612
1599
|
const right = !beforeWhitespace && (!beforePunctuation || afterWhitespace || afterPunctuation);
|
|
1613
|
-
if (config.
|
|
1600
|
+
if (config.flags & 1) return (left ? 1 : 0) | (right ? 2 : 0);
|
|
1614
1601
|
return (left && (!right || beforePunctuation) ? 1 : 0) | (right && (!left || afterPunctuation) ? 2 : 0);
|
|
1615
1602
|
}
|
|
1616
1603
|
function canPair(opener, closer) {
|
|
1617
|
-
if (!opener.
|
|
1618
|
-
if (closer.config.
|
|
1619
|
-
if (!closer.config.
|
|
1604
|
+
if (!(opener.flanking & 1) || !(closer.flanking & 2)) return false;
|
|
1605
|
+
if (closer.config.flags & 2 && opener.length !== closer.length) return false;
|
|
1606
|
+
if (!(closer.config.flags & 4) || !(opener.flanking & 2) && !(closer.flanking & 1)) return true;
|
|
1620
1607
|
return (opener.length + closer.length) % 3 !== 0 || opener.length % 3 === 0 && closer.length % 3 === 0;
|
|
1621
1608
|
}
|
|
1622
1609
|
function appendFragment(result, tokens, tokenIndex, start, end, kind) {
|
|
@@ -1638,11 +1625,11 @@ function matchDelimiterRuns(runs, first, replacements) {
|
|
|
1638
1625
|
while (current >= 0) {
|
|
1639
1626
|
const closer = runs[current];
|
|
1640
1627
|
const next = closer.next;
|
|
1641
|
-
if (!closer.
|
|
1628
|
+
if (!(closer.flanking & 2) || closer.remaining === 0) {
|
|
1642
1629
|
current = next;
|
|
1643
1630
|
continue;
|
|
1644
1631
|
}
|
|
1645
|
-
const bottomSlot = closer.config.index * 6 + (closer.
|
|
1632
|
+
const bottomSlot = closer.config.index * 6 + (closer.flanking & 1 ? 3 : 0) + closer.length % 3;
|
|
1646
1633
|
const bottom = openersBottom[bottomSlot] ?? -1;
|
|
1647
1634
|
let openerIndex = closer.previous;
|
|
1648
1635
|
while (openerIndex >= 0 && openerIndex !== bottom) {
|
|
@@ -1652,15 +1639,15 @@ function matchDelimiterRuns(runs, first, replacements) {
|
|
|
1652
1639
|
}
|
|
1653
1640
|
if (openerIndex < 0 || openerIndex === bottom) {
|
|
1654
1641
|
openersBottom[bottomSlot] = closer.previous;
|
|
1655
|
-
if (!closer.
|
|
1642
|
+
if (!(closer.flanking & 1)) unlinkRun(runs, current);
|
|
1656
1643
|
current = next;
|
|
1657
1644
|
continue;
|
|
1658
1645
|
}
|
|
1659
1646
|
const opener = runs[openerIndex];
|
|
1660
1647
|
const use = opener.remaining >= 2 && closer.remaining >= 2 && closer.config.double ? 2 : 1;
|
|
1661
|
-
const openEnd = opener.
|
|
1648
|
+
const openEnd = opener.start + opener.remaining;
|
|
1662
1649
|
const openStart = openEnd - use;
|
|
1663
|
-
const closeStart = closer.
|
|
1650
|
+
const closeStart = closer.start;
|
|
1664
1651
|
const closeEnd = closeStart + use;
|
|
1665
1652
|
const pair = use === 2 ? closer.config.double : closer.config.single;
|
|
1666
1653
|
addReplacement(replacements, opener.tokenIndex, {
|
|
@@ -1710,20 +1697,18 @@ function resolveDelimiterRuns(source, tokens, configByKind, isolationCloseByOpen
|
|
|
1710
1697
|
const offset = inlineTokenStart(tokens, tokenIndex);
|
|
1711
1698
|
const end = inlineTokenEnd(tokens, tokenIndex);
|
|
1712
1699
|
const length = end - offset;
|
|
1713
|
-
if (config.
|
|
1700
|
+
if (config.flags & 2 && (length > 2 || (length === 1 ? !config.single : !config.double))) continue;
|
|
1714
1701
|
const flags = flanking(source, offset, end, config);
|
|
1715
1702
|
runs.push({
|
|
1716
1703
|
tokenIndex,
|
|
1717
|
-
offset,
|
|
1718
1704
|
config,
|
|
1719
1705
|
length,
|
|
1720
|
-
start:
|
|
1706
|
+
start: offset,
|
|
1721
1707
|
remaining: length,
|
|
1722
1708
|
scope: isolationScopes[isolationScopes.length - 1] ?? -1,
|
|
1723
1709
|
previous: -1,
|
|
1724
1710
|
next: -1,
|
|
1725
|
-
|
|
1726
|
-
canClose: Boolean(flags & 2)
|
|
1711
|
+
flanking: flags
|
|
1727
1712
|
});
|
|
1728
1713
|
}
|
|
1729
1714
|
if (runs.length === 0) return tokens;
|
|
@@ -1766,25 +1751,15 @@ function createDelimiterResolver(delimiterConfigs, isolationCloseByOpen) {
|
|
|
1766
1751
|
const delimiterByKind = [];
|
|
1767
1752
|
delimiterConfigs.forEach((config, index) => {
|
|
1768
1753
|
delimiterByKind[config.token] = {
|
|
1769
|
-
single: config.single
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
} : void 0,
|
|
1773
|
-
double: config.double ? {
|
|
1774
|
-
open: config.double.open,
|
|
1775
|
-
close: config.double.close
|
|
1776
|
-
} : void 0,
|
|
1777
|
-
allowIntraword: config.allowIntraword,
|
|
1778
|
-
matchWholeRun: config.pairing.kind === "whole" ? true : void 0,
|
|
1779
|
-
ruleOfThree: config.pairing.kind === "partial" ? config.pairing.ruleOfThree : void 0,
|
|
1754
|
+
single: config.single,
|
|
1755
|
+
double: config.double,
|
|
1756
|
+
flags: (config.allowIntraword !== false ? 1 : 0) | (config.pairing.kind === "whole" ? 2 : 0) | (config.pairing.kind === "partial" && config.pairing.ruleOfThree ? 4 : 0),
|
|
1780
1757
|
index
|
|
1781
1758
|
};
|
|
1782
1759
|
});
|
|
1783
|
-
const delimiterKinds = [];
|
|
1784
|
-
for (const config of delimiterConfigs) delimiterKinds[config.token] = true;
|
|
1785
1760
|
return (source, tokens) => {
|
|
1786
1761
|
const count = inlineTokenCount(tokens);
|
|
1787
|
-
for (let tokenIndex = 0; tokenIndex < count; tokenIndex++) if (
|
|
1762
|
+
for (let tokenIndex = 0; tokenIndex < count; tokenIndex++) if (delimiterByKind[inlineTokenKind(tokens, tokenIndex)]) return resolveDelimiterRuns(source, tokens, delimiterByKind, isolationCloseByOpen);
|
|
1788
1763
|
return tokens;
|
|
1789
1764
|
};
|
|
1790
1765
|
}
|
|
@@ -1814,6 +1789,7 @@ function inlineTextEnd(source, start, boundary) {
|
|
|
1814
1789
|
}
|
|
1815
1790
|
function tokenize(source, textBoundary, scannerByCode) {
|
|
1816
1791
|
const tokens = [];
|
|
1792
|
+
let hasContentLine = false;
|
|
1817
1793
|
let offset = 0;
|
|
1818
1794
|
let lineStart = true;
|
|
1819
1795
|
while (offset < source.length) {
|
|
@@ -1838,7 +1814,8 @@ function tokenize(source, textBoundary, scannerByCode) {
|
|
|
1838
1814
|
}
|
|
1839
1815
|
}
|
|
1840
1816
|
offset = content;
|
|
1841
|
-
if (
|
|
1817
|
+
if (hasContentLine) tokens.push(39, offset, offset, 0);
|
|
1818
|
+
hasContentLine = true;
|
|
1842
1819
|
lineStart = false;
|
|
1843
1820
|
continue;
|
|
1844
1821
|
}
|
|
@@ -1873,14 +1850,10 @@ function tokenize(source, textBoundary, scannerByCode) {
|
|
|
1873
1850
|
offset = scannedEnd;
|
|
1874
1851
|
continue;
|
|
1875
1852
|
}
|
|
1876
|
-
|
|
1877
|
-
tokens.push(9, offset, end, 0);
|
|
1878
|
-
offset = end;
|
|
1853
|
+
offset = inlineTextEnd(source, offset + 1, textBoundary);
|
|
1879
1854
|
continue;
|
|
1880
1855
|
}
|
|
1881
|
-
|
|
1882
|
-
tokens.push(9, offset, end, 0);
|
|
1883
|
-
offset = end;
|
|
1856
|
+
offset = inlineTextEnd(source, offset, textBoundary);
|
|
1884
1857
|
}
|
|
1885
1858
|
return tokens;
|
|
1886
1859
|
}
|
|
@@ -1913,40 +1886,40 @@ function compileInlineProfile(features, decodeText) {
|
|
|
1913
1886
|
const delimiters = [];
|
|
1914
1887
|
const scanRules = [];
|
|
1915
1888
|
const transforms = [];
|
|
1916
|
-
const
|
|
1889
|
+
const tokenHandlers = [];
|
|
1890
|
+
const containerByKind = [];
|
|
1891
|
+
const pairByOpenKind = [];
|
|
1892
|
+
const isolationCloseByOpen = [];
|
|
1917
1893
|
for (const feature of features) {
|
|
1918
1894
|
const resolve = feature.resolve;
|
|
1919
1895
|
if (feature.scan) scanRules.push(...feature.scan);
|
|
1920
1896
|
if (resolve?.delimiters) delimiters.push(...resolve.delimiters);
|
|
1921
1897
|
if (resolve?.transform) transforms.push(resolve.transform);
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
closeKind: rule.close,
|
|
1948
|
-
build: rule.build
|
|
1949
|
-
};
|
|
1898
|
+
const build = feature.build;
|
|
1899
|
+
if (!build) continue;
|
|
1900
|
+
for (const rule of build) {
|
|
1901
|
+
if (rule.kind === "decorate") {
|
|
1902
|
+
tokenHandlers[rule.token] = rule.apply;
|
|
1903
|
+
continue;
|
|
1904
|
+
}
|
|
1905
|
+
if (rule.kind === "leaf") {
|
|
1906
|
+
tokenHandlers[rule.token] = rule.build;
|
|
1907
|
+
continue;
|
|
1908
|
+
}
|
|
1909
|
+
if (rule.kind === "container") {
|
|
1910
|
+
isolationCloseByOpen[rule.contentOpen] = rule.close;
|
|
1911
|
+
containerByKind[rule.token] = {
|
|
1912
|
+
closeKind: rule.close,
|
|
1913
|
+
contentOpenKind: rule.contentOpen,
|
|
1914
|
+
build: rule.build
|
|
1915
|
+
};
|
|
1916
|
+
} else {
|
|
1917
|
+
isolationCloseByOpen[rule.open] = rule.close;
|
|
1918
|
+
pairByOpenKind[rule.open] = {
|
|
1919
|
+
closeKind: rule.close,
|
|
1920
|
+
build: rule.build
|
|
1921
|
+
};
|
|
1922
|
+
}
|
|
1950
1923
|
}
|
|
1951
1924
|
}
|
|
1952
1925
|
const resolveDelimiters = createDelimiterResolver(delimiters, isolationCloseByOpen);
|
|
@@ -2161,7 +2134,7 @@ function attributeEndAt(source, start) {
|
|
|
2161
2134
|
function scanAttribute(source, start, tokens) {
|
|
2162
2135
|
const end = attributeEndAt(source, start);
|
|
2163
2136
|
if (end === void 0) return -1;
|
|
2164
|
-
if (tokens.length === 0) {
|
|
2137
|
+
if (tokens.length === 0 && !hasVisibleText(source, 0, start)) {
|
|
2165
2138
|
let textEnd = end;
|
|
2166
2139
|
while (true) {
|
|
2167
2140
|
let next = textEnd;
|
|
@@ -2170,12 +2143,11 @@ function scanAttribute(source, start, tokens) {
|
|
|
2170
2143
|
if (nextEnd === void 0) break;
|
|
2171
2144
|
textEnd = nextEnd;
|
|
2172
2145
|
}
|
|
2173
|
-
appendInlineToken(tokens, 9, start, textEnd);
|
|
2174
2146
|
return textEnd;
|
|
2175
2147
|
}
|
|
2176
2148
|
const previous = inlineTokenCount(tokens) - 1;
|
|
2177
|
-
const previousEnd = previous >= 0 ? inlineTokenEnd(tokens, previous) :
|
|
2178
|
-
if (previousEnd
|
|
2149
|
+
const previousEnd = previous >= 0 ? inlineTokenEnd(tokens, previous) : 0;
|
|
2150
|
+
if (previousEnd < start && (previous >= 0 && inlineTokenKind(tokens, previous) === 36 || hasVisibleText(source, previousEnd, start))) appendInlineToken(tokens, 9, previousEnd, start);
|
|
2179
2151
|
appendInlineToken(tokens, 36, start, end, start > 0 && isMarkdownWhitespace(source.charCodeAt(start - 1)) ? 4 : 0);
|
|
2180
2152
|
let next = end;
|
|
2181
2153
|
while (isMarkdownWhitespace(source.charCodeAt(next))) next++;
|
|
@@ -2426,7 +2398,7 @@ const feature$14 = {
|
|
|
2426
2398
|
}
|
|
2427
2399
|
}, {
|
|
2428
2400
|
kind: "leaf",
|
|
2429
|
-
token:
|
|
2401
|
+
token: 39,
|
|
2430
2402
|
build(tokenIndex, sourceSpan) {
|
|
2431
2403
|
return {
|
|
2432
2404
|
type: "text",
|
|
@@ -2533,28 +2505,24 @@ const feature$13 = { inline: {
|
|
|
2533
2505
|
marker: 38,
|
|
2534
2506
|
scan(source, start, tokens) {
|
|
2535
2507
|
const matchEnd = matchInlinePatternEnd(entity, source, start);
|
|
2536
|
-
|
|
2537
|
-
appendInlineToken(tokens,
|
|
2538
|
-
return
|
|
2508
|
+
if (matchEnd < 0) return start + 1;
|
|
2509
|
+
appendInlineToken(tokens, 6, start, matchEnd, 16);
|
|
2510
|
+
return matchEnd;
|
|
2539
2511
|
}
|
|
2540
2512
|
}, {
|
|
2541
2513
|
marker: 92,
|
|
2542
2514
|
scan(source, start, tokens) {
|
|
2543
2515
|
const next = source.charCodeAt(start + 1);
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
if (next === 10 || next === 13) kind = 7;
|
|
2548
|
-
else if (isAsciiPunctuation(next)) {
|
|
2549
|
-
end++;
|
|
2550
|
-
flags = 16;
|
|
2551
|
-
kind = 8;
|
|
2552
|
-
} else if (next === 32 || next === 9) {
|
|
2553
|
-
end++;
|
|
2554
|
-
kind = 9;
|
|
2516
|
+
if (next === 10 || next === 13) {
|
|
2517
|
+
appendInlineToken(tokens, 7, start, start + 1);
|
|
2518
|
+
return start + 1;
|
|
2555
2519
|
}
|
|
2556
|
-
|
|
2557
|
-
|
|
2520
|
+
if (isAsciiPunctuation(next)) {
|
|
2521
|
+
const end = start + 2;
|
|
2522
|
+
appendInlineToken(tokens, 8, start, end, 16);
|
|
2523
|
+
return end;
|
|
2524
|
+
}
|
|
2525
|
+
return start + (next === 32 || next === 9 ? 2 : 1);
|
|
2558
2526
|
}
|
|
2559
2527
|
}],
|
|
2560
2528
|
build: [
|
|
@@ -2563,11 +2531,6 @@ const feature$13 = { inline: {
|
|
|
2563
2531
|
token: 9,
|
|
2564
2532
|
build: buildInlineText
|
|
2565
2533
|
},
|
|
2566
|
-
{
|
|
2567
|
-
kind: "leaf",
|
|
2568
|
-
token: 39,
|
|
2569
|
-
build: buildInlineText
|
|
2570
|
-
},
|
|
2571
2534
|
{
|
|
2572
2535
|
kind: "leaf",
|
|
2573
2536
|
token: 8,
|
|
@@ -2700,8 +2663,8 @@ const feature$12 = {
|
|
|
2700
2663
|
offset = closeEnd;
|
|
2701
2664
|
}
|
|
2702
2665
|
}
|
|
2703
|
-
if (end < 0)
|
|
2704
|
-
appendInlineToken(tokens,
|
|
2666
|
+
if (end < 0) return start + 1;
|
|
2667
|
+
appendInlineToken(tokens, 2, start, end);
|
|
2705
2668
|
return end;
|
|
2706
2669
|
}
|
|
2707
2670
|
}],
|
|
@@ -3075,20 +3038,11 @@ const blockStarts$2 = [{
|
|
|
3075
3038
|
}];
|
|
3076
3039
|
//#endregion
|
|
3077
3040
|
//#region src/profile/features/component/inline.ts
|
|
3041
|
+
const allowedPrevious = /[ \t\n\r\p{sc=Han}\p{sc=Hira}\p{sc=Kana}\p{sc=Hang}\p{P}]/u;
|
|
3078
3042
|
function inlineComponentEnd(source, start) {
|
|
3079
|
-
const
|
|
3080
|
-
if (start
|
|
3081
|
-
|
|
3082
|
-
}
|
|
3083
|
-
const inlineScans = [{
|
|
3084
|
-
marker: 58,
|
|
3085
|
-
scan(source, start, tokens) {
|
|
3086
|
-
const end = inlineComponentEnd(source, start);
|
|
3087
|
-
if (end === void 0) return -1;
|
|
3088
|
-
appendInlineToken(tokens, 33, start, end);
|
|
3089
|
-
return end;
|
|
3090
|
-
}
|
|
3091
|
-
}];
|
|
3043
|
+
const prev = source[start - 1];
|
|
3044
|
+
if (start <= 0 || prev !== ":" && allowedPrevious.test(prev)) return componentNameEnd(source, start + 1, false);
|
|
3045
|
+
}
|
|
3092
3046
|
function appendLinkCandidates(target, candidates) {
|
|
3093
3047
|
for (const candidate of candidates) {
|
|
3094
3048
|
candidate.inLinkLabel = true;
|
|
@@ -3199,7 +3153,8 @@ function copyRange(target, tokens, start, end, inLinkLabel, normalClosers) {
|
|
|
3199
3153
|
const tokenEnd = inlineTokenEnd(tokens, index);
|
|
3200
3154
|
const fragmentStart = Math.max(start, tokenStart);
|
|
3201
3155
|
const fragmentEnd = Math.min(end, tokenEnd);
|
|
3202
|
-
|
|
3156
|
+
if (inLinkLabel && (kind === 20 || normalClosers.has(tokenStart) && (kind === 21 || kind === 22)) || fragmentStart !== tokenStart || fragmentEnd !== tokenEnd) continue;
|
|
3157
|
+
appendInlineToken(target, kind, tokenStart, tokenEnd, inlineTokenFlags(tokens, index));
|
|
3203
3158
|
}
|
|
3204
3159
|
}
|
|
3205
3160
|
function emitRange(target, tokens, start, end, nested, inLinkLabel, normalClosers) {
|
|
@@ -3238,7 +3193,15 @@ const feature$10 = {
|
|
|
3238
3193
|
starts: blockStarts$2
|
|
3239
3194
|
},
|
|
3240
3195
|
inline: {
|
|
3241
|
-
scan:
|
|
3196
|
+
scan: [{
|
|
3197
|
+
marker: 58,
|
|
3198
|
+
scan(source, start, tokens) {
|
|
3199
|
+
const end = inlineComponentEnd(source, start);
|
|
3200
|
+
if (end === void 0) return -1;
|
|
3201
|
+
appendInlineToken(tokens, 33, start, end);
|
|
3202
|
+
return end;
|
|
3203
|
+
}
|
|
3204
|
+
}],
|
|
3242
3205
|
resolve: { transform: transformComponentTokens },
|
|
3243
3206
|
build: [{
|
|
3244
3207
|
kind: "container",
|
|
@@ -3451,7 +3414,6 @@ const transformFootnoteTokens = (source, tokens, context) => {
|
|
|
3451
3414
|
result = [];
|
|
3452
3415
|
for (let prefix = 0; prefix < index; prefix++) copyInlineToken(result, tokens, prefix);
|
|
3453
3416
|
}
|
|
3454
|
-
if (kind === 19) appendInlineToken(result, 9, start, labelStart, inlineTokenFlags(tokens, index));
|
|
3455
3417
|
appendInlineToken(result, 31, labelStart, label.end, inlineTokenFlags(tokens, index));
|
|
3456
3418
|
index = close;
|
|
3457
3419
|
continue;
|
|
@@ -3486,16 +3448,33 @@ const feature$9 = {
|
|
|
3486
3448
|
};
|
|
3487
3449
|
//#endregion
|
|
3488
3450
|
//#region src/profile/features/formatting.ts
|
|
3451
|
+
const scanFormatting = (source, start, tokens) => {
|
|
3452
|
+
const code = source.charCodeAt(start);
|
|
3453
|
+
const end = inlineMarkerRunEnd(source, start);
|
|
3454
|
+
appendInlineToken(tokens, code === 42 ? 10 : code === 95 ? 11 : 12, start, end);
|
|
3455
|
+
return end;
|
|
3456
|
+
};
|
|
3457
|
+
function createFormattingPair(type, open, close) {
|
|
3458
|
+
return {
|
|
3459
|
+
kind: "pair",
|
|
3460
|
+
open,
|
|
3461
|
+
close,
|
|
3462
|
+
build(openToken, closeToken, sourceSpan, children) {
|
|
3463
|
+
return {
|
|
3464
|
+
type,
|
|
3465
|
+
children,
|
|
3466
|
+
position: sourceSpan
|
|
3467
|
+
};
|
|
3468
|
+
}
|
|
3469
|
+
};
|
|
3470
|
+
}
|
|
3471
|
+
const emphasisPair = createFormattingPair("emphasis", 13, 14);
|
|
3472
|
+
const strongPair = createFormattingPair("strong", 15, 16);
|
|
3473
|
+
const deletePair = createFormattingPair("delete", 17, 18);
|
|
3489
3474
|
const asteriskDelimiter = {
|
|
3490
3475
|
token: 10,
|
|
3491
|
-
single:
|
|
3492
|
-
|
|
3493
|
-
close: 14
|
|
3494
|
-
},
|
|
3495
|
-
double: {
|
|
3496
|
-
open: 15,
|
|
3497
|
-
close: 16
|
|
3498
|
-
},
|
|
3476
|
+
single: emphasisPair,
|
|
3477
|
+
double: strongPair,
|
|
3499
3478
|
pairing: {
|
|
3500
3479
|
kind: "partial",
|
|
3501
3480
|
ruleOfThree: true
|
|
@@ -3503,14 +3482,8 @@ const asteriskDelimiter = {
|
|
|
3503
3482
|
};
|
|
3504
3483
|
const underscoreDelimiter = {
|
|
3505
3484
|
token: 11,
|
|
3506
|
-
single:
|
|
3507
|
-
|
|
3508
|
-
close: 14
|
|
3509
|
-
},
|
|
3510
|
-
double: {
|
|
3511
|
-
open: 15,
|
|
3512
|
-
close: 16
|
|
3513
|
-
},
|
|
3485
|
+
single: emphasisPair,
|
|
3486
|
+
double: strongPair,
|
|
3514
3487
|
pairing: {
|
|
3515
3488
|
kind: "partial",
|
|
3516
3489
|
ruleOfThree: true
|
|
@@ -3519,34 +3492,10 @@ const underscoreDelimiter = {
|
|
|
3519
3492
|
};
|
|
3520
3493
|
const strikethroughDelimiter = {
|
|
3521
3494
|
token: 12,
|
|
3522
|
-
double:
|
|
3523
|
-
open: 17,
|
|
3524
|
-
close: 18
|
|
3525
|
-
},
|
|
3495
|
+
double: deletePair,
|
|
3526
3496
|
pairing: { kind: "whole" }
|
|
3527
3497
|
};
|
|
3528
|
-
const scanFormatting = (source, start, tokens) => {
|
|
3529
|
-
const code = source.charCodeAt(start);
|
|
3530
|
-
const end = inlineMarkerRunEnd(source, start);
|
|
3531
|
-
appendInlineToken(tokens, code === 42 ? 10 : code === 95 ? 11 : 12, start, end);
|
|
3532
|
-
return end;
|
|
3533
|
-
};
|
|
3534
|
-
function createBuildFormatting(type) {
|
|
3535
|
-
return (openToken, closeToken, sourceSpan, children) => ({
|
|
3536
|
-
type,
|
|
3537
|
-
children,
|
|
3538
|
-
position: sourceSpan
|
|
3539
|
-
});
|
|
3540
|
-
}
|
|
3541
3498
|
function feature$8(strikethroughOptions) {
|
|
3542
|
-
const delimiters = [asteriskDelimiter, underscoreDelimiter];
|
|
3543
|
-
const scans = [{
|
|
3544
|
-
marker: 42,
|
|
3545
|
-
scan: scanFormatting
|
|
3546
|
-
}, {
|
|
3547
|
-
marker: 95,
|
|
3548
|
-
scan: scanFormatting
|
|
3549
|
-
}];
|
|
3550
3499
|
const builds = [
|
|
3551
3500
|
{
|
|
3552
3501
|
kind: "leaf",
|
|
@@ -3558,37 +3507,30 @@ function feature$8(strikethroughOptions) {
|
|
|
3558
3507
|
token: 11,
|
|
3559
3508
|
build: buildInlineText
|
|
3560
3509
|
},
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
open: 13,
|
|
3564
|
-
close: 14,
|
|
3565
|
-
build: createBuildFormatting("emphasis")
|
|
3566
|
-
},
|
|
3567
|
-
{
|
|
3568
|
-
kind: "pair",
|
|
3569
|
-
open: 15,
|
|
3570
|
-
close: 16,
|
|
3571
|
-
build: createBuildFormatting("strong")
|
|
3572
|
-
}
|
|
3510
|
+
emphasisPair,
|
|
3511
|
+
strongPair
|
|
3573
3512
|
];
|
|
3513
|
+
const delimiters = [asteriskDelimiter, underscoreDelimiter];
|
|
3514
|
+
const scans = [{
|
|
3515
|
+
marker: 42,
|
|
3516
|
+
scan: scanFormatting
|
|
3517
|
+
}, {
|
|
3518
|
+
marker: 95,
|
|
3519
|
+
scan: scanFormatting
|
|
3520
|
+
}];
|
|
3574
3521
|
if (strikethroughOptions) {
|
|
3575
|
-
scans.push({
|
|
3576
|
-
marker: 126,
|
|
3577
|
-
scan: scanFormatting
|
|
3578
|
-
});
|
|
3579
|
-
delimiters.push(typeof strikethroughOptions !== "object" || strikethroughOptions.singleTilde !== false ? {
|
|
3580
|
-
...strikethroughDelimiter,
|
|
3581
|
-
single: strikethroughDelimiter.double
|
|
3582
|
-
} : strikethroughDelimiter);
|
|
3583
3522
|
builds.push({
|
|
3584
3523
|
kind: "leaf",
|
|
3585
3524
|
token: 12,
|
|
3586
3525
|
build: buildInlineText
|
|
3587
|
-
},
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3526
|
+
}, deletePair);
|
|
3527
|
+
delimiters.push(typeof strikethroughOptions !== "object" || strikethroughOptions.singleTilde !== false ? {
|
|
3528
|
+
...strikethroughDelimiter,
|
|
3529
|
+
single: deletePair
|
|
3530
|
+
} : strikethroughDelimiter);
|
|
3531
|
+
scans.push({
|
|
3532
|
+
marker: 126,
|
|
3533
|
+
scan: scanFormatting
|
|
3592
3534
|
});
|
|
3593
3535
|
}
|
|
3594
3536
|
return { inline: {
|
|
@@ -3864,10 +3806,7 @@ const feature$6 = {
|
|
|
3864
3806
|
end = matchInlinePatternEnd(inlineHtml, source, start);
|
|
3865
3807
|
kind = 5;
|
|
3866
3808
|
}
|
|
3867
|
-
if (end < 0)
|
|
3868
|
-
end = start + 1;
|
|
3869
|
-
kind = 39;
|
|
3870
|
-
}
|
|
3809
|
+
if (end < 0) return start + 1;
|
|
3871
3810
|
appendInlineToken(tokens, kind, start, end);
|
|
3872
3811
|
return end;
|
|
3873
3812
|
}
|
|
@@ -4060,9 +3999,9 @@ const feature$5 = { inline: {
|
|
|
4060
3999
|
{
|
|
4061
4000
|
marker: 33,
|
|
4062
4001
|
scan(source, start, tokens) {
|
|
4063
|
-
|
|
4064
|
-
const end = start +
|
|
4065
|
-
appendInlineToken(tokens,
|
|
4002
|
+
if (source.charCodeAt(start + 1) !== 91) return start + 1;
|
|
4003
|
+
const end = start + 2;
|
|
4004
|
+
appendInlineToken(tokens, 19, start, end);
|
|
4066
4005
|
return end;
|
|
4067
4006
|
}
|
|
4068
4007
|
},
|
|
@@ -4283,11 +4222,17 @@ function hasTaskListContent(source, tokens, firstChunk, contentStart) {
|
|
|
4283
4222
|
}
|
|
4284
4223
|
function childrenSpread(tokenStart, stripBlockQuotes, context, nestedRule) {
|
|
4285
4224
|
const structure = context.structure;
|
|
4225
|
+
const tokens = structure.tokens;
|
|
4286
4226
|
let previous;
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4227
|
+
const tokenEnd = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
4228
|
+
for (let child = tokenStart + 1; child < tokenEnd;) {
|
|
4229
|
+
const length = tokens.nodeLength(child);
|
|
4230
|
+
if (length > 0 && (nestedRule === void 0 ? structure.isBlock(child) : structure.isRule(child, nestedRule))) {
|
|
4231
|
+
const current = payloadBounds(child, context);
|
|
4232
|
+
if (previous && hasBlankLineBetween(context.source, previous.end, current.start, stripBlockQuotes)) return true;
|
|
4233
|
+
previous = current;
|
|
4234
|
+
}
|
|
4235
|
+
child += length || 1;
|
|
4291
4236
|
}
|
|
4292
4237
|
return false;
|
|
4293
4238
|
}
|
|
@@ -4308,8 +4253,14 @@ const buildListItem = (tokenStart, context) => {
|
|
|
4308
4253
|
function createBuildList(ordered) {
|
|
4309
4254
|
return (tokenStart, context) => {
|
|
4310
4255
|
const structure = context.structure;
|
|
4256
|
+
const tokens = structure.tokens;
|
|
4311
4257
|
const items = [];
|
|
4312
|
-
|
|
4258
|
+
const tokenEnd = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
4259
|
+
for (let child = tokenStart + 1; child < tokenEnd;) {
|
|
4260
|
+
const length = tokens.nodeLength(child);
|
|
4261
|
+
if (length > 0 && structure.isRule(child, 17)) items.push(buildListItem(child, context));
|
|
4262
|
+
child += length || 1;
|
|
4263
|
+
}
|
|
4313
4264
|
return {
|
|
4314
4265
|
type: "list",
|
|
4315
4266
|
ordered,
|
|
@@ -4540,8 +4491,8 @@ function createMathScanRule(singleDollarTextMath) {
|
|
|
4540
4491
|
close = closeEnd;
|
|
4541
4492
|
}
|
|
4542
4493
|
}
|
|
4543
|
-
if (end < 0)
|
|
4544
|
-
appendInlineToken(tokens,
|
|
4494
|
+
if (end < 0) return openEnd;
|
|
4495
|
+
appendInlineToken(tokens, 3, start, end);
|
|
4545
4496
|
return end;
|
|
4546
4497
|
}
|
|
4547
4498
|
};
|