satorigear 0.0.9 → 0.0.11
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 +13 -12
- package/dist/index.d.mts +10 -24
- package/dist/index.mjs +1276 -1443
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { decodeString } from "micromark-util-decode-string";
|
|
2
2
|
import { htmlBlockNames, htmlRawNames } from "micromark-util-html-tag-name";
|
|
3
|
-
|
|
3
|
+
// src/block/lines.ts
|
|
4
4
|
var BlockLines = class BlockLines {
|
|
5
5
|
#fields;
|
|
6
6
|
#length = 0;
|
|
7
7
|
#locatorField = 0;
|
|
8
|
-
#relativeStart = Infinity;
|
|
9
8
|
#sourceLength;
|
|
10
9
|
#lineEndingsNormalized = true;
|
|
11
10
|
constructor(sourceLength = 0, lineCapacity = 4) {
|
|
12
11
|
this.#sourceLength = sourceLength;
|
|
13
12
|
this.#fields = new Int32Array(lineCapacity * 4);
|
|
14
13
|
}
|
|
15
|
-
static from(source, start
|
|
14
|
+
static from(source, start, limit) {
|
|
16
15
|
const sourceLength = source.length;
|
|
17
16
|
if (start > 0 || limit < sourceLength) source = source.slice(start, limit);
|
|
18
17
|
const lines = new BlockLines(sourceLength, Math.min(source.length + 15 >>> 4, 16384));
|
|
@@ -23,7 +22,6 @@ var BlockLines = class BlockLines {
|
|
|
23
22
|
scan(source) {
|
|
24
23
|
this.#sourceLength = source.length;
|
|
25
24
|
this.#locatorField = 0;
|
|
26
|
-
this.#relativeStart = Infinity;
|
|
27
25
|
const lineCapacity = Math.min(source.length + 15 >>> 4, 16384);
|
|
28
26
|
this.#ensureCapacity(lineCapacity * 4);
|
|
29
27
|
this.#length = BlockLines.#scan(source, this);
|
|
@@ -40,11 +38,11 @@ var BlockLines = class BlockLines {
|
|
|
40
38
|
while (start < limit) {
|
|
41
39
|
let end = lineFeed;
|
|
42
40
|
let next = end + 1;
|
|
43
|
-
if (carriageReturn
|
|
41
|
+
if (carriageReturn !== -1 && (end < 0 || carriageReturn < end)) {
|
|
44
42
|
end = carriageReturn;
|
|
45
43
|
next = end + (source.charCodeAt(end + 1) === 10 ? 2 : 1);
|
|
46
44
|
carriageReturn = source.indexOf("\r", next);
|
|
47
|
-
if (lineFeed < next) lineFeed = source.indexOf("\n", next);
|
|
45
|
+
if (lineFeed !== -1 && lineFeed < next) lineFeed = source.indexOf("\n", next);
|
|
48
46
|
} else if (lineFeed < 0) end = next = limit;
|
|
49
47
|
else lineFeed = source.indexOf("\n", next);
|
|
50
48
|
if (field >= fields.length) {
|
|
@@ -63,13 +61,13 @@ var BlockLines = class BlockLines {
|
|
|
63
61
|
return this.#length;
|
|
64
62
|
}
|
|
65
63
|
start(index) {
|
|
66
|
-
return this.#
|
|
64
|
+
return this.#fields[index * 4 + 0];
|
|
67
65
|
}
|
|
68
66
|
end(index) {
|
|
69
|
-
return this.#
|
|
67
|
+
return this.#fields[index * 4 + 1];
|
|
70
68
|
}
|
|
71
69
|
next(index) {
|
|
72
|
-
return this.#
|
|
70
|
+
return this.#fields[index * 4 + 2];
|
|
73
71
|
}
|
|
74
72
|
prefixColumns(index) {
|
|
75
73
|
return this.#fields[index * 4 + 3] >>> 1;
|
|
@@ -103,15 +101,15 @@ var BlockLines = class BlockLines {
|
|
|
103
101
|
};
|
|
104
102
|
const fields = this.#fields;
|
|
105
103
|
const sourceLength = this.#sourceLength;
|
|
106
|
-
if (offset === sourceLength &&
|
|
104
|
+
if (offset === sourceLength && fields[fieldLength - 4 + 1] < sourceLength) return {
|
|
107
105
|
line: fieldLength / 4 + 1,
|
|
108
106
|
column: 1,
|
|
109
107
|
offset
|
|
110
108
|
};
|
|
111
109
|
let field = this.#locatorField;
|
|
112
|
-
let start =
|
|
110
|
+
let start = fields[field + 0];
|
|
113
111
|
while (field + 4 < fieldLength) {
|
|
114
|
-
const nextStart =
|
|
112
|
+
const nextStart = fields[field + 4 + 0];
|
|
115
113
|
if (nextStart > offset) break;
|
|
116
114
|
field += 4;
|
|
117
115
|
start = nextStart;
|
|
@@ -132,7 +130,7 @@ var BlockLines = class BlockLines {
|
|
|
132
130
|
physicallyContiguous() {
|
|
133
131
|
return this.#sourceLength > 0;
|
|
134
132
|
}
|
|
135
|
-
push(start, end, next, prefixColumns
|
|
133
|
+
push(start, end, next, prefixColumns, lazy) {
|
|
136
134
|
const field = this.#length * 4;
|
|
137
135
|
let fields = this.#fields;
|
|
138
136
|
if (field >= fields.length) {
|
|
@@ -164,7 +162,7 @@ var BlockLines = class BlockLines {
|
|
|
164
162
|
if (consumed < columns) return -1;
|
|
165
163
|
const contentOffset = offset;
|
|
166
164
|
const prefixColumns = consumed - columns;
|
|
167
|
-
if (
|
|
165
|
+
if (trimLineWhitespaceStart(source, offset, end) < end) {
|
|
168
166
|
this.pushFrom(lines, index, contentOffset, prefixColumns);
|
|
169
167
|
return 1;
|
|
170
168
|
}
|
|
@@ -177,19 +175,22 @@ var BlockLines = class BlockLines {
|
|
|
177
175
|
const end = lines.end(index);
|
|
178
176
|
const next = lines.next(index);
|
|
179
177
|
this.#length = 0;
|
|
180
|
-
this.#relativeStart = Infinity;
|
|
181
178
|
this.push(start, end, next, prefixColumns, lazy);
|
|
182
179
|
}
|
|
183
|
-
|
|
180
|
+
view(start, end = this.length) {
|
|
184
181
|
const result = new BlockLines(this.#sourceLength, 0);
|
|
185
|
-
|
|
186
|
-
const fieldEnd = end * 4;
|
|
187
|
-
result.#fields = this.#fields.slice(fieldStart, fieldEnd);
|
|
182
|
+
result.#fields = this.#fields.subarray(start * 4, end * 4);
|
|
188
183
|
result.#length = end - start;
|
|
189
184
|
result.#lineEndingsNormalized = this.#lineEndingsNormalized;
|
|
190
|
-
if (this.#relativeStart < end) result.#relativeStart = Math.max(0, this.#relativeStart - start);
|
|
191
185
|
return result;
|
|
192
186
|
}
|
|
187
|
+
#copy() {
|
|
188
|
+
const next = new BlockLines(this.#sourceLength, 0);
|
|
189
|
+
next.#fields = this.#fields.slice(0, this.#length * 4);
|
|
190
|
+
next.#length = this.#length;
|
|
191
|
+
next.#lineEndingsNormalized = this.#lineEndingsNormalized;
|
|
192
|
+
return next;
|
|
193
|
+
}
|
|
193
194
|
update(nextSource, restartOffset, oldDamageEnd, delta) {
|
|
194
195
|
const suffix = Math.min(this.length, this.indexAtOrAfter(oldDamageEnd + 1) + 1);
|
|
195
196
|
const newSuffixOffset = (suffix < this.length ? this.start(suffix) : nextSource.length - delta) + delta;
|
|
@@ -197,47 +198,24 @@ var BlockLines = class BlockLines {
|
|
|
197
198
|
if (nextSource.charCodeAt(restartOffset - 1) === 13 && nextSource.charCodeAt(restartOffset) === 10) restartOffset = this.start(--prefixEnd);
|
|
198
199
|
const changed = BlockLines.from(nextSource, restartOffset, newSuffixOffset);
|
|
199
200
|
if (delta === 0 && changed.length === suffix - prefixEnd) {
|
|
200
|
-
const next = this
|
|
201
|
-
|
|
201
|
+
const next = this.#copy();
|
|
202
|
+
const target = prefixEnd * 4;
|
|
203
|
+
const fieldLength = changed.length * 4;
|
|
204
|
+
for (let field = 0; field < fieldLength; field++) next.#fields[target + field] = changed.#fields[field];
|
|
202
205
|
next.#lineEndingsNormalized &&= changed.#lineEndingsNormalized;
|
|
203
206
|
return next;
|
|
204
207
|
}
|
|
205
208
|
const next = new BlockLines(nextSource.length, prefixEnd + changed.length + this.length - suffix);
|
|
206
|
-
next.#
|
|
209
|
+
next.#appendRawRange(this, 0, prefixEnd);
|
|
207
210
|
next.#appendRawRange(changed, 0, changed.length);
|
|
208
|
-
next
|
|
211
|
+
const suffixStart = next.length;
|
|
212
|
+
next.#appendRawRange(this, suffix, this.length);
|
|
213
|
+
if (delta !== 0) next.#shiftPositions(suffixStart, delta);
|
|
209
214
|
next.#lineEndingsNormalized = this.#lineEndingsNormalized && changed.#lineEndingsNormalized;
|
|
210
215
|
return next;
|
|
211
216
|
}
|
|
212
217
|
pop() {
|
|
213
|
-
if (this.#length > 0)
|
|
214
|
-
this.#length--;
|
|
215
|
-
if (this.#relativeStart >= this.length) this.#relativeStart = Infinity;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
#setAbsoluteFrom(index, lines, line) {
|
|
219
|
-
const field = index * 4;
|
|
220
|
-
const sourceField = line * 4;
|
|
221
|
-
const shift = index >= this.#relativeStart ? -this.#sourceLength - 1 : 0;
|
|
222
|
-
this.#fields[field + 0] = lines.#fields[sourceField + 0] + shift;
|
|
223
|
-
this.#fields[field + 1] = lines.#fields[sourceField + 1] + shift;
|
|
224
|
-
this.#fields[field + 2] = lines.#fields[sourceField + 2] + shift;
|
|
225
|
-
this.#fields[field + 3] = lines.#fields[sourceField + 3];
|
|
226
|
-
}
|
|
227
|
-
#appendAbsoluteRange(lines, start, end) {
|
|
228
|
-
const boundary = Math.max(start, Math.min(end, lines.#relativeStart));
|
|
229
|
-
this.#appendRawRange(lines, start, boundary);
|
|
230
|
-
const relativeStart = this.length;
|
|
231
|
-
this.#appendRawRange(lines, boundary, end);
|
|
232
|
-
this.#shiftPositions(relativeStart, lines.#sourceLength + 1);
|
|
233
|
-
}
|
|
234
|
-
#appendRelativeRange(lines, start = 0, end = lines.length) {
|
|
235
|
-
this.#relativeStart = this.length;
|
|
236
|
-
const boundary = Math.max(start, Math.min(end, lines.#relativeStart));
|
|
237
|
-
const absoluteStart = this.length;
|
|
238
|
-
this.#appendRawRange(lines, start, boundary);
|
|
239
|
-
this.#shiftPositions(absoluteStart, -lines.#sourceLength - 1);
|
|
240
|
-
this.#appendRawRange(lines, boundary, end);
|
|
218
|
+
if (this.#length > 0) this.#length--;
|
|
241
219
|
}
|
|
242
220
|
#appendRawRange(lines, start, end) {
|
|
243
221
|
if (start >= end) return;
|
|
@@ -259,9 +237,6 @@ var BlockLines = class BlockLines {
|
|
|
259
237
|
nextFields.set(fields);
|
|
260
238
|
this.#fields = nextFields;
|
|
261
239
|
}
|
|
262
|
-
#position(position) {
|
|
263
|
-
return position < 0 ? position + this.#sourceLength + 1 : position;
|
|
264
|
-
}
|
|
265
240
|
#shiftPositions(start, delta) {
|
|
266
241
|
const fields = this.#fields;
|
|
267
242
|
const fieldLength = this.#length * 4;
|
|
@@ -295,9 +270,9 @@ function lineIndentOffset(source, lines, index) {
|
|
|
295
270
|
}
|
|
296
271
|
function isBlankLine(source, lines, index) {
|
|
297
272
|
const end = lines.end(index);
|
|
298
|
-
return
|
|
273
|
+
return trimLineWhitespaceStart(source, lines.start(index), end) === end;
|
|
299
274
|
}
|
|
300
|
-
function
|
|
275
|
+
function trimLineWhitespaceStart(source, start, end) {
|
|
301
276
|
while (start < end) {
|
|
302
277
|
const code = source.charCodeAt(start);
|
|
303
278
|
if (code !== 32 && code !== 9) break;
|
|
@@ -305,45 +280,34 @@ function skipLineWhitespace(source, start, end) {
|
|
|
305
280
|
}
|
|
306
281
|
return start;
|
|
307
282
|
}
|
|
283
|
+
function trimLineWhitespaceEnd(source, start, end) {
|
|
284
|
+
while (end > start) {
|
|
285
|
+
const code = source.charCodeAt(end - 1);
|
|
286
|
+
if (code !== 32 && code !== 9) break;
|
|
287
|
+
end--;
|
|
288
|
+
}
|
|
289
|
+
return end;
|
|
290
|
+
}
|
|
308
291
|
function physicalColumnAt(source, offset) {
|
|
309
292
|
let start = offset;
|
|
310
|
-
while (start > 0
|
|
293
|
+
while (start > 0) {
|
|
294
|
+
const code = source.charCodeAt(start - 1);
|
|
295
|
+
if (code === 10 || code === 13) break;
|
|
296
|
+
start--;
|
|
297
|
+
}
|
|
311
298
|
let column = 0;
|
|
312
299
|
while (start < offset) {
|
|
313
|
-
column += source
|
|
300
|
+
column += source.charCodeAt(start) === 9 ? 4 - column % 4 : 1;
|
|
314
301
|
start++;
|
|
315
302
|
}
|
|
316
303
|
return column;
|
|
317
304
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
let offset = lines.start(index);
|
|
322
|
-
let logicalColumn = prefixColumns;
|
|
323
|
-
let physicalColumn = physicalColumnAt(source, offset);
|
|
324
|
-
const end = lines.end(index);
|
|
325
|
-
while (offset < end && logicalColumn < 4 && (source[offset] === " " || source[offset] === " ")) {
|
|
326
|
-
if (source[offset] === " ") {
|
|
327
|
-
result += " ";
|
|
328
|
-
logicalColumn++;
|
|
329
|
-
physicalColumn++;
|
|
330
|
-
} else {
|
|
331
|
-
const logicalWidth = 4 - logicalColumn % 4;
|
|
332
|
-
const physicalWidth = 4 - physicalColumn % 4;
|
|
333
|
-
result += " " + " ".repeat(Math.max(0, physicalWidth - logicalWidth));
|
|
334
|
-
logicalColumn += Math.max(logicalWidth, physicalWidth);
|
|
335
|
-
physicalColumn += physicalWidth;
|
|
336
|
-
}
|
|
337
|
-
offset++;
|
|
338
|
-
}
|
|
339
|
-
return result + source.slice(offset, lines.next(index));
|
|
340
|
-
}
|
|
341
|
-
//#endregion
|
|
342
|
-
//#region src/primitives.ts
|
|
305
|
+
// src/constants/block.ts
|
|
306
|
+
const boundaryBreak = Symbol();
|
|
307
|
+
// src/primitives.ts
|
|
343
308
|
const emptyArray = [];
|
|
344
309
|
const emptySet = new Set();
|
|
345
|
-
|
|
346
|
-
//#region src/block/tokens.ts
|
|
310
|
+
// src/block/tokens.ts
|
|
347
311
|
function copyMetadata(target, source, start, end, targetStart) {
|
|
348
312
|
end = Math.min(end, source.length);
|
|
349
313
|
for (let read = start, write = targetStart; read < end; read++, write++) {
|
|
@@ -356,44 +320,32 @@ var BlockTokenStream = class {
|
|
|
356
320
|
#definitionMembershipChanges;
|
|
357
321
|
#fieldLength = 0;
|
|
358
322
|
#fields = new Int32Array();
|
|
359
|
-
#groupField = -1;
|
|
360
323
|
#metadata;
|
|
361
324
|
#opens = [];
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
constructor(sourceLength = 0) {
|
|
365
|
-
this.#sourceLength = sourceLength;
|
|
366
|
-
}
|
|
367
|
-
reset(sourceLength) {
|
|
325
|
+
constructor() {}
|
|
326
|
+
reset() {
|
|
368
327
|
this.#definitionCounts?.clear();
|
|
369
328
|
this.#definitionMembershipChanges?.clear();
|
|
370
329
|
this.#fieldLength = 0;
|
|
371
|
-
this.#groupField = -1;
|
|
372
330
|
this.#metadata = void 0;
|
|
373
|
-
this.#opens.length = 0;
|
|
374
|
-
this.#relativeStart = Infinity;
|
|
375
|
-
this.#sourceLength = sourceLength;
|
|
331
|
+
if (this.#opens.length) this.#opens.length = 0;
|
|
376
332
|
}
|
|
377
333
|
get length() {
|
|
378
334
|
return this.#fieldLength / 4;
|
|
379
335
|
}
|
|
380
|
-
get sourceLength() {
|
|
381
|
-
return this.#sourceLength;
|
|
382
|
-
}
|
|
383
336
|
hasDefinition(key) {
|
|
384
337
|
return this.#definitionCounts?.has(key) === true;
|
|
385
338
|
}
|
|
386
339
|
hasDefinitions() {
|
|
387
340
|
return !!this.#definitionCounts?.size;
|
|
388
341
|
}
|
|
389
|
-
push(kind, start, end, meta
|
|
390
|
-
const encodedRole = role ?? kind;
|
|
342
|
+
push(kind, start, end, meta) {
|
|
391
343
|
const field = this.#fieldLength;
|
|
392
344
|
this.#ensureCapacity(field + 4);
|
|
393
345
|
this.#fields[field + 0] = kind;
|
|
394
346
|
this.#fields[field + 1] = start;
|
|
395
347
|
this.#fields[field + 2] = end;
|
|
396
|
-
this.#fields[field + 3] =
|
|
348
|
+
this.#fields[field + 3] = kind < 64 ? 0 : this.#indexToken(field, kind);
|
|
397
349
|
this.#fieldLength += 4;
|
|
398
350
|
if (meta) {
|
|
399
351
|
this.#metadata ??= [];
|
|
@@ -402,23 +354,27 @@ var BlockTokenStream = class {
|
|
|
402
354
|
if (definitionKey !== void 0) this.#updateDefinitionCount(definitionKey, 1, false);
|
|
403
355
|
}
|
|
404
356
|
}
|
|
405
|
-
|
|
406
|
-
|
|
357
|
+
closeRange(start, end) {
|
|
358
|
+
const field = this.#fieldLength;
|
|
359
|
+
this.#ensureCapacity(field + 4);
|
|
360
|
+
this.#fields[field + 0] = start < end ? 1 : 0;
|
|
361
|
+
this.#fields[field + 1] = start;
|
|
362
|
+
this.#fields[field + 2] = end;
|
|
363
|
+
this.#fields[field + 3] = 0;
|
|
364
|
+
const open = this.#opens.pop();
|
|
365
|
+
this.#fields[open + 3] = (field - open) / 4 + 1;
|
|
366
|
+
this.#fieldLength += 4;
|
|
367
|
+
}
|
|
368
|
+
#indexToken(field, kind) {
|
|
369
|
+
if (kind < 192) {
|
|
407
370
|
this.#opens.push(field);
|
|
408
371
|
return 0;
|
|
409
372
|
}
|
|
410
|
-
if (
|
|
373
|
+
if (kind < 256) {
|
|
411
374
|
const open = this.#opens.pop();
|
|
412
375
|
this.#fields[open + 3] = (field - open) / 4 + 1;
|
|
413
376
|
return 0;
|
|
414
377
|
}
|
|
415
|
-
if (encodedRole < 320) return 1;
|
|
416
|
-
const previous = field - 4;
|
|
417
|
-
if (this.#groupField >= 0 && this.#fields[previous + 0] >= 320) {
|
|
418
|
-
this.#fields[this.#groupField + 3]++;
|
|
419
|
-
return 0;
|
|
420
|
-
}
|
|
421
|
-
this.#groupField = field;
|
|
422
378
|
return 1;
|
|
423
379
|
}
|
|
424
380
|
nodeLength(index) {
|
|
@@ -444,11 +400,10 @@ var BlockTokenStream = class {
|
|
|
444
400
|
if (damageStart === void 0 || damageEnd === void 0) return true;
|
|
445
401
|
return start === end || end <= damageStart || start >= damageEnd;
|
|
446
402
|
}
|
|
447
|
-
replace(start, end, replacement, damageStart, damageEnd) {
|
|
403
|
+
replace(start, end, replacement, damageStart, damageEnd, sourceDelta) {
|
|
448
404
|
const previousLength = this.length;
|
|
449
405
|
const replacedLength = end - start;
|
|
450
406
|
const replacementLength = replacement.length;
|
|
451
|
-
const sourceDelta = replacement.#sourceLength - this.#sourceLength;
|
|
452
407
|
const overlapLength = Math.min(replacedLength, replacementLength);
|
|
453
408
|
let stablePrefixLength = 0;
|
|
454
409
|
while (stablePrefixLength < overlapLength && this.equalsAfterShift(start + stablePrefixLength, replacement, stablePrefixLength, 0, damageStart, damageEnd)) stablePrefixLength++;
|
|
@@ -466,38 +421,21 @@ var BlockTokenStream = class {
|
|
|
466
421
|
oldEnd,
|
|
467
422
|
oldStart
|
|
468
423
|
};
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
this.#fields[field + 2] += this.#sourceLength + 1;
|
|
473
|
-
}
|
|
474
|
-
else if (this.#relativeStart > end) {
|
|
475
|
-
const relativeEnd = Math.min(this.#relativeStart, previousLength);
|
|
476
|
-
for (let index = end; index < relativeEnd; index++) {
|
|
477
|
-
const field = index * 4;
|
|
478
|
-
this.#fields[field + 1] -= this.#sourceLength + 1;
|
|
479
|
-
this.#fields[field + 2] -= this.#sourceLength + 1;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
424
|
+
const fieldStart = start * 4;
|
|
425
|
+
const replacementFieldLength = replacement.#fieldLength;
|
|
426
|
+
let fieldLength = this.#fieldLength;
|
|
482
427
|
if (end === previousLength) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
this.#fields.set(replacement.#fields.subarray(0, replacement.#fieldLength), fieldStart);
|
|
487
|
-
this.#fieldLength = fieldEnd;
|
|
488
|
-
} else if (replacementLength === replacedLength) {
|
|
489
|
-
const fieldStart = start * 4;
|
|
490
|
-
this.#fields.set(replacement.#fields.subarray(0, replacement.#fieldLength), fieldStart);
|
|
491
|
-
} else {
|
|
492
|
-
const fieldStart = start * 4;
|
|
428
|
+
fieldLength = fieldStart + replacementFieldLength;
|
|
429
|
+
this.#ensureCapacity(fieldLength);
|
|
430
|
+
} else if (replacementLength !== replacedLength) {
|
|
493
431
|
const oldFieldEnd = end * 4;
|
|
494
|
-
const newFieldEnd = fieldStart +
|
|
495
|
-
|
|
496
|
-
this.#ensureCapacity(
|
|
432
|
+
const newFieldEnd = fieldStart + replacementFieldLength;
|
|
433
|
+
fieldLength += newFieldEnd - oldFieldEnd;
|
|
434
|
+
this.#ensureCapacity(fieldLength);
|
|
497
435
|
this.#fields.copyWithin(newFieldEnd, oldFieldEnd, this.#fieldLength);
|
|
498
|
-
this.#fields.set(replacement.#fields.subarray(0, replacement.#fieldLength), fieldStart);
|
|
499
|
-
this.#fieldLength = nextFieldLength;
|
|
500
436
|
}
|
|
437
|
+
this.#fields.set(replacement.#fields.subarray(0, replacementFieldLength), fieldStart);
|
|
438
|
+
this.#fieldLength = fieldLength;
|
|
501
439
|
const indexDelta = replacementLength - replacedLength;
|
|
502
440
|
if (end === previousLength || indexDelta === 0) {
|
|
503
441
|
const metadata = this.#metadata;
|
|
@@ -517,12 +455,16 @@ var BlockTokenStream = class {
|
|
|
517
455
|
this.#metadata = metadata.length > 0 ? metadata : void 0;
|
|
518
456
|
}
|
|
519
457
|
const newSuffixStart = start + replacementLength;
|
|
520
|
-
|
|
521
|
-
|
|
458
|
+
if (sourceDelta !== 0 && newSuffixStart < this.length) {
|
|
459
|
+
const suffixFieldStart = newSuffixStart * 4;
|
|
460
|
+
for (let field = suffixFieldStart; field < this.#fieldLength; field += 4) {
|
|
461
|
+
this.#fields[field + 1] += sourceDelta;
|
|
462
|
+
this.#fields[field + 2] += sourceDelta;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
522
465
|
return change;
|
|
523
466
|
}
|
|
524
467
|
truncate(length) {
|
|
525
|
-
this.#groupField = -1;
|
|
526
468
|
this.#fieldLength = length * 4;
|
|
527
469
|
const metadata = this.#metadata;
|
|
528
470
|
if (metadata) {
|
|
@@ -540,18 +482,19 @@ var BlockTokenStream = class {
|
|
|
540
482
|
this.#fields[index * 4] = kind;
|
|
541
483
|
}
|
|
542
484
|
start(index) {
|
|
543
|
-
return this.#
|
|
485
|
+
return this.#fields[index * 4 + 1];
|
|
544
486
|
}
|
|
545
487
|
setStart(index, start) {
|
|
546
488
|
this.#fields[index * 4 + 1] = start;
|
|
547
489
|
}
|
|
548
490
|
end(index) {
|
|
549
|
-
return this.#
|
|
491
|
+
return this.#fields[index * 4 + 2];
|
|
492
|
+
}
|
|
493
|
+
setEnd(index, end) {
|
|
494
|
+
this.#fields[index * 4 + 2] = end;
|
|
550
495
|
}
|
|
551
496
|
contentEnd(source, index) {
|
|
552
|
-
|
|
553
|
-
const last = source.charCodeAt(end - 1);
|
|
554
|
-
return last === 10 ? end - (source.charCodeAt(end - 2) === 13 ? 2 : 1) : last === 13 ? end - 1 : end;
|
|
497
|
+
return lineContentEnd(source, this.start(index), this.end(index));
|
|
555
498
|
}
|
|
556
499
|
text(source, index) {
|
|
557
500
|
return this.#metadata?.[index]?.text ?? source.slice(this.start(index), this.end(index));
|
|
@@ -559,6 +502,11 @@ var BlockTokenStream = class {
|
|
|
559
502
|
value(index) {
|
|
560
503
|
return this.#metadata?.[index]?.value;
|
|
561
504
|
}
|
|
505
|
+
setValue(index, value) {
|
|
506
|
+
this.#metadata ??= [];
|
|
507
|
+
this.#metadata[index] ??= {};
|
|
508
|
+
this.#metadata[index].value = value;
|
|
509
|
+
}
|
|
562
510
|
definitionKey(index) {
|
|
563
511
|
return this.#metadata?.[index]?.definitionKey;
|
|
564
512
|
}
|
|
@@ -569,7 +517,7 @@ var BlockTokenStream = class {
|
|
|
569
517
|
const nextCount = previousCount + delta;
|
|
570
518
|
if (nextCount === 0) counts.delete(key);
|
|
571
519
|
else counts.set(key, nextCount);
|
|
572
|
-
if (trackMembership && previousCount === 0
|
|
520
|
+
if (trackMembership && (previousCount === 0 || nextCount === 0)) {
|
|
573
521
|
const changes = this.#definitionMembershipChanges ??= new Set();
|
|
574
522
|
if (!changes.delete(key)) changes.add(key);
|
|
575
523
|
}
|
|
@@ -582,19 +530,16 @@ var BlockTokenStream = class {
|
|
|
582
530
|
fields.set(this.#fields.subarray(0, this.#fieldLength));
|
|
583
531
|
this.#fields = fields;
|
|
584
532
|
}
|
|
585
|
-
#position(position) {
|
|
586
|
-
return position < 0 ? position + this.#sourceLength + 1 : position;
|
|
587
|
-
}
|
|
588
533
|
};
|
|
589
|
-
function appendLogicalToken(
|
|
534
|
+
function appendLogicalToken(source, lines, tokens, kind, start, end, value) {
|
|
590
535
|
const count = end - start;
|
|
591
536
|
const tokenStart = lines.start(start);
|
|
592
537
|
const lastLine = end - 1;
|
|
593
538
|
const tokenEnd = lines.next(lastLine);
|
|
594
539
|
let canSliceSource = lines.physicallyContiguous();
|
|
595
540
|
if (!canSliceSource) {
|
|
596
|
-
const previous = source
|
|
597
|
-
canSliceSource = lines.prefixColumns(start) === 0 && (tokenStart === 0 || previous ===
|
|
541
|
+
const previous = source.charCodeAt(tokenStart - 1);
|
|
542
|
+
canSliceSource = lines.prefixColumns(start) === 0 && (tokenStart === 0 || previous === 10 || previous === 13);
|
|
598
543
|
let previousLineEnd = lines.next(start);
|
|
599
544
|
for (let line = start + 1; canSliceSource && line < end; line++) {
|
|
600
545
|
if (lines.prefixColumns(line) !== 0 || lines.start(line) !== previousLineEnd) {
|
|
@@ -607,16 +552,18 @@ function appendLogicalToken(out, kind, source, lines, start, end, value) {
|
|
|
607
552
|
let text;
|
|
608
553
|
if (!canSliceSource) {
|
|
609
554
|
const logicalLines = new Array(count);
|
|
610
|
-
for (let index = 0; index < count; index++)
|
|
555
|
+
for (let index = 0; index < count; index++) {
|
|
556
|
+
const line = start + index;
|
|
557
|
+
logicalLines[index] = " ".repeat(lines.prefixColumns(line)) + source.slice(lines.start(line), lines.next(line));
|
|
558
|
+
}
|
|
611
559
|
text = logicalLines.join("");
|
|
612
560
|
}
|
|
613
|
-
|
|
561
|
+
tokens.push(kind, tokenStart, tokenEnd, text === void 0 && value === void 0 ? void 0 : {
|
|
614
562
|
text,
|
|
615
563
|
value
|
|
616
564
|
});
|
|
617
565
|
}
|
|
618
|
-
|
|
619
|
-
//#region src/block/scanner.ts
|
|
566
|
+
// src/block/scanner.ts
|
|
620
567
|
function sameShiftedBlock(previous, record, next, tokenStart, tokenEnd, delta) {
|
|
621
568
|
const length = previous.nodeLength(record.tokenStart);
|
|
622
569
|
if (length !== tokenEnd - tokenStart) return false;
|
|
@@ -668,7 +615,7 @@ var BlockScanContext = class {
|
|
|
668
615
|
view.resetFrom(lines, index, start, prefixColumns);
|
|
669
616
|
return view;
|
|
670
617
|
}
|
|
671
|
-
scanBlockLines(source, lines,
|
|
618
|
+
scanBlockLines(source, lines, tokens, visit) {
|
|
672
619
|
const profile = this.#profile;
|
|
673
620
|
for (let index = 0; index < lines.length;) {
|
|
674
621
|
let contentOffset = lines.start(index);
|
|
@@ -686,15 +633,15 @@ var BlockScanContext = class {
|
|
|
686
633
|
}
|
|
687
634
|
if (columns > 3) contentOffset = -1;
|
|
688
635
|
const lineStart = index;
|
|
689
|
-
const tokenStart =
|
|
690
|
-
index = profile.dispatch(source, lines, index, contentOffset,
|
|
691
|
-
if (visit(lineStart, index, tokenStart,
|
|
636
|
+
const tokenStart = tokens.length;
|
|
637
|
+
index = profile.dispatch(source, lines, tokens, index, contentOffset, this);
|
|
638
|
+
if (visit?.(lineStart, index, tokenStart, tokens.length)) return;
|
|
692
639
|
}
|
|
693
640
|
}
|
|
694
|
-
scanLines(source, lines,
|
|
641
|
+
scanLines(source, lines, tokens) {
|
|
695
642
|
let blankSeparated = false;
|
|
696
643
|
let previousContentEnd = -1;
|
|
697
|
-
this.scanBlockLines(source, lines,
|
|
644
|
+
this.scanBlockLines(source, lines, tokens, (lineStart, lineEnd) => {
|
|
698
645
|
blankSeparated ||= previousContentEnd >= 0 && lineStart > previousContentEnd;
|
|
699
646
|
previousContentEnd = lineEnd;
|
|
700
647
|
while (previousContentEnd > lineStart && isBlankLine(source, lines, previousContentEnd - 1)) previousContentEnd--;
|
|
@@ -720,14 +667,18 @@ var BlockScanner = class {
|
|
|
720
667
|
this.#context = new BlockScanContext(profile);
|
|
721
668
|
this.builds = profile.builds;
|
|
722
669
|
}
|
|
723
|
-
scan(source) {
|
|
670
|
+
scan(source, indexed) {
|
|
724
671
|
const lines = this.#lines.scan(source);
|
|
672
|
+
const context = this.#context;
|
|
725
673
|
const tokens = this.#tokens;
|
|
726
|
-
|
|
674
|
+
context.resetLookahead();
|
|
675
|
+
tokens.reset();
|
|
676
|
+
if (!indexed) {
|
|
677
|
+
context.scanBlockLines(source, lines, tokens);
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
727
680
|
const records = this.#records;
|
|
728
|
-
const context = this.#context;
|
|
729
681
|
let recordIndex = 0;
|
|
730
|
-
context.resetLookahead();
|
|
731
682
|
context.scanBlockLines(source, lines, tokens, (lineStart, lineEnd, tokenStart) => {
|
|
732
683
|
const end = lines.next(lineEnd - 1);
|
|
733
684
|
const dependencyEnd = Math.max(end, context.consumeLookahead());
|
|
@@ -770,53 +721,40 @@ var BlockScanner = class {
|
|
|
770
721
|
const scanLineStart = nextLines.indexAtOrAfter(restartOffset);
|
|
771
722
|
const stableBlockCount = Math.max(0, restartIndex);
|
|
772
723
|
const oldTokenStart = restartRecord?.tokenStart ?? 0;
|
|
773
|
-
const replacement = new BlockTokenStream(
|
|
724
|
+
const replacement = new BlockTokenStream();
|
|
774
725
|
const rescannedRecords = [];
|
|
775
|
-
const
|
|
726
|
+
const scanLines = scanLineStart === 0 ? nextLines : nextLines.view(scanLineStart);
|
|
776
727
|
let convergedIndex = -1;
|
|
777
|
-
let
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
const
|
|
781
|
-
|
|
782
|
-
context.
|
|
783
|
-
|
|
784
|
-
const
|
|
785
|
-
|
|
786
|
-
const
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
while (convergenceIndex < previousRecords.length && previousRecords[convergenceIndex].start < candidateStart) convergenceIndex++;
|
|
792
|
-
const candidateRecord = previousRecords[convergenceIndex];
|
|
793
|
-
if (candidateRecord?.start + offsetDelta === blockStart && candidateRecord.end + offsetDelta === blockEnd && candidateRecord.dependencyEnd + offsetDelta === dependencyEnd && sameShiftedBlock(this.#tokens, candidateRecord, replacement, tokenStart, tokenEnd, offsetDelta)) {
|
|
794
|
-
replacement.truncate(tokenStart);
|
|
795
|
-
convergedIndex = convergenceIndex;
|
|
796
|
-
return true;
|
|
797
|
-
}
|
|
728
|
+
let convergenceIndex = affectedIndex;
|
|
729
|
+
context.resetLookahead();
|
|
730
|
+
context.scanBlockLines(nextSource, scanLines, replacement, (lineStart, lineEnd, tokenStart, tokenEnd) => {
|
|
731
|
+
const blockStart = scanLines.start(lineStart);
|
|
732
|
+
const blockEnd = scanLines.next(lineEnd - 1);
|
|
733
|
+
const dependencyEnd = Math.max(blockEnd, context.consumeLookahead());
|
|
734
|
+
if (blockEnd >= changedSpan.end) {
|
|
735
|
+
const candidateStart = Math.max(oldChangedEnd, blockStart - offsetDelta);
|
|
736
|
+
while (convergenceIndex < previousRecords.length && previousRecords[convergenceIndex].start < candidateStart) convergenceIndex++;
|
|
737
|
+
const candidateRecord = previousRecords[convergenceIndex];
|
|
738
|
+
if (candidateRecord?.start + offsetDelta === blockStart && candidateRecord.end + offsetDelta === blockEnd && candidateRecord.dependencyEnd + offsetDelta === dependencyEnd && sameShiftedBlock(this.#tokens, candidateRecord, replacement, tokenStart, tokenEnd, offsetDelta)) {
|
|
739
|
+
replacement.truncate(tokenStart);
|
|
740
|
+
convergedIndex = convergenceIndex;
|
|
741
|
+
return true;
|
|
798
742
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
743
|
+
}
|
|
744
|
+
rescannedRecords.push({
|
|
745
|
+
start: blockStart,
|
|
746
|
+
end: blockEnd,
|
|
747
|
+
dependencyEnd,
|
|
748
|
+
tokenStart: oldTokenStart + tokenStart
|
|
805
749
|
});
|
|
806
|
-
|
|
807
|
-
replacement.reset(nextSource.length);
|
|
808
|
-
rescannedRecords.length = 0;
|
|
809
|
-
const expandedEnd = Math.min(nextSource.length, restartOffset + (scanEnd - restartOffset) * 2);
|
|
810
|
-
scanLineEnd = nextLines.indexAtOrAfter(expandedEnd);
|
|
811
|
-
}
|
|
750
|
+
});
|
|
812
751
|
const oldTokenLength = this.#tokens.length;
|
|
813
752
|
const oldTokenEnd = convergedIndex < 0 ? oldTokenLength : previousRecords[convergedIndex].tokenStart;
|
|
814
|
-
const tokenChange = this.#tokens.replace(oldTokenStart, oldTokenEnd, replacement, changedSpan.start, oldChangedEnd);
|
|
753
|
+
const tokenChange = this.#tokens.replace(oldTokenStart, oldTokenEnd, replacement, changedSpan.start, oldChangedEnd, offsetDelta);
|
|
815
754
|
const tokenDelta = tokenChange.newEnd - tokenChange.oldEnd;
|
|
816
755
|
let oldRecordStart = stableBlockCount;
|
|
817
756
|
while (oldRecordStart < previousRecords.length && (previousRecords[oldRecordStart + 1]?.tokenStart ?? oldTokenLength) <= tokenChange.oldStart) oldRecordStart++;
|
|
818
|
-
|
|
819
|
-
while (oldRecordEnd < previousRecords.length && previousRecords[oldRecordEnd].tokenStart < tokenChange.oldEnd) oldRecordEnd++;
|
|
757
|
+
const oldRecordEnd = convergedIndex < 0 ? previousRecords.length : convergedIndex;
|
|
820
758
|
const nextRecords = previousRecords.slice(0, stableBlockCount);
|
|
821
759
|
nextRecords.push(...rescannedRecords);
|
|
822
760
|
const shiftSuffix = offsetDelta !== 0 || tokenDelta !== 0;
|
|
@@ -843,23 +781,10 @@ var BlockScanner = class {
|
|
|
843
781
|
};
|
|
844
782
|
}
|
|
845
783
|
};
|
|
846
|
-
|
|
847
|
-
//#region src/fragment/block.ts
|
|
848
|
-
function blockEnd(tokenStart, context) {
|
|
849
|
-
const tokens = context.structure.tokens;
|
|
850
|
-
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
851
|
-
return close === tokenStart ? tokens.contentEnd(context.source, close) : tokens.end(close);
|
|
852
|
-
}
|
|
784
|
+
// src/fragment/block.ts
|
|
853
785
|
function leafBlockPosition(tokenStart, context) {
|
|
854
786
|
const tokens = context.structure.tokens;
|
|
855
|
-
|
|
856
|
-
return context.locator.positionAt(tokens.start(tokenStart), tokens.contentEnd(context.source, close));
|
|
857
|
-
}
|
|
858
|
-
function fencedBlockPosition(tokenStart, block, context) {
|
|
859
|
-
const tokens = context.structure.tokens;
|
|
860
|
-
const end = tokens.end(tokenStart);
|
|
861
|
-
const positionEnd = block.closed || end < tokens.sourceLength ? blockEnd(tokenStart, context) : end;
|
|
862
|
-
return context.locator.positionAt(tokens.start(tokenStart) + block.markerOffset, positionEnd);
|
|
787
|
+
return context.locator.positionAt(tokens.start(tokenStart), tokens.contentEnd(context.source, tokenStart));
|
|
863
788
|
}
|
|
864
789
|
function buildBlockNode(tokenStart, context) {
|
|
865
790
|
const kind = context.structure.tokens.kind(tokenStart);
|
|
@@ -873,16 +798,21 @@ function buildBlockChildren(tokenStart, context) {
|
|
|
873
798
|
for (let child = tokenStart + 1; child < tokenEnd;) {
|
|
874
799
|
const length = tokens.nodeLength(child);
|
|
875
800
|
if (length > 0) {
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
if (role === 64 || role === 256) children.push(builds[kind](child, context));
|
|
801
|
+
const build = builds[tokens.kind(child)];
|
|
802
|
+
if (build) children.push(build(child, context));
|
|
879
803
|
}
|
|
880
804
|
child += length || 1;
|
|
881
805
|
}
|
|
882
806
|
return children;
|
|
883
807
|
}
|
|
884
|
-
|
|
885
|
-
|
|
808
|
+
// src/source-view.ts
|
|
809
|
+
function cloneLocation(location) {
|
|
810
|
+
return {
|
|
811
|
+
line: location.line,
|
|
812
|
+
column: location.column,
|
|
813
|
+
offset: location.offset
|
|
814
|
+
};
|
|
815
|
+
}
|
|
886
816
|
function containingSegment(segments, offset) {
|
|
887
817
|
let low = 0;
|
|
888
818
|
let high = segments.length >>> 1;
|
|
@@ -896,34 +826,33 @@ function containingSegment(segments, offset) {
|
|
|
896
826
|
var SourceView = class {
|
|
897
827
|
#offset = 0;
|
|
898
828
|
#segments;
|
|
899
|
-
text;
|
|
829
|
+
text = "";
|
|
830
|
+
withBoundaryBreak = false;
|
|
900
831
|
constructor(source, tokens, tokenStart, nodeLength) {
|
|
832
|
+
this.reset(source, tokens, tokenStart, nodeLength);
|
|
833
|
+
}
|
|
834
|
+
reset(source, tokens, tokenStart, nodeLength) {
|
|
835
|
+
this.withBoundaryBreak = tokens.value(tokenStart) === boundaryBreak;
|
|
901
836
|
let token = tokenStart + 1;
|
|
902
837
|
const firstStart = tokens.start(token);
|
|
903
838
|
const tokenEnd = tokenStart + nodeLength;
|
|
904
|
-
let segmentStart = firstStart;
|
|
905
839
|
let end = tokens.end(token++);
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
}
|
|
916
|
-
end = tokens.end(token);
|
|
917
|
-
token++;
|
|
918
|
-
}
|
|
919
|
-
if (parts && segments) {
|
|
920
|
-
parts.push(source.slice(segmentStart, end));
|
|
921
|
-
segments.push(segmentStart - viewEnd, viewEnd + end - segmentStart);
|
|
840
|
+
if (token < tokenEnd && tokens.kind(token) === 1) {
|
|
841
|
+
const parts = [source.slice(firstStart, end)];
|
|
842
|
+
let viewEnd = end - firstStart;
|
|
843
|
+
const segments = [firstStart, viewEnd];
|
|
844
|
+
do {
|
|
845
|
+
const start = tokens.start(token);
|
|
846
|
+
end = tokens.end(token++);
|
|
847
|
+
parts.push(source.slice(start, end));
|
|
848
|
+
segments.push(start - viewEnd, viewEnd += end - start);
|
|
849
|
+
} while (token < tokenEnd && tokens.kind(token) === 1);
|
|
922
850
|
this.#segments = segments;
|
|
923
851
|
this.text = parts.join("");
|
|
924
852
|
return;
|
|
925
853
|
}
|
|
926
854
|
this.#offset = firstStart;
|
|
855
|
+
this.#segments = void 0;
|
|
927
856
|
this.text = source.slice(firstStart, end);
|
|
928
857
|
}
|
|
929
858
|
mapOffset(offset) {
|
|
@@ -946,8 +875,7 @@ var SourceView = class {
|
|
|
946
875
|
for (let index = 0; index < segments.length; index += 2) segments[index] += delta;
|
|
947
876
|
}
|
|
948
877
|
};
|
|
949
|
-
|
|
950
|
-
//#region src/inline/region.ts
|
|
878
|
+
// src/inline/region.ts
|
|
951
879
|
const definitionAny = Symbol();
|
|
952
880
|
var TrackedDefinitionLookup = class {
|
|
953
881
|
definitions;
|
|
@@ -972,20 +900,20 @@ var InlineRegion = class {
|
|
|
972
900
|
tokens;
|
|
973
901
|
tokenStart;
|
|
974
902
|
view;
|
|
975
|
-
constructor(profile,
|
|
903
|
+
constructor(profile, tokenStart, view, definitions) {
|
|
976
904
|
this.#profile = profile;
|
|
977
|
-
this.tokenStart =
|
|
978
|
-
this.view =
|
|
979
|
-
this.#updateTokens(
|
|
980
|
-
}
|
|
981
|
-
update(
|
|
982
|
-
this.#updateTokens(
|
|
983
|
-
this.tokenStart =
|
|
984
|
-
this.view =
|
|
905
|
+
this.tokenStart = tokenStart;
|
|
906
|
+
this.view = view;
|
|
907
|
+
this.#updateTokens(view, definitions, emptySet);
|
|
908
|
+
}
|
|
909
|
+
update(tokenStart, view, definitions, definitionMembershipChanges) {
|
|
910
|
+
this.#updateTokens(view, definitions, definitionMembershipChanges);
|
|
911
|
+
this.tokenStart = tokenStart;
|
|
912
|
+
this.view = view;
|
|
985
913
|
return this;
|
|
986
914
|
}
|
|
987
915
|
updateDefinitions(definitions, definitionMembershipChanges) {
|
|
988
|
-
return this.#updateTokens(this.view
|
|
916
|
+
return this.#updateTokens(this.view, definitions, definitionMembershipChanges);
|
|
989
917
|
}
|
|
990
918
|
shift(delta, tokenDelta) {
|
|
991
919
|
this.tokenStart += tokenDelta;
|
|
@@ -1000,13 +928,13 @@ var InlineRegion = class {
|
|
|
1000
928
|
} else for (const key of definitionMembershipChanges) if (dependencies.has(key)) return true;
|
|
1001
929
|
return false;
|
|
1002
930
|
}
|
|
1003
|
-
#updateTokens(
|
|
931
|
+
#updateTokens(view, definitions, definitionMembershipChanges) {
|
|
1004
932
|
const previousTokens = this.#rawTokens;
|
|
1005
|
-
const sourceUnchanged = previousTokens !== void 0 &&
|
|
933
|
+
const sourceUnchanged = previousTokens !== void 0 && view.text === this.view.text;
|
|
1006
934
|
if (sourceUnchanged && !this.#dependenciesChanged(definitionMembershipChanges)) return false;
|
|
1007
935
|
definitions.dependencies = void 0;
|
|
1008
|
-
const rawTokens = sourceUnchanged ? previousTokens : this.#profile.tokenize(
|
|
1009
|
-
const tokens = this.#profile.resolve(
|
|
936
|
+
const rawTokens = sourceUnchanged ? previousTokens : this.#profile.tokenize(view.text, view.withBoundaryBreak);
|
|
937
|
+
const tokens = this.#profile.resolve(view.text, rawTokens, definitions);
|
|
1010
938
|
this.#definitionDependencies = definitions.dependencies ?? emptySet;
|
|
1011
939
|
this.#rawTokens = rawTokens;
|
|
1012
940
|
this.tokens = tokens;
|
|
@@ -1038,55 +966,36 @@ var InlineRegionState = class {
|
|
|
1038
966
|
const definitionMembershipChanges = change?.tokenChange.definitionMembershipChanges ?? emptySet;
|
|
1039
967
|
const regionsByBlock = stableBlockCount === 0 ? [] : previousRegionsByBlock.slice(0, stableBlockCount);
|
|
1040
968
|
let invalidatedBlocks;
|
|
1041
|
-
const bindings = [];
|
|
1042
|
-
const bindingOffsets = [];
|
|
1043
|
-
for (let index = stableBlockCount; index < newRecordEnd; index++) {
|
|
1044
|
-
const tokenStart = structure.records[index].tokenStart;
|
|
1045
|
-
const tokenEnd = tokenStart + tokens.nodeLength(tokenStart);
|
|
1046
|
-
bindingOffsets.push(bindings.length);
|
|
1047
|
-
for (let token = tokenStart; token < tokenEnd; token++) {
|
|
1048
|
-
const nodeLength = tokens.nodeLength(token);
|
|
1049
|
-
if (nodeLength === 0) continue;
|
|
1050
|
-
if (tokens.kind(token) & 32) {
|
|
1051
|
-
if (tokens.kind(token + 1) === 1) bindings.push({
|
|
1052
|
-
tokenStart: token,
|
|
1053
|
-
view: new SourceView(source, tokens, token, nodeLength)
|
|
1054
|
-
});
|
|
1055
|
-
token += nodeLength - 1;
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
regionsByBlock.push(emptyArray);
|
|
1059
|
-
}
|
|
1060
|
-
bindingOffsets.push(bindings.length);
|
|
1061
969
|
const tokenChange = change?.tokenChange;
|
|
1062
970
|
const suffixTokenDelta = tokenChange ? tokenChange.newEnd - tokenChange.oldEnd : 0;
|
|
1063
|
-
for (let index = oldRecordEnd; index < previousRegionsByBlock.length; index++) {
|
|
1064
|
-
const regions = previousRegionsByBlock[index];
|
|
1065
|
-
if (offsetDelta !== 0 || suffixTokenDelta !== 0) for (const region of regions) region.shift(offsetDelta, suffixTokenDelta);
|
|
1066
|
-
regionsByBlock.push(regions);
|
|
1067
|
-
}
|
|
1068
971
|
const displacedRegions = [];
|
|
1069
972
|
for (let index = oldRecordStart; index < oldRecordEnd; index++) for (const region of previousRegionsByBlock[index]) displacedRegions.push(region);
|
|
1070
|
-
const displacedBindingStart = bindingOffsets[Math.min(oldRecordStart, newRecordEnd) - stableBlockCount];
|
|
1071
973
|
let displacedIndex = 0;
|
|
1072
974
|
for (let blockIndex = stableBlockCount; blockIndex < newRecordEnd; blockIndex++) {
|
|
1073
975
|
const previousRegions = blockIndex < oldRecordStart ? previousRegionsByBlock[blockIndex] : void 0;
|
|
1074
|
-
const
|
|
1075
|
-
const
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
const regionIndex =
|
|
976
|
+
const tokenStart = structure.records[blockIndex].tokenStart;
|
|
977
|
+
const tokenEnd = tokenStart + tokens.nodeLength(tokenStart);
|
|
978
|
+
const regions = [];
|
|
979
|
+
for (let token = tokenStart; token < tokenEnd; token++) {
|
|
980
|
+
const nodeLength = tokens.nodeLength(token);
|
|
981
|
+
if (nodeLength <= 1 || tokens.kind(token + 1) !== 1) continue;
|
|
982
|
+
const regionIndex = regions.length;
|
|
1081
983
|
let candidate = previousRegions?.[regionIndex];
|
|
1082
|
-
if (!candidate && tokenChange &&
|
|
1083
|
-
const previousTokenStart =
|
|
984
|
+
if (!candidate && tokenChange && blockIndex >= oldRecordStart) {
|
|
985
|
+
const previousTokenStart = token < tokenChange.oldStart ? token : token >= tokenChange.newEnd ? token - suffixTokenDelta : -1;
|
|
1084
986
|
while (displacedIndex < displacedRegions.length && displacedRegions[displacedIndex].tokenStart < previousTokenStart) displacedIndex++;
|
|
1085
987
|
if (displacedRegions[displacedIndex]?.tokenStart === previousTokenStart) candidate = displacedRegions[displacedIndex++];
|
|
1086
988
|
}
|
|
1087
|
-
|
|
989
|
+
const view = new SourceView(source, tokens, token, nodeLength);
|
|
990
|
+
regions.push(candidate?.update(token, view, this.#lookup, definitionMembershipChanges) ?? new InlineRegion(this.#profile, token, view, this.#lookup));
|
|
991
|
+
token += nodeLength - 1;
|
|
1088
992
|
}
|
|
1089
|
-
regionsByBlock
|
|
993
|
+
regionsByBlock.push(regions);
|
|
994
|
+
}
|
|
995
|
+
for (let index = oldRecordEnd; index < previousRegionsByBlock.length; index++) {
|
|
996
|
+
const regions = previousRegionsByBlock[index];
|
|
997
|
+
if (offsetDelta !== 0 || suffixTokenDelta !== 0) for (const region of regions) region.shift(offsetDelta, suffixTokenDelta);
|
|
998
|
+
regionsByBlock.push(regions);
|
|
1090
999
|
}
|
|
1091
1000
|
if (previousRegionsByBlock.length > 0 && definitionMembershipChanges.size > 0) {
|
|
1092
1001
|
const refreshDefinitions = (start, end) => {
|
|
@@ -1118,8 +1027,7 @@ var InlineRegionCursor = class {
|
|
|
1118
1027
|
return region;
|
|
1119
1028
|
}
|
|
1120
1029
|
};
|
|
1121
|
-
|
|
1122
|
-
//#region src/document.ts
|
|
1030
|
+
// src/document.ts
|
|
1123
1031
|
function applyEdits(source, edits) {
|
|
1124
1032
|
const parts = [];
|
|
1125
1033
|
let cursor = 0;
|
|
@@ -1169,7 +1077,7 @@ var DocumentImpl = class {
|
|
|
1169
1077
|
this.#profile = profile;
|
|
1170
1078
|
this.#source = source;
|
|
1171
1079
|
this.#blockScanner = new BlockScanner(profile.block);
|
|
1172
|
-
this.#blockScanner.scan(source);
|
|
1080
|
+
this.#blockScanner.scan(source, true);
|
|
1173
1081
|
this.#regionState = new InlineRegionState(profile.inline, this.#blockScanner);
|
|
1174
1082
|
this.#updateTree(this.#regionState.update(source));
|
|
1175
1083
|
}
|
|
@@ -1267,9 +1175,9 @@ var DocumentImpl = class {
|
|
|
1267
1175
|
source
|
|
1268
1176
|
};
|
|
1269
1177
|
const start = locator.locationAt(0);
|
|
1270
|
-
const
|
|
1271
|
-
const children =
|
|
1272
|
-
for (let
|
|
1178
|
+
const tokens = blockScanner.tokens;
|
|
1179
|
+
const children = [];
|
|
1180
|
+
for (let token = 0; token < tokens.length; token += tokens.nodeLength(token)) children.push(buildBlockNode(token, context));
|
|
1273
1181
|
return {
|
|
1274
1182
|
type: "root",
|
|
1275
1183
|
children,
|
|
@@ -1280,36 +1188,35 @@ var DocumentImpl = class {
|
|
|
1280
1188
|
};
|
|
1281
1189
|
}
|
|
1282
1190
|
};
|
|
1283
|
-
|
|
1284
|
-
//#region src/block/profile.ts
|
|
1191
|
+
// src/block/profile.ts
|
|
1285
1192
|
function generateBlockDispatch(starts, fallbacks) {
|
|
1286
1193
|
try {
|
|
1287
1194
|
const resolvers = [];
|
|
1288
1195
|
const call = (resolve) => {
|
|
1289
|
-
return `e=r${resolvers.push(resolve) - 1}(s,l,i,o,
|
|
1196
|
+
return `e=r${resolvers.push(resolve) - 1}(s,l,t,i,o,c);if(e!==void 0)return e;`;
|
|
1290
1197
|
};
|
|
1291
1198
|
let cases = "";
|
|
1292
1199
|
for (const code in starts) cases += `case ${code}:${starts[code].map(call).join("")}break;`;
|
|
1293
1200
|
const source = [
|
|
1294
|
-
`return(s,l,i,o,
|
|
1201
|
+
`return(s,l,t,i,o,c)=>{`,
|
|
1295
1202
|
`let e;switch(o<0?-1:s.charCodeAt(o)){${cases}}`,
|
|
1296
1203
|
...fallbacks.map(call),
|
|
1297
|
-
`throw new Error("
|
|
1204
|
+
`throw new Error("No block fallback")}`
|
|
1298
1205
|
].join("");
|
|
1299
1206
|
const names = resolvers.map((resolver, index) => `r${index}`);
|
|
1300
1207
|
return Function(...names, source)(...resolvers);
|
|
1301
1208
|
} catch {
|
|
1302
|
-
return (source, lines, start, contentOffset,
|
|
1209
|
+
return (source, lines, tokens, start, contentOffset, context) => {
|
|
1303
1210
|
const resolvers = starts[contentOffset < 0 ? -1 : source.charCodeAt(contentOffset)];
|
|
1304
1211
|
if (resolvers) for (const resolve of resolvers) {
|
|
1305
|
-
const end = resolve(source, lines, start, contentOffset,
|
|
1212
|
+
const end = resolve(source, lines, tokens, start, contentOffset, context);
|
|
1306
1213
|
if (end !== void 0) return end;
|
|
1307
1214
|
}
|
|
1308
1215
|
for (const fallback of fallbacks) {
|
|
1309
|
-
const end = fallback(source, lines, start, contentOffset,
|
|
1216
|
+
const end = fallback(source, lines, tokens, start, contentOffset, context);
|
|
1310
1217
|
if (end !== void 0) return end;
|
|
1311
1218
|
}
|
|
1312
|
-
throw new Error("
|
|
1219
|
+
throw new Error("No block fallback");
|
|
1313
1220
|
};
|
|
1314
1221
|
}
|
|
1315
1222
|
}
|
|
@@ -1352,9 +1259,41 @@ function compileBlockProfile(features) {
|
|
|
1352
1259
|
lazyContinuationUnwrappers
|
|
1353
1260
|
};
|
|
1354
1261
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1262
|
+
// src/inline/tokens.ts
|
|
1263
|
+
function inlineTokenCount(tokens) {
|
|
1264
|
+
return tokens.length / 4;
|
|
1265
|
+
}
|
|
1266
|
+
function inlineTokenKind(tokens, index) {
|
|
1267
|
+
return tokens[index * 4 + 0];
|
|
1268
|
+
}
|
|
1269
|
+
function inlineTokenStart(tokens, index) {
|
|
1270
|
+
return tokens[index * 4 + 1];
|
|
1271
|
+
}
|
|
1272
|
+
function inlineTokenEnd(tokens, index) {
|
|
1273
|
+
return tokens[index * 4 + 2];
|
|
1274
|
+
}
|
|
1275
|
+
function inlineTokenData(tokens, index) {
|
|
1276
|
+
return tokens[index * 4 + 3];
|
|
1277
|
+
}
|
|
1278
|
+
function setInlineTokenData(tokens, index, data) {
|
|
1279
|
+
tokens[index * 4 + 3] = data;
|
|
1280
|
+
}
|
|
1281
|
+
function rewriteInlineTokenTail(tokens, kind, end) {
|
|
1282
|
+
const offset = tokens.length - 4;
|
|
1283
|
+
tokens[offset + 0] = kind;
|
|
1284
|
+
tokens[offset + 2] = end;
|
|
1285
|
+
}
|
|
1286
|
+
function inlineTokenText(source, tokens, index, startPadding = 0, endPadding = startPadding) {
|
|
1287
|
+
return source.slice(inlineTokenStart(tokens, index) + startPadding, inlineTokenEnd(tokens, index) - endPadding);
|
|
1288
|
+
}
|
|
1289
|
+
function appendInlineToken(target, kind, start, end, data = 0) {
|
|
1290
|
+
target.push(kind, start, end, data);
|
|
1291
|
+
}
|
|
1292
|
+
function copyInlineToken(target, tokens, index) {
|
|
1293
|
+
const offset = index * 4;
|
|
1294
|
+
target.push(tokens[offset], tokens[offset + 1], tokens[offset + 2], tokens[offset + 3]);
|
|
1295
|
+
}
|
|
1296
|
+
// src/inline/tokenize.ts
|
|
1358
1297
|
function matchInlinePatternEnd(pattern, source, start) {
|
|
1359
1298
|
pattern.lastIndex = start;
|
|
1360
1299
|
return pattern.test(source) ? pattern.lastIndex : -1;
|
|
@@ -1365,84 +1304,84 @@ function inlineMarkerRunEnd(source, start) {
|
|
|
1365
1304
|
while (source.charCodeAt(end) === marker) end++;
|
|
1366
1305
|
return end;
|
|
1367
1306
|
}
|
|
1368
|
-
function
|
|
1369
|
-
|
|
1370
|
-
const
|
|
1307
|
+
function implicitSoftBreak(source, start, tokens) {
|
|
1308
|
+
if (start <= (tokens.length ? inlineTokenEnd(tokens, inlineTokenCount(tokens) - 1) : 0)) return false;
|
|
1309
|
+
const previous = source.charCodeAt(start - 1);
|
|
1310
|
+
return previous !== 32 && previous !== 9;
|
|
1311
|
+
}
|
|
1312
|
+
function nextBoundaryOffset(source, boundary, offset) {
|
|
1313
|
+
if (offset >= source.length) return -1;
|
|
1314
|
+
boundary.lastIndex = offset;
|
|
1315
|
+
return boundary.test(source) ? boundary.lastIndex - 1 : -1;
|
|
1316
|
+
}
|
|
1317
|
+
function tokenize(source, boundary, scanners) {
|
|
1371
1318
|
let offset = 0;
|
|
1372
1319
|
while (source.charCodeAt(offset) === 32) offset++;
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1320
|
+
offset = nextBoundaryOffset(source, boundary, offset);
|
|
1321
|
+
if (offset < 0) return emptyArray;
|
|
1322
|
+
const tokens = [];
|
|
1323
|
+
for (; offset >= 0; offset = nextBoundaryOffset(source, boundary, offset)) {
|
|
1377
1324
|
const code = source.charCodeAt(offset);
|
|
1378
1325
|
if (code === 10 || code === 13) {
|
|
1379
|
-
|
|
1380
|
-
let spaces = offset - 2;
|
|
1381
|
-
while (source.charCodeAt(spaces - 1) === 32) spaces--;
|
|
1382
|
-
tokens.push(128, spaces, offset, 0);
|
|
1383
|
-
}
|
|
1326
|
+
const spacesBreak = source.charCodeAt(offset - 1) === 32 && source.charCodeAt(offset - 2) === 32;
|
|
1384
1327
|
const endingStart = offset++;
|
|
1385
1328
|
if (code === 13 && source.charCodeAt(offset) === 10) offset++;
|
|
1386
1329
|
const lineStart = offset;
|
|
1387
1330
|
while (source.charCodeAt(offset) === 32) offset++;
|
|
1388
|
-
|
|
1331
|
+
if (spacesBreak) {
|
|
1332
|
+
let spaces = endingStart - 2;
|
|
1333
|
+
while (source.charCodeAt(spaces - 1) === 32) spaces--;
|
|
1334
|
+
tokens.push(128, spaces, offset, lineStart);
|
|
1335
|
+
} else if (code !== 10 || lineStart !== offset || !implicitSoftBreak(source, endingStart, tokens)) tokens.push(67, endingStart, offset, 0);
|
|
1389
1336
|
continue;
|
|
1390
1337
|
}
|
|
1391
|
-
const scannedEnd =
|
|
1338
|
+
const scannedEnd = scanners[code]?.(source, offset, tokens) ?? offset;
|
|
1392
1339
|
offset = scannedEnd > offset ? scannedEnd : offset + 1;
|
|
1393
1340
|
}
|
|
1394
1341
|
return tokens;
|
|
1395
1342
|
}
|
|
1396
|
-
function generateInlineTokenizer(
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
const
|
|
1401
|
-
const
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
`tokens.push(67,endingStart,offset,lineStart);continue}`,
|
|
1414
|
-
`let scannedEnd;switch(code){${boundaryCodes.map((code, index) => `case ${code}:scannedEnd=scan${index}(source,offset,tokens);break;`).join("")}default:scannedEnd=offset}`,
|
|
1415
|
-
`offset=scannedEnd>offset?scannedEnd:offset+1}`,
|
|
1416
|
-
`return tokens}`
|
|
1417
|
-
].join("");
|
|
1418
|
-
tokenizerFactories.set(key, factory = Function("textBoundary", ...names, source));
|
|
1419
|
-
}
|
|
1420
|
-
return factory(textBoundary, ...boundaryCodes.map((code) => scannerByCode[code]));
|
|
1343
|
+
function generateInlineTokenizer(boundaryFast, boundarySlow, boundaryCodes, scanners) {
|
|
1344
|
+
const names = boundaryCodes.map((code, index) => `s${index}`);
|
|
1345
|
+
const cases = boundaryCodes.map((code, index) => `case ${code}:d=s${index}(s,o,t);break;`).join("");
|
|
1346
|
+
return Function("f", "b", "a", "i", "n", ...names, [
|
|
1347
|
+
`return(s,u)=>{const x=u?b:f;let o=0;while(s.charCodeAt(o)===32)o++;`,
|
|
1348
|
+
`o=n(s,x,o);if(o<0)return a;const t=[];for(;o>=0;o=n(s,x,o)){`,
|
|
1349
|
+
`const c=s.charCodeAt(o);`,
|
|
1350
|
+
`if(c===10||c===13){`,
|
|
1351
|
+
`const k=s.charCodeAt(o-1)===32&&s.charCodeAt(o-2)===32;`,
|
|
1352
|
+
`const r=o++;if(c===13&&s.charCodeAt(o)===10)o++;`,
|
|
1353
|
+
`const l=o;while(s.charCodeAt(o)===32)o++;`,
|
|
1354
|
+
`if(k){let h=r-2;while(s.charCodeAt(h-1)===32)h--;t.push(128,h,o,l)}`,
|
|
1355
|
+
`else if(c!==10||l!==o||!i(s,r,t))t.push(67,r,o,0);continue}`,
|
|
1356
|
+
`let d;switch(c){${cases}default:d=o}`,
|
|
1357
|
+
`o=d>o?d:o+1}`,
|
|
1358
|
+
`return t}`
|
|
1359
|
+
].join(""))(boundaryFast, boundarySlow, emptyArray, implicitSoftBreak, nextBoundaryOffset, ...boundaryCodes.map((code) => scanners[code]));
|
|
1421
1360
|
}
|
|
1422
1361
|
function compileInlineTokenizer(rules) {
|
|
1423
|
-
const
|
|
1362
|
+
const scanners = [];
|
|
1424
1363
|
const boundaryCodes = [];
|
|
1425
1364
|
for (const rule of rules) {
|
|
1426
1365
|
const code = rule.marker;
|
|
1427
|
-
const previous =
|
|
1428
|
-
|
|
1366
|
+
const previous = scanners[code];
|
|
1367
|
+
scanners[code] = previous === void 0 ? rule.scan : (source, start, tokens) => {
|
|
1429
1368
|
const end = previous(source, start, tokens);
|
|
1430
1369
|
return end > start ? end : rule.scan(source, start, tokens);
|
|
1431
1370
|
};
|
|
1432
1371
|
if (previous === void 0) boundaryCodes.push(code);
|
|
1433
1372
|
}
|
|
1434
1373
|
const boundaries = String.fromCharCode(...boundaryCodes).replaceAll(/[\\\]-]/g, "\\$&");
|
|
1435
|
-
const
|
|
1374
|
+
const boundaryFast = new RegExp(`[\\r${boundaries}]`, "g");
|
|
1375
|
+
const boundarySlow = new RegExp(`[\\r${boundaries}]|\\n(?:(?<=[ \\t]\\n)|(?= ))`, "g");
|
|
1436
1376
|
try {
|
|
1437
|
-
return generateInlineTokenizer(
|
|
1377
|
+
return generateInlineTokenizer(boundaryFast, boundarySlow, boundaryCodes, scanners);
|
|
1438
1378
|
} catch {
|
|
1439
|
-
return (source) => tokenize(source,
|
|
1379
|
+
return (source, withBoundaryBreak) => tokenize(source, withBoundaryBreak ? boundarySlow : boundaryFast, scanners);
|
|
1440
1380
|
}
|
|
1441
1381
|
}
|
|
1442
|
-
|
|
1443
|
-
//#region src/inline/profile.ts
|
|
1382
|
+
// src/inline/profile.ts
|
|
1444
1383
|
function compileInlineProfile(features, compileInlineResolver) {
|
|
1445
|
-
const
|
|
1384
|
+
const builders = [];
|
|
1446
1385
|
const delimiters = [];
|
|
1447
1386
|
const scanRules = [];
|
|
1448
1387
|
for (const feature of features) {
|
|
@@ -1452,23 +1391,22 @@ function compileInlineProfile(features, compileInlineResolver) {
|
|
|
1452
1391
|
if (!build) continue;
|
|
1453
1392
|
for (const rule of build) switch (rule.kind) {
|
|
1454
1393
|
case "decorate":
|
|
1455
|
-
|
|
1394
|
+
builders[rule.token] = rule.apply;
|
|
1456
1395
|
break;
|
|
1457
1396
|
case "leaf":
|
|
1458
1397
|
case "text":
|
|
1459
|
-
case "pair":
|
|
1398
|
+
case "pair": builders[rule.token] = rule.build;
|
|
1460
1399
|
}
|
|
1461
1400
|
}
|
|
1462
1401
|
return {
|
|
1463
|
-
|
|
1402
|
+
builders,
|
|
1464
1403
|
resolve: compileInlineResolver(delimiters),
|
|
1465
1404
|
tokenize: compileInlineTokenizer(scanRules)
|
|
1466
1405
|
};
|
|
1467
1406
|
}
|
|
1468
|
-
|
|
1469
|
-
//#region src/profile/features/attributes/block.ts
|
|
1407
|
+
// src/profile/features/attributes/block.ts
|
|
1470
1408
|
const blockDecorators = [{
|
|
1471
|
-
token: [
|
|
1409
|
+
token: [73, 74],
|
|
1472
1410
|
decorate(build) {
|
|
1473
1411
|
return (tokenStart, context) => {
|
|
1474
1412
|
const result = build(tokenStart, context);
|
|
@@ -1483,7 +1421,7 @@ const blockDecorators = [{
|
|
|
1483
1421
|
};
|
|
1484
1422
|
}
|
|
1485
1423
|
}, {
|
|
1486
|
-
token:
|
|
1424
|
+
token: 72,
|
|
1487
1425
|
decorate(build) {
|
|
1488
1426
|
return (tokenStart, context) => {
|
|
1489
1427
|
const result = build(tokenStart, context);
|
|
@@ -1496,49 +1434,16 @@ const blockDecorators = [{
|
|
|
1496
1434
|
};
|
|
1497
1435
|
}
|
|
1498
1436
|
}];
|
|
1499
|
-
|
|
1500
|
-
//#region src/inline/tokens.ts
|
|
1501
|
-
function inlineTokenCount(tokens) {
|
|
1502
|
-
return tokens.length / 4;
|
|
1503
|
-
}
|
|
1504
|
-
function inlineTokenKind(tokens, index) {
|
|
1505
|
-
return tokens[index * 4 + 0];
|
|
1506
|
-
}
|
|
1507
|
-
function inlineTokenStart(tokens, index) {
|
|
1508
|
-
return tokens[index * 4 + 1];
|
|
1509
|
-
}
|
|
1510
|
-
function inlineTokenEnd(tokens, index) {
|
|
1511
|
-
return tokens[index * 4 + 2];
|
|
1512
|
-
}
|
|
1513
|
-
function inlineTokenData(tokens, index) {
|
|
1514
|
-
return tokens[index * 4 + 3];
|
|
1515
|
-
}
|
|
1516
|
-
function setInlineTokenData(tokens, index, data) {
|
|
1517
|
-
tokens[index * 4 + 3] = data;
|
|
1518
|
-
}
|
|
1519
|
-
function rewriteInlineTokenTail(tokens, kind, end) {
|
|
1520
|
-
const offset = tokens.length - 4;
|
|
1521
|
-
tokens[offset + 0] = kind;
|
|
1522
|
-
tokens[offset + 2] = end;
|
|
1523
|
-
}
|
|
1524
|
-
function inlineTokenText(source, tokens, index, startPadding = 0, endPadding = startPadding) {
|
|
1525
|
-
return source.slice(inlineTokenStart(tokens, index) + startPadding, inlineTokenEnd(tokens, index) - endPadding);
|
|
1526
|
-
}
|
|
1527
|
-
function appendInlineToken(target, kind, start, end, data = 0) {
|
|
1528
|
-
target.push(kind, start, end, data);
|
|
1529
|
-
}
|
|
1530
|
-
function copyInlineToken(target, tokens, index) {
|
|
1531
|
-
const offset = index * 4;
|
|
1532
|
-
target.push(tokens[offset], tokens[offset + 1], tokens[offset + 2], tokens[offset + 3]);
|
|
1533
|
-
}
|
|
1534
|
-
//#endregion
|
|
1535
|
-
//#region src/profile/utils.ts
|
|
1437
|
+
// src/profile/utils.ts
|
|
1536
1438
|
const inlineColonBoundary = /[ \t\n\r\p{sc=Han}\p{sc=Hira}\p{sc=Kana}\p{sc=Hang}\p{P}]/u;
|
|
1439
|
+
function isAsciiDigit(code) {
|
|
1440
|
+
return code >= 48 && code <= 57;
|
|
1441
|
+
}
|
|
1537
1442
|
function isAsciiLetter(code) {
|
|
1538
1443
|
return code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
1539
1444
|
}
|
|
1540
|
-
function
|
|
1541
|
-
return code >=
|
|
1445
|
+
function isAsciiPunctuation(code) {
|
|
1446
|
+
return code >= 33 && code <= 47 || code >= 58 && code <= 64 || code >= 91 && code <= 96 || code >= 123 && code <= 126;
|
|
1542
1447
|
}
|
|
1543
1448
|
function isMarkdownWhitespace(code) {
|
|
1544
1449
|
return code === 9 || code === 10 || code === 13 || code === 32;
|
|
@@ -1551,32 +1456,35 @@ function hasInlineColonBoundary(source, start) {
|
|
|
1551
1456
|
function semanticText(value) {
|
|
1552
1457
|
return value.includes("\\") || value.includes("&") ? decodeString(value) : value;
|
|
1553
1458
|
}
|
|
1554
|
-
function
|
|
1459
|
+
function normalizeIdentifier(identifier) {
|
|
1555
1460
|
scan: {
|
|
1556
1461
|
let hasUppercase = false;
|
|
1557
|
-
for (let index = 0; index <
|
|
1558
|
-
const code =
|
|
1462
|
+
for (let index = 0; index < identifier.length; index++) {
|
|
1463
|
+
const code = identifier.charCodeAt(index);
|
|
1559
1464
|
if (code === 32) {
|
|
1560
|
-
if (index === 0 || index + 1 ===
|
|
1465
|
+
if (index === 0 || index + 1 === identifier.length || identifier.charCodeAt(index + 1) === 32) break scan;
|
|
1561
1466
|
continue;
|
|
1562
1467
|
}
|
|
1563
1468
|
if (code < 32 || code > 126) break scan;
|
|
1564
1469
|
if (code >= 65 && code <= 90) hasUppercase = true;
|
|
1565
1470
|
}
|
|
1566
|
-
return hasUppercase ?
|
|
1471
|
+
return hasUppercase ? identifier.toLowerCase() : identifier;
|
|
1567
1472
|
}
|
|
1568
|
-
return
|
|
1473
|
+
return identifier.trim().replace(/[ \t\r\n]+/g, " ").toLowerCase().toUpperCase().toLowerCase();
|
|
1569
1474
|
}
|
|
1570
|
-
|
|
1571
|
-
//#region src/profile/features/attributes/shared.ts
|
|
1475
|
+
// src/profile/features/attributes/shared.ts
|
|
1572
1476
|
const brackets = {
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1477
|
+
[91]: 93,
|
|
1478
|
+
[123]: 125,
|
|
1479
|
+
[40]: 41
|
|
1576
1480
|
};
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1481
|
+
const stops1 = new Set([
|
|
1482
|
+
32,
|
|
1483
|
+
35,
|
|
1484
|
+
46,
|
|
1485
|
+
125
|
|
1486
|
+
]);
|
|
1487
|
+
const stops2 = new Set([32, 125]);
|
|
1580
1488
|
function assignAttribute(attributes, name, value) {
|
|
1581
1489
|
if (name === "class" && typeof value === "string" && typeof attributes.class === "string") attributes.class += ` ${value}`;
|
|
1582
1490
|
else attributes[name] = value;
|
|
@@ -1585,23 +1493,23 @@ function mergeAttributes(target, source) {
|
|
|
1585
1493
|
for (const key in source) assignAttribute(target, key, source[key]);
|
|
1586
1494
|
}
|
|
1587
1495
|
function scanAttributes(source, start, attributes, limit = source.length) {
|
|
1588
|
-
if (source
|
|
1496
|
+
if (source.charCodeAt(start) !== 123 || source.charCodeAt(start + 1) === 123) return;
|
|
1589
1497
|
let offset = start + 1;
|
|
1590
1498
|
const scanUntil = (stops) => {
|
|
1591
1499
|
while (offset < limit) {
|
|
1592
|
-
const
|
|
1593
|
-
if (
|
|
1594
|
-
offset +=
|
|
1500
|
+
const code = source.charCodeAt(offset);
|
|
1501
|
+
if (code === 10 || code === 13 || stops.has(code)) break;
|
|
1502
|
+
offset += code === 92 && offset + 1 < limit ? 2 : 1;
|
|
1595
1503
|
}
|
|
1596
1504
|
};
|
|
1597
1505
|
const scanQuoted = (quote) => {
|
|
1598
1506
|
offset++;
|
|
1599
1507
|
while (offset < limit) {
|
|
1600
|
-
const character = source
|
|
1601
|
-
if (character ===
|
|
1602
|
-
offset += character ===
|
|
1508
|
+
const character = source.charCodeAt(offset);
|
|
1509
|
+
if (character === quote || character === 10 || character === 13) break;
|
|
1510
|
+
offset += character === 92 && offset + 1 < limit ? 2 : 1;
|
|
1603
1511
|
}
|
|
1604
|
-
if (source
|
|
1512
|
+
if (source.charCodeAt(offset) !== quote) return false;
|
|
1605
1513
|
offset++;
|
|
1606
1514
|
return true;
|
|
1607
1515
|
};
|
|
@@ -1609,33 +1517,33 @@ function scanAttributes(source, start, attributes, limit = source.length) {
|
|
|
1609
1517
|
const stack = [close];
|
|
1610
1518
|
offset++;
|
|
1611
1519
|
while (offset < limit && stack.length > 0) {
|
|
1612
|
-
const
|
|
1613
|
-
if (
|
|
1614
|
-
if (
|
|
1520
|
+
const code = source.charCodeAt(offset);
|
|
1521
|
+
if (code === 10 || code === 13) return false;
|
|
1522
|
+
if (code === 92 && offset + 1 < limit) {
|
|
1615
1523
|
offset += 2;
|
|
1616
1524
|
continue;
|
|
1617
1525
|
}
|
|
1618
|
-
if (
|
|
1619
|
-
if (!scanQuoted(
|
|
1526
|
+
if (code === 34 || code === 39 || code === 96) {
|
|
1527
|
+
if (!scanQuoted(code)) return false;
|
|
1620
1528
|
continue;
|
|
1621
1529
|
}
|
|
1622
|
-
const
|
|
1623
|
-
if (
|
|
1624
|
-
else if (
|
|
1530
|
+
const nested = brackets[code];
|
|
1531
|
+
if (nested) stack.push(nested);
|
|
1532
|
+
else if (code === stack.at(-1)) stack.pop();
|
|
1625
1533
|
offset++;
|
|
1626
1534
|
}
|
|
1627
1535
|
return stack.length === 0;
|
|
1628
1536
|
};
|
|
1629
1537
|
while (offset < limit) {
|
|
1630
|
-
|
|
1631
|
-
if (source
|
|
1632
|
-
const marker = source
|
|
1633
|
-
if (marker ===
|
|
1538
|
+
offset = trimLineWhitespaceStart(source, offset, limit);
|
|
1539
|
+
if (source.charCodeAt(offset) === 125) return offset + 1;
|
|
1540
|
+
const marker = source.charCodeAt(offset);
|
|
1541
|
+
if (marker === 46 || marker === 35) {
|
|
1634
1542
|
offset++;
|
|
1635
1543
|
const valueStart = offset;
|
|
1636
|
-
scanUntil(
|
|
1544
|
+
scanUntil(stops1);
|
|
1637
1545
|
if (offset === valueStart) return;
|
|
1638
|
-
if (attributes) assignAttribute(attributes, marker ===
|
|
1546
|
+
if (attributes) assignAttribute(attributes, marker === 46 ? "class" : "id", source.slice(valueStart, offset));
|
|
1639
1547
|
continue;
|
|
1640
1548
|
}
|
|
1641
1549
|
const nameStart = offset;
|
|
@@ -1649,8 +1557,8 @@ function scanAttributes(source, start, attributes, limit = source.length) {
|
|
|
1649
1557
|
offset++;
|
|
1650
1558
|
}
|
|
1651
1559
|
const nameEnd = offset;
|
|
1652
|
-
|
|
1653
|
-
if (source
|
|
1560
|
+
offset = trimLineWhitespaceStart(source, offset, limit);
|
|
1561
|
+
if (source.charCodeAt(offset) !== 61) {
|
|
1654
1562
|
if (attributes) {
|
|
1655
1563
|
const name = source.slice(nameStart, nameEnd);
|
|
1656
1564
|
assignAttribute(attributes, source.charCodeAt(nameStart) === 58 ? name : `:${name}`, "true");
|
|
@@ -1658,19 +1566,19 @@ function scanAttributes(source, start, attributes, limit = source.length) {
|
|
|
1658
1566
|
continue;
|
|
1659
1567
|
}
|
|
1660
1568
|
offset++;
|
|
1661
|
-
|
|
1662
|
-
const character = source
|
|
1569
|
+
offset = trimLineWhitespaceStart(source, offset, limit);
|
|
1570
|
+
const character = source.charCodeAt(offset);
|
|
1663
1571
|
let valueStart = offset;
|
|
1664
1572
|
let valueEnd;
|
|
1665
|
-
if (character ===
|
|
1573
|
+
if (character === 34 || character === 39 || character === 96) {
|
|
1666
1574
|
if (!scanQuoted(character)) return;
|
|
1667
1575
|
valueStart++;
|
|
1668
1576
|
valueEnd = offset - 1;
|
|
1669
|
-
} else if (brackets
|
|
1577
|
+
} else if (character in brackets) {
|
|
1670
1578
|
if (!scanBracketed(brackets[character])) return;
|
|
1671
1579
|
valueEnd = offset;
|
|
1672
1580
|
} else {
|
|
1673
|
-
scanUntil(
|
|
1581
|
+
scanUntil(stops2);
|
|
1674
1582
|
valueEnd = offset;
|
|
1675
1583
|
if (valueEnd === valueStart) return;
|
|
1676
1584
|
}
|
|
@@ -1685,17 +1593,18 @@ function parseAttributes(source, start) {
|
|
|
1685
1593
|
scanAttributes(source, start, attributes);
|
|
1686
1594
|
return attributes;
|
|
1687
1595
|
}
|
|
1688
|
-
|
|
1689
|
-
//#region src/profile/features/attributes/inline.ts
|
|
1596
|
+
// src/profile/features/attributes/inline.ts
|
|
1690
1597
|
function hasVisibleText(source, start, end) {
|
|
1691
1598
|
for (let offset = start; offset < end; offset++) if (!isMarkdownWhitespace(source.charCodeAt(offset))) return true;
|
|
1692
1599
|
return false;
|
|
1693
1600
|
}
|
|
1694
1601
|
function attributeEndAt(source, start) {
|
|
1695
|
-
|
|
1602
|
+
if (source.charCodeAt(start + 1) !== 123) {
|
|
1603
|
+
const code = source.charCodeAt(start - 1);
|
|
1604
|
+
if (code !== 123 && code !== 36) return attributesEnd(source, start);
|
|
1605
|
+
}
|
|
1696
1606
|
}
|
|
1697
|
-
|
|
1698
|
-
//#region src/profile/features/attributes/index.ts
|
|
1607
|
+
// src/profile/features/attributes/index.ts
|
|
1699
1608
|
const feature$18 = {
|
|
1700
1609
|
block: { decorators: blockDecorators },
|
|
1701
1610
|
inline: {
|
|
@@ -1754,8 +1663,7 @@ const feature$18 = {
|
|
|
1754
1663
|
}]
|
|
1755
1664
|
}
|
|
1756
1665
|
};
|
|
1757
|
-
|
|
1758
|
-
//#region src/profile/features/binding.ts
|
|
1666
|
+
// src/profile/features/binding.ts
|
|
1759
1667
|
const feature$17 = { inline: {
|
|
1760
1668
|
scans: [{
|
|
1761
1669
|
marker: 123,
|
|
@@ -1774,7 +1682,7 @@ const feature$17 = { inline: {
|
|
|
1774
1682
|
builds: [{
|
|
1775
1683
|
kind: "leaf",
|
|
1776
1684
|
token: 135,
|
|
1777
|
-
build(tokenIndex,
|
|
1685
|
+
build(tokenIndex, position, context) {
|
|
1778
1686
|
const source = context.view.text;
|
|
1779
1687
|
const tokenStart = inlineTokenStart(context.tokens, tokenIndex);
|
|
1780
1688
|
const start = tokenStart + 2;
|
|
@@ -1789,19 +1697,18 @@ const feature$17 = { inline: {
|
|
|
1789
1697
|
name: "binding",
|
|
1790
1698
|
attributes,
|
|
1791
1699
|
children: [],
|
|
1792
|
-
position
|
|
1700
|
+
position
|
|
1793
1701
|
};
|
|
1794
1702
|
}
|
|
1795
1703
|
}]
|
|
1796
1704
|
} };
|
|
1797
|
-
|
|
1798
|
-
//#region src/profile/features/blockquote.ts
|
|
1705
|
+
// src/profile/features/blockquote.ts
|
|
1799
1706
|
function blockQuoteOffset(source, lines, index, markerOffset) {
|
|
1800
|
-
if (markerOffset < 0 || source
|
|
1707
|
+
if (markerOffset < 0 || source.charCodeAt(markerOffset) !== 62) return;
|
|
1801
1708
|
let offset = markerOffset + 1;
|
|
1802
1709
|
let prefixColumns = lines.prefixColumns(index);
|
|
1803
|
-
if (source
|
|
1804
|
-
else if (source
|
|
1710
|
+
if (source.charCodeAt(offset) === 32) offset++;
|
|
1711
|
+
else if (source.charCodeAt(offset) === 9) {
|
|
1805
1712
|
prefixColumns += 4 - physicalColumnAt(source, offset) % 4 - 1;
|
|
1806
1713
|
offset++;
|
|
1807
1714
|
}
|
|
@@ -1812,16 +1719,17 @@ function blockQuoteOffset(source, lines, index, markerOffset) {
|
|
|
1812
1719
|
}
|
|
1813
1720
|
const feature$16 = { block: {
|
|
1814
1721
|
builds: [{
|
|
1815
|
-
token:
|
|
1722
|
+
token: 72,
|
|
1816
1723
|
build(tokenStart, context) {
|
|
1817
1724
|
const tokens = context.structure.tokens;
|
|
1725
|
+
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
1818
1726
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
1819
1727
|
return {
|
|
1820
1728
|
type: "blockquote",
|
|
1821
1729
|
children: buildBlockChildren(tokenStart, context),
|
|
1822
1730
|
position: {
|
|
1823
1731
|
start,
|
|
1824
|
-
end: context.locator.locationAt(
|
|
1732
|
+
end: context.locator.locationAt(tokens.end(close))
|
|
1825
1733
|
}
|
|
1826
1734
|
};
|
|
1827
1735
|
}
|
|
@@ -1837,32 +1745,32 @@ const feature$16 = { block: {
|
|
|
1837
1745
|
interrupt() {
|
|
1838
1746
|
return true;
|
|
1839
1747
|
},
|
|
1840
|
-
start(source, lines, start, contentOffset,
|
|
1748
|
+
start(source, lines, tokens, start, contentOffset, context) {
|
|
1841
1749
|
const firstMarker = blockQuoteOffset(source, lines, start, contentOffset);
|
|
1842
1750
|
const quoteLines = context.createLineView(lines, start, firstMarker.offset, firstMarker.prefixColumns);
|
|
1843
1751
|
let index = start + 1;
|
|
1844
|
-
let lazyParagraph
|
|
1752
|
+
let lazyParagraph;
|
|
1845
1753
|
for (; index < lines.length; index++) {
|
|
1846
1754
|
const markerOffset = lineIndentOffset(source, lines, index);
|
|
1847
1755
|
const marker = blockQuoteOffset(source, lines, index, markerOffset);
|
|
1848
1756
|
if (marker) {
|
|
1849
1757
|
quoteLines.pushFrom(lines, index, marker.offset, marker.prefixColumns);
|
|
1850
|
-
lazyParagraph =
|
|
1758
|
+
lazyParagraph = void 0;
|
|
1851
1759
|
continue;
|
|
1852
1760
|
}
|
|
1761
|
+
lazyParagraph ??= context.endsWithParagraphLeaf(source, quoteLines, quoteLines.length - 1);
|
|
1853
1762
|
if (!lazyParagraph || markerOffset < 0 && isBlankLine(source, lines, index) || !lines.lazy(index) && context.startsInterruptingBlock(source, lines, index, markerOffset)) break;
|
|
1854
1763
|
quoteLines.pushLazy(lines, index);
|
|
1855
1764
|
}
|
|
1856
|
-
|
|
1857
|
-
context.scanLines(source, quoteLines,
|
|
1858
|
-
const end = quoteLines.
|
|
1859
|
-
|
|
1765
|
+
tokens.push(72, contentOffset, contentOffset + 1);
|
|
1766
|
+
context.scanLines(source, quoteLines, tokens);
|
|
1767
|
+
const end = quoteLines.end(quoteLines.length - 1);
|
|
1768
|
+
tokens.push(192, end, end);
|
|
1860
1769
|
return index;
|
|
1861
1770
|
}
|
|
1862
1771
|
}]
|
|
1863
1772
|
} };
|
|
1864
|
-
|
|
1865
|
-
//#region src/profile/features/break.ts
|
|
1773
|
+
// src/profile/features/break.ts
|
|
1866
1774
|
function isThematicBreak(source, lines, index, contentOffset) {
|
|
1867
1775
|
const marker = source.charCodeAt(contentOffset);
|
|
1868
1776
|
if (marker !== 42 && marker !== 45 && marker !== 95) return false;
|
|
@@ -1894,9 +1802,9 @@ const feature$15 = {
|
|
|
1894
1802
|
interrupt(source, lines, index, contentOffset) {
|
|
1895
1803
|
return isThematicBreak(source, lines, index, contentOffset);
|
|
1896
1804
|
},
|
|
1897
|
-
start(source, lines, start, contentOffset
|
|
1805
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
1898
1806
|
if (!isThematicBreak(source, lines, start, contentOffset)) return;
|
|
1899
|
-
|
|
1807
|
+
tokens.push(256, contentOffset, lines.end(start));
|
|
1900
1808
|
return start + 1;
|
|
1901
1809
|
}
|
|
1902
1810
|
}]
|
|
@@ -1904,17 +1812,20 @@ const feature$15 = {
|
|
|
1904
1812
|
inline: { builds: [{
|
|
1905
1813
|
kind: "leaf",
|
|
1906
1814
|
token: 128,
|
|
1907
|
-
build(tokenIndex,
|
|
1815
|
+
build(tokenIndex, position, context) {
|
|
1816
|
+
const lineStart = inlineTokenData(context.tokens, tokenIndex);
|
|
1908
1817
|
return {
|
|
1909
1818
|
type: "break",
|
|
1910
|
-
position:
|
|
1819
|
+
position: {
|
|
1820
|
+
start: position.start,
|
|
1821
|
+
end: context.locator.locationAt(context.view.mapOffset(lineStart - 1) + 1)
|
|
1822
|
+
}
|
|
1911
1823
|
};
|
|
1912
1824
|
}
|
|
1913
1825
|
}] }
|
|
1914
1826
|
};
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
function fenceAt$1(source, lines, index, rule, markerOffset) {
|
|
1827
|
+
// src/block/fence.ts
|
|
1828
|
+
function fenceAt(source, lines, index, rule, markerOffset) {
|
|
1918
1829
|
const marker = source.charCodeAt(markerOffset);
|
|
1919
1830
|
if (marker !== rule.marker && marker !== rule.alternateMarker) return;
|
|
1920
1831
|
let offset = markerOffset + 1;
|
|
@@ -1947,66 +1858,56 @@ function closesFence(source, lines, index, fence) {
|
|
|
1947
1858
|
while (source.charCodeAt(offset) === fence.marker) offset++;
|
|
1948
1859
|
if (offset < markerEnd) return false;
|
|
1949
1860
|
const lineEnd = lines.end(index);
|
|
1950
|
-
return
|
|
1951
|
-
}
|
|
1952
|
-
function fencedBlock(source, lines, index, end, fence, closed) {
|
|
1953
|
-
const lineEnd = lines.end(index);
|
|
1954
|
-
const infoStart = skipLineWhitespace(source, fence.offset + fence.length, lineEnd);
|
|
1955
|
-
let content;
|
|
1956
|
-
if (lines.physicallyContiguous()) {
|
|
1957
|
-
const contentStart = lines.next(index);
|
|
1958
|
-
const lastContentLine = end - (closed ? 2 : 1);
|
|
1959
|
-
content = source.slice(contentStart, lastContentLine > index ? lines.end(lastContentLine) : contentStart);
|
|
1960
|
-
}
|
|
1961
|
-
return {
|
|
1962
|
-
closed,
|
|
1963
|
-
content,
|
|
1964
|
-
indent: fence.indent,
|
|
1965
|
-
info: source.slice(infoStart, lineEnd),
|
|
1966
|
-
markerOffset: fence.offset - lines.start(index)
|
|
1967
|
-
};
|
|
1861
|
+
return trimLineWhitespaceStart(source, offset, lineEnd) === lineEnd;
|
|
1968
1862
|
}
|
|
1969
1863
|
const fenceSpaceIndent = [
|
|
1970
1864
|
/^(?<![\u2028\u2029]) /gm,
|
|
1971
1865
|
/^(?<![\u2028\u2029]) {1,2}/gm,
|
|
1972
1866
|
/^(?<![\u2028\u2029]) {1,3}/gm
|
|
1973
1867
|
];
|
|
1974
|
-
const
|
|
1868
|
+
const fenceTabIndent = [
|
|
1975
1869
|
/^(?<![\u2028\u2029])\t/gm,
|
|
1976
1870
|
/^(?<![\u2028\u2029]) ?\t/gm,
|
|
1977
1871
|
/^(?<![\u2028\u2029]) {0,2}\t/gm
|
|
1978
1872
|
];
|
|
1979
|
-
function
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
content
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
}
|
|
1989
|
-
function
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
1873
|
+
function appendFencedToken(source, lines, tokens, kind, start, end, fence, closed, normalizeEndings) {
|
|
1874
|
+
const content = lines.physicallyContiguous() ? physicalFenceContent(source, lines, start, end - (closed ? 2 : 1), fence.indent, normalizeEndings) : logicalFenceContent(source, lines, start, end, closed, fence.indent, normalizeEndings);
|
|
1875
|
+
const lineEnd = lines.end(start);
|
|
1876
|
+
const infoStart = trimLineWhitespaceStart(source, fence.offset + fence.length, lineEnd);
|
|
1877
|
+
const consumedEnd = lines.next(end - 1);
|
|
1878
|
+
tokens.push(kind, fence.offset, closed || consumedEnd < source.length ? lines.end(end - 1) : consumedEnd, {
|
|
1879
|
+
text: content,
|
|
1880
|
+
value: source.slice(infoStart, lineEnd)
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
function physicalFenceContent(source, lines, start, last, indent, normalizeEndings) {
|
|
1884
|
+
const firstOffset = lines.next(start);
|
|
1885
|
+
let content = source.slice(firstOffset, last > start ? lines.end(last) : firstOffset);
|
|
1886
|
+
if (normalizeEndings) content = lines.normalizeLineEndings(content);
|
|
1887
|
+
if (!indent) return content;
|
|
1888
|
+
if (content.includes(" ")) content = content.replace(fenceTabIndent[indent - 1], " ");
|
|
1889
|
+
return content.replace(fenceSpaceIndent[indent - 1], "");
|
|
1890
|
+
}
|
|
1891
|
+
function logicalFenceContent(source, lines, start, end, closed, indent, normalizeEndings) {
|
|
1892
|
+
let last = end - (closed ? 2 : 1);
|
|
1893
|
+
if (!closed && last > start && lines.start(last) === lines.next(last) && !lines.prefixColumns(last)) last--;
|
|
1894
|
+
const parts = [];
|
|
1895
|
+
for (let index = start + 1; index <= last; index++) {
|
|
1896
|
+
let offset = lines.start(index);
|
|
1897
|
+
const lineEnd = lines.end(index);
|
|
1898
|
+
let columns = lines.prefixColumns(index);
|
|
1899
|
+
while (offset < lineEnd && columns < indent) {
|
|
1900
|
+
const code = source.charCodeAt(offset);
|
|
1901
|
+
if (code === 32) columns++;
|
|
1902
|
+
else if (code === 9) columns += 4 - physicalColumnAt(source, offset) % 4;
|
|
1903
|
+
else break;
|
|
1904
|
+
offset++;
|
|
1905
|
+
}
|
|
1906
|
+
parts.push(" ".repeat(Math.max(0, columns - indent)) + source.slice(offset, lineEnd) + (index < last ? normalizeEndings ? "\n" : source.slice(lineEnd, lines.next(index)) : ""));
|
|
1907
|
+
}
|
|
1908
|
+
return parts.join("");
|
|
1909
|
+
}
|
|
1910
|
+
// src/profile/features/code.ts
|
|
2010
1911
|
const codeFenceRule = {
|
|
2011
1912
|
alternateMarker: 126,
|
|
2012
1913
|
forbiddenInfoMarker: 96,
|
|
@@ -2014,17 +1915,32 @@ const codeFenceRule = {
|
|
|
2014
1915
|
minimumLength: 3
|
|
2015
1916
|
};
|
|
2016
1917
|
function codeFenceAt(source, lines, index, markerOffset) {
|
|
2017
|
-
return fenceAt
|
|
1918
|
+
return fenceAt(source, lines, index, codeFenceRule, markerOffset);
|
|
1919
|
+
}
|
|
1920
|
+
function indentedContent(source, lines, start, end) {
|
|
1921
|
+
const parts = [];
|
|
1922
|
+
for (let index = start; index < end; index++) {
|
|
1923
|
+
let offset = lines.start(index);
|
|
1924
|
+
let columns = lines.prefixColumns(index);
|
|
1925
|
+
const lineEnd = lines.end(index);
|
|
1926
|
+
while (offset < lineEnd && columns < 4) {
|
|
1927
|
+
const code = source.charCodeAt(offset);
|
|
1928
|
+
if (code === 32) columns++;
|
|
1929
|
+
else if (code === 9) columns += Math.max(4 - columns, 4 - physicalColumnAt(source, offset) % 4);
|
|
1930
|
+
else break;
|
|
1931
|
+
offset++;
|
|
1932
|
+
}
|
|
1933
|
+
parts.push(" ".repeat(Math.max(0, columns - 4)) + source.slice(offset, lineEnd));
|
|
1934
|
+
}
|
|
1935
|
+
return parts.join("\n");
|
|
2018
1936
|
}
|
|
2019
1937
|
const feature$14 = {
|
|
2020
1938
|
block: {
|
|
2021
1939
|
builds: [{
|
|
2022
|
-
token:
|
|
1940
|
+
token: [258, 259],
|
|
2023
1941
|
build(tokenStart, context) {
|
|
2024
1942
|
const tokens = context.structure.tokens;
|
|
2025
|
-
const
|
|
2026
|
-
const source = context.locator.normalizeLineEndings(block.content ?? tokens.text(context.source, tokenStart));
|
|
2027
|
-
const rawInfo = semanticText(block.info);
|
|
1943
|
+
const rawInfo = semanticText(tokens.value(tokenStart) ?? "");
|
|
2028
1944
|
const langEnd = rawInfo.search(/[ \t]/);
|
|
2029
1945
|
const lang = rawInfo ? langEnd < 0 ? rawInfo : rawInfo.slice(0, langEnd) : null;
|
|
2030
1946
|
const metaStart = langEnd < 0 ? -1 : rawInfo.slice(langEnd).search(/[^ \t]/);
|
|
@@ -2032,34 +1948,19 @@ const feature$14 = {
|
|
|
2032
1948
|
type: "code",
|
|
2033
1949
|
lang,
|
|
2034
1950
|
meta: metaStart < 0 ? null : rawInfo.slice(langEnd + metaStart),
|
|
2035
|
-
value:
|
|
2036
|
-
position:
|
|
2037
|
-
};
|
|
2038
|
-
}
|
|
2039
|
-
}, {
|
|
2040
|
-
token: 258,
|
|
2041
|
-
build(tokenStart, context) {
|
|
2042
|
-
const tokens = context.structure.tokens;
|
|
2043
|
-
const offset = tokens.start(tokenStart);
|
|
2044
|
-
const contentLength = tokens.value(tokenStart);
|
|
2045
|
-
return {
|
|
2046
|
-
type: "code",
|
|
2047
|
-
lang: null,
|
|
2048
|
-
meta: null,
|
|
2049
|
-
value: context.locator.normalizeLineEndings(tokens.text(context.source, tokenStart)).replace(/^(?: {0,3}\t| {4}| {1,3}$)/gm, "").replace(/\n(?:[ \t]*\n)*[ \t]*$/, ""),
|
|
2050
|
-
position: context.locator.positionAt(offset, offset + contentLength)
|
|
1951
|
+
value: tokens.text(context.source, tokenStart),
|
|
1952
|
+
position: context.locator.positionAt(tokens.start(tokenStart), tokens.end(tokenStart))
|
|
2051
1953
|
};
|
|
2052
1954
|
}
|
|
2053
1955
|
}],
|
|
2054
1956
|
starts: [{
|
|
2055
1957
|
codes: [-1],
|
|
2056
|
-
start(source, lines,
|
|
1958
|
+
start(source, lines, tokens, start) {
|
|
2057
1959
|
let end = start + 1;
|
|
2058
1960
|
while (end < lines.length && lineIndentOffset(source, lines, end) < 0) end++;
|
|
2059
1961
|
let contentEnd = end;
|
|
2060
1962
|
while (contentEnd > start && isBlankLine(source, lines, contentEnd - 1)) contentEnd--;
|
|
2061
|
-
|
|
2062
|
-
appendLogicalToken(out, 258, source, lines, start, end, contentLength);
|
|
1963
|
+
tokens.push(259, lines.start(start), lines.end(contentEnd - 1), { text: indentedContent(source, lines, start, contentEnd) });
|
|
2063
1964
|
return end;
|
|
2064
1965
|
}
|
|
2065
1966
|
}, {
|
|
@@ -2067,14 +1968,14 @@ const feature$14 = {
|
|
|
2067
1968
|
interrupt(source, lines, index, contentOffset) {
|
|
2068
1969
|
return !!codeFenceAt(source, lines, index, contentOffset);
|
|
2069
1970
|
},
|
|
2070
|
-
start(source, lines, start, contentOffset
|
|
1971
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
2071
1972
|
const fence = codeFenceAt(source, lines, start, contentOffset);
|
|
2072
1973
|
if (!fence) return;
|
|
2073
1974
|
let end = start + 1;
|
|
2074
1975
|
while (end < lines.length && !closesFence(source, lines, end, fence)) end++;
|
|
2075
1976
|
const closed = end < lines.length;
|
|
2076
1977
|
if (end < lines.length) end++;
|
|
2077
|
-
|
|
1978
|
+
appendFencedToken(source, lines, tokens, 258, start, end, fence, closed, true);
|
|
2078
1979
|
return end;
|
|
2079
1980
|
}
|
|
2080
1981
|
}]
|
|
@@ -2083,8 +1984,8 @@ const feature$14 = {
|
|
|
2083
1984
|
scans: [{
|
|
2084
1985
|
marker: 96,
|
|
2085
1986
|
scan(source, start, tokens) {
|
|
2086
|
-
if (source.charCodeAt(start - 1) === 96) return start + 1;
|
|
2087
1987
|
const openEnd = inlineMarkerRunEnd(source, start);
|
|
1988
|
+
if (source.charCodeAt(start - 1) === 96) return openEnd;
|
|
2088
1989
|
const markerLength = openEnd - start;
|
|
2089
1990
|
let offset = openEnd;
|
|
2090
1991
|
while (offset < source.length) {
|
|
@@ -2097,59 +1998,45 @@ const feature$14 = {
|
|
|
2097
1998
|
}
|
|
2098
1999
|
offset = closeEnd;
|
|
2099
2000
|
}
|
|
2100
|
-
return
|
|
2001
|
+
return openEnd;
|
|
2101
2002
|
}
|
|
2102
2003
|
}],
|
|
2103
2004
|
builds: [{
|
|
2104
2005
|
kind: "leaf",
|
|
2105
2006
|
token: 129,
|
|
2106
|
-
build: (tokenIndex,
|
|
2007
|
+
build: (tokenIndex, position, context) => {
|
|
2107
2008
|
const markerLength = inlineTokenData(context.tokens, tokenIndex);
|
|
2108
2009
|
let value = context.locator.normalizeLineEndings(inlineTokenText(context.view.text, context.tokens, tokenIndex, markerLength));
|
|
2109
2010
|
if (/^[ \n]/.test(value) && /[ \n]$/.test(value) && /[^ \n]/.test(value)) value = value.slice(1, -1);
|
|
2110
2011
|
return {
|
|
2111
2012
|
type: "inlineCode",
|
|
2112
2013
|
value: context.tableCell ? value.replace(/\\\|/g, "|") : value,
|
|
2113
|
-
position
|
|
2014
|
+
position
|
|
2114
2015
|
};
|
|
2115
2016
|
}
|
|
2116
2017
|
}]
|
|
2117
2018
|
}
|
|
2118
2019
|
};
|
|
2119
|
-
|
|
2120
|
-
//#region src/fragment/inline.ts
|
|
2020
|
+
// src/fragment/inline.ts
|
|
2121
2021
|
function createInlineOutput(children, cursor) {
|
|
2122
2022
|
return {
|
|
2123
2023
|
children,
|
|
2124
2024
|
cursor,
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2025
|
+
pendingText: void 0,
|
|
2026
|
+
pendingEnd: 0,
|
|
2027
|
+
pendingLiteral: ""
|
|
2128
2028
|
};
|
|
2129
2029
|
}
|
|
2130
|
-
function
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
const previousText = output.lastText;
|
|
2141
|
-
const mergeForward = previousText !== void 0 && !("attributes" in previousText);
|
|
2142
|
-
let offset = value.length;
|
|
2143
|
-
while (offset > 0) {
|
|
2144
|
-
const code = value.charCodeAt(offset - 1);
|
|
2145
|
-
if (code !== 32 && code !== 9) break;
|
|
2146
|
-
offset--;
|
|
2147
|
-
}
|
|
2148
|
-
const trailingSpaces = value.length - offset;
|
|
2149
|
-
output.trailingSpaces = trailingSpaces === value.length && mergeForward ? output.trailingSpaces + trailingSpaces : trailingSpaces;
|
|
2150
|
-
if (mergeForward) previousText.value += value;
|
|
2151
|
-
else {
|
|
2152
|
-
const startLocation = context.locator.locationAt(start);
|
|
2030
|
+
function createLiteralChildren(context, start, end) {
|
|
2031
|
+
return start >= end ? [] : [{
|
|
2032
|
+
type: "text",
|
|
2033
|
+
value: context.view.text.slice(start, end),
|
|
2034
|
+
position: context.locator.positionAt(context.view.mapOffset(start), context.view.mapEnd(end))
|
|
2035
|
+
}];
|
|
2036
|
+
}
|
|
2037
|
+
function appendText(context, output, value, start, end, literal) {
|
|
2038
|
+
if (output.pendingText === void 0 || "attributes" in output.pendingText) {
|
|
2039
|
+
const startLocation = context.locator.locationAt(context.view.mapOffset(start));
|
|
2153
2040
|
const text = {
|
|
2154
2041
|
type: "text",
|
|
2155
2042
|
value,
|
|
@@ -2159,69 +2046,75 @@ function appendText(output, value, start, end, context) {
|
|
|
2159
2046
|
}
|
|
2160
2047
|
};
|
|
2161
2048
|
output.children.push(text);
|
|
2162
|
-
output.
|
|
2049
|
+
output.pendingText = text;
|
|
2050
|
+
output.pendingLiteral = literal ? value : "";
|
|
2051
|
+
} else {
|
|
2052
|
+
output.pendingText.value += value;
|
|
2053
|
+
output.pendingLiteral = literal ? output.pendingLiteral + value : "";
|
|
2163
2054
|
}
|
|
2164
|
-
output.
|
|
2055
|
+
output.pendingEnd = end;
|
|
2056
|
+
}
|
|
2057
|
+
function finishText(context, output) {
|
|
2058
|
+
if (output.pendingText) output.pendingText.position.end = context.locator.locationAt(context.view.mapEnd(output.pendingEnd));
|
|
2165
2059
|
}
|
|
2166
|
-
function
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2060
|
+
function trimTrailingText(context, output) {
|
|
2061
|
+
if (output.pendingText) {
|
|
2062
|
+
const literal = output.pendingLiteral;
|
|
2063
|
+
const removed = literal.length - trimLineWhitespaceEnd(literal, 0, literal.length);
|
|
2064
|
+
if (removed > 0) {
|
|
2065
|
+
if (removed === output.pendingText.value.length) output.pendingText.position.start = context.locator.locationAt(context.view.mapOffset(output.pendingEnd));
|
|
2066
|
+
output.pendingText.value = output.pendingText.value.slice(0, -removed);
|
|
2067
|
+
output.pendingEnd -= removed;
|
|
2068
|
+
output.pendingLiteral = "";
|
|
2069
|
+
}
|
|
2171
2070
|
}
|
|
2172
2071
|
}
|
|
2173
|
-
function appendGap(
|
|
2174
|
-
appendText(output, context.view.text.slice(start, end),
|
|
2072
|
+
function appendGap(context, output, start, end) {
|
|
2073
|
+
appendText(context, output, context.view.text.slice(start, end), start, end, true);
|
|
2175
2074
|
}
|
|
2176
|
-
function
|
|
2177
|
-
if (start > output.cursor) appendGap(
|
|
2075
|
+
function appendLeaf(context, output, token, start, end, build) {
|
|
2076
|
+
if (start > output.cursor) appendGap(context, output, output.cursor, start);
|
|
2178
2077
|
const sourceStart = context.view.mapOffset(start);
|
|
2179
2078
|
const sourceEnd = start === end ? sourceStart : context.view.mapEnd(end);
|
|
2180
|
-
finishText(
|
|
2079
|
+
finishText(context, output);
|
|
2181
2080
|
output.children.push(build(token, context.locator.positionAt(sourceStart, sourceEnd), context));
|
|
2182
|
-
output.
|
|
2081
|
+
output.pendingText = void 0;
|
|
2183
2082
|
}
|
|
2184
|
-
function appendRange(
|
|
2083
|
+
function appendRange(profile, context, output, startToken, endToken) {
|
|
2185
2084
|
let index = startToken;
|
|
2186
2085
|
while (index < endToken) {
|
|
2187
2086
|
const kind = inlineTokenKind(context.tokens, index);
|
|
2188
2087
|
if (kind === 67) {
|
|
2189
2088
|
const endingStart = inlineTokenStart(context.tokens, index);
|
|
2190
|
-
const lineStart = inlineTokenData(context.tokens, index);
|
|
2191
2089
|
const contentStart = inlineTokenEnd(context.tokens, index);
|
|
2192
|
-
if (endingStart > output.cursor) appendGap(
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
else {
|
|
2196
|
-
trimTrailingText(output);
|
|
2197
|
-
appendText(output, "\n", context.view.mapOffset(endingStart), context.view.mapEnd(contentStart), context);
|
|
2198
|
-
}
|
|
2090
|
+
if (endingStart > output.cursor) appendGap(context, output, output.cursor, endingStart);
|
|
2091
|
+
trimTrailingText(context, output);
|
|
2092
|
+
appendText(context, output, "\n", endingStart, contentStart, false);
|
|
2199
2093
|
output.cursor = contentStart;
|
|
2200
2094
|
index++;
|
|
2201
2095
|
continue;
|
|
2202
2096
|
}
|
|
2203
|
-
|
|
2204
|
-
const build = profile.buildByKind[kind];
|
|
2097
|
+
const build = profile.builders[kind];
|
|
2205
2098
|
const childStart = inlineTokenStart(context.tokens, index);
|
|
2206
2099
|
if (kind < 192) {
|
|
2207
2100
|
const childEnd = inlineTokenEnd(context.tokens, index);
|
|
2208
2101
|
if (kind < 128) {
|
|
2209
|
-
if (childStart > output.cursor) appendGap(
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
} else appendLeafToken(output, context, index, childStart, childEnd, build);
|
|
2102
|
+
if (childStart > output.cursor) appendGap(context, output, output.cursor, childStart);
|
|
2103
|
+
appendText(context, output, build(index, context), childStart, childEnd, kind === 64);
|
|
2104
|
+
} else appendLeaf(context, output, index, childStart, childEnd, build);
|
|
2213
2105
|
output.cursor = childEnd;
|
|
2214
2106
|
index++;
|
|
2215
2107
|
continue;
|
|
2216
2108
|
}
|
|
2217
2109
|
if (kind < 256) {
|
|
2218
|
-
if (
|
|
2219
|
-
|
|
2220
|
-
|
|
2110
|
+
if (kind & 1) break;
|
|
2111
|
+
if (childStart > output.cursor) appendGap(context, output, output.cursor, childStart);
|
|
2112
|
+
finishText(context, output);
|
|
2113
|
+
index = appendPair(profile, context, output, index, endToken, build);
|
|
2221
2114
|
continue;
|
|
2222
2115
|
}
|
|
2223
2116
|
const childEnd = inlineTokenEnd(context.tokens, index);
|
|
2224
|
-
finishText(
|
|
2117
|
+
finishText(context, output);
|
|
2225
2118
|
const sourceStart = context.view.mapOffset(childStart);
|
|
2226
2119
|
const sourceSpan = {
|
|
2227
2120
|
start: sourceStart,
|
|
@@ -2229,31 +2122,39 @@ function appendRange(startToken, endToken, profile, context, output, closeKind =
|
|
|
2229
2122
|
};
|
|
2230
2123
|
if (build(index, sourceSpan, context, output)) {
|
|
2231
2124
|
const previous = output.children.at(-1);
|
|
2232
|
-
output.
|
|
2125
|
+
output.pendingText = previous?.type === "text" ? previous : void 0;
|
|
2126
|
+
output.pendingEnd = childEnd;
|
|
2233
2127
|
output.cursor = childEnd;
|
|
2234
2128
|
}
|
|
2235
2129
|
index++;
|
|
2236
2130
|
}
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2131
|
+
const contentEnd = index < endToken ? inlineTokenStart(context.tokens, index) : context.view.text.length;
|
|
2132
|
+
if (contentEnd > output.cursor) appendGap(context, output, output.cursor, contentEnd);
|
|
2133
|
+
if (startToken === 0) {
|
|
2134
|
+
trimTrailingText(context, output);
|
|
2135
|
+
if (output.pendingText && !output.pendingText.value) output.children.pop();
|
|
2136
|
+
}
|
|
2137
|
+
finishText(context, output);
|
|
2242
2138
|
return index;
|
|
2243
2139
|
}
|
|
2244
|
-
function
|
|
2140
|
+
function appendPair(profile, context, output, openToken, endToken, build) {
|
|
2245
2141
|
const childStart = inlineTokenStart(context.tokens, openToken);
|
|
2246
2142
|
const positionStart = context.locator.locationAt(context.view.mapOffset(childStart));
|
|
2247
|
-
const
|
|
2248
|
-
const
|
|
2249
|
-
|
|
2143
|
+
const nextToken = openToken + 1;
|
|
2144
|
+
const nextKind = inlineTokenKind(context.tokens, nextToken);
|
|
2145
|
+
let children;
|
|
2146
|
+
let closeToken;
|
|
2147
|
+
if (nextKind >= 192 && nextKind < 256 && nextKind & 1) {
|
|
2148
|
+
children = createLiteralChildren(context, inlineTokenEnd(context.tokens, openToken), inlineTokenStart(context.tokens, nextToken));
|
|
2149
|
+
closeToken = nextToken;
|
|
2150
|
+
} else closeToken = appendRange(profile, context, createInlineOutput(children = [], inlineTokenEnd(context.tokens, openToken)), nextToken, endToken);
|
|
2250
2151
|
const childEnd = inlineTokenEnd(context.tokens, closeToken);
|
|
2251
2152
|
const value = build(openToken, closeToken, {
|
|
2252
2153
|
start: positionStart,
|
|
2253
2154
|
end: context.locator.locationAt(context.view.mapEnd(childEnd))
|
|
2254
2155
|
}, children, context);
|
|
2255
2156
|
output.children.push(value);
|
|
2256
|
-
output.
|
|
2157
|
+
output.pendingText = void 0;
|
|
2257
2158
|
output.cursor = childEnd;
|
|
2258
2159
|
return closeToken + 1;
|
|
2259
2160
|
}
|
|
@@ -2267,9 +2168,12 @@ function buildInlineFragment(tokenStart, tableCell, context) {
|
|
|
2267
2168
|
view = region.view;
|
|
2268
2169
|
} else {
|
|
2269
2170
|
const blockTokens = context.structure.tokens;
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2171
|
+
const nodeLength = blockTokens.nodeLength(tokenStart);
|
|
2172
|
+
if (nodeLength <= 1 || blockTokens.kind(tokenStart + 1) !== 1) return { children: [] };
|
|
2173
|
+
const previousView = context.inlineContext?.view;
|
|
2174
|
+
view = (previousView?.reset(context.source, blockTokens, tokenStart, nodeLength), previousView) ?? new SourceView(context.source, blockTokens, tokenStart, nodeLength);
|
|
2175
|
+
tokens = context.profile.tokenize(view.text, view.withBoundaryBreak);
|
|
2176
|
+
if (tokens.length) tokens = context.profile.resolve(view.text, tokens, blockTokens);
|
|
2273
2177
|
}
|
|
2274
2178
|
const inlineContext = context.inlineContext ??= {
|
|
2275
2179
|
locator: context.locator,
|
|
@@ -2280,26 +2184,17 @@ function buildInlineFragment(tokenStart, tableCell, context) {
|
|
|
2280
2184
|
inlineContext.tableCell = tableCell;
|
|
2281
2185
|
inlineContext.tokens = tokens;
|
|
2282
2186
|
inlineContext.view = view;
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
const removed = trimTrailingText(result);
|
|
2288
|
-
if (removed > 0) {
|
|
2289
|
-
last.position.end.offset -= removed;
|
|
2290
|
-
last.position.end.column -= removed;
|
|
2291
|
-
}
|
|
2292
|
-
if (!last.value) result.children.pop();
|
|
2293
|
-
}
|
|
2294
|
-
return result;
|
|
2187
|
+
if (tokens.length === 0) return { children: createLiteralChildren(inlineContext, 0, trimLineWhitespaceEnd(view.text, 0, view.text.length)) };
|
|
2188
|
+
const output = createInlineOutput([], 0);
|
|
2189
|
+
appendRange(context.profile, inlineContext, output, 0, inlineTokenCount(tokens));
|
|
2190
|
+
return output;
|
|
2295
2191
|
}
|
|
2296
|
-
|
|
2297
|
-
//#region src/profile/features/frontmatter.ts
|
|
2192
|
+
// src/profile/features/frontmatter.ts
|
|
2298
2193
|
function frontmatterFenceAt(source, lines, index, marker) {
|
|
2299
2194
|
const start = lines.start(index);
|
|
2300
2195
|
if (source[start] !== marker || source[start + 1] !== marker || source[start + 2] !== marker) return false;
|
|
2301
2196
|
const end = lines.end(index);
|
|
2302
|
-
return
|
|
2197
|
+
return trimLineWhitespaceStart(source, start + 3, end) === end;
|
|
2303
2198
|
}
|
|
2304
2199
|
const buildYamlBlock = (tokenStart, context) => {
|
|
2305
2200
|
const tokens = context.structure.tokens;
|
|
@@ -2316,15 +2211,15 @@ const buildYamlBlock = (tokenStart, context) => {
|
|
|
2316
2211
|
function feature$13(marker) {
|
|
2317
2212
|
return { block: {
|
|
2318
2213
|
builds: [{
|
|
2319
|
-
token:
|
|
2214
|
+
token: 261,
|
|
2320
2215
|
build: buildYamlBlock
|
|
2321
2216
|
}],
|
|
2322
2217
|
starts: [{
|
|
2323
2218
|
codes: [marker.charCodeAt(0)],
|
|
2324
|
-
start(source, lines, start, contentOffset,
|
|
2219
|
+
start(source, lines, tokens, start, contentOffset, context) {
|
|
2325
2220
|
if (lines.start(start) !== 0 || !frontmatterFenceAt(source, lines, start, marker)) return;
|
|
2326
2221
|
for (let end = start + 1; end < lines.length; end++) if (frontmatterFenceAt(source, lines, end, marker)) {
|
|
2327
|
-
appendLogicalToken(
|
|
2222
|
+
appendLogicalToken(source, lines, tokens, 261, start, end + 1);
|
|
2328
2223
|
return end + 1;
|
|
2329
2224
|
}
|
|
2330
2225
|
context.retainLookahead(lines.next(lines.length - 1));
|
|
@@ -2332,8 +2227,7 @@ function feature$13(marker) {
|
|
|
2332
2227
|
}]
|
|
2333
2228
|
} };
|
|
2334
2229
|
}
|
|
2335
|
-
|
|
2336
|
-
//#region src/profile/features/component/shared.ts
|
|
2230
|
+
// src/profile/features/component/shared.ts
|
|
2337
2231
|
function componentNameEnd(source, start, block) {
|
|
2338
2232
|
let code = source.charCodeAt(start);
|
|
2339
2233
|
if (!isAsciiLetter(code) && code !== 36) return;
|
|
@@ -2366,15 +2260,17 @@ function normalizeComponentName(value) {
|
|
|
2366
2260
|
}
|
|
2367
2261
|
return result.toLowerCase();
|
|
2368
2262
|
}
|
|
2369
|
-
|
|
2370
|
-
//#region src/profile/features/component/block.ts
|
|
2263
|
+
// src/profile/features/component/block.ts
|
|
2371
2264
|
function closingBracket(source, start, limit) {
|
|
2372
2265
|
let depth = 0;
|
|
2373
|
-
for (let offset = start + 1; offset < limit; offset++)
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
if (
|
|
2377
|
-
|
|
2266
|
+
for (let offset = start + 1; offset < limit; offset++) {
|
|
2267
|
+
const code = source.charCodeAt(offset);
|
|
2268
|
+
if (code === 92 && offset + 1 < limit) offset++;
|
|
2269
|
+
else if (code === 91) depth++;
|
|
2270
|
+
else if (code === 93) {
|
|
2271
|
+
if (depth === 0) return offset;
|
|
2272
|
+
depth--;
|
|
2273
|
+
}
|
|
2378
2274
|
}
|
|
2379
2275
|
}
|
|
2380
2276
|
function lineValue(source, lines, index) {
|
|
@@ -2396,22 +2292,24 @@ function yamlPropsEnd(source, lines, start, end) {
|
|
|
2396
2292
|
for (let index = start + 1; index < end; index++) if (lineValue(source, lines, index) === marker) return index + 1;
|
|
2397
2293
|
}
|
|
2398
2294
|
function slotOpeningAt(source, lines, index, contentOffset) {
|
|
2399
|
-
if (source
|
|
2295
|
+
if (source.charCodeAt(contentOffset) !== 35) return;
|
|
2296
|
+
const code = source.charCodeAt(contentOffset + 1);
|
|
2297
|
+
if (code === 35 || code === 32 || code === 9) return;
|
|
2400
2298
|
const nameEnd = componentNameEnd(source, contentOffset + 1, true);
|
|
2401
2299
|
const lineEnd = lines.end(index);
|
|
2402
2300
|
if (nameEnd === void 0 || nameEnd > lineEnd) return;
|
|
2403
|
-
let offset =
|
|
2301
|
+
let offset = trimLineWhitespaceStart(source, nameEnd, lineEnd);
|
|
2404
2302
|
let attributesStart;
|
|
2405
|
-
let
|
|
2406
|
-
if (source
|
|
2407
|
-
parsedAttributesEnd = attributesEnd(source, offset, lineEnd);
|
|
2408
|
-
if (parsedAttributesEnd === void 0) return;
|
|
2303
|
+
let attributesEndValue;
|
|
2304
|
+
if (source.charCodeAt(offset) === 123) {
|
|
2409
2305
|
attributesStart = offset;
|
|
2410
|
-
|
|
2306
|
+
attributesEndValue = attributesEnd(source, offset, lineEnd);
|
|
2307
|
+
if (attributesEndValue === void 0) return;
|
|
2308
|
+
offset = attributesEndValue;
|
|
2411
2309
|
}
|
|
2412
|
-
if (
|
|
2310
|
+
if (trimLineWhitespaceStart(source, offset, lineEnd) !== lineEnd) return;
|
|
2413
2311
|
return {
|
|
2414
|
-
attributesEnd:
|
|
2312
|
+
attributesEnd: attributesEndValue,
|
|
2415
2313
|
attributesStart,
|
|
2416
2314
|
nameEnd,
|
|
2417
2315
|
offset: contentOffset
|
|
@@ -2419,34 +2317,34 @@ function slotOpeningAt(source, lines, index, contentOffset) {
|
|
|
2419
2317
|
}
|
|
2420
2318
|
function blockOpeningAt(source, lines, index, contentOffset, shorthand) {
|
|
2421
2319
|
let offset = contentOffset;
|
|
2422
|
-
while (source
|
|
2320
|
+
while (source.charCodeAt(offset) === 58) offset++;
|
|
2423
2321
|
const fenceSize = offset - contentOffset;
|
|
2424
2322
|
if (shorthand ? fenceSize !== 1 : fenceSize < 2) return;
|
|
2425
2323
|
const lineEnd = lines.end(index);
|
|
2426
|
-
if (!shorthand) offset =
|
|
2324
|
+
if (!shorthand) offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
2427
2325
|
const nameEnd = componentNameEnd(source, offset, true);
|
|
2428
2326
|
if (nameEnd === void 0 || nameEnd > lineEnd) return;
|
|
2429
|
-
offset =
|
|
2327
|
+
offset = trimLineWhitespaceStart(source, nameEnd, lineEnd);
|
|
2430
2328
|
let labelStart;
|
|
2431
2329
|
let labelEnd;
|
|
2432
|
-
if (source
|
|
2330
|
+
if (source.charCodeAt(offset) === 91) {
|
|
2433
2331
|
const close = closingBracket(source, offset, lineEnd);
|
|
2434
2332
|
if (close === void 0) return;
|
|
2435
2333
|
labelStart = offset;
|
|
2436
2334
|
labelEnd = close + 1;
|
|
2437
|
-
offset =
|
|
2335
|
+
offset = trimLineWhitespaceStart(source, labelEnd, lineEnd);
|
|
2438
2336
|
}
|
|
2439
2337
|
let attributesStart;
|
|
2440
|
-
let
|
|
2441
|
-
if (source
|
|
2442
|
-
parsedAttributesEnd = attributesEnd(source, offset, lineEnd);
|
|
2443
|
-
if (parsedAttributesEnd === void 0) return;
|
|
2338
|
+
let attributesEndValue;
|
|
2339
|
+
if (source.charCodeAt(offset) === 123) {
|
|
2444
2340
|
attributesStart = offset;
|
|
2445
|
-
|
|
2341
|
+
attributesEndValue = attributesEnd(source, offset, lineEnd);
|
|
2342
|
+
if (attributesEndValue === void 0) return;
|
|
2343
|
+
offset = attributesEndValue;
|
|
2446
2344
|
}
|
|
2447
|
-
if (
|
|
2345
|
+
if (trimLineWhitespaceStart(source, offset, lineEnd) !== lineEnd) return;
|
|
2448
2346
|
return {
|
|
2449
|
-
attributesEnd:
|
|
2347
|
+
attributesEnd: attributesEndValue,
|
|
2450
2348
|
attributesStart,
|
|
2451
2349
|
fenceSize,
|
|
2452
2350
|
labelEnd,
|
|
@@ -2454,13 +2352,6 @@ function blockOpeningAt(source, lines, index, contentOffset, shorthand) {
|
|
|
2454
2352
|
nameEnd
|
|
2455
2353
|
};
|
|
2456
2354
|
}
|
|
2457
|
-
function fenceAt(source, lines, index, size, contentOffset) {
|
|
2458
|
-
let offset = contentOffset;
|
|
2459
|
-
while (source[offset] === ":") offset++;
|
|
2460
|
-
const lineEnd = lines.end(index);
|
|
2461
|
-
if (offset - contentOffset !== size || skipLineWhitespace(source, offset, lineEnd) !== lineEnd) return;
|
|
2462
|
-
return contentOffset;
|
|
2463
|
-
}
|
|
2464
2355
|
function blockClose(source, lines, start, opening) {
|
|
2465
2356
|
let codeFence;
|
|
2466
2357
|
let depth = 0;
|
|
@@ -2473,11 +2364,12 @@ function blockClose(source, lines, start, opening) {
|
|
|
2473
2364
|
if (contentOffset < 0) continue;
|
|
2474
2365
|
codeFence = codeFenceAt(source, lines, index, contentOffset);
|
|
2475
2366
|
if (codeFence) continue;
|
|
2476
|
-
|
|
2477
|
-
|
|
2367
|
+
let markerEnd = contentOffset;
|
|
2368
|
+
while (source.charCodeAt(markerEnd) === 58) markerEnd++;
|
|
2369
|
+
if (markerEnd - contentOffset === opening.fenceSize && trimLineWhitespaceStart(source, markerEnd, lines.end(index)) === lines.end(index)) {
|
|
2478
2370
|
if (depth === 0) return {
|
|
2479
2371
|
index,
|
|
2480
|
-
offset:
|
|
2372
|
+
offset: contentOffset
|
|
2481
2373
|
};
|
|
2482
2374
|
depth--;
|
|
2483
2375
|
continue;
|
|
@@ -2505,39 +2397,39 @@ function nextSlot(source, lines, start, end) {
|
|
|
2505
2397
|
if (nested) index = blockClose(source, lines, index, nested)?.index ?? index;
|
|
2506
2398
|
}
|
|
2507
2399
|
}
|
|
2508
|
-
function emitComponentBody(source, lines, start, end, closingOffset,
|
|
2400
|
+
function emitComponentBody(source, lines, tokens, start, end, closingOffset, context) {
|
|
2509
2401
|
let cursor = start;
|
|
2510
2402
|
const yamlEnd = cursor < end ? yamlPropsEnd(source, lines, cursor, end) : void 0;
|
|
2511
2403
|
if (yamlEnd !== void 0) {
|
|
2512
|
-
appendLogicalToken(
|
|
2404
|
+
appendLogicalToken(source, lines, tokens, 263, cursor, yamlEnd);
|
|
2513
2405
|
cursor = yamlEnd;
|
|
2514
2406
|
}
|
|
2515
2407
|
let slot = nextSlot(source, lines, cursor, end);
|
|
2516
2408
|
if (!slot) {
|
|
2517
|
-
context.scanLines(source, lines.
|
|
2409
|
+
context.scanLines(source, lines.view(cursor, end), tokens);
|
|
2518
2410
|
return;
|
|
2519
2411
|
}
|
|
2520
|
-
if (slot.index > cursor) context.scanLines(source, lines.
|
|
2412
|
+
if (slot.index > cursor) context.scanLines(source, lines.view(cursor, slot.index), tokens);
|
|
2521
2413
|
while (slot) {
|
|
2522
2414
|
const following = nextSlot(source, lines, slot.index + 1, end);
|
|
2523
2415
|
const next = following?.index ?? end;
|
|
2524
2416
|
const opening = slot.opening;
|
|
2525
|
-
|
|
2526
|
-
if (opening.attributesStart !== void 0 && opening.attributesEnd !== void 0)
|
|
2527
|
-
context.scanLines(source, lines.
|
|
2417
|
+
tokens.push(84, opening.offset, opening.nameEnd);
|
|
2418
|
+
if (opening.attributesStart !== void 0 && opening.attributesEnd !== void 0) tokens.push(2, opening.attributesStart, opening.attributesEnd);
|
|
2419
|
+
context.scanLines(source, lines.view(slot.index + 1, next), tokens);
|
|
2528
2420
|
const slotEnd = following ? following.opening.offset : closingOffset;
|
|
2529
|
-
|
|
2421
|
+
tokens.push(202, slotEnd, slotEnd);
|
|
2530
2422
|
slot = following;
|
|
2531
2423
|
}
|
|
2532
2424
|
}
|
|
2533
|
-
function emitOpening(contentOffset, opening
|
|
2534
|
-
|
|
2425
|
+
function emitOpening(tokens, contentOffset, opening) {
|
|
2426
|
+
tokens.push(83, contentOffset, opening.nameEnd);
|
|
2535
2427
|
if (opening.labelStart !== void 0 && opening.labelEnd !== void 0) {
|
|
2536
|
-
|
|
2537
|
-
if (opening.labelEnd > opening.labelStart + 2)
|
|
2538
|
-
|
|
2428
|
+
tokens.push(85, opening.labelStart, opening.labelStart + 1);
|
|
2429
|
+
if (opening.labelEnd > opening.labelStart + 2) tokens.push(1, opening.labelStart + 1, opening.labelEnd - 1);
|
|
2430
|
+
tokens.push(201, opening.labelEnd - 1, opening.labelEnd);
|
|
2539
2431
|
}
|
|
2540
|
-
if (opening.attributesStart !== void 0 && opening.attributesEnd !== void 0)
|
|
2432
|
+
if (opening.attributesStart !== void 0 && opening.attributesEnd !== void 0) tokens.push(2, opening.attributesStart, opening.attributesEnd);
|
|
2541
2433
|
}
|
|
2542
2434
|
const buildBlockLabel = (tokenStart, context) => {
|
|
2543
2435
|
const tokens = context.structure.tokens;
|
|
@@ -2553,13 +2445,13 @@ const buildBlockLabel = (tokenStart, context) => {
|
|
|
2553
2445
|
};
|
|
2554
2446
|
};
|
|
2555
2447
|
function createBlockStart(shorthand) {
|
|
2556
|
-
return (source, lines, start, contentOffset,
|
|
2448
|
+
return (source, lines, tokens, start, contentOffset, context) => {
|
|
2557
2449
|
const opening = blockOpeningAt(source, lines, start, contentOffset, shorthand);
|
|
2558
2450
|
if (!opening) return;
|
|
2559
2451
|
if (shorthand) {
|
|
2560
|
-
emitOpening(contentOffset, opening
|
|
2452
|
+
emitOpening(tokens, contentOffset, opening);
|
|
2561
2453
|
const lineEnd = lines.end(start);
|
|
2562
|
-
|
|
2454
|
+
tokens.push(200, lineEnd, lineEnd);
|
|
2563
2455
|
return start + 1;
|
|
2564
2456
|
}
|
|
2565
2457
|
const closing = blockClose(source, lines, start, opening);
|
|
@@ -2567,30 +2459,35 @@ function createBlockStart(shorthand) {
|
|
|
2567
2459
|
context.retainLookahead(lines.next(lines.length - 1));
|
|
2568
2460
|
return;
|
|
2569
2461
|
}
|
|
2570
|
-
emitOpening(contentOffset, opening
|
|
2571
|
-
emitComponentBody(source, lines, start + 1, closing.index, closing.offset,
|
|
2572
|
-
|
|
2462
|
+
emitOpening(tokens, contentOffset, opening);
|
|
2463
|
+
emitComponentBody(source, lines, tokens, start + 1, closing.index, closing.offset, context);
|
|
2464
|
+
tokens.push(200, closing.offset, lines.end(closing.index));
|
|
2573
2465
|
return closing.index + 1;
|
|
2574
2466
|
};
|
|
2575
2467
|
}
|
|
2576
2468
|
const blockBuilds$2 = [
|
|
2577
2469
|
{
|
|
2578
|
-
token:
|
|
2470
|
+
token: 85,
|
|
2471
|
+
build: buildBlockLabel
|
|
2472
|
+
},
|
|
2473
|
+
{
|
|
2474
|
+
token: 263,
|
|
2579
2475
|
build: buildYamlBlock
|
|
2580
2476
|
},
|
|
2581
2477
|
{
|
|
2582
|
-
token:
|
|
2478
|
+
token: 83,
|
|
2583
2479
|
build(tokenStart, context) {
|
|
2584
2480
|
const tokens = context.structure.tokens;
|
|
2585
2481
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
2586
2482
|
let openingToken = tokenStart + 1;
|
|
2587
|
-
|
|
2588
|
-
if (
|
|
2589
|
-
|
|
2590
|
-
|
|
2483
|
+
let parsed;
|
|
2484
|
+
if (tokens.kind(openingToken) === 85) openingToken += tokens.nodeLength(openingToken);
|
|
2485
|
+
if (tokens.kind(openingToken) === 2) {
|
|
2486
|
+
parsed = parseAttributes(context.source, tokens.start(openingToken));
|
|
2487
|
+
openingToken++;
|
|
2488
|
+
}
|
|
2591
2489
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
2592
|
-
|
|
2593
|
-
if (label) children = [buildBlockLabel(label, context), ...children];
|
|
2490
|
+
const children = buildBlockChildren(tokenStart, context);
|
|
2594
2491
|
const opening = tokens.text(context.source, tokenStart);
|
|
2595
2492
|
return {
|
|
2596
2493
|
type: "blockComponent",
|
|
@@ -2605,26 +2502,25 @@ const blockBuilds$2 = [
|
|
|
2605
2502
|
}
|
|
2606
2503
|
},
|
|
2607
2504
|
{
|
|
2608
|
-
token:
|
|
2505
|
+
token: 84,
|
|
2609
2506
|
build(tokenStart, context) {
|
|
2610
2507
|
const tokens = context.structure.tokens;
|
|
2611
2508
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
2612
|
-
const attributesToken = tokens.kind(tokenStart + 1) ===
|
|
2509
|
+
const attributesToken = tokens.kind(tokenStart + 1) === 2 ? tokenStart + 1 : void 0;
|
|
2613
2510
|
const parsed = attributesToken !== void 0 ? parseAttributes(context.source, tokens.start(attributesToken)) : void 0;
|
|
2614
2511
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
2615
|
-
const children = buildBlockChildren(tokenStart, context);
|
|
2616
2512
|
return {
|
|
2617
2513
|
type: "blockComponent",
|
|
2618
2514
|
name: "template",
|
|
2619
|
-
|
|
2620
|
-
...parsed,
|
|
2621
|
-
name: normalizeComponentName(tokens.text(context.source, tokenStart).slice(1).trim())
|
|
2622
|
-
},
|
|
2623
|
-
children,
|
|
2515
|
+
children: buildBlockChildren(tokenStart, context),
|
|
2624
2516
|
position: {
|
|
2625
2517
|
start,
|
|
2626
2518
|
end: context.locator.locationAt(tokens.end(close))
|
|
2627
|
-
}
|
|
2519
|
+
},
|
|
2520
|
+
attributes: {
|
|
2521
|
+
...parsed,
|
|
2522
|
+
name: normalizeComponentName(tokens.text(context.source, tokenStart).slice(1).trim())
|
|
2523
|
+
}
|
|
2628
2524
|
};
|
|
2629
2525
|
}
|
|
2630
2526
|
}
|
|
@@ -2639,8 +2535,7 @@ const blockStarts$2 = [{
|
|
|
2639
2535
|
codes: [58],
|
|
2640
2536
|
start: createBlockStart(true)
|
|
2641
2537
|
}];
|
|
2642
|
-
|
|
2643
|
-
//#region src/profile/features/component/inline.ts
|
|
2538
|
+
// src/profile/features/component/inline.ts
|
|
2644
2539
|
const inlineScans = [{
|
|
2645
2540
|
marker: 58,
|
|
2646
2541
|
scan(source, start, tokens) {
|
|
@@ -2650,18 +2545,17 @@ const inlineScans = [{
|
|
|
2650
2545
|
return end;
|
|
2651
2546
|
}
|
|
2652
2547
|
}];
|
|
2653
|
-
const buildInlineComponent = (open, close,
|
|
2548
|
+
const buildInlineComponent = (open, close, position, children, context) => {
|
|
2654
2549
|
const nameEnd = inlineTokenEnd(context.tokens, open) - (inlineTokenKind(context.tokens, open) === 208 ? 1 : 0);
|
|
2655
2550
|
return {
|
|
2656
2551
|
type: "inlineComponent",
|
|
2657
2552
|
name: normalizeComponentName(context.view.text.slice(inlineTokenStart(context.tokens, open) + 1, nameEnd)),
|
|
2658
2553
|
attributes: {},
|
|
2659
2554
|
children,
|
|
2660
|
-
position
|
|
2555
|
+
position
|
|
2661
2556
|
};
|
|
2662
2557
|
};
|
|
2663
|
-
|
|
2664
|
-
//#region src/profile/features/component/index.ts
|
|
2558
|
+
// src/profile/features/component/index.ts
|
|
2665
2559
|
const feature$12 = {
|
|
2666
2560
|
block: {
|
|
2667
2561
|
builds: blockBuilds$2,
|
|
@@ -2673,8 +2567,8 @@ const feature$12 = {
|
|
|
2673
2567
|
{
|
|
2674
2568
|
kind: "leaf",
|
|
2675
2569
|
token: 137,
|
|
2676
|
-
build(token,
|
|
2677
|
-
return buildInlineComponent(token, token,
|
|
2570
|
+
build(token, position, context) {
|
|
2571
|
+
return buildInlineComponent(token, token, position, [], context);
|
|
2678
2572
|
}
|
|
2679
2573
|
},
|
|
2680
2574
|
{
|
|
@@ -2685,21 +2579,20 @@ const feature$12 = {
|
|
|
2685
2579
|
{
|
|
2686
2580
|
kind: "pair",
|
|
2687
2581
|
token: 206,
|
|
2688
|
-
build(open, close,
|
|
2582
|
+
build(open, close, position, children) {
|
|
2689
2583
|
return {
|
|
2690
2584
|
type: "inlineComponent",
|
|
2691
2585
|
name: "span",
|
|
2692
2586
|
attributes: {},
|
|
2693
2587
|
children,
|
|
2694
|
-
position
|
|
2588
|
+
position
|
|
2695
2589
|
};
|
|
2696
2590
|
}
|
|
2697
2591
|
}
|
|
2698
2592
|
]
|
|
2699
2593
|
}
|
|
2700
2594
|
};
|
|
2701
|
-
|
|
2702
|
-
//#region src/profile/features/emoji/index.ts
|
|
2595
|
+
// src/profile/features/emoji/index.ts
|
|
2703
2596
|
function isShortcodeCharacter(code) {
|
|
2704
2597
|
return isAsciiLetter(code) || isAsciiDigit(code) || code === 43 || code === 45 || code === 95;
|
|
2705
2598
|
}
|
|
@@ -2719,17 +2612,16 @@ const feature$11 = { inline: {
|
|
|
2719
2612
|
builds: [{
|
|
2720
2613
|
kind: "leaf",
|
|
2721
2614
|
token: 136,
|
|
2722
|
-
build(tokenIndex,
|
|
2615
|
+
build(tokenIndex, position, context) {
|
|
2723
2616
|
return {
|
|
2724
2617
|
type: "emoji",
|
|
2725
2618
|
value: inlineTokenText(context.view.text, context.tokens, tokenIndex),
|
|
2726
|
-
position
|
|
2619
|
+
position
|
|
2727
2620
|
};
|
|
2728
2621
|
}
|
|
2729
2622
|
}]
|
|
2730
2623
|
} };
|
|
2731
|
-
|
|
2732
|
-
//#region src/profile/features/footnote/shared.ts
|
|
2624
|
+
// src/profile/features/footnote/shared.ts
|
|
2733
2625
|
const footnoteDefinitionPrefix = "footnote\0";
|
|
2734
2626
|
function footnoteLabelAt(source, start, limit) {
|
|
2735
2627
|
if (source.charCodeAt(start) !== 91 || source.charCodeAt(start + 1) !== 94) return;
|
|
@@ -2746,7 +2638,7 @@ function footnoteLabelAt(source, start, limit) {
|
|
|
2746
2638
|
} else if (code === 93) {
|
|
2747
2639
|
if (length === 0) return;
|
|
2748
2640
|
const label = source.slice(labelStart, offset);
|
|
2749
|
-
const normalizedLabel =
|
|
2641
|
+
const normalizedLabel = normalizeIdentifier(label);
|
|
2750
2642
|
return {
|
|
2751
2643
|
definitionKey: footnoteDefinitionPrefix + normalizedLabel,
|
|
2752
2644
|
end: offset + 1,
|
|
@@ -2761,31 +2653,30 @@ function footnoteLabelAt(source, start, limit) {
|
|
|
2761
2653
|
if (length > 999) return;
|
|
2762
2654
|
}
|
|
2763
2655
|
}
|
|
2764
|
-
|
|
2765
|
-
//#region src/profile/features/footnote/block.ts
|
|
2656
|
+
// src/profile/features/footnote/block.ts
|
|
2766
2657
|
function definitionAt(source, lines, index, markerStart) {
|
|
2767
2658
|
const lineEnd = lines.end(index);
|
|
2768
2659
|
const label = footnoteLabelAt(source, markerStart, lineEnd);
|
|
2769
2660
|
if (!label || source.charCodeAt(label.end) !== 58) return;
|
|
2770
2661
|
const markerEnd = label.end + 1;
|
|
2771
|
-
const contentOffset =
|
|
2662
|
+
const contentOffset = trimLineWhitespaceStart(source, markerEnd, lineEnd);
|
|
2772
2663
|
return {
|
|
2773
2664
|
...label,
|
|
2774
2665
|
contentOffset,
|
|
2775
2666
|
markerEnd
|
|
2776
2667
|
};
|
|
2777
2668
|
}
|
|
2778
|
-
|
|
2779
|
-
//#region src/profile/features/footnote/index.ts
|
|
2669
|
+
// src/profile/features/footnote/index.ts
|
|
2780
2670
|
const feature$10 = {
|
|
2781
2671
|
block: {
|
|
2782
2672
|
builds: [{
|
|
2783
|
-
token:
|
|
2673
|
+
token: 78,
|
|
2784
2674
|
build(tokenStart, context) {
|
|
2785
2675
|
const tokens = context.structure.tokens;
|
|
2786
|
-
const
|
|
2676
|
+
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
2787
2677
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
2788
2678
|
const children = buildBlockChildren(tokenStart, context);
|
|
2679
|
+
const fields = tokens.value(tokenStart);
|
|
2789
2680
|
return {
|
|
2790
2681
|
type: "footnoteDefinition",
|
|
2791
2682
|
identifier: fields.normalizedLabel,
|
|
@@ -2793,7 +2684,7 @@ const feature$10 = {
|
|
|
2793
2684
|
children,
|
|
2794
2685
|
position: {
|
|
2795
2686
|
start,
|
|
2796
|
-
end: context.locator.locationAt(
|
|
2687
|
+
end: context.locator.locationAt(tokens.end(close))
|
|
2797
2688
|
}
|
|
2798
2689
|
};
|
|
2799
2690
|
}
|
|
@@ -2809,12 +2700,12 @@ const feature$10 = {
|
|
|
2809
2700
|
interrupt(source, lines, index, contentOffset) {
|
|
2810
2701
|
return definitionAt(source, lines, index, contentOffset) !== void 0;
|
|
2811
2702
|
},
|
|
2812
|
-
start(source, lines, start, contentOffset,
|
|
2703
|
+
start(source, lines, tokens, start, contentOffset, context) {
|
|
2813
2704
|
const match = definitionAt(source, lines, start, contentOffset);
|
|
2814
2705
|
if (!match) return;
|
|
2815
2706
|
const definitionLines = context.createLineView(lines, start, match.contentOffset, 0);
|
|
2816
2707
|
let index = start + 1;
|
|
2817
|
-
let lazyParagraph
|
|
2708
|
+
let lazyParagraph;
|
|
2818
2709
|
while (index < lines.length) {
|
|
2819
2710
|
const line = definitionLines.pushAfterColumns(source, lines, index, 4);
|
|
2820
2711
|
if (line === 0) {
|
|
@@ -2824,25 +2715,26 @@ const feature$10 = {
|
|
|
2824
2715
|
continue;
|
|
2825
2716
|
}
|
|
2826
2717
|
if (line === 1) {
|
|
2827
|
-
lazyParagraph =
|
|
2718
|
+
lazyParagraph = void 0;
|
|
2828
2719
|
index++;
|
|
2829
2720
|
continue;
|
|
2830
2721
|
}
|
|
2722
|
+
lazyParagraph ??= context.endsWithParagraphLeaf(source, definitionLines, definitionLines.length - 1);
|
|
2831
2723
|
if (!lazyParagraph || !lines.lazy(index) && context.startsInterruptingBlock(source, lines, index)) break;
|
|
2832
2724
|
definitionLines.pushLazy(lines, index);
|
|
2833
2725
|
index++;
|
|
2834
2726
|
}
|
|
2835
2727
|
while (definitionLines.length > 0 && isBlankLine(source, definitionLines, definitionLines.length - 1)) definitionLines.pop();
|
|
2836
|
-
|
|
2728
|
+
tokens.push(78, contentOffset, match.markerEnd, {
|
|
2837
2729
|
definitionKey: match.definitionKey,
|
|
2838
2730
|
value: {
|
|
2839
2731
|
label: match.label,
|
|
2840
2732
|
normalizedLabel: match.normalizedLabel
|
|
2841
2733
|
}
|
|
2842
2734
|
});
|
|
2843
|
-
context.scanLines(source, definitionLines,
|
|
2735
|
+
context.scanLines(source, definitionLines, tokens);
|
|
2844
2736
|
const end = definitionLines.length > 0 ? definitionLines.next(definitionLines.length - 1) : match.markerEnd;
|
|
2845
|
-
|
|
2737
|
+
tokens.push(197, end, end);
|
|
2846
2738
|
return index;
|
|
2847
2739
|
}
|
|
2848
2740
|
}]
|
|
@@ -2850,159 +2742,90 @@ const feature$10 = {
|
|
|
2850
2742
|
inline: { builds: [{
|
|
2851
2743
|
kind: "leaf",
|
|
2852
2744
|
token: 133,
|
|
2853
|
-
build(tokenIndex,
|
|
2745
|
+
build(tokenIndex, position, context) {
|
|
2854
2746
|
const label = inlineTokenText(context.view.text, context.tokens, tokenIndex, 2, 1);
|
|
2855
2747
|
return {
|
|
2856
2748
|
type: "footnoteReference",
|
|
2857
|
-
identifier:
|
|
2749
|
+
identifier: normalizeIdentifier(label),
|
|
2858
2750
|
label: semanticText(label),
|
|
2859
|
-
position
|
|
2751
|
+
position
|
|
2860
2752
|
};
|
|
2861
2753
|
}
|
|
2862
2754
|
}] }
|
|
2863
2755
|
};
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
const buildDecodedInlineText = (tokenIndex, context) => {
|
|
2874
|
-
return semanticText(inlineTokenText(context.view.text, context.tokens, tokenIndex));
|
|
2875
|
-
};
|
|
2876
|
-
const feature$9 = { inline: {
|
|
2877
|
-
scans: [{
|
|
2878
|
-
marker: 38,
|
|
2879
|
-
scan(source, start, tokens) {
|
|
2880
|
-
const matchEnd = matchInlinePatternEnd(entity, source, start);
|
|
2881
|
-
if (matchEnd < 0) return start + 1;
|
|
2882
|
-
appendInlineToken(tokens, 66, start, matchEnd);
|
|
2883
|
-
return matchEnd;
|
|
2884
|
-
}
|
|
2885
|
-
}, {
|
|
2886
|
-
marker: 92,
|
|
2887
|
-
scan(source, start, tokens) {
|
|
2888
|
-
const next = source.charCodeAt(start + 1);
|
|
2889
|
-
if (next === 10 || next === 13) {
|
|
2890
|
-
appendInlineToken(tokens, 128, start, start + 1);
|
|
2891
|
-
return start + 1;
|
|
2892
|
-
}
|
|
2893
|
-
if (isAsciiPunctuation(next)) {
|
|
2894
|
-
const end = start + 2;
|
|
2895
|
-
appendInlineToken(tokens, 65, start, end);
|
|
2756
|
+
// src/profile/features/formatting.ts
|
|
2757
|
+
function createFormatting(type, marker, buildToken, delimiter) {
|
|
2758
|
+
return {
|
|
2759
|
+
delimiter,
|
|
2760
|
+
scanner: {
|
|
2761
|
+
marker,
|
|
2762
|
+
scan(source, start, tokens) {
|
|
2763
|
+
const end = inlineMarkerRunEnd(source, start);
|
|
2764
|
+
appendInlineToken(tokens, delimiter.token, start, end);
|
|
2896
2765
|
return end;
|
|
2897
2766
|
}
|
|
2898
|
-
return start + (next === 32 || next === 9 ? 2 : 1);
|
|
2899
|
-
}
|
|
2900
|
-
}],
|
|
2901
|
-
builds: [
|
|
2902
|
-
{
|
|
2903
|
-
kind: "text",
|
|
2904
|
-
token: 64,
|
|
2905
|
-
build: buildInlineText
|
|
2906
2767
|
},
|
|
2907
|
-
{
|
|
2908
|
-
kind: "
|
|
2909
|
-
token:
|
|
2910
|
-
build:
|
|
2911
|
-
},
|
|
2912
|
-
{
|
|
2913
|
-
kind: "text",
|
|
2914
|
-
token: 66,
|
|
2915
|
-
build: buildDecodedInlineText
|
|
2916
|
-
}
|
|
2917
|
-
]
|
|
2918
|
-
} };
|
|
2919
|
-
//#endregion
|
|
2920
|
-
//#region src/profile/features/formatting.ts
|
|
2921
|
-
const scanFormatting = (source, start, tokens) => {
|
|
2922
|
-
const code = source.charCodeAt(start);
|
|
2923
|
-
const end = inlineMarkerRunEnd(source, start);
|
|
2924
|
-
appendInlineToken(tokens, code === 42 ? 68 : code === 95 ? 69 : 70, start, end);
|
|
2925
|
-
return end;
|
|
2926
|
-
};
|
|
2927
|
-
function createFormattingPair(type, open, close) {
|
|
2928
|
-
return {
|
|
2929
|
-
kind: "pair",
|
|
2930
|
-
token: open,
|
|
2931
|
-
open,
|
|
2932
|
-
close,
|
|
2933
|
-
build(openToken, closeToken, sourceSpan, children) {
|
|
2934
|
-
return {
|
|
2768
|
+
builder: {
|
|
2769
|
+
kind: "pair",
|
|
2770
|
+
token: buildToken,
|
|
2771
|
+
build: (openToken, closeToken, position, children) => ({
|
|
2935
2772
|
type,
|
|
2936
2773
|
children,
|
|
2937
|
-
position
|
|
2938
|
-
}
|
|
2774
|
+
position
|
|
2775
|
+
})
|
|
2939
2776
|
}
|
|
2940
2777
|
};
|
|
2941
2778
|
}
|
|
2942
|
-
const
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
double:
|
|
2779
|
+
const formattingAsterisk = createFormatting("emphasis", 42, 192, {
|
|
2780
|
+
token: 1,
|
|
2781
|
+
single: {
|
|
2782
|
+
open: 192,
|
|
2783
|
+
close: 193
|
|
2784
|
+
},
|
|
2785
|
+
double: {
|
|
2786
|
+
open: 194,
|
|
2787
|
+
close: 195
|
|
2788
|
+
},
|
|
2949
2789
|
pairing: {
|
|
2950
2790
|
kind: "partial",
|
|
2951
2791
|
ruleOfThree: true
|
|
2952
2792
|
}
|
|
2953
|
-
};
|
|
2954
|
-
const
|
|
2955
|
-
token:
|
|
2956
|
-
single:
|
|
2957
|
-
|
|
2793
|
+
});
|
|
2794
|
+
const formattingUnderscore = createFormatting("strong", 95, 194, {
|
|
2795
|
+
token: 2,
|
|
2796
|
+
single: {
|
|
2797
|
+
open: 192,
|
|
2798
|
+
close: 193
|
|
2799
|
+
},
|
|
2800
|
+
double: {
|
|
2801
|
+
open: 194,
|
|
2802
|
+
close: 195
|
|
2803
|
+
},
|
|
2958
2804
|
pairing: {
|
|
2959
2805
|
kind: "partial",
|
|
2960
2806
|
ruleOfThree: true
|
|
2961
2807
|
},
|
|
2962
2808
|
allowIntraword: false
|
|
2963
|
-
};
|
|
2964
|
-
const
|
|
2965
|
-
token:
|
|
2966
|
-
double:
|
|
2809
|
+
});
|
|
2810
|
+
const formattingStrikethrough = createFormatting("delete", 126, 196, {
|
|
2811
|
+
token: 3,
|
|
2812
|
+
double: {
|
|
2813
|
+
open: 196,
|
|
2814
|
+
close: 197
|
|
2815
|
+
},
|
|
2967
2816
|
pairing: { kind: "whole" }
|
|
2968
|
-
};
|
|
2969
|
-
function feature$
|
|
2970
|
-
const
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
token: 68,
|
|
2974
|
-
build: buildInlineText
|
|
2975
|
-
},
|
|
2976
|
-
{
|
|
2977
|
-
kind: "text",
|
|
2978
|
-
token: 69,
|
|
2979
|
-
build: buildInlineText
|
|
2980
|
-
},
|
|
2981
|
-
emphasisPair,
|
|
2982
|
-
strongPair
|
|
2983
|
-
];
|
|
2984
|
-
const delimiters = [asteriskDelimiter, underscoreDelimiter];
|
|
2985
|
-
const scans = [{
|
|
2986
|
-
marker: 42,
|
|
2987
|
-
scan: scanFormatting
|
|
2988
|
-
}, {
|
|
2989
|
-
marker: 95,
|
|
2990
|
-
scan: scanFormatting
|
|
2991
|
-
}];
|
|
2817
|
+
});
|
|
2818
|
+
function feature$9(strikethroughOptions) {
|
|
2819
|
+
const scans = [formattingAsterisk.scanner, formattingUnderscore.scanner];
|
|
2820
|
+
const delimiters = [formattingAsterisk.delimiter, formattingUnderscore.delimiter];
|
|
2821
|
+
const builds = [formattingAsterisk.builder, formattingUnderscore.builder];
|
|
2992
2822
|
if (strikethroughOptions) {
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
token: 70,
|
|
2996
|
-
build: buildInlineText
|
|
2997
|
-
}, deletePair);
|
|
2823
|
+
scans.push(formattingStrikethrough.scanner);
|
|
2824
|
+
builds.push(formattingStrikethrough.builder);
|
|
2998
2825
|
delimiters.push(typeof strikethroughOptions !== "object" || strikethroughOptions.singleTilde !== false ? {
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
} :
|
|
3002
|
-
scans.push({
|
|
3003
|
-
marker: 126,
|
|
3004
|
-
scan: scanFormatting
|
|
3005
|
-
});
|
|
2826
|
+
single: formattingStrikethrough.delimiter.double,
|
|
2827
|
+
...formattingStrikethrough.delimiter
|
|
2828
|
+
} : formattingStrikethrough.delimiter);
|
|
3006
2829
|
}
|
|
3007
2830
|
return { inline: {
|
|
3008
2831
|
scans,
|
|
@@ -3010,86 +2833,66 @@ function feature$8(strikethroughOptions) {
|
|
|
3010
2833
|
builds
|
|
3011
2834
|
} };
|
|
3012
2835
|
}
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
function cloneLocation(location) {
|
|
3016
|
-
return {
|
|
3017
|
-
line: location.line,
|
|
3018
|
-
column: location.column,
|
|
3019
|
-
offset: location.offset
|
|
3020
|
-
};
|
|
3021
|
-
}
|
|
3022
|
-
function firstChildStart(children) {
|
|
3023
|
-
const first = children[0];
|
|
3024
|
-
return cloneLocation(first.position.start);
|
|
3025
|
-
}
|
|
3026
|
-
function lastChildEnd(children) {
|
|
3027
|
-
const last = children.at(-1);
|
|
3028
|
-
return last ? cloneLocation(last.position.end) : void 0;
|
|
3029
|
-
}
|
|
3030
|
-
//#endregion
|
|
3031
|
-
//#region src/profile/features/heading.ts
|
|
3032
|
-
function atxAt(source, lines, index, markerOffset) {
|
|
2836
|
+
// src/profile/features/heading.ts
|
|
2837
|
+
function atxMarkerEnd(source, markerOffset, lineEnd) {
|
|
3033
2838
|
let markerEnd = markerOffset + 1;
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
let contentEnd = lineEnd;
|
|
3039
|
-
while (contentEnd > contentOffset && (source[contentEnd - 1] === " " || source[contentEnd - 1] === " ")) contentEnd--;
|
|
3040
|
-
let closer = contentEnd;
|
|
3041
|
-
while (closer > contentOffset && source[closer - 1] === "#") closer--;
|
|
3042
|
-
if (closer < contentEnd && (closer === contentOffset || source[closer - 1] === " " || source[closer - 1] === " ")) {
|
|
3043
|
-
contentEnd = closer;
|
|
3044
|
-
while (contentEnd > contentOffset && (source[contentEnd - 1] === " " || source[contentEnd - 1] === " ")) contentEnd--;
|
|
2839
|
+
while (markerEnd < lineEnd && markerEnd - markerOffset < 6 && source.charCodeAt(markerEnd) === 35) markerEnd++;
|
|
2840
|
+
if (markerEnd < lineEnd) {
|
|
2841
|
+
const code = source.charCodeAt(markerEnd);
|
|
2842
|
+
if (code !== 32 && code !== 9) return 0;
|
|
3045
2843
|
}
|
|
3046
|
-
return
|
|
3047
|
-
markerEnd,
|
|
3048
|
-
contentOffset,
|
|
3049
|
-
contentEnd
|
|
3050
|
-
};
|
|
2844
|
+
return markerEnd;
|
|
3051
2845
|
}
|
|
3052
2846
|
function setextMarkerAt(source, lines, index, markerOffset) {
|
|
3053
|
-
const marker = source
|
|
3054
|
-
if (marker !==
|
|
2847
|
+
const marker = source.charCodeAt(markerOffset);
|
|
2848
|
+
if (marker !== 61 && marker !== 45) return;
|
|
3055
2849
|
const lineEnd = lines.end(index);
|
|
3056
2850
|
let offset = markerOffset + 1;
|
|
3057
|
-
while (offset < lineEnd && source
|
|
3058
|
-
offset =
|
|
2851
|
+
while (offset < lineEnd && source.charCodeAt(offset) === marker) offset++;
|
|
2852
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
3059
2853
|
return offset === lineEnd ? marker : void 0;
|
|
3060
2854
|
}
|
|
3061
|
-
const feature$
|
|
2855
|
+
const feature$8 = { block: {
|
|
3062
2856
|
builds: [{
|
|
3063
|
-
token:
|
|
2857
|
+
token: [
|
|
2858
|
+
64,
|
|
2859
|
+
65,
|
|
2860
|
+
66,
|
|
2861
|
+
67,
|
|
2862
|
+
68,
|
|
2863
|
+
69
|
|
2864
|
+
],
|
|
3064
2865
|
build(tokenStart, context) {
|
|
3065
2866
|
const tokens = context.structure.tokens;
|
|
2867
|
+
const kind = tokens.kind(tokenStart);
|
|
3066
2868
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
3067
2869
|
const inline = buildInlineFragment(tokenStart, false, context);
|
|
3068
2870
|
const result = {
|
|
3069
2871
|
type: "heading",
|
|
3070
|
-
depth:
|
|
2872
|
+
depth: kind - 64 + 1,
|
|
3071
2873
|
children: inline.children,
|
|
3072
2874
|
position: {
|
|
3073
2875
|
start,
|
|
3074
|
-
end: context.locator.locationAt(
|
|
2876
|
+
end: context.locator.locationAt(tokens.end(tokenStart))
|
|
3075
2877
|
}
|
|
3076
2878
|
};
|
|
3077
2879
|
if (inline.attributes) result.attributes = inline.attributes;
|
|
3078
2880
|
return result;
|
|
3079
2881
|
}
|
|
3080
2882
|
}, {
|
|
3081
|
-
token: [
|
|
2883
|
+
token: [70, 71],
|
|
3082
2884
|
build(tokenStart, context) {
|
|
3083
2885
|
const tokens = context.structure.tokens;
|
|
2886
|
+
const kind = tokens.kind(tokenStart);
|
|
2887
|
+
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
3084
2888
|
const inline = buildInlineFragment(tokenStart, false, context);
|
|
3085
|
-
const children = inline.children;
|
|
3086
2889
|
const result = {
|
|
3087
2890
|
type: "heading",
|
|
3088
|
-
depth:
|
|
3089
|
-
children,
|
|
2891
|
+
depth: kind - 70 + 1,
|
|
2892
|
+
children: inline.children,
|
|
3090
2893
|
position: {
|
|
3091
|
-
start
|
|
3092
|
-
end: context.locator.locationAt(tokens.
|
|
2894
|
+
start,
|
|
2895
|
+
end: context.locator.locationAt(tokens.end(tokenStart))
|
|
3093
2896
|
}
|
|
3094
2897
|
};
|
|
3095
2898
|
if (inline.attributes) result.attributes = inline.attributes;
|
|
@@ -3099,21 +2902,28 @@ const feature$7 = { block: {
|
|
|
3099
2902
|
starts: [{
|
|
3100
2903
|
codes: [35],
|
|
3101
2904
|
interrupt(source, lines, index, contentOffset) {
|
|
3102
|
-
return
|
|
2905
|
+
return atxMarkerEnd(source, contentOffset, lines.end(index)) > 0;
|
|
3103
2906
|
},
|
|
3104
|
-
start(source, lines, start, contentOffset
|
|
3105
|
-
const atx = atxAt(source, lines, start, contentOffset);
|
|
3106
|
-
if (!atx) return;
|
|
3107
|
-
out.push(96, contentOffset, atx.markerEnd);
|
|
3108
|
-
if (atx.contentEnd > atx.contentOffset) out.push(1, atx.contentOffset, atx.contentEnd);
|
|
2907
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
3109
2908
|
const lineEnd = lines.end(start);
|
|
3110
|
-
|
|
2909
|
+
const markerEnd = atxMarkerEnd(source, contentOffset, lineEnd);
|
|
2910
|
+
if (markerEnd <= 0) return;
|
|
2911
|
+
const contentStart = trimLineWhitespaceStart(source, markerEnd, lineEnd);
|
|
2912
|
+
let contentEnd = trimLineWhitespaceEnd(source, contentStart, lineEnd);
|
|
2913
|
+
let closer = contentEnd;
|
|
2914
|
+
let code = source.charCodeAt(closer - 1);
|
|
2915
|
+
while (closer > contentStart && code === 35) {
|
|
2916
|
+
closer--;
|
|
2917
|
+
code = source.charCodeAt(closer - 1);
|
|
2918
|
+
}
|
|
2919
|
+
if (closer < contentEnd && (closer === contentStart || code === 32 || code === 9)) contentEnd = trimLineWhitespaceEnd(source, contentStart, closer);
|
|
2920
|
+
tokens.push(64 + markerEnd - contentOffset - 1, contentOffset, lineEnd);
|
|
2921
|
+
tokens.closeRange(contentStart, contentEnd);
|
|
3111
2922
|
return start + 1;
|
|
3112
2923
|
}
|
|
3113
2924
|
}]
|
|
3114
2925
|
} };
|
|
3115
|
-
|
|
3116
|
-
//#region src/profile/features/html.ts
|
|
2926
|
+
// src/profile/features/html.ts
|
|
3117
2927
|
const htmlBlockTags = new Set(htmlBlockNames);
|
|
3118
2928
|
const htmlTagName = "[a-z][a-z0-9-]*";
|
|
3119
2929
|
const completeHtmlTag = new RegExp(`^(?:<${htmlTagName}(?:\\s+[a-z_:][\\w.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'|"[^"]*"))?)*\\s*/?>|</${htmlTagName}\\s*>)[ \\t]*$`, "i");
|
|
@@ -3150,17 +2960,17 @@ function htmlStartAt(source, lines, index, contentOffset) {
|
|
|
3150
2960
|
if (tag && htmlBlockTags.has(tag)) return { interruptParagraph: true };
|
|
3151
2961
|
if (completeHtmlTag.test(body)) return { interruptParagraph: false };
|
|
3152
2962
|
}
|
|
3153
|
-
const buildInlineHtml = (tokenIndex,
|
|
2963
|
+
const buildInlineHtml = (tokenIndex, position, context) => {
|
|
3154
2964
|
return {
|
|
3155
2965
|
type: "html",
|
|
3156
2966
|
value: inlineTokenText(context.view.text, context.tokens, tokenIndex),
|
|
3157
|
-
position
|
|
2967
|
+
position
|
|
3158
2968
|
};
|
|
3159
2969
|
};
|
|
3160
|
-
const feature$
|
|
2970
|
+
const feature$7 = {
|
|
3161
2971
|
block: {
|
|
3162
2972
|
builds: [{
|
|
3163
|
-
token:
|
|
2973
|
+
token: 260,
|
|
3164
2974
|
build(tokenStart, context) {
|
|
3165
2975
|
const tokens = context.structure.tokens;
|
|
3166
2976
|
const offset = tokens.start(tokenStart);
|
|
@@ -3171,7 +2981,7 @@ const feature$6 = {
|
|
|
3171
2981
|
return {
|
|
3172
2982
|
type: "html",
|
|
3173
2983
|
value: html,
|
|
3174
|
-
position: context.locator.positionAt(offset, html.endsWith("\n") ? end :
|
|
2984
|
+
position: context.locator.positionAt(offset, html.endsWith("\n") ? end : tokens.contentEnd(context.source, tokenStart))
|
|
3175
2985
|
};
|
|
3176
2986
|
}
|
|
3177
2987
|
}],
|
|
@@ -3180,7 +2990,7 @@ const feature$6 = {
|
|
|
3180
2990
|
interrupt(source, lines, index, contentOffset) {
|
|
3181
2991
|
return !!htmlStartAt(source, lines, index, contentOffset)?.interruptParagraph;
|
|
3182
2992
|
},
|
|
3183
|
-
start(source, lines, start, contentOffset
|
|
2993
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
3184
2994
|
const htmlStart = htmlStartAt(source, lines, start, contentOffset);
|
|
3185
2995
|
if (!htmlStart) return;
|
|
3186
2996
|
let end = start;
|
|
@@ -3193,7 +3003,7 @@ const feature$6 = {
|
|
|
3193
3003
|
end++;
|
|
3194
3004
|
while (end < lines.length && !isBlankLine(source, lines, end)) end++;
|
|
3195
3005
|
}
|
|
3196
|
-
appendLogicalToken(
|
|
3006
|
+
appendLogicalToken(source, lines, tokens, 260, start, end, unterminated);
|
|
3197
3007
|
return end;
|
|
3198
3008
|
}
|
|
3199
3009
|
}]
|
|
@@ -3228,15 +3038,71 @@ const feature$6 = {
|
|
|
3228
3038
|
}]
|
|
3229
3039
|
}
|
|
3230
3040
|
};
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3041
|
+
// src/profile/features/text.ts
|
|
3042
|
+
const entity = /&(?:#x[0-9A-F]{1,6}|#\d{1,7}|[A-Z][A-Z0-9]{0,30});/iy;
|
|
3043
|
+
const buildLiteralInlineText = (tokenIndex, context) => {
|
|
3044
|
+
return inlineTokenText(context.view.text, context.tokens, tokenIndex);
|
|
3045
|
+
};
|
|
3046
|
+
const buildEscapedInlineText = (tokenIndex, context) => {
|
|
3047
|
+
return inlineTokenText(context.view.text, context.tokens, tokenIndex, 1, 0);
|
|
3048
|
+
};
|
|
3049
|
+
const buildDecodedInlineText = (tokenIndex, context) => {
|
|
3050
|
+
return semanticText(inlineTokenText(context.view.text, context.tokens, tokenIndex));
|
|
3051
|
+
};
|
|
3052
|
+
const feature$6 = { inline: {
|
|
3053
|
+
scans: [{
|
|
3054
|
+
marker: 38,
|
|
3055
|
+
scan(source, start, tokens) {
|
|
3056
|
+
const matchEnd = matchInlinePatternEnd(entity, source, start);
|
|
3057
|
+
if (matchEnd < 0) return start + 1;
|
|
3058
|
+
appendInlineToken(tokens, 66, start, matchEnd);
|
|
3059
|
+
return matchEnd;
|
|
3060
|
+
}
|
|
3061
|
+
}, {
|
|
3062
|
+
marker: 92,
|
|
3063
|
+
scan(source, start, tokens) {
|
|
3064
|
+
const next = source.charCodeAt(start + 1);
|
|
3065
|
+
if (next === 10 || next === 13) {
|
|
3066
|
+
let offset = start + 2;
|
|
3067
|
+
if (next === 13 && source.charCodeAt(offset) === 10) offset++;
|
|
3068
|
+
const lineStart = offset;
|
|
3069
|
+
while (source.charCodeAt(offset) === 32) offset++;
|
|
3070
|
+
appendInlineToken(tokens, 128, start, offset, lineStart);
|
|
3071
|
+
return offset;
|
|
3072
|
+
}
|
|
3073
|
+
if (isAsciiPunctuation(next)) {
|
|
3074
|
+
const end = start + 2;
|
|
3075
|
+
appendInlineToken(tokens, 65, start, end);
|
|
3076
|
+
return end;
|
|
3077
|
+
}
|
|
3078
|
+
return start + (next === 32 || next === 9 ? 2 : 1);
|
|
3079
|
+
}
|
|
3080
|
+
}],
|
|
3081
|
+
builds: [
|
|
3082
|
+
{
|
|
3083
|
+
kind: "text",
|
|
3084
|
+
token: 64,
|
|
3085
|
+
build: buildLiteralInlineText
|
|
3086
|
+
},
|
|
3087
|
+
{
|
|
3088
|
+
kind: "text",
|
|
3089
|
+
token: 65,
|
|
3090
|
+
build: buildEscapedInlineText
|
|
3091
|
+
},
|
|
3092
|
+
{
|
|
3093
|
+
kind: "text",
|
|
3094
|
+
token: 66,
|
|
3095
|
+
build: buildDecodedInlineText
|
|
3096
|
+
}
|
|
3097
|
+
]
|
|
3098
|
+
} };
|
|
3099
|
+
// src/profile/features/link.ts
|
|
3100
|
+
function skipWhitespace(source, start, end = source.length) {
|
|
3101
|
+
while (start < end) {
|
|
3102
|
+
if (!isMarkdownWhitespace(source.charCodeAt(start))) break;
|
|
3103
|
+
start++;
|
|
3238
3104
|
}
|
|
3239
|
-
return
|
|
3105
|
+
return start;
|
|
3240
3106
|
}
|
|
3241
3107
|
function linkDestinationEnd(source, start) {
|
|
3242
3108
|
if (source.charCodeAt(start) === 60) {
|
|
@@ -3298,7 +3164,7 @@ function scanLinkTail(source, start, tokens) {
|
|
|
3298
3164
|
simpleLinkTail.lastIndex = start + 1;
|
|
3299
3165
|
if (simpleLinkTail.test(source)) {
|
|
3300
3166
|
const end = simpleLinkTail.lastIndex;
|
|
3301
|
-
appendInlineToken(tokens,
|
|
3167
|
+
appendInlineToken(tokens, 68, start, end, end - start - 1);
|
|
3302
3168
|
return end;
|
|
3303
3169
|
}
|
|
3304
3170
|
if (source.charCodeAt(start + 1) !== 40) return -1;
|
|
@@ -3317,44 +3183,9 @@ function scanLinkTail(source, start, tokens) {
|
|
|
3317
3183
|
if (source.charCodeAt(offset) !== 41) return -1;
|
|
3318
3184
|
}
|
|
3319
3185
|
const end = offset + 1;
|
|
3320
|
-
appendInlineToken(tokens,
|
|
3186
|
+
appendInlineToken(tokens, 68, start, end, destinationEnd - start);
|
|
3321
3187
|
return end;
|
|
3322
3188
|
}
|
|
3323
|
-
function resourceAt(source, tokens, tokenIndex) {
|
|
3324
|
-
const tokenStart = inlineTokenStart(tokens, tokenIndex);
|
|
3325
|
-
const tokenEnd = inlineTokenEnd(tokens, tokenIndex);
|
|
3326
|
-
let start = tokenStart + 2;
|
|
3327
|
-
let end = tokenEnd - 1;
|
|
3328
|
-
while (start < end && isMarkdownWhitespace(source.charCodeAt(start))) start++;
|
|
3329
|
-
while (end > start && isMarkdownWhitespace(source.charCodeAt(end - 1))) end--;
|
|
3330
|
-
if (start === end) return {
|
|
3331
|
-
url: "",
|
|
3332
|
-
title: null
|
|
3333
|
-
};
|
|
3334
|
-
const resourceEnd = tokenStart + inlineTokenData(tokens, tokenIndex);
|
|
3335
|
-
let destinationStart = start;
|
|
3336
|
-
let destinationEnd = resourceEnd;
|
|
3337
|
-
if (source[start] === "<") {
|
|
3338
|
-
destinationStart++;
|
|
3339
|
-
destinationEnd--;
|
|
3340
|
-
}
|
|
3341
|
-
start = resourceEnd;
|
|
3342
|
-
while (start < end && isMarkdownWhitespace(source.charCodeAt(start))) start++;
|
|
3343
|
-
return {
|
|
3344
|
-
url: semanticText(source.slice(destinationStart, destinationEnd)),
|
|
3345
|
-
title: start < end ? semanticText(source.slice(start + 1, end - 1)) : null
|
|
3346
|
-
};
|
|
3347
|
-
}
|
|
3348
|
-
function reference(close, syntaxStart, syntaxEnd, context, image) {
|
|
3349
|
-
const closeText = inlineTokenText(context.view.text, context.tokens, close);
|
|
3350
|
-
const full = closeText.startsWith("][") && closeText !== "][]";
|
|
3351
|
-
const labelSource = full ? closeText.slice(2, -1) : context.view.text.slice(syntaxStart + (image ? 2 : 1), syntaxEnd - closeText.length);
|
|
3352
|
-
return {
|
|
3353
|
-
identifier: normalizeAssociationLabel(labelSource),
|
|
3354
|
-
label: semanticText(labelSource),
|
|
3355
|
-
referenceType: full ? "full" : closeText === "][]" ? "collapsed" : "shortcut"
|
|
3356
|
-
};
|
|
3357
|
-
}
|
|
3358
3189
|
function phrasingText(children) {
|
|
3359
3190
|
let result = "";
|
|
3360
3191
|
for (const child of children) if (child.type === "text" || child.type === "inlineCode" || child.type === "html") result += child.value;
|
|
@@ -3364,34 +3195,63 @@ function phrasingText(children) {
|
|
|
3364
3195
|
return result;
|
|
3365
3196
|
}
|
|
3366
3197
|
function createBuildMedia(media, resourceKind) {
|
|
3367
|
-
const
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3198
|
+
const isImage = media === "image";
|
|
3199
|
+
return resourceKind === "reference" ? (openToken, closeToken, position, children, context) => {
|
|
3200
|
+
const closeText = inlineTokenText(context.view.text, context.tokens, closeToken);
|
|
3201
|
+
const syntaxStart = inlineTokenStart(context.tokens, openToken);
|
|
3202
|
+
const syntaxEnd = inlineTokenEnd(context.tokens, closeToken);
|
|
3203
|
+
const full = closeText.startsWith("][") && closeText !== "][]";
|
|
3204
|
+
const labelSource = full ? closeText.slice(2, -1) : context.view.text.slice(syntaxStart + (isImage ? 2 : 1), syntaxEnd - closeText.length);
|
|
3205
|
+
const identifier = normalizeIdentifier(labelSource);
|
|
3206
|
+
const label = semanticText(labelSource);
|
|
3207
|
+
const referenceType = full ? "full" : closeText === "][]" ? "collapsed" : "shortcut";
|
|
3208
|
+
return isImage ? {
|
|
3209
|
+
type: "imageReference",
|
|
3210
|
+
alt: phrasingText(children),
|
|
3211
|
+
identifier,
|
|
3212
|
+
label,
|
|
3213
|
+
referenceType,
|
|
3214
|
+
position
|
|
3215
|
+
} : {
|
|
3216
|
+
type: "linkReference",
|
|
3217
|
+
children,
|
|
3218
|
+
identifier,
|
|
3219
|
+
label,
|
|
3220
|
+
referenceType,
|
|
3221
|
+
position
|
|
3222
|
+
};
|
|
3223
|
+
} : (openToken, closeToken, position, children, context) => {
|
|
3224
|
+
let url = "";
|
|
3225
|
+
let title = null;
|
|
3226
|
+
const tokenStart = inlineTokenStart(context.tokens, closeToken);
|
|
3227
|
+
let end = inlineTokenEnd(context.tokens, closeToken) - 1;
|
|
3228
|
+
const resourceEnd = tokenStart + inlineTokenData(context.tokens, closeToken);
|
|
3229
|
+
let start = skipWhitespace(context.view.text, tokenStart + 2, resourceEnd);
|
|
3230
|
+
if (start !== end) {
|
|
3231
|
+
let destinationEnd = resourceEnd;
|
|
3232
|
+
if (context.view.text.charCodeAt(start) === 60) {
|
|
3233
|
+
start++;
|
|
3234
|
+
destinationEnd--;
|
|
3235
|
+
}
|
|
3236
|
+
url = semanticText(context.view.text.slice(start, destinationEnd));
|
|
3237
|
+
start = skipWhitespace(context.view.text, resourceEnd, end);
|
|
3238
|
+
if (start < end) {
|
|
3239
|
+
while (end > start && isMarkdownWhitespace(context.view.text.charCodeAt(end - 1))) end--;
|
|
3240
|
+
title = semanticText(context.view.text.slice(start + 1, end - 1));
|
|
3241
|
+
}
|
|
3383
3242
|
}
|
|
3384
|
-
|
|
3385
|
-
return image ? {
|
|
3243
|
+
return isImage ? {
|
|
3386
3244
|
type: "image",
|
|
3387
3245
|
alt: phrasingText(children),
|
|
3388
|
-
|
|
3389
|
-
|
|
3246
|
+
url,
|
|
3247
|
+
title,
|
|
3248
|
+
position
|
|
3390
3249
|
} : {
|
|
3391
3250
|
type: "link",
|
|
3392
3251
|
children,
|
|
3393
|
-
|
|
3394
|
-
|
|
3252
|
+
url,
|
|
3253
|
+
title,
|
|
3254
|
+
position
|
|
3395
3255
|
};
|
|
3396
3256
|
};
|
|
3397
3257
|
}
|
|
@@ -3406,7 +3266,7 @@ const feature$5 = { inline: {
|
|
|
3406
3266
|
scan(source, start, tokens) {
|
|
3407
3267
|
if (source.charCodeAt(start + 1) !== 91) return start + 1;
|
|
3408
3268
|
const end = start + 2;
|
|
3409
|
-
appendInlineToken(tokens,
|
|
3269
|
+
appendInlineToken(tokens, 4, start, end);
|
|
3410
3270
|
return end;
|
|
3411
3271
|
}
|
|
3412
3272
|
},
|
|
@@ -3414,7 +3274,7 @@ const feature$5 = { inline: {
|
|
|
3414
3274
|
marker: 91,
|
|
3415
3275
|
scan(source, start, tokens) {
|
|
3416
3276
|
const end = start + 1;
|
|
3417
|
-
appendInlineToken(tokens,
|
|
3277
|
+
appendInlineToken(tokens, 5, start, end);
|
|
3418
3278
|
return end;
|
|
3419
3279
|
}
|
|
3420
3280
|
},
|
|
@@ -3423,7 +3283,7 @@ const feature$5 = { inline: {
|
|
|
3423
3283
|
scan(source, start, tokens) {
|
|
3424
3284
|
const end = scanLinkTail(source, start, tokens);
|
|
3425
3285
|
if (end >= 0) return end;
|
|
3426
|
-
appendInlineToken(tokens,
|
|
3286
|
+
appendInlineToken(tokens, 6, start, start + 1);
|
|
3427
3287
|
return start + 1;
|
|
3428
3288
|
}
|
|
3429
3289
|
}
|
|
@@ -3452,7 +3312,7 @@ const feature$5 = { inline: {
|
|
|
3452
3312
|
{
|
|
3453
3313
|
kind: "leaf",
|
|
3454
3314
|
token: 132,
|
|
3455
|
-
build(tokenIndex,
|
|
3315
|
+
build(tokenIndex, position, context) {
|
|
3456
3316
|
const label = inlineTokenText(context.view.text, context.tokens, tokenIndex, 1);
|
|
3457
3317
|
return {
|
|
3458
3318
|
type: "link",
|
|
@@ -3463,45 +3323,29 @@ const feature$5 = { inline: {
|
|
|
3463
3323
|
value: label,
|
|
3464
3324
|
position: {
|
|
3465
3325
|
start: {
|
|
3466
|
-
line:
|
|
3467
|
-
column:
|
|
3468
|
-
offset:
|
|
3326
|
+
line: position.start.line,
|
|
3327
|
+
column: position.start.column + 1,
|
|
3328
|
+
offset: position.start.offset + 1
|
|
3469
3329
|
},
|
|
3470
3330
|
end: {
|
|
3471
|
-
line:
|
|
3472
|
-
column:
|
|
3473
|
-
offset:
|
|
3331
|
+
line: position.end.line,
|
|
3332
|
+
column: position.end.column - 1,
|
|
3333
|
+
offset: position.end.offset - 1
|
|
3474
3334
|
}
|
|
3475
3335
|
}
|
|
3476
3336
|
}],
|
|
3477
|
-
position
|
|
3337
|
+
position
|
|
3478
3338
|
};
|
|
3479
3339
|
}
|
|
3480
3340
|
},
|
|
3481
3341
|
{
|
|
3482
3342
|
kind: "text",
|
|
3483
|
-
token:
|
|
3484
|
-
build: buildInlineText
|
|
3485
|
-
},
|
|
3486
|
-
{
|
|
3487
|
-
kind: "text",
|
|
3488
|
-
token: 71,
|
|
3489
|
-
build: buildInlineText
|
|
3490
|
-
},
|
|
3491
|
-
{
|
|
3492
|
-
kind: "text",
|
|
3493
|
-
token: 73,
|
|
3343
|
+
token: 68,
|
|
3494
3344
|
build: buildDecodedInlineText
|
|
3495
|
-
},
|
|
3496
|
-
{
|
|
3497
|
-
kind: "text",
|
|
3498
|
-
token: 74,
|
|
3499
|
-
build: buildInlineText
|
|
3500
3345
|
}
|
|
3501
3346
|
]
|
|
3502
3347
|
} };
|
|
3503
|
-
|
|
3504
|
-
//#region src/profile/features/list.ts
|
|
3348
|
+
// src/profile/features/list.ts
|
|
3505
3349
|
function listMarkerAt(source, lines, index, contentOffset) {
|
|
3506
3350
|
if (contentOffset < 0) return;
|
|
3507
3351
|
const indent = lines.prefixColumns(index) + contentOffset - lines.start(index);
|
|
@@ -3584,7 +3428,8 @@ function taskListMarkerAt(source, start, end) {
|
|
|
3584
3428
|
};
|
|
3585
3429
|
}
|
|
3586
3430
|
function hasTaskListContent(source, tokens, firstChunk, contentStart) {
|
|
3587
|
-
|
|
3431
|
+
const tokenEnd = firstChunk - 1 + tokens.nodeLength(firstChunk - 1);
|
|
3432
|
+
for (let token = firstChunk; token < tokenEnd; token++) {
|
|
3588
3433
|
const start = token === firstChunk ? contentStart : tokens.start(token);
|
|
3589
3434
|
const end = tokens.end(token);
|
|
3590
3435
|
for (let offset = start; offset < end; offset++) if (!isTaskListWhitespace(source.charCodeAt(offset))) return true;
|
|
@@ -3594,47 +3439,49 @@ function hasTaskListContent(source, tokens, firstChunk, contentStart) {
|
|
|
3594
3439
|
const buildListItem = (tokenStart, context) => {
|
|
3595
3440
|
const tokens = context.structure.tokens;
|
|
3596
3441
|
const markerKind = tokens.kind(tokenStart);
|
|
3442
|
+
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
3597
3443
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
3598
3444
|
const children = buildBlockChildren(tokenStart, context);
|
|
3599
|
-
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
3600
3445
|
return {
|
|
3601
3446
|
type: "listItem",
|
|
3602
|
-
spread: tokens.
|
|
3603
|
-
checked: markerKind ===
|
|
3447
|
+
spread: tokens.kind(close) === 194,
|
|
3448
|
+
checked: markerKind === 77 ? true : markerKind === 76 ? false : null,
|
|
3604
3449
|
children,
|
|
3605
3450
|
position: {
|
|
3606
3451
|
start,
|
|
3607
|
-
end:
|
|
3452
|
+
end: children.length ? cloneLocation(children.at(-1).position.end) : context.locator.locationAt(tokens.end(close))
|
|
3608
3453
|
}
|
|
3609
3454
|
};
|
|
3610
3455
|
};
|
|
3456
|
+
function listStartNumber(source, tokens, tokenStart) {
|
|
3457
|
+
const digits = source.slice(tokens.start(tokenStart), tokens.end(tokenStart) - 1);
|
|
3458
|
+
return Number(digits);
|
|
3459
|
+
}
|
|
3611
3460
|
function createBuildList(ordered) {
|
|
3612
3461
|
return (tokenStart, context) => {
|
|
3613
3462
|
const tokens = context.structure.tokens;
|
|
3614
|
-
const items = [];
|
|
3615
3463
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
3616
|
-
|
|
3464
|
+
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
3465
|
+
const children = buildBlockChildren(tokenStart, context);
|
|
3617
3466
|
return {
|
|
3618
3467
|
type: "list",
|
|
3619
3468
|
ordered,
|
|
3620
|
-
start: ordered ? tokens
|
|
3621
|
-
spread: tokens.
|
|
3622
|
-
children
|
|
3469
|
+
start: ordered ? listStartNumber(context.source, tokens, tokenStart) : null,
|
|
3470
|
+
spread: tokens.kind(close) === 196,
|
|
3471
|
+
children,
|
|
3623
3472
|
position: {
|
|
3624
|
-
start
|
|
3625
|
-
end:
|
|
3473
|
+
start,
|
|
3474
|
+
end: cloneLocation(children.at(-1).position.end)
|
|
3626
3475
|
}
|
|
3627
3476
|
};
|
|
3628
3477
|
};
|
|
3629
3478
|
}
|
|
3630
|
-
const listStart = (source, lines, start, contentOffset,
|
|
3479
|
+
const listStart = (source, lines, tokens, start, contentOffset, context) => {
|
|
3631
3480
|
let marker = listMarkerAt(source, lines, start, contentOffset);
|
|
3632
3481
|
if (!marker) return;
|
|
3633
3482
|
const delimiter = marker.delimiter;
|
|
3634
|
-
const
|
|
3635
|
-
|
|
3636
|
-
const listClose = ordered ? 196 : 195;
|
|
3637
|
-
out.push(listOpen, marker.offset, marker.end, ordered ? { value: marker.startNumber } : void 0);
|
|
3483
|
+
const listOpen = delimiter === 46 || delimiter === 41 ? 74 : 73;
|
|
3484
|
+
tokens.push(listOpen, marker.offset, marker.end);
|
|
3638
3485
|
let index = start;
|
|
3639
3486
|
let listEnd = marker.end;
|
|
3640
3487
|
let listSpread = false;
|
|
@@ -3643,7 +3490,7 @@ const listStart = (source, lines, start, contentOffset, out, context) => {
|
|
|
3643
3490
|
let sibling;
|
|
3644
3491
|
listSpread ||= trailingBlank;
|
|
3645
3492
|
trailingBlank = false;
|
|
3646
|
-
|
|
3493
|
+
tokens.push(75, marker.offset, marker.end);
|
|
3647
3494
|
const itemLines = context.createLineView(lines, index, marker.contentOffset, marker.contentPrefixColumns);
|
|
3648
3495
|
let hasContent = marker.hasContent;
|
|
3649
3496
|
let paragraphLeaf = hasContent ? 2 : 0;
|
|
@@ -3681,43 +3528,55 @@ const listStart = (source, lines, start, contentOffset, out, context) => {
|
|
|
3681
3528
|
itemLines.pushLazy(lines, index);
|
|
3682
3529
|
index++;
|
|
3683
3530
|
}
|
|
3684
|
-
const itemSpread = context.scanLines(source, itemLines,
|
|
3685
|
-
|
|
3686
|
-
|
|
3531
|
+
const itemSpread = context.scanLines(source, itemLines, tokens);
|
|
3532
|
+
const itemEnd = itemLines.length ? itemLines.end(itemLines.length - 1) : marker.end;
|
|
3533
|
+
tokens.push(itemSpread ? 194 : 193, itemEnd, itemEnd);
|
|
3534
|
+
listEnd = itemEnd;
|
|
3687
3535
|
marker = sibling;
|
|
3688
3536
|
}
|
|
3689
|
-
|
|
3537
|
+
tokens.push(listSpread ? 196 : 195, listEnd, listEnd);
|
|
3690
3538
|
return index;
|
|
3691
3539
|
};
|
|
3692
|
-
const taskListStart = (source, lines, start, contentOffset,
|
|
3693
|
-
const listToken =
|
|
3694
|
-
const nextLine = listStart(source, lines, start, contentOffset,
|
|
3540
|
+
const taskListStart = (source, lines, tokens, start, contentOffset, context) => {
|
|
3541
|
+
const listToken = tokens.length;
|
|
3542
|
+
const nextLine = listStart(source, lines, tokens, start, contentOffset, context);
|
|
3695
3543
|
if (nextLine === void 0) return;
|
|
3696
|
-
for (let item = listToken + 1; item <
|
|
3544
|
+
for (let item = listToken + 1; item < tokens.length - 1; item += tokens.nodeLength(item)) {
|
|
3697
3545
|
let paragraph = item + 1;
|
|
3698
|
-
let contentKind =
|
|
3699
|
-
while (contentKind ===
|
|
3700
|
-
paragraph
|
|
3701
|
-
contentKind =
|
|
3546
|
+
let contentKind = tokens.kind(paragraph);
|
|
3547
|
+
while (contentKind === 257) {
|
|
3548
|
+
paragraph += tokens.nodeLength(paragraph);
|
|
3549
|
+
contentKind = tokens.kind(paragraph);
|
|
3702
3550
|
}
|
|
3703
|
-
if (contentKind !==
|
|
3551
|
+
if (contentKind !== 79) continue;
|
|
3704
3552
|
const firstChunk = paragraph + 1;
|
|
3705
|
-
const marker = taskListMarkerAt(source,
|
|
3706
|
-
if (!marker || !hasTaskListContent(source,
|
|
3707
|
-
|
|
3708
|
-
|
|
3553
|
+
const marker = taskListMarkerAt(source, tokens.start(firstChunk), tokens.end(firstChunk));
|
|
3554
|
+
if (!marker || !hasTaskListContent(source, tokens, firstChunk, marker.contentStart)) continue;
|
|
3555
|
+
tokens.setKind(item, marker.checked ? 77 : 76);
|
|
3556
|
+
tokens.setStart(firstChunk, marker.contentStart);
|
|
3709
3557
|
}
|
|
3710
3558
|
return nextLine;
|
|
3711
3559
|
};
|
|
3712
3560
|
function feature$4(taskList = false) {
|
|
3713
3561
|
return { block: {
|
|
3714
|
-
builds: [
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3562
|
+
builds: [
|
|
3563
|
+
{
|
|
3564
|
+
token: [
|
|
3565
|
+
75,
|
|
3566
|
+
76,
|
|
3567
|
+
77
|
|
3568
|
+
],
|
|
3569
|
+
build: buildListItem
|
|
3570
|
+
},
|
|
3571
|
+
{
|
|
3572
|
+
token: 73,
|
|
3573
|
+
build: createBuildList(false)
|
|
3574
|
+
},
|
|
3575
|
+
{
|
|
3576
|
+
token: 74,
|
|
3577
|
+
build: createBuildList(true)
|
|
3578
|
+
}
|
|
3579
|
+
],
|
|
3721
3580
|
starts: [{
|
|
3722
3581
|
codes: [
|
|
3723
3582
|
42,
|
|
@@ -3748,45 +3607,41 @@ function feature$4(taskList = false) {
|
|
|
3748
3607
|
}]
|
|
3749
3608
|
} };
|
|
3750
3609
|
}
|
|
3751
|
-
|
|
3752
|
-
//#region src/profile/features/math/block.ts
|
|
3610
|
+
// src/profile/features/math/block.ts
|
|
3753
3611
|
const mathFenceRule = {
|
|
3754
3612
|
forbiddenInfoMarker: 36,
|
|
3755
3613
|
marker: 36,
|
|
3756
3614
|
minimumLength: 2
|
|
3757
3615
|
};
|
|
3758
3616
|
const blockBuilds = [{
|
|
3759
|
-
token:
|
|
3617
|
+
token: 262,
|
|
3760
3618
|
build(tokenStart, context) {
|
|
3761
3619
|
const tokens = context.structure.tokens;
|
|
3762
|
-
const block = tokens.value(tokenStart);
|
|
3763
|
-
const value = block.content ?? tokens.text(context.source, tokenStart);
|
|
3764
3620
|
return {
|
|
3765
3621
|
type: "math",
|
|
3766
|
-
meta: semanticText(
|
|
3767
|
-
value:
|
|
3768
|
-
position:
|
|
3622
|
+
meta: semanticText(tokens.value(tokenStart)) || null,
|
|
3623
|
+
value: tokens.text(context.source, tokenStart),
|
|
3624
|
+
position: context.locator.positionAt(tokens.start(tokenStart), tokens.end(tokenStart))
|
|
3769
3625
|
};
|
|
3770
3626
|
}
|
|
3771
3627
|
}];
|
|
3772
3628
|
const blockStarts = [{
|
|
3773
3629
|
codes: [36],
|
|
3774
3630
|
interrupt(source, lines, index, contentOffset) {
|
|
3775
|
-
return fenceAt
|
|
3631
|
+
return fenceAt(source, lines, index, mathFenceRule, contentOffset) !== void 0;
|
|
3776
3632
|
},
|
|
3777
|
-
start(source, lines, start, contentOffset
|
|
3778
|
-
const fence = fenceAt
|
|
3633
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
3634
|
+
const fence = fenceAt(source, lines, start, mathFenceRule, contentOffset);
|
|
3779
3635
|
if (!fence) return;
|
|
3780
3636
|
let end = start + 1;
|
|
3781
3637
|
while (end < lines.length && !closesFence(source, lines, end, fence)) end++;
|
|
3782
3638
|
const closed = end < lines.length;
|
|
3783
3639
|
if (end < lines.length) end++;
|
|
3784
|
-
|
|
3640
|
+
appendFencedToken(source, lines, tokens, 262, start, end, fence, closed, false);
|
|
3785
3641
|
return end;
|
|
3786
3642
|
}
|
|
3787
3643
|
}];
|
|
3788
|
-
|
|
3789
|
-
//#region src/profile/features/math/inline.ts
|
|
3644
|
+
// src/profile/features/math/inline.ts
|
|
3790
3645
|
function createMathScanRule(singleDollarTextMath) {
|
|
3791
3646
|
const minimum = singleDollarTextMath ? 1 : 2;
|
|
3792
3647
|
return {
|
|
@@ -3817,7 +3672,7 @@ function createMathScanRule(singleDollarTextMath) {
|
|
|
3817
3672
|
const inlineBuilds = [{
|
|
3818
3673
|
kind: "leaf",
|
|
3819
3674
|
token: 134,
|
|
3820
|
-
build(tokenIndex,
|
|
3675
|
+
build(tokenIndex, position, context) {
|
|
3821
3676
|
const markerLength = inlineTokenData(context.tokens, tokenIndex);
|
|
3822
3677
|
let value = inlineTokenText(context.view.text, context.tokens, tokenIndex, markerLength);
|
|
3823
3678
|
const startPadding = value.startsWith("\r\n") ? 2 : /^[ \r\n]/.test(value) ? 1 : 0;
|
|
@@ -3826,12 +3681,11 @@ const inlineBuilds = [{
|
|
|
3826
3681
|
return {
|
|
3827
3682
|
type: "inlineMath",
|
|
3828
3683
|
value,
|
|
3829
|
-
position
|
|
3684
|
+
position
|
|
3830
3685
|
};
|
|
3831
3686
|
}
|
|
3832
3687
|
}];
|
|
3833
|
-
|
|
3834
|
-
//#region src/profile/features/math/index.ts
|
|
3688
|
+
// src/profile/features/math/index.ts
|
|
3835
3689
|
function feature$3(options) {
|
|
3836
3690
|
const singleDollarTextMath = typeof options !== "object" || options.singleDollarTextMath !== false;
|
|
3837
3691
|
return {
|
|
@@ -3845,49 +3699,61 @@ function feature$3(options) {
|
|
|
3845
3699
|
}
|
|
3846
3700
|
};
|
|
3847
3701
|
}
|
|
3848
|
-
|
|
3849
|
-
//#region src/profile/features/paragraph.ts
|
|
3702
|
+
// src/profile/features/paragraph.ts
|
|
3850
3703
|
const feature$2 = { block: {
|
|
3851
|
-
fallbacks: [(source, lines, start, contentOffset,
|
|
3852
|
-
const openToken =
|
|
3853
|
-
|
|
3854
|
-
out.push(99, offset, offset);
|
|
3704
|
+
fallbacks: [(source, lines, tokens, start, contentOffset, context) => {
|
|
3705
|
+
const openToken = tokens.length;
|
|
3706
|
+
tokens.push(79, contentOffset, contentOffset);
|
|
3855
3707
|
let chunkOffset = contentOffset;
|
|
3708
|
+
let withBoundaryBreak = false;
|
|
3856
3709
|
let index = start + 1;
|
|
3857
3710
|
while (index < lines.length) {
|
|
3858
3711
|
const lineEnd = lines.end(index);
|
|
3859
|
-
const contentStart =
|
|
3712
|
+
const contentStart = trimLineWhitespaceStart(source, lines.start(index), lineEnd);
|
|
3860
3713
|
if (contentStart === lineEnd) break;
|
|
3861
3714
|
const chunkStart = indentOffset(source, lines, index);
|
|
3862
3715
|
if (!lines.lazy(index) && chunkStart === contentStart) {
|
|
3863
3716
|
const setext = setextMarkerAt(source, lines, index, contentStart);
|
|
3864
3717
|
if (setext) {
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3718
|
+
tokens.setKind(openToken, setext === 61 ? 70 : 71);
|
|
3719
|
+
tokens.setEnd(openToken, lineEnd);
|
|
3720
|
+
tokens.closeRange(chunkOffset, lines.end(index - 1));
|
|
3868
3721
|
return index + 1;
|
|
3869
3722
|
}
|
|
3870
3723
|
if (context.startsInterruptingBlock(source, lines, index, contentStart)) break;
|
|
3871
3724
|
}
|
|
3872
|
-
|
|
3873
|
-
|
|
3725
|
+
const previousEnd = lines.next(index - 1);
|
|
3726
|
+
const newline = lines.end(index - 1);
|
|
3727
|
+
if (!withBoundaryBreak && source.charCodeAt(newline) === 10) {
|
|
3728
|
+
const previous = source.charCodeAt(newline - 1);
|
|
3729
|
+
if (previous === 32 || previous === 9 || source.charCodeAt(chunkStart) === 32) {
|
|
3730
|
+
withBoundaryBreak = true;
|
|
3731
|
+
tokens.setValue(openToken, boundaryBreak);
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
if (chunkStart !== previousEnd) {
|
|
3735
|
+
tokens.push(1, chunkOffset, previousEnd);
|
|
3736
|
+
chunkOffset = chunkStart;
|
|
3737
|
+
}
|
|
3874
3738
|
index++;
|
|
3875
3739
|
}
|
|
3876
3740
|
const close = lines.end(index - 1);
|
|
3877
|
-
|
|
3878
|
-
out.push(194, close, close);
|
|
3741
|
+
tokens.closeRange(chunkOffset, close);
|
|
3879
3742
|
return index;
|
|
3880
3743
|
}],
|
|
3881
3744
|
builds: [{
|
|
3882
|
-
token:
|
|
3745
|
+
token: 79,
|
|
3883
3746
|
build(tokenStart, context) {
|
|
3747
|
+
const tokens = context.structure.tokens;
|
|
3748
|
+
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
3749
|
+
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
3884
3750
|
const inline = buildInlineFragment(tokenStart, false, context);
|
|
3885
3751
|
const result = {
|
|
3886
3752
|
type: "paragraph",
|
|
3887
3753
|
children: inline.children,
|
|
3888
3754
|
position: {
|
|
3889
|
-
start
|
|
3890
|
-
end: context.locator.locationAt(
|
|
3755
|
+
start,
|
|
3756
|
+
end: context.locator.locationAt(tokens.end(close))
|
|
3891
3757
|
}
|
|
3892
3758
|
};
|
|
3893
3759
|
if (inline.attributes) result.attributes = inline.attributes;
|
|
@@ -3895,8 +3761,7 @@ const feature$2 = { block: {
|
|
|
3895
3761
|
}
|
|
3896
3762
|
}]
|
|
3897
3763
|
} };
|
|
3898
|
-
|
|
3899
|
-
//#region src/profile/features/reference.ts
|
|
3764
|
+
// src/profile/features/reference.ts
|
|
3900
3765
|
function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
3901
3766
|
let offset = contentOffset + 1;
|
|
3902
3767
|
const labelClose = source.indexOf("]", offset);
|
|
@@ -3944,7 +3809,7 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
3944
3809
|
if (!labelHasContent) break parseDefinition;
|
|
3945
3810
|
offset += 2;
|
|
3946
3811
|
let lineEnd = lines.end(lineIndex);
|
|
3947
|
-
offset =
|
|
3812
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
3948
3813
|
if (offset === lineEnd) {
|
|
3949
3814
|
const nextLine = lineIndex + 1;
|
|
3950
3815
|
lookaheadEnd = nextLine < lines.length ? lines.end(nextLine) : lines.next(lineIndex);
|
|
@@ -3952,18 +3817,20 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
3952
3817
|
lineIndex++;
|
|
3953
3818
|
offset = lines.start(lineIndex);
|
|
3954
3819
|
lineEnd = lines.end(lineIndex);
|
|
3955
|
-
offset =
|
|
3820
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
3956
3821
|
}
|
|
3957
3822
|
let destination;
|
|
3958
|
-
if (source
|
|
3823
|
+
if (source.charCodeAt(offset) === 60) {
|
|
3959
3824
|
offset++;
|
|
3825
|
+
let code = source.charCodeAt(offset);
|
|
3960
3826
|
const destinationStart = offset;
|
|
3961
|
-
while (offset < lineEnd &&
|
|
3962
|
-
if (
|
|
3963
|
-
if (
|
|
3827
|
+
while (offset < lineEnd && code !== 62) {
|
|
3828
|
+
if (code === 60) break parseDefinition;
|
|
3829
|
+
if (code === 92 && offset + 1 < lineEnd) offset += 2;
|
|
3964
3830
|
else offset++;
|
|
3831
|
+
code = source.charCodeAt(offset);
|
|
3965
3832
|
}
|
|
3966
|
-
if (
|
|
3833
|
+
if (code !== 62) break parseDefinition;
|
|
3967
3834
|
destination = source.slice(destinationStart, offset);
|
|
3968
3835
|
offset++;
|
|
3969
3836
|
} else {
|
|
@@ -3985,25 +3852,29 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
3985
3852
|
destination = source.slice(destinationStart, offset);
|
|
3986
3853
|
}
|
|
3987
3854
|
const destinationLine = lineIndex;
|
|
3988
|
-
if (offset < lineEnd
|
|
3989
|
-
|
|
3855
|
+
if (offset < lineEnd) {
|
|
3856
|
+
const code = source.charCodeAt(offset);
|
|
3857
|
+
if (code !== 32 && code !== 9) break parseDefinition;
|
|
3858
|
+
}
|
|
3859
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
3990
3860
|
let titleOnNextLine = false;
|
|
3991
3861
|
if (offset === lineEnd && lineIndex + 1 < lines.length) {
|
|
3992
3862
|
lookaheadEnd = lines.end(lineIndex + 1);
|
|
3993
3863
|
lineIndex++;
|
|
3994
3864
|
offset = lines.start(lineIndex);
|
|
3995
3865
|
lineEnd = lines.end(lineIndex);
|
|
3996
|
-
offset =
|
|
3866
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
3997
3867
|
titleOnNextLine = true;
|
|
3998
3868
|
}
|
|
3999
|
-
const
|
|
4000
|
-
const
|
|
3869
|
+
const code = source.charCodeAt(offset);
|
|
3870
|
+
const closer = code === 40 ? 41 : code === 34 || code === 39 ? code : void 0;
|
|
3871
|
+
const definitionKey = normalizeIdentifier(label);
|
|
4001
3872
|
const fields = {
|
|
4002
3873
|
destination,
|
|
4003
3874
|
label,
|
|
4004
3875
|
title: void 0
|
|
4005
3876
|
};
|
|
4006
|
-
if (
|
|
3877
|
+
if (closer === void 0) return {
|
|
4007
3878
|
definitionKey,
|
|
4008
3879
|
end: destinationLine + 1,
|
|
4009
3880
|
fields
|
|
@@ -4015,11 +3886,12 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
4015
3886
|
while (lineIndex < lines.length) {
|
|
4016
3887
|
lineEnd = lines.end(lineIndex);
|
|
4017
3888
|
while (offset < lineEnd) {
|
|
4018
|
-
|
|
3889
|
+
const code = source.charCodeAt(offset);
|
|
3890
|
+
if (code === 92 && offset + 1 < lineEnd) {
|
|
4019
3891
|
offset += 2;
|
|
4020
3892
|
continue;
|
|
4021
3893
|
}
|
|
4022
|
-
if (
|
|
3894
|
+
if (code === closer) {
|
|
4023
3895
|
title += source.slice(titleStart, offset);
|
|
4024
3896
|
offset++;
|
|
4025
3897
|
closed = true;
|
|
@@ -4037,7 +3909,7 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
4037
3909
|
titleStart = offset;
|
|
4038
3910
|
}
|
|
4039
3911
|
if (closed) {
|
|
4040
|
-
offset =
|
|
3912
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
4041
3913
|
if (offset === lineEnd) {
|
|
4042
3914
|
fields.title = title;
|
|
4043
3915
|
return {
|
|
@@ -4059,7 +3931,7 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
4059
3931
|
}
|
|
4060
3932
|
const feature$1 = { block: {
|
|
4061
3933
|
builds: [{
|
|
4062
|
-
token:
|
|
3934
|
+
token: 257,
|
|
4063
3935
|
build(tokenStart, context) {
|
|
4064
3936
|
const tokens = context.structure.tokens;
|
|
4065
3937
|
const fields = tokens.value(tokenStart);
|
|
@@ -4075,72 +3947,47 @@ const feature$1 = { block: {
|
|
|
4075
3947
|
}],
|
|
4076
3948
|
starts: [{
|
|
4077
3949
|
codes: [91],
|
|
4078
|
-
start(source, lines, start, contentOffset,
|
|
3950
|
+
start(source, lines, tokens, start, contentOffset, context) {
|
|
4079
3951
|
const definition = linkDefinitionAt(source, lines, start, contentOffset, context);
|
|
4080
3952
|
if (!definition) return;
|
|
4081
|
-
|
|
3953
|
+
tokens.push(257, contentOffset, lines.end(definition.end - 1), {
|
|
4082
3954
|
definitionKey: definition.definitionKey,
|
|
4083
3955
|
value: definition.fields
|
|
4084
3956
|
});
|
|
4085
|
-
let definitionEnd = contentOffset;
|
|
4086
|
-
for (let definitionLine = start; definitionLine < definition.end; definitionLine++) {
|
|
4087
|
-
definitionEnd = definitionLine + 1 < definition.end ? lines.next(definitionLine) : lines.end(definitionLine);
|
|
4088
|
-
out.push(2, lines.start(definitionLine), definitionEnd);
|
|
4089
|
-
}
|
|
4090
|
-
out.push(198, definitionEnd, definitionEnd);
|
|
4091
3957
|
return definition.end;
|
|
4092
3958
|
}
|
|
4093
3959
|
}]
|
|
4094
3960
|
} };
|
|
4095
|
-
|
|
4096
|
-
//#region src/profile/features/table.ts
|
|
3961
|
+
// src/profile/features/table.ts
|
|
4097
3962
|
function appendTableCell(cells, source, start, contentStart, contentEnd) {
|
|
4098
|
-
contentStart =
|
|
4099
|
-
|
|
4100
|
-
const code = source.charCodeAt(contentEnd - 1);
|
|
4101
|
-
if (code !== 32 && code !== 9) break;
|
|
4102
|
-
contentEnd--;
|
|
4103
|
-
}
|
|
3963
|
+
contentStart = trimLineWhitespaceStart(source, contentStart, contentEnd);
|
|
3964
|
+
contentEnd = trimLineWhitespaceEnd(source, contentStart, contentEnd);
|
|
4104
3965
|
cells.push(start, contentStart, contentEnd);
|
|
4105
3966
|
}
|
|
4106
3967
|
function tableCellsAt(source, lines, index, requirePipe, contentOffset) {
|
|
4107
3968
|
if (contentOffset < 0) return;
|
|
4108
|
-
const pipes = [];
|
|
4109
|
-
let backslashes = 0;
|
|
4110
3969
|
const lineEnd = lines.end(index);
|
|
4111
|
-
|
|
4112
|
-
const code = source.charCodeAt(offset);
|
|
4113
|
-
if (code === 92) {
|
|
4114
|
-
backslashes++;
|
|
4115
|
-
continue;
|
|
4116
|
-
}
|
|
4117
|
-
if (code === 124 && backslashes % 2 === 0) pipes.push(offset);
|
|
4118
|
-
backslashes = 0;
|
|
4119
|
-
}
|
|
4120
|
-
if (requirePipe && pipes.length === 0) return;
|
|
4121
|
-
let visibleEnd = lineEnd;
|
|
4122
|
-
while (visibleEnd > contentOffset) {
|
|
4123
|
-
const code = source.charCodeAt(visibleEnd - 1);
|
|
4124
|
-
if (code !== 32 && code !== 9) break;
|
|
4125
|
-
visibleEnd--;
|
|
4126
|
-
}
|
|
4127
|
-
const trailingPipe = pipes.at(-1) === visibleEnd - 1;
|
|
4128
|
-
const leadingPipe = pipes[0] === contentOffset;
|
|
3970
|
+
const row = source.slice(contentOffset, lineEnd);
|
|
4129
3971
|
const cells = [];
|
|
4130
3972
|
let contentStart = contentOffset;
|
|
4131
3973
|
let spanStart = contentOffset;
|
|
4132
|
-
let
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
3974
|
+
let lastPipe;
|
|
3975
|
+
for (let pipe = row.indexOf("|"); pipe >= 0; pipe = row.indexOf("|", pipe + 1)) {
|
|
3976
|
+
let escapeStart = pipe;
|
|
3977
|
+
while (escapeStart > 0 && row.charCodeAt(escapeStart - 1) === 92) escapeStart--;
|
|
3978
|
+
if ((pipe - escapeStart) % 2 !== 0) continue;
|
|
3979
|
+
lastPipe = contentOffset + pipe;
|
|
3980
|
+
if (pipe === 0) {
|
|
3981
|
+
contentStart++;
|
|
3982
|
+
continue;
|
|
3983
|
+
}
|
|
3984
|
+
appendTableCell(cells, source, spanStart, contentStart, lastPipe);
|
|
3985
|
+
spanStart = lastPipe;
|
|
3986
|
+
contentStart = lastPipe + 1;
|
|
3987
|
+
}
|
|
3988
|
+
if (requirePipe && lastPipe === void 0) return;
|
|
3989
|
+
const visibleEnd = trimLineWhitespaceEnd(source, contentOffset, lineEnd);
|
|
3990
|
+
if (lastPipe !== visibleEnd - 1) appendTableCell(cells, source, spanStart, contentStart, lineEnd);
|
|
4144
3991
|
return cells.length > 0 ? cells : void 0;
|
|
4145
3992
|
}
|
|
4146
3993
|
function alignmentAt(source, cells, cell) {
|
|
@@ -4150,9 +3997,9 @@ function alignmentAt(source, cells, cell) {
|
|
|
4150
3997
|
if (left) start++;
|
|
4151
3998
|
const right = source.charCodeAt(end - 1) === 58;
|
|
4152
3999
|
if (right) end--;
|
|
4153
|
-
if (start
|
|
4000
|
+
if (start >= end) return;
|
|
4154
4001
|
for (let offset = start; offset < end; offset++) if (source.charCodeAt(offset) !== 45) return;
|
|
4155
|
-
return left ? right ?
|
|
4002
|
+
return left ? right ? 267 : 265 : right ? 266 : 264;
|
|
4156
4003
|
}
|
|
4157
4004
|
function delimiterAt(source, lines, index, contentOffset) {
|
|
4158
4005
|
const first = source.charCodeAt(contentOffset);
|
|
@@ -4166,15 +4013,15 @@ function delimiterAt(source, lines, index, contentOffset) {
|
|
|
4166
4013
|
}
|
|
4167
4014
|
return cells;
|
|
4168
4015
|
}
|
|
4169
|
-
function emitTableRow(lines, index, cells
|
|
4170
|
-
|
|
4016
|
+
function emitTableRow(lines, tokens, index, cells) {
|
|
4017
|
+
tokens.push(81, cells[0], cells[0]);
|
|
4171
4018
|
for (let cell = 0; cell < cells.length; cell += 3) {
|
|
4172
4019
|
const start = cells[cell];
|
|
4173
|
-
|
|
4174
|
-
|
|
4020
|
+
tokens.push(82, start, start);
|
|
4021
|
+
tokens.closeRange(cells[cell + 1], cells[cell + 2]);
|
|
4175
4022
|
}
|
|
4176
4023
|
const lineEnd = lines.end(index);
|
|
4177
|
-
|
|
4024
|
+
tokens.push(199, lineEnd, lineEnd);
|
|
4178
4025
|
}
|
|
4179
4026
|
const buildTableCell = (tokenStart, context) => {
|
|
4180
4027
|
const tokens = context.structure.tokens;
|
|
@@ -4192,11 +4039,9 @@ const buildTableRow = (tokenStart, context) => {
|
|
|
4192
4039
|
const tokens = context.structure.tokens;
|
|
4193
4040
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
4194
4041
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
4195
|
-
const children = [];
|
|
4196
|
-
for (let cell = tokenStart + 1; cell < close; cell += tokens.nodeLength(cell)) children.push(buildTableCell(cell, context));
|
|
4197
4042
|
return {
|
|
4198
4043
|
type: "tableRow",
|
|
4199
|
-
children,
|
|
4044
|
+
children: buildBlockChildren(tokenStart, context),
|
|
4200
4045
|
position: {
|
|
4201
4046
|
start,
|
|
4202
4047
|
end: context.locator.locationAt(tokens.start(close))
|
|
@@ -4205,16 +4050,15 @@ const buildTableRow = (tokenStart, context) => {
|
|
|
4205
4050
|
};
|
|
4206
4051
|
function tableAlignment(tokenStart, context) {
|
|
4207
4052
|
const tokens = context.structure.tokens;
|
|
4208
|
-
const tokenEnd = tokenStart + tokens.nodeLength(tokenStart);
|
|
4209
4053
|
const result = [];
|
|
4210
|
-
for (let token = tokenStart; token
|
|
4054
|
+
for (let token = tokenStart; tokens.kind(token) !== 81 && tokens.kind(token) !== 198; token++) {
|
|
4211
4055
|
const kind = tokens.kind(token);
|
|
4212
|
-
result.push(kind ===
|
|
4056
|
+
result.push(kind === 265 ? "left" : kind === 266 ? "right" : kind === 267 ? "center" : null);
|
|
4213
4057
|
}
|
|
4214
4058
|
return result;
|
|
4215
4059
|
}
|
|
4216
4060
|
const feature = { block: {
|
|
4217
|
-
fallbacks: [(source, lines, start, contentOffset,
|
|
4061
|
+
fallbacks: [(source, lines, tokens, start, contentOffset, context) => {
|
|
4218
4062
|
const delimiterLine = start + 1;
|
|
4219
4063
|
if (delimiterLine >= lines.length) return;
|
|
4220
4064
|
const delimiterOffset = lineIndentOffset(source, lines, delimiterLine);
|
|
@@ -4223,47 +4067,53 @@ const feature = { block: {
|
|
|
4223
4067
|
if (!delimiter) return;
|
|
4224
4068
|
const header = tableCellsAt(source, lines, start, true, contentOffset);
|
|
4225
4069
|
if (header?.length !== delimiter.length) return;
|
|
4226
|
-
|
|
4227
|
-
emitTableRow(lines, start, header
|
|
4070
|
+
tokens.push(80, header[0], header[0]);
|
|
4071
|
+
emitTableRow(lines, tokens, start, header);
|
|
4228
4072
|
const delimiterEnd = lines.end(delimiterLine);
|
|
4229
|
-
for (let cell = 0; cell < delimiter.length; cell += 3)
|
|
4073
|
+
for (let cell = 0; cell < delimiter.length; cell += 3) tokens.push(delimiter[cell + 1], delimiter[cell], delimiter[cell + 3] ?? delimiterEnd);
|
|
4230
4074
|
let end = start + 2;
|
|
4231
4075
|
while (end < lines.length) {
|
|
4232
4076
|
const contentOffset = lineIndentOffset(source, lines, end);
|
|
4233
4077
|
if (contentOffset < 0 || context.startsInterruptingBlock(source, lines, end, contentOffset)) break;
|
|
4234
4078
|
const cells = tableCellsAt(source, lines, end, false, contentOffset);
|
|
4235
4079
|
if (!cells) break;
|
|
4236
|
-
emitTableRow(lines, end, cells
|
|
4080
|
+
emitTableRow(lines, tokens, end, cells);
|
|
4237
4081
|
end++;
|
|
4238
4082
|
}
|
|
4239
4083
|
const tableEnd = lines.end(end - 1);
|
|
4240
|
-
|
|
4084
|
+
tokens.push(198, tableEnd, tableEnd);
|
|
4241
4085
|
return end;
|
|
4242
4086
|
}],
|
|
4243
|
-
builds: [
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4087
|
+
builds: [
|
|
4088
|
+
{
|
|
4089
|
+
token: 82,
|
|
4090
|
+
build: buildTableCell
|
|
4091
|
+
},
|
|
4092
|
+
{
|
|
4093
|
+
token: 81,
|
|
4094
|
+
build: buildTableRow
|
|
4095
|
+
},
|
|
4096
|
+
{
|
|
4097
|
+
token: 80,
|
|
4098
|
+
build(tokenStart, context) {
|
|
4099
|
+
const tokens = context.structure.tokens;
|
|
4100
|
+
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
4101
|
+
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
4102
|
+
const header = tokenStart + 1;
|
|
4103
|
+
return {
|
|
4104
|
+
type: "table",
|
|
4105
|
+
align: tableAlignment(header + tokens.nodeLength(header), context),
|
|
4106
|
+
children: buildBlockChildren(tokenStart, context),
|
|
4107
|
+
position: {
|
|
4108
|
+
start,
|
|
4109
|
+
end: context.locator.locationAt(tokens.start(close))
|
|
4110
|
+
}
|
|
4111
|
+
};
|
|
4112
|
+
}
|
|
4262
4113
|
}
|
|
4263
|
-
|
|
4114
|
+
]
|
|
4264
4115
|
} };
|
|
4265
|
-
|
|
4266
|
-
//#region src/inline/delimiter.ts
|
|
4116
|
+
// src/inline/delimiter.ts
|
|
4267
4117
|
const whitespace = /\s/u;
|
|
4268
4118
|
const punctuation = /[\p{P}\p{S}]/u;
|
|
4269
4119
|
function codePointBefore(source, offset) {
|
|
@@ -4278,7 +4128,7 @@ function codePointBefore(source, offset) {
|
|
|
4278
4128
|
function delimiterCharacterClass(code) {
|
|
4279
4129
|
if (code <= 127) {
|
|
4280
4130
|
if (code === 32 || code >= 9 && code <= 13) return 1;
|
|
4281
|
-
return code
|
|
4131
|
+
return isAsciiPunctuation(code) ? 2 : 0;
|
|
4282
4132
|
}
|
|
4283
4133
|
const character = String.fromCodePoint(code);
|
|
4284
4134
|
return whitespace.test(character) ? 1 : punctuation.test(character) ? 2 : 0;
|
|
@@ -4297,36 +4147,31 @@ function canPair(opener, closer) {
|
|
|
4297
4147
|
if (!(closer.config.bits & 4) || !(opener.state & 2) && !(closer.state & 1)) return true;
|
|
4298
4148
|
return (opener.state & 12) + (closer.state & 12) !== 12;
|
|
4299
4149
|
}
|
|
4300
|
-
function unlinkRun(
|
|
4301
|
-
|
|
4302
|
-
if (run.
|
|
4303
|
-
if (run.next >= 0) runs[run.next].previous = run.previous;
|
|
4150
|
+
function unlinkRun(run) {
|
|
4151
|
+
if (run.previous) run.previous.next = run.next;
|
|
4152
|
+
if (run.next) run.next.previous = run.previous;
|
|
4304
4153
|
}
|
|
4305
|
-
function resolveDelimiterScope(
|
|
4154
|
+
function resolveDelimiterScope(first, replacements = []) {
|
|
4306
4155
|
const openersBottom = [];
|
|
4307
|
-
let
|
|
4308
|
-
while (
|
|
4309
|
-
const closer = runs[current];
|
|
4310
|
-
const next = closer.next;
|
|
4156
|
+
let closer = first;
|
|
4157
|
+
while (closer) {
|
|
4311
4158
|
if (!(closer.state & 2)) {
|
|
4312
|
-
|
|
4159
|
+
closer = closer.next;
|
|
4313
4160
|
continue;
|
|
4314
4161
|
}
|
|
4315
4162
|
const bottomSlot = (closer.config.bits >>> 3) + (closer.state & 1 ? 3 : 0) + (closer.state >> 2);
|
|
4316
|
-
const bottom = openersBottom[bottomSlot] ??
|
|
4317
|
-
let
|
|
4318
|
-
while (
|
|
4319
|
-
const opener = runs[openerIndex];
|
|
4163
|
+
const bottom = openersBottom[bottomSlot] ?? 0;
|
|
4164
|
+
let opener = closer.previous;
|
|
4165
|
+
while (opener && opener.tokenIndex >= bottom) {
|
|
4320
4166
|
if (opener.config === closer.config && canPair(opener, closer)) break;
|
|
4321
|
-
|
|
4167
|
+
opener = opener.previous;
|
|
4322
4168
|
}
|
|
4323
|
-
if (
|
|
4324
|
-
openersBottom[bottomSlot] = closer.
|
|
4325
|
-
if (!(closer.state & 1)) unlinkRun(
|
|
4326
|
-
|
|
4169
|
+
if (!opener || opener.tokenIndex < bottom) {
|
|
4170
|
+
openersBottom[bottomSlot] = closer.tokenIndex;
|
|
4171
|
+
if (!(closer.state & 1)) unlinkRun(closer);
|
|
4172
|
+
closer = closer.next;
|
|
4327
4173
|
continue;
|
|
4328
4174
|
}
|
|
4329
|
-
const opener = runs[openerIndex];
|
|
4330
4175
|
const use = opener.remaining >= 2 && closer.remaining >= 2 && closer.config.double ? 2 : 1;
|
|
4331
4176
|
const openEnd = opener.start + opener.remaining;
|
|
4332
4177
|
const openStart = openEnd - use;
|
|
@@ -4334,24 +4179,24 @@ function resolveDelimiterScope(runs, first, replacements = []) {
|
|
|
4334
4179
|
const closeEnd = closeStart + use;
|
|
4335
4180
|
const pair = use === 2 ? closer.config.double : closer.config.single;
|
|
4336
4181
|
(replacements[opener.tokenIndex] ??= []).push({
|
|
4337
|
-
|
|
4182
|
+
start: openStart,
|
|
4338
4183
|
end: openEnd,
|
|
4339
4184
|
kind: pair.open
|
|
4340
4185
|
});
|
|
4341
4186
|
(replacements[closer.tokenIndex] ??= []).push({
|
|
4342
|
-
|
|
4187
|
+
start: closeStart,
|
|
4343
4188
|
end: closeEnd,
|
|
4344
4189
|
kind: pair.close
|
|
4345
4190
|
});
|
|
4346
4191
|
opener.remaining -= use;
|
|
4347
4192
|
closer.start += use;
|
|
4348
4193
|
closer.remaining -= use;
|
|
4349
|
-
opener.next =
|
|
4350
|
-
closer.previous =
|
|
4351
|
-
if (opener.remaining === 0) unlinkRun(
|
|
4194
|
+
opener.next = closer;
|
|
4195
|
+
closer.previous = opener;
|
|
4196
|
+
if (opener.remaining === 0) unlinkRun(opener);
|
|
4352
4197
|
if (closer.remaining === 0) {
|
|
4353
|
-
unlinkRun(
|
|
4354
|
-
|
|
4198
|
+
unlinkRun(closer);
|
|
4199
|
+
closer = closer.next;
|
|
4355
4200
|
}
|
|
4356
4201
|
}
|
|
4357
4202
|
return replacements;
|
|
@@ -4367,27 +4212,22 @@ function delimiterRunAt(source, tokens, tokenIndex, config) {
|
|
|
4367
4212
|
config,
|
|
4368
4213
|
start: offset,
|
|
4369
4214
|
remaining: length,
|
|
4370
|
-
previous:
|
|
4371
|
-
next:
|
|
4215
|
+
previous: void 0,
|
|
4216
|
+
next: void 0,
|
|
4372
4217
|
state: delimiterFlanking | length % 3 << 2
|
|
4373
4218
|
};
|
|
4374
4219
|
}
|
|
4375
|
-
function
|
|
4220
|
+
function appendResolvedRawToken(result, tokens, tokenIndex, replacements) {
|
|
4376
4221
|
const matched = replacements[tokenIndex];
|
|
4377
|
-
if (
|
|
4378
|
-
|
|
4379
|
-
|
|
4222
|
+
if (matched) {
|
|
4223
|
+
if (matched.length > 1) matched.sort((left, right) => left.start - right.start);
|
|
4224
|
+
for (const replacement of matched) appendInlineToken(result, replacement.kind, replacement.start, replacement.end);
|
|
4380
4225
|
}
|
|
4381
|
-
if (
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
if (replacement.offset > offset) appendInlineToken(result, kind, offset, replacement.offset);
|
|
4386
|
-
appendInlineToken(result, replacement.kind, replacement.offset, replacement.end);
|
|
4387
|
-
offset = replacement.end;
|
|
4226
|
+
if (inlineTokenKind(tokens, tokenIndex + 1) >= 256) {
|
|
4227
|
+
const start = matched ? matched[matched.length - 1].end : inlineTokenStart(tokens, tokenIndex);
|
|
4228
|
+
const end = inlineTokenEnd(tokens, tokenIndex);
|
|
4229
|
+
if (start < end) appendInlineToken(result, 64, start, end);
|
|
4388
4230
|
}
|
|
4389
|
-
const end = inlineTokenEnd(tokens, tokenIndex);
|
|
4390
|
-
if (offset < end) appendInlineToken(result, kind, offset, end);
|
|
4391
4231
|
}
|
|
4392
4232
|
function compileDelimiterConfigs(delimiterConfigs) {
|
|
4393
4233
|
const delimiterByKind = [];
|
|
@@ -4400,25 +4240,17 @@ function compileDelimiterConfigs(delimiterConfigs) {
|
|
|
4400
4240
|
});
|
|
4401
4241
|
return delimiterByKind;
|
|
4402
4242
|
}
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
const frameHeaderSize = 1;
|
|
4406
|
-
const noBracketFrames = [0];
|
|
4407
|
-
const noDelimiterReplacements = [];
|
|
4408
|
-
function setFrameState(frames, frame, state) {
|
|
4409
|
-
frames[frame + 5] = state;
|
|
4410
|
-
frames[0] = 1;
|
|
4411
|
-
}
|
|
4412
|
-
function rewriteLinkCandidates(frames, top, bottom) {
|
|
4243
|
+
// src/profile/resolve.ts
|
|
4244
|
+
function rewriteLinkCandidates(top, bottom) {
|
|
4413
4245
|
let candidate = top;
|
|
4414
4246
|
top = bottom;
|
|
4415
|
-
while (candidate !== bottom) {
|
|
4416
|
-
const next =
|
|
4417
|
-
const state =
|
|
4418
|
-
if (state === 3)
|
|
4247
|
+
while (candidate && candidate !== bottom) {
|
|
4248
|
+
const next = candidate.candidateNext;
|
|
4249
|
+
const state = candidate.state;
|
|
4250
|
+
if (state === 3) candidate.state = 0;
|
|
4419
4251
|
else {
|
|
4420
|
-
|
|
4421
|
-
|
|
4252
|
+
candidate.state = state | 16;
|
|
4253
|
+
candidate.candidateNext = top;
|
|
4422
4254
|
top = candidate;
|
|
4423
4255
|
}
|
|
4424
4256
|
candidate = next;
|
|
@@ -4461,70 +4293,80 @@ function acceptsShortcutLabel(source, start, end) {
|
|
|
4461
4293
|
}
|
|
4462
4294
|
return hasContent;
|
|
4463
4295
|
}
|
|
4464
|
-
function analyzeBrackets(source, tokens, definitions, options) {
|
|
4465
|
-
let
|
|
4466
|
-
let
|
|
4467
|
-
let
|
|
4468
|
-
|
|
4469
|
-
for (let tokenIndex =
|
|
4296
|
+
function analyzeBrackets(source, tokens, definitions, options, start, end) {
|
|
4297
|
+
let first;
|
|
4298
|
+
let last;
|
|
4299
|
+
let candidateTop;
|
|
4300
|
+
let stackTop;
|
|
4301
|
+
for (let tokenIndex = start; tokenIndex < end; tokenIndex++) {
|
|
4470
4302
|
const kind = inlineTokenKind(tokens, tokenIndex);
|
|
4471
|
-
if (kind >=
|
|
4472
|
-
const
|
|
4473
|
-
|
|
4474
|
-
|
|
4303
|
+
if (kind >= 4 && kind <= 5) {
|
|
4304
|
+
const frame = {
|
|
4305
|
+
open: tokenIndex,
|
|
4306
|
+
close: -1,
|
|
4307
|
+
parent: stackTop,
|
|
4308
|
+
next: void 0,
|
|
4309
|
+
state: kind === 4 ? 8 : 0,
|
|
4310
|
+
candidateBottom: candidateTop,
|
|
4311
|
+
candidateNext: void 0,
|
|
4312
|
+
delimiterBottom: void 0,
|
|
4313
|
+
resolvedEnd: 0,
|
|
4314
|
+
logicalParent: void 0,
|
|
4315
|
+
closingLink: void 0
|
|
4316
|
+
};
|
|
4317
|
+
if (last) last.next = frame;
|
|
4318
|
+
else first = frame;
|
|
4319
|
+
last = frame;
|
|
4475
4320
|
stackTop = frame;
|
|
4476
4321
|
continue;
|
|
4477
4322
|
}
|
|
4478
|
-
if (kind
|
|
4479
|
-
if (stackTop
|
|
4323
|
+
if (kind !== 68 && kind !== 6) continue;
|
|
4324
|
+
if (!stackTop) continue;
|
|
4480
4325
|
const frame = stackTop;
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
const openToken = arena[frame + 0];
|
|
4326
|
+
stackTop = frame.parent;
|
|
4327
|
+
frame.close = tokenIndex;
|
|
4328
|
+
const image = (frame.state & 8) !== 0;
|
|
4329
|
+
if (options.footnote && kind === 6) {
|
|
4330
|
+
const openToken = frame.open;
|
|
4487
4331
|
const label = footnoteLabelAt(source, inlineTokenStart(tokens, openToken) + (image ? 1 : 0), source.length);
|
|
4488
|
-
if (label
|
|
4489
|
-
|
|
4490
|
-
candidateTop =
|
|
4332
|
+
if (label?.end === inlineTokenEnd(tokens, tokenIndex) && definitions.hasDefinition(label.definitionKey)) {
|
|
4333
|
+
frame.state = 1;
|
|
4334
|
+
candidateTop = frame.candidateBottom;
|
|
4491
4335
|
continue;
|
|
4492
4336
|
}
|
|
4493
4337
|
}
|
|
4494
4338
|
if (!options.component || image) continue;
|
|
4495
|
-
if (kind ===
|
|
4496
|
-
const openToken =
|
|
4339
|
+
if (kind === 68) candidateTop = rewriteLinkCandidates(candidateTop, frame.candidateBottom);
|
|
4340
|
+
const openToken = frame.open;
|
|
4497
4341
|
const componentToken = openToken - 1;
|
|
4498
4342
|
if (componentToken >= 0 && inlineTokenKind(tokens, componentToken) === 137 && inlineTokenEnd(tokens, componentToken) === inlineTokenStart(tokens, openToken)) {
|
|
4499
|
-
|
|
4500
|
-
|
|
4343
|
+
frame.state = 2;
|
|
4344
|
+
frame.candidateNext = candidateTop;
|
|
4501
4345
|
candidateTop = frame;
|
|
4502
4346
|
continue;
|
|
4503
4347
|
}
|
|
4504
4348
|
const suffixStart = inlineTokenStart(tokens, tokenIndex) + 1;
|
|
4505
4349
|
const trailing = source.charCodeAt(suffixStart);
|
|
4506
4350
|
if (trailing === 40 || trailing === 91) continue;
|
|
4507
|
-
|
|
4508
|
-
|
|
4351
|
+
frame.state = trailing === 123 && attributesEnd(source, suffixStart) !== void 0 ? 4 : 3;
|
|
4352
|
+
frame.candidateNext = candidateTop;
|
|
4509
4353
|
candidateTop = frame;
|
|
4510
4354
|
}
|
|
4511
|
-
return
|
|
4355
|
+
return first;
|
|
4512
4356
|
}
|
|
4513
|
-
function resolvePairedSyntax(source, tokens,
|
|
4514
|
-
const hasDefinitions =
|
|
4515
|
-
let
|
|
4516
|
-
let
|
|
4357
|
+
function resolvePairedSyntax(source, tokens, nextFrame, definitions, delimiterByKind, start, end) {
|
|
4358
|
+
const hasDefinitions = nextFrame !== void 0 && definitions.hasDefinitions();
|
|
4359
|
+
let firstRun;
|
|
4360
|
+
let lastRun;
|
|
4517
4361
|
let replacements;
|
|
4518
|
-
let rawTop
|
|
4519
|
-
let logicalTop
|
|
4520
|
-
let frameCursor = frameHeaderSize;
|
|
4362
|
+
let rawTop;
|
|
4363
|
+
let logicalTop;
|
|
4521
4364
|
let consumedEnd = -1;
|
|
4522
4365
|
let consumeFrames = false;
|
|
4523
4366
|
let inactiveBefore = 0;
|
|
4524
4367
|
let lastVisibleOpener = -1;
|
|
4525
4368
|
let literalDepth = 0;
|
|
4526
|
-
|
|
4527
|
-
for (let tokenIndex = 0; tokenIndex < count; tokenIndex++) {
|
|
4369
|
+
for (let tokenIndex = start; tokenIndex < end; tokenIndex++) {
|
|
4528
4370
|
const kind = inlineTokenKind(tokens, tokenIndex);
|
|
4529
4371
|
const tokenStart = inlineTokenStart(tokens, tokenIndex);
|
|
4530
4372
|
if (consumedEnd >= 0 && tokenStart >= consumedEnd) {
|
|
@@ -4536,28 +4378,25 @@ function resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKin
|
|
|
4536
4378
|
if (!consuming && delimiter) {
|
|
4537
4379
|
const run = delimiterRunAt(source, tokens, tokenIndex, delimiter);
|
|
4538
4380
|
if (run) {
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
arena[runIndex - 1].next = runIndex;
|
|
4544
|
-
}
|
|
4545
|
-
arena[runIndex] = run;
|
|
4381
|
+
run.previous = lastRun;
|
|
4382
|
+
if (lastRun) lastRun.next = run;
|
|
4383
|
+
else firstRun = run;
|
|
4384
|
+
lastRun = run;
|
|
4546
4385
|
}
|
|
4547
4386
|
}
|
|
4548
|
-
if (kind >=
|
|
4549
|
-
const frame =
|
|
4550
|
-
|
|
4387
|
+
if (kind >= 4 && kind <= 5) {
|
|
4388
|
+
const frame = nextFrame;
|
|
4389
|
+
nextFrame = frame.next;
|
|
4551
4390
|
rawTop = frame;
|
|
4552
4391
|
if (consuming) {
|
|
4553
|
-
if (consumeFrames)
|
|
4392
|
+
if (consumeFrames) frame.state = 7;
|
|
4554
4393
|
continue;
|
|
4555
4394
|
}
|
|
4556
|
-
|
|
4557
|
-
const state =
|
|
4395
|
+
frame.delimiterBottom = lastRun;
|
|
4396
|
+
const state = frame.state;
|
|
4558
4397
|
const claim = state & 7;
|
|
4559
4398
|
if (claim === 1) {
|
|
4560
|
-
const closeToken =
|
|
4399
|
+
const closeToken = frame.close;
|
|
4561
4400
|
consumedEnd = inlineTokenEnd(tokens, closeToken);
|
|
4562
4401
|
continue;
|
|
4563
4402
|
}
|
|
@@ -4565,57 +4404,58 @@ function resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKin
|
|
|
4565
4404
|
if (state & 16) literalDepth++;
|
|
4566
4405
|
continue;
|
|
4567
4406
|
}
|
|
4568
|
-
if (literalDepth > 0 && !(kind ===
|
|
4569
|
-
|
|
4407
|
+
if (literalDepth > 0 && !(kind === 4)) {
|
|
4408
|
+
frame.state = state | 32;
|
|
4570
4409
|
continue;
|
|
4571
4410
|
}
|
|
4572
|
-
|
|
4411
|
+
frame.logicalParent = logicalTop;
|
|
4573
4412
|
logicalTop = frame;
|
|
4574
4413
|
lastVisibleOpener = tokenIndex;
|
|
4575
4414
|
continue;
|
|
4576
4415
|
}
|
|
4577
|
-
if (kind
|
|
4416
|
+
if (kind !== 68 && kind !== 6) continue;
|
|
4578
4417
|
const rawFrame = rawTop;
|
|
4579
|
-
if (rawFrame
|
|
4418
|
+
if (rawFrame !== void 0) rawTop = rawFrame.parent;
|
|
4580
4419
|
if (consuming) {
|
|
4581
|
-
if (consumeFrames && rawFrame
|
|
4420
|
+
if (consumeFrames && rawFrame !== void 0) rawFrame.state = 7;
|
|
4582
4421
|
continue;
|
|
4583
4422
|
}
|
|
4584
|
-
const rawState = rawFrame
|
|
4423
|
+
const rawState = rawFrame === void 0 ? 0 : rawFrame.state;
|
|
4585
4424
|
const rawClaim = rawState & 7;
|
|
4586
|
-
let
|
|
4587
|
-
if (
|
|
4425
|
+
let scopeFrame = rawClaim >= 1 && rawClaim <= 4 ? rawFrame : void 0;
|
|
4426
|
+
if (scopeFrame === void 0 && (literalDepth <= 0 || rawFrame === void 0 || (rawState & 8) !== 0)) {
|
|
4588
4427
|
const frame = logicalTop;
|
|
4589
|
-
if (frame
|
|
4590
|
-
if (frame
|
|
4591
|
-
const openToken =
|
|
4592
|
-
const image = (
|
|
4428
|
+
if (frame !== void 0) logicalTop = frame.logicalParent;
|
|
4429
|
+
if (frame !== void 0 && (kind === 68 || hasDefinitions)) {
|
|
4430
|
+
const openToken = frame.open;
|
|
4431
|
+
const image = (frame.state & 8) !== 0;
|
|
4593
4432
|
if (image || openToken + 1 >= inactiveBefore) {
|
|
4594
4433
|
const contentStart = inlineTokenEnd(tokens, openToken);
|
|
4595
4434
|
const contentEnd = tokenStart;
|
|
4596
4435
|
const tokenEnd = inlineTokenEnd(tokens, tokenIndex);
|
|
4597
4436
|
let closeEnd = tokenEnd;
|
|
4598
4437
|
let reference = false;
|
|
4599
|
-
let matched = kind ===
|
|
4438
|
+
let matched = kind === 68;
|
|
4600
4439
|
if (!matched) {
|
|
4601
4440
|
const labelEnd = referenceLabelEnd(source, closeEnd);
|
|
4602
4441
|
if (labelEnd > 0) {
|
|
4603
4442
|
const label = source.slice(closeEnd + 1, labelEnd - 1) || source.slice(contentStart, contentEnd);
|
|
4604
|
-
matched = definitions.hasDefinition(
|
|
4443
|
+
matched = definitions.hasDefinition(normalizeIdentifier(label));
|
|
4605
4444
|
if (matched) {
|
|
4606
4445
|
closeEnd = labelEnd;
|
|
4607
4446
|
reference = true;
|
|
4608
4447
|
}
|
|
4609
|
-
} else if (lastVisibleOpener <= openToken && acceptsShortcutLabel(source, contentStart, contentEnd) && definitions.hasDefinition(
|
|
4448
|
+
} else if (lastVisibleOpener <= openToken && acceptsShortcutLabel(source, contentStart, contentEnd) && definitions.hasDefinition(normalizeIdentifier(source.slice(contentStart, contentEnd)))) {
|
|
4610
4449
|
matched = true;
|
|
4611
4450
|
reference = true;
|
|
4612
4451
|
}
|
|
4613
4452
|
}
|
|
4614
4453
|
if (matched) {
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4454
|
+
frame.state = (reference ? 6 : 5) | (image ? 8 : 0);
|
|
4455
|
+
frame.close = tokenIndex;
|
|
4456
|
+
frame.resolvedEnd = closeEnd;
|
|
4457
|
+
rawFrame.closingLink = frame;
|
|
4458
|
+
scopeFrame = frame;
|
|
4619
4459
|
if (!image) inactiveBefore = openToken + 1;
|
|
4620
4460
|
if (closeEnd > tokenEnd) {
|
|
4621
4461
|
consumedEnd = closeEnd;
|
|
@@ -4626,86 +4466,85 @@ function resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKin
|
|
|
4626
4466
|
}
|
|
4627
4467
|
}
|
|
4628
4468
|
if (rawState & 16) literalDepth--;
|
|
4629
|
-
if (
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
const
|
|
4469
|
+
if (scopeFrame && lastRun !== scopeFrame.delimiterBottom) {
|
|
4470
|
+
const bottom = scopeFrame.delimiterBottom;
|
|
4471
|
+
const first = bottom ? bottom.next : firstRun;
|
|
4472
|
+
if (bottom) bottom.next = void 0;
|
|
4473
|
+
else firstRun = void 0;
|
|
4474
|
+
first.previous = void 0;
|
|
4475
|
+
replacements = resolveDelimiterScope(first, replacements);
|
|
4476
|
+
lastRun = bottom;
|
|
4477
|
+
}
|
|
4478
|
+
}
|
|
4479
|
+
if (firstRun) replacements = resolveDelimiterScope(firstRun, replacements);
|
|
4480
|
+
return replacements ?? emptyArray;
|
|
4481
|
+
}
|
|
4482
|
+
function appendReferenceBoundary(result, tokens, frame, close) {
|
|
4483
|
+
const token = close ? frame.close : frame.open;
|
|
4484
|
+
const state = frame.state;
|
|
4644
4485
|
const kind = ((state & 7) === 6 ? 202 : 198) + (state & 8 ? 2 : 0) + (close ? 1 : 0);
|
|
4645
|
-
const end = close ?
|
|
4486
|
+
const end = close ? frame.resolvedEnd : inlineTokenEnd(tokens, token);
|
|
4646
4487
|
appendInlineToken(result, kind, inlineTokenStart(tokens, token), end, inlineTokenData(tokens, token));
|
|
4647
4488
|
return end;
|
|
4648
4489
|
}
|
|
4649
|
-
function emitResolvedTokens(tokens,
|
|
4650
|
-
const result = [];
|
|
4651
|
-
let rawTop
|
|
4652
|
-
let referenceTop = -1;
|
|
4653
|
-
let frameCursor = frameHeaderSize;
|
|
4490
|
+
function emitResolvedTokens(tokens, nextFrame, replacements, start, end) {
|
|
4491
|
+
const result = start ? tokens.slice(0, start * 4) : [];
|
|
4492
|
+
let rawTop;
|
|
4654
4493
|
let skipEnd = -1;
|
|
4655
|
-
|
|
4656
|
-
for (let tokenIndex = 0; tokenIndex < count; tokenIndex++) {
|
|
4494
|
+
for (let tokenIndex = start; tokenIndex < end; tokenIndex++) {
|
|
4657
4495
|
const kind = inlineTokenKind(tokens, tokenIndex);
|
|
4658
4496
|
const tokenStart = inlineTokenStart(tokens, tokenIndex);
|
|
4659
4497
|
if (skipEnd >= 0 && tokenStart >= skipEnd) skipEnd = -1;
|
|
4660
4498
|
const skipping = skipEnd >= 0;
|
|
4661
|
-
if (kind >=
|
|
4662
|
-
const frame =
|
|
4663
|
-
|
|
4499
|
+
if (kind >= 4 && kind <= 5) {
|
|
4500
|
+
const frame = nextFrame;
|
|
4501
|
+
nextFrame = frame.next;
|
|
4664
4502
|
rawTop = frame;
|
|
4665
|
-
const state =
|
|
4503
|
+
const state = frame.state;
|
|
4666
4504
|
const claim = state & 7;
|
|
4667
4505
|
if (!skipping) {
|
|
4668
4506
|
if (claim === 1) {
|
|
4669
|
-
const closeToken =
|
|
4670
|
-
const start = inlineTokenStart(tokens, tokenIndex) + (kind ===
|
|
4507
|
+
const closeToken = frame.close;
|
|
4508
|
+
const start = inlineTokenStart(tokens, tokenIndex) + (kind === 4 ? 1 : 0);
|
|
4671
4509
|
skipEnd = inlineTokenEnd(tokens, closeToken);
|
|
4672
4510
|
appendInlineToken(result, 133, start, skipEnd);
|
|
4673
4511
|
} else if (claim === 2) {
|
|
4674
|
-
const closeToken =
|
|
4512
|
+
const closeToken = frame.close;
|
|
4675
4513
|
const openEnd = inlineTokenEnd(tokens, tokenIndex);
|
|
4676
4514
|
if (openEnd < inlineTokenStart(tokens, closeToken)) rewriteInlineTokenTail(result, 208, openEnd);
|
|
4677
4515
|
} else if (claim >= 3 && claim <= 4) appendInlineToken(result, 206, inlineTokenStart(tokens, tokenIndex), inlineTokenEnd(tokens, tokenIndex));
|
|
4678
|
-
else if (claim === 5 || claim === 6)
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
referenceTop = frame;
|
|
4682
|
-
} else if (claim === 7) skipEnd = inlineTokenEnd(tokens, frames[frame + 1]);
|
|
4683
|
-
else if (!(state & 32)) appendResolvedDelimiterToken(result, tokens, tokenIndex, replacements);
|
|
4516
|
+
else if (claim === 5 || claim === 6) appendReferenceBoundary(result, tokens, frame, false);
|
|
4517
|
+
else if (claim === 7) skipEnd = inlineTokenEnd(tokens, frame.close);
|
|
4518
|
+
else if (!(state & 32)) appendResolvedRawToken(result, tokens, tokenIndex, replacements);
|
|
4684
4519
|
}
|
|
4685
4520
|
continue;
|
|
4686
4521
|
}
|
|
4687
|
-
if (kind
|
|
4522
|
+
if (kind === 68 || kind === 6) {
|
|
4688
4523
|
const rawFrame = rawTop;
|
|
4689
|
-
if (rawFrame
|
|
4690
|
-
const
|
|
4691
|
-
|
|
4692
|
-
if (
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
skipEnd = appendReferenceBoundary(result, tokens, frames, referenceFrame, true);
|
|
4696
|
-
} else if (rawFrame >= 0) {
|
|
4697
|
-
const state = frames[rawFrame + 5];
|
|
4698
|
-
const claim = state & 7;
|
|
4699
|
-
if (claim === 2) {
|
|
4700
|
-
const openToken = frames[rawFrame + 0];
|
|
4701
|
-
if (inlineTokenEnd(tokens, openToken) < tokenStart) appendInlineToken(result, 209, tokenStart, tokenStart + 1);
|
|
4702
|
-
} else if (claim >= 3 && claim <= 4) appendInlineToken(result, 207, tokenStart, tokenStart + 1);
|
|
4703
|
-
else if (claim !== 1 && !(state & 32)) appendResolvedDelimiterToken(result, tokens, tokenIndex, replacements);
|
|
4704
|
-
} else appendResolvedDelimiterToken(result, tokens, tokenIndex, replacements);
|
|
4524
|
+
if (rawFrame !== void 0) rawTop = rawFrame.parent;
|
|
4525
|
+
const closingLink = rawFrame?.closingLink;
|
|
4526
|
+
if (skipping) continue;
|
|
4527
|
+
if (closingLink) {
|
|
4528
|
+
skipEnd = appendReferenceBoundary(result, tokens, closingLink, true);
|
|
4529
|
+
continue;
|
|
4705
4530
|
}
|
|
4706
|
-
|
|
4531
|
+
const state = rawFrame === void 0 ? 0 : rawFrame.state;
|
|
4532
|
+
const claim = state & 7;
|
|
4533
|
+
if (claim === 2) {
|
|
4534
|
+
const openToken = rawFrame.open;
|
|
4535
|
+
if (inlineTokenEnd(tokens, openToken) < tokenStart) appendInlineToken(result, 209, tokenStart, tokenStart + 1);
|
|
4536
|
+
continue;
|
|
4537
|
+
}
|
|
4538
|
+
if (claim >= 3 && claim <= 4) {
|
|
4539
|
+
appendInlineToken(result, 207, tokenStart, tokenStart + 1);
|
|
4540
|
+
continue;
|
|
4541
|
+
}
|
|
4542
|
+
if (claim === 1 || state & 32) continue;
|
|
4543
|
+
}
|
|
4544
|
+
if (!skipping) {
|
|
4545
|
+
if (kind >= 64) copyInlineToken(result, tokens, tokenIndex);
|
|
4546
|
+
else appendResolvedRawToken(result, tokens, tokenIndex, replacements);
|
|
4707
4547
|
}
|
|
4708
|
-
if (!skipping) appendResolvedDelimiterToken(result, tokens, tokenIndex, replacements);
|
|
4709
4548
|
}
|
|
4710
4549
|
return result;
|
|
4711
4550
|
}
|
|
@@ -4713,34 +4552,30 @@ function compileInlineResolver(options) {
|
|
|
4713
4552
|
return (delimiterConfigs) => {
|
|
4714
4553
|
const delimiterByKind = compileDelimiterConfigs(delimiterConfigs);
|
|
4715
4554
|
return (source, tokens, definitions) => {
|
|
4716
|
-
let
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
const frames = analyzeBrackets(source, tokens, definitions, options);
|
|
4723
|
-
const replacements = resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKind) ?? noDelimiterReplacements;
|
|
4724
|
-
return frames[0] & 1 || replacements.length > 0 ? emitResolvedTokens(tokens, frames, replacements) : tokens;
|
|
4555
|
+
let start = 0;
|
|
4556
|
+
const end = inlineTokenCount(tokens);
|
|
4557
|
+
while (start < end && inlineTokenKind(tokens, start) >= 64) start++;
|
|
4558
|
+
if (start === end) return tokens;
|
|
4559
|
+
const frames = analyzeBrackets(source, tokens, definitions, options, start, end);
|
|
4560
|
+
return emitResolvedTokens(tokens, frames, resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKind, start, end), start, end);
|
|
4725
4561
|
};
|
|
4726
4562
|
};
|
|
4727
4563
|
}
|
|
4728
|
-
|
|
4729
|
-
//#region src/profile/index.ts
|
|
4564
|
+
// src/profile/index.ts
|
|
4730
4565
|
function compileProfile(options = {}) {
|
|
4731
4566
|
const features = [
|
|
4732
|
-
feature$
|
|
4567
|
+
feature$8,
|
|
4733
4568
|
feature$15,
|
|
4734
4569
|
feature$16,
|
|
4735
4570
|
feature$4(options.taskList),
|
|
4736
4571
|
feature$14,
|
|
4737
|
-
feature$
|
|
4572
|
+
feature$7
|
|
4738
4573
|
];
|
|
4739
4574
|
if (options.footnote) features.push(feature$10);
|
|
4740
4575
|
if (options.frontmatter) features.unshift(feature$13(typeof options.frontmatter === "object" ? options.frontmatter.marker : "-"));
|
|
4741
4576
|
if (options.table) features.push(feature);
|
|
4742
4577
|
if (options.math) features.push(feature$3(options.math));
|
|
4743
|
-
features.push(feature$2, feature$
|
|
4578
|
+
features.push(feature$2, feature$6, feature$9(options.strikethrough), feature$5);
|
|
4744
4579
|
if (options.attributes) features.push(feature$18);
|
|
4745
4580
|
if (options.binding) features.push(feature$17);
|
|
4746
4581
|
if (options.emoji) features.push(feature$11);
|
|
@@ -4760,8 +4595,7 @@ function compileProfile(options = {}) {
|
|
|
4760
4595
|
}))
|
|
4761
4596
|
};
|
|
4762
4597
|
}
|
|
4763
|
-
|
|
4764
|
-
//#region src/parser.ts
|
|
4598
|
+
// src/parser.ts
|
|
4765
4599
|
function createParser(options) {
|
|
4766
4600
|
const profile = compileProfile(options?.features);
|
|
4767
4601
|
let blockScanner;
|
|
@@ -4770,5 +4604,4 @@ function createParser(options) {
|
|
|
4770
4604
|
parse: (source) => DocumentImpl.parse(source, profile, blockScanner ??= new BlockScanner(profile.block))
|
|
4771
4605
|
};
|
|
4772
4606
|
}
|
|
4773
|
-
|
|
4774
|
-
export { createParser };
|
|
4607
|
+
export { createParser, normalizeIdentifier };
|