satorigear 0.0.10 → 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 +11 -11
- package/dist/index.mjs +1180 -1287
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,6 @@ 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) {
|
|
@@ -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;
|
|
@@ -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,39 +280,30 @@ 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
|
-
let result = " ".repeat(prefixColumns);
|
|
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
|
-
}
|
|
305
|
+
// src/constants/block.ts
|
|
306
|
+
const boundaryBreak = Symbol();
|
|
341
307
|
// src/primitives.ts
|
|
342
308
|
const emptyArray = [];
|
|
343
309
|
const emptySet = new Set();
|
|
@@ -354,44 +320,32 @@ var BlockTokenStream = class {
|
|
|
354
320
|
#definitionMembershipChanges;
|
|
355
321
|
#fieldLength = 0;
|
|
356
322
|
#fields = new Int32Array();
|
|
357
|
-
#groupField = -1;
|
|
358
323
|
#metadata;
|
|
359
324
|
#opens = [];
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
constructor(sourceLength = 0) {
|
|
363
|
-
this.#sourceLength = sourceLength;
|
|
364
|
-
}
|
|
365
|
-
reset(sourceLength) {
|
|
325
|
+
constructor() {}
|
|
326
|
+
reset() {
|
|
366
327
|
this.#definitionCounts?.clear();
|
|
367
328
|
this.#definitionMembershipChanges?.clear();
|
|
368
329
|
this.#fieldLength = 0;
|
|
369
|
-
this.#groupField = -1;
|
|
370
330
|
this.#metadata = void 0;
|
|
371
|
-
this.#opens.length = 0;
|
|
372
|
-
this.#relativeStart = Infinity;
|
|
373
|
-
this.#sourceLength = sourceLength;
|
|
331
|
+
if (this.#opens.length) this.#opens.length = 0;
|
|
374
332
|
}
|
|
375
333
|
get length() {
|
|
376
334
|
return this.#fieldLength / 4;
|
|
377
335
|
}
|
|
378
|
-
get sourceLength() {
|
|
379
|
-
return this.#sourceLength;
|
|
380
|
-
}
|
|
381
336
|
hasDefinition(key) {
|
|
382
337
|
return this.#definitionCounts?.has(key) === true;
|
|
383
338
|
}
|
|
384
339
|
hasDefinitions() {
|
|
385
340
|
return !!this.#definitionCounts?.size;
|
|
386
341
|
}
|
|
387
|
-
push(kind, start, end, meta
|
|
388
|
-
const encodedRole = role ?? kind;
|
|
342
|
+
push(kind, start, end, meta) {
|
|
389
343
|
const field = this.#fieldLength;
|
|
390
344
|
this.#ensureCapacity(field + 4);
|
|
391
345
|
this.#fields[field + 0] = kind;
|
|
392
346
|
this.#fields[field + 1] = start;
|
|
393
347
|
this.#fields[field + 2] = end;
|
|
394
|
-
this.#fields[field + 3] =
|
|
348
|
+
this.#fields[field + 3] = kind < 64 ? 0 : this.#indexToken(field, kind);
|
|
395
349
|
this.#fieldLength += 4;
|
|
396
350
|
if (meta) {
|
|
397
351
|
this.#metadata ??= [];
|
|
@@ -400,23 +354,27 @@ var BlockTokenStream = class {
|
|
|
400
354
|
if (definitionKey !== void 0) this.#updateDefinitionCount(definitionKey, 1, false);
|
|
401
355
|
}
|
|
402
356
|
}
|
|
403
|
-
|
|
404
|
-
|
|
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) {
|
|
405
370
|
this.#opens.push(field);
|
|
406
371
|
return 0;
|
|
407
372
|
}
|
|
408
|
-
if (
|
|
373
|
+
if (kind < 256) {
|
|
409
374
|
const open = this.#opens.pop();
|
|
410
375
|
this.#fields[open + 3] = (field - open) / 4 + 1;
|
|
411
376
|
return 0;
|
|
412
377
|
}
|
|
413
|
-
if (encodedRole < 320) return 1;
|
|
414
|
-
const previous = field - 4;
|
|
415
|
-
if (this.#groupField >= 0 && this.#fields[previous + 0] >= 320) {
|
|
416
|
-
this.#fields[this.#groupField + 3]++;
|
|
417
|
-
return 0;
|
|
418
|
-
}
|
|
419
|
-
this.#groupField = field;
|
|
420
378
|
return 1;
|
|
421
379
|
}
|
|
422
380
|
nodeLength(index) {
|
|
@@ -442,11 +400,10 @@ var BlockTokenStream = class {
|
|
|
442
400
|
if (damageStart === void 0 || damageEnd === void 0) return true;
|
|
443
401
|
return start === end || end <= damageStart || start >= damageEnd;
|
|
444
402
|
}
|
|
445
|
-
replace(start, end, replacement, damageStart, damageEnd) {
|
|
403
|
+
replace(start, end, replacement, damageStart, damageEnd, sourceDelta) {
|
|
446
404
|
const previousLength = this.length;
|
|
447
405
|
const replacedLength = end - start;
|
|
448
406
|
const replacementLength = replacement.length;
|
|
449
|
-
const sourceDelta = replacement.#sourceLength - this.#sourceLength;
|
|
450
407
|
const overlapLength = Math.min(replacedLength, replacementLength);
|
|
451
408
|
let stablePrefixLength = 0;
|
|
452
409
|
while (stablePrefixLength < overlapLength && this.equalsAfterShift(start + stablePrefixLength, replacement, stablePrefixLength, 0, damageStart, damageEnd)) stablePrefixLength++;
|
|
@@ -464,38 +421,21 @@ var BlockTokenStream = class {
|
|
|
464
421
|
oldEnd,
|
|
465
422
|
oldStart
|
|
466
423
|
};
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
this.#fields[field + 2] += this.#sourceLength + 1;
|
|
471
|
-
}
|
|
472
|
-
else if (this.#relativeStart > end) {
|
|
473
|
-
const relativeEnd = Math.min(this.#relativeStart, previousLength);
|
|
474
|
-
for (let index = end; index < relativeEnd; index++) {
|
|
475
|
-
const field = index * 4;
|
|
476
|
-
this.#fields[field + 1] -= this.#sourceLength + 1;
|
|
477
|
-
this.#fields[field + 2] -= this.#sourceLength + 1;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
424
|
+
const fieldStart = start * 4;
|
|
425
|
+
const replacementFieldLength = replacement.#fieldLength;
|
|
426
|
+
let fieldLength = this.#fieldLength;
|
|
480
427
|
if (end === previousLength) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
this.#fields.set(replacement.#fields.subarray(0, replacement.#fieldLength), fieldStart);
|
|
485
|
-
this.#fieldLength = fieldEnd;
|
|
486
|
-
} else if (replacementLength === replacedLength) {
|
|
487
|
-
const fieldStart = start * 4;
|
|
488
|
-
this.#fields.set(replacement.#fields.subarray(0, replacement.#fieldLength), fieldStart);
|
|
489
|
-
} else {
|
|
490
|
-
const fieldStart = start * 4;
|
|
428
|
+
fieldLength = fieldStart + replacementFieldLength;
|
|
429
|
+
this.#ensureCapacity(fieldLength);
|
|
430
|
+
} else if (replacementLength !== replacedLength) {
|
|
491
431
|
const oldFieldEnd = end * 4;
|
|
492
|
-
const newFieldEnd = fieldStart +
|
|
493
|
-
|
|
494
|
-
this.#ensureCapacity(
|
|
432
|
+
const newFieldEnd = fieldStart + replacementFieldLength;
|
|
433
|
+
fieldLength += newFieldEnd - oldFieldEnd;
|
|
434
|
+
this.#ensureCapacity(fieldLength);
|
|
495
435
|
this.#fields.copyWithin(newFieldEnd, oldFieldEnd, this.#fieldLength);
|
|
496
|
-
this.#fields.set(replacement.#fields.subarray(0, replacement.#fieldLength), fieldStart);
|
|
497
|
-
this.#fieldLength = nextFieldLength;
|
|
498
436
|
}
|
|
437
|
+
this.#fields.set(replacement.#fields.subarray(0, replacementFieldLength), fieldStart);
|
|
438
|
+
this.#fieldLength = fieldLength;
|
|
499
439
|
const indexDelta = replacementLength - replacedLength;
|
|
500
440
|
if (end === previousLength || indexDelta === 0) {
|
|
501
441
|
const metadata = this.#metadata;
|
|
@@ -515,12 +455,16 @@ var BlockTokenStream = class {
|
|
|
515
455
|
this.#metadata = metadata.length > 0 ? metadata : void 0;
|
|
516
456
|
}
|
|
517
457
|
const newSuffixStart = start + replacementLength;
|
|
518
|
-
|
|
519
|
-
|
|
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
|
+
}
|
|
520
465
|
return change;
|
|
521
466
|
}
|
|
522
467
|
truncate(length) {
|
|
523
|
-
this.#groupField = -1;
|
|
524
468
|
this.#fieldLength = length * 4;
|
|
525
469
|
const metadata = this.#metadata;
|
|
526
470
|
if (metadata) {
|
|
@@ -538,13 +482,16 @@ var BlockTokenStream = class {
|
|
|
538
482
|
this.#fields[index * 4] = kind;
|
|
539
483
|
}
|
|
540
484
|
start(index) {
|
|
541
|
-
return this.#
|
|
485
|
+
return this.#fields[index * 4 + 1];
|
|
542
486
|
}
|
|
543
487
|
setStart(index, start) {
|
|
544
488
|
this.#fields[index * 4 + 1] = start;
|
|
545
489
|
}
|
|
546
490
|
end(index) {
|
|
547
|
-
return this.#
|
|
491
|
+
return this.#fields[index * 4 + 2];
|
|
492
|
+
}
|
|
493
|
+
setEnd(index, end) {
|
|
494
|
+
this.#fields[index * 4 + 2] = end;
|
|
548
495
|
}
|
|
549
496
|
contentEnd(source, index) {
|
|
550
497
|
return lineContentEnd(source, this.start(index), this.end(index));
|
|
@@ -555,6 +502,11 @@ var BlockTokenStream = class {
|
|
|
555
502
|
value(index) {
|
|
556
503
|
return this.#metadata?.[index]?.value;
|
|
557
504
|
}
|
|
505
|
+
setValue(index, value) {
|
|
506
|
+
this.#metadata ??= [];
|
|
507
|
+
this.#metadata[index] ??= {};
|
|
508
|
+
this.#metadata[index].value = value;
|
|
509
|
+
}
|
|
558
510
|
definitionKey(index) {
|
|
559
511
|
return this.#metadata?.[index]?.definitionKey;
|
|
560
512
|
}
|
|
@@ -565,7 +517,7 @@ var BlockTokenStream = class {
|
|
|
565
517
|
const nextCount = previousCount + delta;
|
|
566
518
|
if (nextCount === 0) counts.delete(key);
|
|
567
519
|
else counts.set(key, nextCount);
|
|
568
|
-
if (trackMembership && previousCount === 0
|
|
520
|
+
if (trackMembership && (previousCount === 0 || nextCount === 0)) {
|
|
569
521
|
const changes = this.#definitionMembershipChanges ??= new Set();
|
|
570
522
|
if (!changes.delete(key)) changes.add(key);
|
|
571
523
|
}
|
|
@@ -578,19 +530,16 @@ var BlockTokenStream = class {
|
|
|
578
530
|
fields.set(this.#fields.subarray(0, this.#fieldLength));
|
|
579
531
|
this.#fields = fields;
|
|
580
532
|
}
|
|
581
|
-
#position(position) {
|
|
582
|
-
return position < 0 ? position + this.#sourceLength + 1 : position;
|
|
583
|
-
}
|
|
584
533
|
};
|
|
585
|
-
function appendLogicalToken(
|
|
534
|
+
function appendLogicalToken(source, lines, tokens, kind, start, end, value) {
|
|
586
535
|
const count = end - start;
|
|
587
536
|
const tokenStart = lines.start(start);
|
|
588
537
|
const lastLine = end - 1;
|
|
589
538
|
const tokenEnd = lines.next(lastLine);
|
|
590
539
|
let canSliceSource = lines.physicallyContiguous();
|
|
591
540
|
if (!canSliceSource) {
|
|
592
|
-
const previous = source
|
|
593
|
-
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);
|
|
594
543
|
let previousLineEnd = lines.next(start);
|
|
595
544
|
for (let line = start + 1; canSliceSource && line < end; line++) {
|
|
596
545
|
if (lines.prefixColumns(line) !== 0 || lines.start(line) !== previousLineEnd) {
|
|
@@ -603,10 +552,13 @@ function appendLogicalToken(out, kind, source, lines, start, end, value) {
|
|
|
603
552
|
let text;
|
|
604
553
|
if (!canSliceSource) {
|
|
605
554
|
const logicalLines = new Array(count);
|
|
606
|
-
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
|
+
}
|
|
607
559
|
text = logicalLines.join("");
|
|
608
560
|
}
|
|
609
|
-
|
|
561
|
+
tokens.push(kind, tokenStart, tokenEnd, text === void 0 && value === void 0 ? void 0 : {
|
|
610
562
|
text,
|
|
611
563
|
value
|
|
612
564
|
});
|
|
@@ -663,7 +615,7 @@ var BlockScanContext = class {
|
|
|
663
615
|
view.resetFrom(lines, index, start, prefixColumns);
|
|
664
616
|
return view;
|
|
665
617
|
}
|
|
666
|
-
scanBlockLines(source, lines,
|
|
618
|
+
scanBlockLines(source, lines, tokens, visit) {
|
|
667
619
|
const profile = this.#profile;
|
|
668
620
|
for (let index = 0; index < lines.length;) {
|
|
669
621
|
let contentOffset = lines.start(index);
|
|
@@ -681,15 +633,15 @@ var BlockScanContext = class {
|
|
|
681
633
|
}
|
|
682
634
|
if (columns > 3) contentOffset = -1;
|
|
683
635
|
const lineStart = index;
|
|
684
|
-
const tokenStart =
|
|
685
|
-
index = profile.dispatch(source, lines, index, contentOffset,
|
|
686
|
-
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;
|
|
687
639
|
}
|
|
688
640
|
}
|
|
689
|
-
scanLines(source, lines,
|
|
641
|
+
scanLines(source, lines, tokens) {
|
|
690
642
|
let blankSeparated = false;
|
|
691
643
|
let previousContentEnd = -1;
|
|
692
|
-
this.scanBlockLines(source, lines,
|
|
644
|
+
this.scanBlockLines(source, lines, tokens, (lineStart, lineEnd) => {
|
|
693
645
|
blankSeparated ||= previousContentEnd >= 0 && lineStart > previousContentEnd;
|
|
694
646
|
previousContentEnd = lineEnd;
|
|
695
647
|
while (previousContentEnd > lineStart && isBlankLine(source, lines, previousContentEnd - 1)) previousContentEnd--;
|
|
@@ -720,7 +672,7 @@ var BlockScanner = class {
|
|
|
720
672
|
const context = this.#context;
|
|
721
673
|
const tokens = this.#tokens;
|
|
722
674
|
context.resetLookahead();
|
|
723
|
-
tokens.reset(
|
|
675
|
+
tokens.reset();
|
|
724
676
|
if (!indexed) {
|
|
725
677
|
context.scanBlockLines(source, lines, tokens);
|
|
726
678
|
return;
|
|
@@ -769,53 +721,40 @@ var BlockScanner = class {
|
|
|
769
721
|
const scanLineStart = nextLines.indexAtOrAfter(restartOffset);
|
|
770
722
|
const stableBlockCount = Math.max(0, restartIndex);
|
|
771
723
|
const oldTokenStart = restartRecord?.tokenStart ?? 0;
|
|
772
|
-
const replacement = new BlockTokenStream(
|
|
724
|
+
const replacement = new BlockTokenStream();
|
|
773
725
|
const rescannedRecords = [];
|
|
774
|
-
const
|
|
726
|
+
const scanLines = scanLineStart === 0 ? nextLines : nextLines.view(scanLineStart);
|
|
775
727
|
let convergedIndex = -1;
|
|
776
|
-
let
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
context.
|
|
782
|
-
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
while (convergenceIndex < previousRecords.length && previousRecords[convergenceIndex].start < candidateStart) convergenceIndex++;
|
|
791
|
-
const candidateRecord = previousRecords[convergenceIndex];
|
|
792
|
-
if (candidateRecord?.start + offsetDelta === blockStart && candidateRecord.end + offsetDelta === blockEnd && candidateRecord.dependencyEnd + offsetDelta === dependencyEnd && sameShiftedBlock(this.#tokens, candidateRecord, replacement, tokenStart, tokenEnd, offsetDelta)) {
|
|
793
|
-
replacement.truncate(tokenStart);
|
|
794
|
-
convergedIndex = convergenceIndex;
|
|
795
|
-
return true;
|
|
796
|
-
}
|
|
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;
|
|
797
742
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
743
|
+
}
|
|
744
|
+
rescannedRecords.push({
|
|
745
|
+
start: blockStart,
|
|
746
|
+
end: blockEnd,
|
|
747
|
+
dependencyEnd,
|
|
748
|
+
tokenStart: oldTokenStart + tokenStart
|
|
804
749
|
});
|
|
805
|
-
|
|
806
|
-
replacement.reset(nextSource.length);
|
|
807
|
-
rescannedRecords.length = 0;
|
|
808
|
-
const expandedEnd = Math.min(nextSource.length, restartOffset + (scanEnd - restartOffset) * 2);
|
|
809
|
-
scanLineEnd = nextLines.indexAtOrAfter(expandedEnd);
|
|
810
|
-
}
|
|
750
|
+
});
|
|
811
751
|
const oldTokenLength = this.#tokens.length;
|
|
812
752
|
const oldTokenEnd = convergedIndex < 0 ? oldTokenLength : previousRecords[convergedIndex].tokenStart;
|
|
813
|
-
const tokenChange = this.#tokens.replace(oldTokenStart, oldTokenEnd, replacement, changedSpan.start, oldChangedEnd);
|
|
753
|
+
const tokenChange = this.#tokens.replace(oldTokenStart, oldTokenEnd, replacement, changedSpan.start, oldChangedEnd, offsetDelta);
|
|
814
754
|
const tokenDelta = tokenChange.newEnd - tokenChange.oldEnd;
|
|
815
755
|
let oldRecordStart = stableBlockCount;
|
|
816
756
|
while (oldRecordStart < previousRecords.length && (previousRecords[oldRecordStart + 1]?.tokenStart ?? oldTokenLength) <= tokenChange.oldStart) oldRecordStart++;
|
|
817
|
-
|
|
818
|
-
while (oldRecordEnd < previousRecords.length && previousRecords[oldRecordEnd].tokenStart < tokenChange.oldEnd) oldRecordEnd++;
|
|
757
|
+
const oldRecordEnd = convergedIndex < 0 ? previousRecords.length : convergedIndex;
|
|
819
758
|
const nextRecords = previousRecords.slice(0, stableBlockCount);
|
|
820
759
|
nextRecords.push(...rescannedRecords);
|
|
821
760
|
const shiftSuffix = offsetDelta !== 0 || tokenDelta !== 0;
|
|
@@ -843,21 +782,9 @@ var BlockScanner = class {
|
|
|
843
782
|
}
|
|
844
783
|
};
|
|
845
784
|
// src/fragment/block.ts
|
|
846
|
-
function blockEnd(tokenStart, context) {
|
|
847
|
-
const tokens = context.structure.tokens;
|
|
848
|
-
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
849
|
-
return close === tokenStart ? tokens.contentEnd(context.source, close) : tokens.end(close);
|
|
850
|
-
}
|
|
851
785
|
function leafBlockPosition(tokenStart, context) {
|
|
852
786
|
const tokens = context.structure.tokens;
|
|
853
|
-
|
|
854
|
-
return context.locator.positionAt(tokens.start(tokenStart), tokens.contentEnd(context.source, close));
|
|
855
|
-
}
|
|
856
|
-
function fencedBlockPosition(tokenStart, block, context) {
|
|
857
|
-
const tokens = context.structure.tokens;
|
|
858
|
-
const end = tokens.end(tokenStart);
|
|
859
|
-
const positionEnd = block.closed || end < tokens.sourceLength ? blockEnd(tokenStart, context) : end;
|
|
860
|
-
return context.locator.positionAt(tokens.start(tokenStart) + block.markerOffset, positionEnd);
|
|
787
|
+
return context.locator.positionAt(tokens.start(tokenStart), tokens.contentEnd(context.source, tokenStart));
|
|
861
788
|
}
|
|
862
789
|
function buildBlockNode(tokenStart, context) {
|
|
863
790
|
const kind = context.structure.tokens.kind(tokenStart);
|
|
@@ -871,15 +798,21 @@ function buildBlockChildren(tokenStart, context) {
|
|
|
871
798
|
for (let child = tokenStart + 1; child < tokenEnd;) {
|
|
872
799
|
const length = tokens.nodeLength(child);
|
|
873
800
|
if (length > 0) {
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
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));
|
|
877
803
|
}
|
|
878
804
|
child += length || 1;
|
|
879
805
|
}
|
|
880
806
|
return children;
|
|
881
807
|
}
|
|
882
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
|
+
}
|
|
883
816
|
function containingSegment(segments, offset) {
|
|
884
817
|
let low = 0;
|
|
885
818
|
let high = segments.length >>> 1;
|
|
@@ -893,34 +826,33 @@ function containingSegment(segments, offset) {
|
|
|
893
826
|
var SourceView = class {
|
|
894
827
|
#offset = 0;
|
|
895
828
|
#segments;
|
|
896
|
-
text;
|
|
829
|
+
text = "";
|
|
830
|
+
withBoundaryBreak = false;
|
|
897
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;
|
|
898
836
|
let token = tokenStart + 1;
|
|
899
837
|
const firstStart = tokens.start(token);
|
|
900
838
|
const tokenEnd = tokenStart + nodeLength;
|
|
901
|
-
let segmentStart = firstStart;
|
|
902
839
|
let end = tokens.end(token++);
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
end = tokens.end(token);
|
|
914
|
-
token++;
|
|
915
|
-
}
|
|
916
|
-
if (parts && segments) {
|
|
917
|
-
parts.push(source.slice(segmentStart, end));
|
|
918
|
-
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);
|
|
919
850
|
this.#segments = segments;
|
|
920
851
|
this.text = parts.join("");
|
|
921
852
|
return;
|
|
922
853
|
}
|
|
923
854
|
this.#offset = firstStart;
|
|
855
|
+
this.#segments = void 0;
|
|
924
856
|
this.text = source.slice(firstStart, end);
|
|
925
857
|
}
|
|
926
858
|
mapOffset(offset) {
|
|
@@ -968,20 +900,20 @@ var InlineRegion = class {
|
|
|
968
900
|
tokens;
|
|
969
901
|
tokenStart;
|
|
970
902
|
view;
|
|
971
|
-
constructor(profile,
|
|
903
|
+
constructor(profile, tokenStart, view, definitions) {
|
|
972
904
|
this.#profile = profile;
|
|
973
|
-
this.tokenStart =
|
|
974
|
-
this.view =
|
|
975
|
-
this.#updateTokens(
|
|
976
|
-
}
|
|
977
|
-
update(
|
|
978
|
-
this.#updateTokens(
|
|
979
|
-
this.tokenStart =
|
|
980
|
-
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;
|
|
981
913
|
return this;
|
|
982
914
|
}
|
|
983
915
|
updateDefinitions(definitions, definitionMembershipChanges) {
|
|
984
|
-
return this.#updateTokens(this.view
|
|
916
|
+
return this.#updateTokens(this.view, definitions, definitionMembershipChanges);
|
|
985
917
|
}
|
|
986
918
|
shift(delta, tokenDelta) {
|
|
987
919
|
this.tokenStart += tokenDelta;
|
|
@@ -996,13 +928,13 @@ var InlineRegion = class {
|
|
|
996
928
|
} else for (const key of definitionMembershipChanges) if (dependencies.has(key)) return true;
|
|
997
929
|
return false;
|
|
998
930
|
}
|
|
999
|
-
#updateTokens(
|
|
931
|
+
#updateTokens(view, definitions, definitionMembershipChanges) {
|
|
1000
932
|
const previousTokens = this.#rawTokens;
|
|
1001
|
-
const sourceUnchanged = previousTokens !== void 0 &&
|
|
933
|
+
const sourceUnchanged = previousTokens !== void 0 && view.text === this.view.text;
|
|
1002
934
|
if (sourceUnchanged && !this.#dependenciesChanged(definitionMembershipChanges)) return false;
|
|
1003
935
|
definitions.dependencies = void 0;
|
|
1004
|
-
const rawTokens = sourceUnchanged ? previousTokens : this.#profile.tokenize(
|
|
1005
|
-
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);
|
|
1006
938
|
this.#definitionDependencies = definitions.dependencies ?? emptySet;
|
|
1007
939
|
this.#rawTokens = rawTokens;
|
|
1008
940
|
this.tokens = tokens;
|
|
@@ -1034,55 +966,36 @@ var InlineRegionState = class {
|
|
|
1034
966
|
const definitionMembershipChanges = change?.tokenChange.definitionMembershipChanges ?? emptySet;
|
|
1035
967
|
const regionsByBlock = stableBlockCount === 0 ? [] : previousRegionsByBlock.slice(0, stableBlockCount);
|
|
1036
968
|
let invalidatedBlocks;
|
|
1037
|
-
const bindings = [];
|
|
1038
|
-
const bindingOffsets = [];
|
|
1039
|
-
for (let index = stableBlockCount; index < newRecordEnd; index++) {
|
|
1040
|
-
const tokenStart = structure.records[index].tokenStart;
|
|
1041
|
-
const tokenEnd = tokenStart + tokens.nodeLength(tokenStart);
|
|
1042
|
-
bindingOffsets.push(bindings.length);
|
|
1043
|
-
for (let token = tokenStart; token < tokenEnd; token++) {
|
|
1044
|
-
const nodeLength = tokens.nodeLength(token);
|
|
1045
|
-
if (nodeLength === 0) continue;
|
|
1046
|
-
if (tokens.kind(token) & 32) {
|
|
1047
|
-
if (tokens.kind(token + 1) === 1) bindings.push({
|
|
1048
|
-
tokenStart: token,
|
|
1049
|
-
view: new SourceView(source, tokens, token, nodeLength)
|
|
1050
|
-
});
|
|
1051
|
-
token += nodeLength - 1;
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
regionsByBlock.push(emptyArray);
|
|
1055
|
-
}
|
|
1056
|
-
bindingOffsets.push(bindings.length);
|
|
1057
969
|
const tokenChange = change?.tokenChange;
|
|
1058
970
|
const suffixTokenDelta = tokenChange ? tokenChange.newEnd - tokenChange.oldEnd : 0;
|
|
1059
|
-
for (let index = oldRecordEnd; index < previousRegionsByBlock.length; index++) {
|
|
1060
|
-
const regions = previousRegionsByBlock[index];
|
|
1061
|
-
if (offsetDelta !== 0 || suffixTokenDelta !== 0) for (const region of regions) region.shift(offsetDelta, suffixTokenDelta);
|
|
1062
|
-
regionsByBlock.push(regions);
|
|
1063
|
-
}
|
|
1064
971
|
const displacedRegions = [];
|
|
1065
972
|
for (let index = oldRecordStart; index < oldRecordEnd; index++) for (const region of previousRegionsByBlock[index]) displacedRegions.push(region);
|
|
1066
|
-
const displacedBindingStart = bindingOffsets[Math.min(oldRecordStart, newRecordEnd) - stableBlockCount];
|
|
1067
973
|
let displacedIndex = 0;
|
|
1068
974
|
for (let blockIndex = stableBlockCount; blockIndex < newRecordEnd; blockIndex++) {
|
|
1069
975
|
const previousRegions = blockIndex < oldRecordStart ? previousRegionsByBlock[blockIndex] : void 0;
|
|
1070
|
-
const
|
|
1071
|
-
const
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
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;
|
|
1077
983
|
let candidate = previousRegions?.[regionIndex];
|
|
1078
|
-
if (!candidate && tokenChange &&
|
|
1079
|
-
const previousTokenStart =
|
|
984
|
+
if (!candidate && tokenChange && blockIndex >= oldRecordStart) {
|
|
985
|
+
const previousTokenStart = token < tokenChange.oldStart ? token : token >= tokenChange.newEnd ? token - suffixTokenDelta : -1;
|
|
1080
986
|
while (displacedIndex < displacedRegions.length && displacedRegions[displacedIndex].tokenStart < previousTokenStart) displacedIndex++;
|
|
1081
987
|
if (displacedRegions[displacedIndex]?.tokenStart === previousTokenStart) candidate = displacedRegions[displacedIndex++];
|
|
1082
988
|
}
|
|
1083
|
-
|
|
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;
|
|
1084
992
|
}
|
|
1085
|
-
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);
|
|
1086
999
|
}
|
|
1087
1000
|
if (previousRegionsByBlock.length > 0 && definitionMembershipChanges.size > 0) {
|
|
1088
1001
|
const refreshDefinitions = (start, end) => {
|
|
@@ -1280,30 +1193,30 @@ function generateBlockDispatch(starts, fallbacks) {
|
|
|
1280
1193
|
try {
|
|
1281
1194
|
const resolvers = [];
|
|
1282
1195
|
const call = (resolve) => {
|
|
1283
|
-
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;`;
|
|
1284
1197
|
};
|
|
1285
1198
|
let cases = "";
|
|
1286
1199
|
for (const code in starts) cases += `case ${code}:${starts[code].map(call).join("")}break;`;
|
|
1287
1200
|
const source = [
|
|
1288
|
-
`return(s,l,i,o,
|
|
1201
|
+
`return(s,l,t,i,o,c)=>{`,
|
|
1289
1202
|
`let e;switch(o<0?-1:s.charCodeAt(o)){${cases}}`,
|
|
1290
1203
|
...fallbacks.map(call),
|
|
1291
|
-
`throw new Error("
|
|
1204
|
+
`throw new Error("No block fallback")}`
|
|
1292
1205
|
].join("");
|
|
1293
1206
|
const names = resolvers.map((resolver, index) => `r${index}`);
|
|
1294
1207
|
return Function(...names, source)(...resolvers);
|
|
1295
1208
|
} catch {
|
|
1296
|
-
return (source, lines, start, contentOffset,
|
|
1209
|
+
return (source, lines, tokens, start, contentOffset, context) => {
|
|
1297
1210
|
const resolvers = starts[contentOffset < 0 ? -1 : source.charCodeAt(contentOffset)];
|
|
1298
1211
|
if (resolvers) for (const resolve of resolvers) {
|
|
1299
|
-
const end = resolve(source, lines, start, contentOffset,
|
|
1212
|
+
const end = resolve(source, lines, tokens, start, contentOffset, context);
|
|
1300
1213
|
if (end !== void 0) return end;
|
|
1301
1214
|
}
|
|
1302
1215
|
for (const fallback of fallbacks) {
|
|
1303
|
-
const end = fallback(source, lines, start, contentOffset,
|
|
1216
|
+
const end = fallback(source, lines, tokens, start, contentOffset, context);
|
|
1304
1217
|
if (end !== void 0) return end;
|
|
1305
1218
|
}
|
|
1306
|
-
throw new Error("
|
|
1219
|
+
throw new Error("No block fallback");
|
|
1307
1220
|
};
|
|
1308
1221
|
}
|
|
1309
1222
|
}
|
|
@@ -1346,8 +1259,41 @@ function compileBlockProfile(features) {
|
|
|
1346
1259
|
lazyContinuationUnwrappers
|
|
1347
1260
|
};
|
|
1348
1261
|
}
|
|
1349
|
-
// src/inline/
|
|
1350
|
-
|
|
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
|
|
1351
1297
|
function matchInlinePatternEnd(pattern, source, start) {
|
|
1352
1298
|
pattern.lastIndex = start;
|
|
1353
1299
|
return pattern.test(source) ? pattern.lastIndex : -1;
|
|
@@ -1358,78 +1304,79 @@ function inlineMarkerRunEnd(source, start) {
|
|
|
1358
1304
|
while (source.charCodeAt(end) === marker) end++;
|
|
1359
1305
|
return end;
|
|
1360
1306
|
}
|
|
1361
|
-
function
|
|
1362
|
-
|
|
1363
|
-
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) {
|
|
1364
1318
|
let offset = 0;
|
|
1365
1319
|
while (source.charCodeAt(offset) === 32) offset++;
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1320
|
+
offset = nextBoundaryOffset(source, boundary, offset);
|
|
1321
|
+
if (offset < 0) return emptyArray;
|
|
1322
|
+
const tokens = [];
|
|
1323
|
+
for (; offset >= 0; offset = nextBoundaryOffset(source, boundary, offset)) {
|
|
1370
1324
|
const code = source.charCodeAt(offset);
|
|
1371
1325
|
if (code === 10 || code === 13) {
|
|
1372
|
-
|
|
1373
|
-
let spaces = offset - 2;
|
|
1374
|
-
while (source.charCodeAt(spaces - 1) === 32) spaces--;
|
|
1375
|
-
tokens.push(128, spaces, offset, 0);
|
|
1376
|
-
}
|
|
1326
|
+
const spacesBreak = source.charCodeAt(offset - 1) === 32 && source.charCodeAt(offset - 2) === 32;
|
|
1377
1327
|
const endingStart = offset++;
|
|
1378
1328
|
if (code === 13 && source.charCodeAt(offset) === 10) offset++;
|
|
1379
1329
|
const lineStart = offset;
|
|
1380
1330
|
while (source.charCodeAt(offset) === 32) offset++;
|
|
1381
|
-
|
|
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);
|
|
1382
1336
|
continue;
|
|
1383
1337
|
}
|
|
1384
|
-
const scannedEnd =
|
|
1338
|
+
const scannedEnd = scanners[code]?.(source, offset, tokens) ?? offset;
|
|
1385
1339
|
offset = scannedEnd > offset ? scannedEnd : offset + 1;
|
|
1386
1340
|
}
|
|
1387
1341
|
return tokens;
|
|
1388
1342
|
}
|
|
1389
|
-
function generateInlineTokenizer(
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
const
|
|
1394
|
-
const
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
`tokens.push(67,endingStart,offset,lineStart);continue}`,
|
|
1407
|
-
`let scannedEnd;switch(code){${boundaryCodes.map((code, index) => `case ${code}:scannedEnd=scan${index}(source,offset,tokens);break;`).join("")}default:scannedEnd=offset}`,
|
|
1408
|
-
`offset=scannedEnd>offset?scannedEnd:offset+1}`,
|
|
1409
|
-
`return tokens}`
|
|
1410
|
-
].join("");
|
|
1411
|
-
tokenizerFactories.set(key, factory = Function("textBoundary", ...names, source));
|
|
1412
|
-
}
|
|
1413
|
-
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]));
|
|
1414
1360
|
}
|
|
1415
1361
|
function compileInlineTokenizer(rules) {
|
|
1416
|
-
const
|
|
1362
|
+
const scanners = [];
|
|
1417
1363
|
const boundaryCodes = [];
|
|
1418
1364
|
for (const rule of rules) {
|
|
1419
1365
|
const code = rule.marker;
|
|
1420
|
-
const previous =
|
|
1421
|
-
|
|
1366
|
+
const previous = scanners[code];
|
|
1367
|
+
scanners[code] = previous === void 0 ? rule.scan : (source, start, tokens) => {
|
|
1422
1368
|
const end = previous(source, start, tokens);
|
|
1423
1369
|
return end > start ? end : rule.scan(source, start, tokens);
|
|
1424
1370
|
};
|
|
1425
1371
|
if (previous === void 0) boundaryCodes.push(code);
|
|
1426
1372
|
}
|
|
1427
1373
|
const boundaries = String.fromCharCode(...boundaryCodes).replaceAll(/[\\\]-]/g, "\\$&");
|
|
1428
|
-
const
|
|
1374
|
+
const boundaryFast = new RegExp(`[\\r${boundaries}]`, "g");
|
|
1375
|
+
const boundarySlow = new RegExp(`[\\r${boundaries}]|\\n(?:(?<=[ \\t]\\n)|(?= ))`, "g");
|
|
1429
1376
|
try {
|
|
1430
|
-
return generateInlineTokenizer(
|
|
1377
|
+
return generateInlineTokenizer(boundaryFast, boundarySlow, boundaryCodes, scanners);
|
|
1431
1378
|
} catch {
|
|
1432
|
-
return (source) => tokenize(source,
|
|
1379
|
+
return (source, withBoundaryBreak) => tokenize(source, withBoundaryBreak ? boundarySlow : boundaryFast, scanners);
|
|
1433
1380
|
}
|
|
1434
1381
|
}
|
|
1435
1382
|
// src/inline/profile.ts
|
|
@@ -1459,7 +1406,7 @@ function compileInlineProfile(features, compileInlineResolver) {
|
|
|
1459
1406
|
}
|
|
1460
1407
|
// src/profile/features/attributes/block.ts
|
|
1461
1408
|
const blockDecorators = [{
|
|
1462
|
-
token: [
|
|
1409
|
+
token: [73, 74],
|
|
1463
1410
|
decorate(build) {
|
|
1464
1411
|
return (tokenStart, context) => {
|
|
1465
1412
|
const result = build(tokenStart, context);
|
|
@@ -1474,7 +1421,7 @@ const blockDecorators = [{
|
|
|
1474
1421
|
};
|
|
1475
1422
|
}
|
|
1476
1423
|
}, {
|
|
1477
|
-
token:
|
|
1424
|
+
token: 72,
|
|
1478
1425
|
decorate(build) {
|
|
1479
1426
|
return (tokenStart, context) => {
|
|
1480
1427
|
const result = build(tokenStart, context);
|
|
@@ -1487,40 +1434,6 @@ const blockDecorators = [{
|
|
|
1487
1434
|
};
|
|
1488
1435
|
}
|
|
1489
1436
|
}];
|
|
1490
|
-
// src/inline/tokens.ts
|
|
1491
|
-
function inlineTokenCount(tokens) {
|
|
1492
|
-
return tokens.length / 4;
|
|
1493
|
-
}
|
|
1494
|
-
function inlineTokenKind(tokens, index) {
|
|
1495
|
-
return tokens[index * 4 + 0];
|
|
1496
|
-
}
|
|
1497
|
-
function inlineTokenStart(tokens, index) {
|
|
1498
|
-
return tokens[index * 4 + 1];
|
|
1499
|
-
}
|
|
1500
|
-
function inlineTokenEnd(tokens, index) {
|
|
1501
|
-
return tokens[index * 4 + 2];
|
|
1502
|
-
}
|
|
1503
|
-
function inlineTokenData(tokens, index) {
|
|
1504
|
-
return tokens[index * 4 + 3];
|
|
1505
|
-
}
|
|
1506
|
-
function setInlineTokenData(tokens, index, data) {
|
|
1507
|
-
tokens[index * 4 + 3] = data;
|
|
1508
|
-
}
|
|
1509
|
-
function rewriteInlineTokenTail(tokens, kind, end) {
|
|
1510
|
-
const offset = tokens.length - 4;
|
|
1511
|
-
tokens[offset + 0] = kind;
|
|
1512
|
-
tokens[offset + 2] = end;
|
|
1513
|
-
}
|
|
1514
|
-
function inlineTokenText(source, tokens, index, startPadding = 0, endPadding = startPadding) {
|
|
1515
|
-
return source.slice(inlineTokenStart(tokens, index) + startPadding, inlineTokenEnd(tokens, index) - endPadding);
|
|
1516
|
-
}
|
|
1517
|
-
function appendInlineToken(target, kind, start, end, data = 0) {
|
|
1518
|
-
target.push(kind, start, end, data);
|
|
1519
|
-
}
|
|
1520
|
-
function copyInlineToken(target, tokens, index) {
|
|
1521
|
-
const offset = index * 4;
|
|
1522
|
-
target.push(tokens[offset], tokens[offset + 1], tokens[offset + 2], tokens[offset + 3]);
|
|
1523
|
-
}
|
|
1524
1437
|
// src/profile/utils.ts
|
|
1525
1438
|
const inlineColonBoundary = /[ \t\n\r\p{sc=Han}\p{sc=Hira}\p{sc=Kana}\p{sc=Hang}\p{P}]/u;
|
|
1526
1439
|
function isAsciiDigit(code) {
|
|
@@ -1561,13 +1474,17 @@ function normalizeIdentifier(identifier) {
|
|
|
1561
1474
|
}
|
|
1562
1475
|
// src/profile/features/attributes/shared.ts
|
|
1563
1476
|
const brackets = {
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1477
|
+
[91]: 93,
|
|
1478
|
+
[123]: 125,
|
|
1479
|
+
[40]: 41
|
|
1567
1480
|
};
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1481
|
+
const stops1 = new Set([
|
|
1482
|
+
32,
|
|
1483
|
+
35,
|
|
1484
|
+
46,
|
|
1485
|
+
125
|
|
1486
|
+
]);
|
|
1487
|
+
const stops2 = new Set([32, 125]);
|
|
1571
1488
|
function assignAttribute(attributes, name, value) {
|
|
1572
1489
|
if (name === "class" && typeof value === "string" && typeof attributes.class === "string") attributes.class += ` ${value}`;
|
|
1573
1490
|
else attributes[name] = value;
|
|
@@ -1576,23 +1493,23 @@ function mergeAttributes(target, source) {
|
|
|
1576
1493
|
for (const key in source) assignAttribute(target, key, source[key]);
|
|
1577
1494
|
}
|
|
1578
1495
|
function scanAttributes(source, start, attributes, limit = source.length) {
|
|
1579
|
-
if (source
|
|
1496
|
+
if (source.charCodeAt(start) !== 123 || source.charCodeAt(start + 1) === 123) return;
|
|
1580
1497
|
let offset = start + 1;
|
|
1581
1498
|
const scanUntil = (stops) => {
|
|
1582
1499
|
while (offset < limit) {
|
|
1583
|
-
const
|
|
1584
|
-
if (
|
|
1585
|
-
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;
|
|
1586
1503
|
}
|
|
1587
1504
|
};
|
|
1588
1505
|
const scanQuoted = (quote) => {
|
|
1589
1506
|
offset++;
|
|
1590
1507
|
while (offset < limit) {
|
|
1591
|
-
const character = source
|
|
1592
|
-
if (character ===
|
|
1593
|
-
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;
|
|
1594
1511
|
}
|
|
1595
|
-
if (source
|
|
1512
|
+
if (source.charCodeAt(offset) !== quote) return false;
|
|
1596
1513
|
offset++;
|
|
1597
1514
|
return true;
|
|
1598
1515
|
};
|
|
@@ -1600,33 +1517,33 @@ function scanAttributes(source, start, attributes, limit = source.length) {
|
|
|
1600
1517
|
const stack = [close];
|
|
1601
1518
|
offset++;
|
|
1602
1519
|
while (offset < limit && stack.length > 0) {
|
|
1603
|
-
const
|
|
1604
|
-
if (
|
|
1605
|
-
if (
|
|
1520
|
+
const code = source.charCodeAt(offset);
|
|
1521
|
+
if (code === 10 || code === 13) return false;
|
|
1522
|
+
if (code === 92 && offset + 1 < limit) {
|
|
1606
1523
|
offset += 2;
|
|
1607
1524
|
continue;
|
|
1608
1525
|
}
|
|
1609
|
-
if (
|
|
1610
|
-
if (!scanQuoted(
|
|
1526
|
+
if (code === 34 || code === 39 || code === 96) {
|
|
1527
|
+
if (!scanQuoted(code)) return false;
|
|
1611
1528
|
continue;
|
|
1612
1529
|
}
|
|
1613
|
-
const
|
|
1614
|
-
if (
|
|
1615
|
-
else if (
|
|
1530
|
+
const nested = brackets[code];
|
|
1531
|
+
if (nested) stack.push(nested);
|
|
1532
|
+
else if (code === stack.at(-1)) stack.pop();
|
|
1616
1533
|
offset++;
|
|
1617
1534
|
}
|
|
1618
1535
|
return stack.length === 0;
|
|
1619
1536
|
};
|
|
1620
1537
|
while (offset < limit) {
|
|
1621
|
-
|
|
1622
|
-
if (source
|
|
1623
|
-
const marker = source
|
|
1624
|
-
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) {
|
|
1625
1542
|
offset++;
|
|
1626
1543
|
const valueStart = offset;
|
|
1627
|
-
scanUntil(
|
|
1544
|
+
scanUntil(stops1);
|
|
1628
1545
|
if (offset === valueStart) return;
|
|
1629
|
-
if (attributes) assignAttribute(attributes, marker ===
|
|
1546
|
+
if (attributes) assignAttribute(attributes, marker === 46 ? "class" : "id", source.slice(valueStart, offset));
|
|
1630
1547
|
continue;
|
|
1631
1548
|
}
|
|
1632
1549
|
const nameStart = offset;
|
|
@@ -1640,8 +1557,8 @@ function scanAttributes(source, start, attributes, limit = source.length) {
|
|
|
1640
1557
|
offset++;
|
|
1641
1558
|
}
|
|
1642
1559
|
const nameEnd = offset;
|
|
1643
|
-
|
|
1644
|
-
if (source
|
|
1560
|
+
offset = trimLineWhitespaceStart(source, offset, limit);
|
|
1561
|
+
if (source.charCodeAt(offset) !== 61) {
|
|
1645
1562
|
if (attributes) {
|
|
1646
1563
|
const name = source.slice(nameStart, nameEnd);
|
|
1647
1564
|
assignAttribute(attributes, source.charCodeAt(nameStart) === 58 ? name : `:${name}`, "true");
|
|
@@ -1649,19 +1566,19 @@ function scanAttributes(source, start, attributes, limit = source.length) {
|
|
|
1649
1566
|
continue;
|
|
1650
1567
|
}
|
|
1651
1568
|
offset++;
|
|
1652
|
-
|
|
1653
|
-
const character = source
|
|
1569
|
+
offset = trimLineWhitespaceStart(source, offset, limit);
|
|
1570
|
+
const character = source.charCodeAt(offset);
|
|
1654
1571
|
let valueStart = offset;
|
|
1655
1572
|
let valueEnd;
|
|
1656
|
-
if (character ===
|
|
1573
|
+
if (character === 34 || character === 39 || character === 96) {
|
|
1657
1574
|
if (!scanQuoted(character)) return;
|
|
1658
1575
|
valueStart++;
|
|
1659
1576
|
valueEnd = offset - 1;
|
|
1660
|
-
} else if (brackets
|
|
1577
|
+
} else if (character in brackets) {
|
|
1661
1578
|
if (!scanBracketed(brackets[character])) return;
|
|
1662
1579
|
valueEnd = offset;
|
|
1663
1580
|
} else {
|
|
1664
|
-
scanUntil(
|
|
1581
|
+
scanUntil(stops2);
|
|
1665
1582
|
valueEnd = offset;
|
|
1666
1583
|
if (valueEnd === valueStart) return;
|
|
1667
1584
|
}
|
|
@@ -1682,7 +1599,10 @@ function hasVisibleText(source, start, end) {
|
|
|
1682
1599
|
return false;
|
|
1683
1600
|
}
|
|
1684
1601
|
function attributeEndAt(source, start) {
|
|
1685
|
-
|
|
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
|
+
}
|
|
1686
1606
|
}
|
|
1687
1607
|
// src/profile/features/attributes/index.ts
|
|
1688
1608
|
const feature$18 = {
|
|
@@ -1762,7 +1682,7 @@ const feature$17 = { inline: {
|
|
|
1762
1682
|
builds: [{
|
|
1763
1683
|
kind: "leaf",
|
|
1764
1684
|
token: 135,
|
|
1765
|
-
build(tokenIndex,
|
|
1685
|
+
build(tokenIndex, position, context) {
|
|
1766
1686
|
const source = context.view.text;
|
|
1767
1687
|
const tokenStart = inlineTokenStart(context.tokens, tokenIndex);
|
|
1768
1688
|
const start = tokenStart + 2;
|
|
@@ -1777,18 +1697,18 @@ const feature$17 = { inline: {
|
|
|
1777
1697
|
name: "binding",
|
|
1778
1698
|
attributes,
|
|
1779
1699
|
children: [],
|
|
1780
|
-
position
|
|
1700
|
+
position
|
|
1781
1701
|
};
|
|
1782
1702
|
}
|
|
1783
1703
|
}]
|
|
1784
1704
|
} };
|
|
1785
1705
|
// src/profile/features/blockquote.ts
|
|
1786
1706
|
function blockQuoteOffset(source, lines, index, markerOffset) {
|
|
1787
|
-
if (markerOffset < 0 || source
|
|
1707
|
+
if (markerOffset < 0 || source.charCodeAt(markerOffset) !== 62) return;
|
|
1788
1708
|
let offset = markerOffset + 1;
|
|
1789
1709
|
let prefixColumns = lines.prefixColumns(index);
|
|
1790
|
-
if (source
|
|
1791
|
-
else if (source
|
|
1710
|
+
if (source.charCodeAt(offset) === 32) offset++;
|
|
1711
|
+
else if (source.charCodeAt(offset) === 9) {
|
|
1792
1712
|
prefixColumns += 4 - physicalColumnAt(source, offset) % 4 - 1;
|
|
1793
1713
|
offset++;
|
|
1794
1714
|
}
|
|
@@ -1799,16 +1719,17 @@ function blockQuoteOffset(source, lines, index, markerOffset) {
|
|
|
1799
1719
|
}
|
|
1800
1720
|
const feature$16 = { block: {
|
|
1801
1721
|
builds: [{
|
|
1802
|
-
token:
|
|
1722
|
+
token: 72,
|
|
1803
1723
|
build(tokenStart, context) {
|
|
1804
1724
|
const tokens = context.structure.tokens;
|
|
1725
|
+
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
1805
1726
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
1806
1727
|
return {
|
|
1807
1728
|
type: "blockquote",
|
|
1808
1729
|
children: buildBlockChildren(tokenStart, context),
|
|
1809
1730
|
position: {
|
|
1810
1731
|
start,
|
|
1811
|
-
end: context.locator.locationAt(
|
|
1732
|
+
end: context.locator.locationAt(tokens.end(close))
|
|
1812
1733
|
}
|
|
1813
1734
|
};
|
|
1814
1735
|
}
|
|
@@ -1824,26 +1745,27 @@ const feature$16 = { block: {
|
|
|
1824
1745
|
interrupt() {
|
|
1825
1746
|
return true;
|
|
1826
1747
|
},
|
|
1827
|
-
start(source, lines, start, contentOffset,
|
|
1748
|
+
start(source, lines, tokens, start, contentOffset, context) {
|
|
1828
1749
|
const firstMarker = blockQuoteOffset(source, lines, start, contentOffset);
|
|
1829
1750
|
const quoteLines = context.createLineView(lines, start, firstMarker.offset, firstMarker.prefixColumns);
|
|
1830
1751
|
let index = start + 1;
|
|
1831
|
-
let lazyParagraph
|
|
1752
|
+
let lazyParagraph;
|
|
1832
1753
|
for (; index < lines.length; index++) {
|
|
1833
1754
|
const markerOffset = lineIndentOffset(source, lines, index);
|
|
1834
1755
|
const marker = blockQuoteOffset(source, lines, index, markerOffset);
|
|
1835
1756
|
if (marker) {
|
|
1836
1757
|
quoteLines.pushFrom(lines, index, marker.offset, marker.prefixColumns);
|
|
1837
|
-
lazyParagraph =
|
|
1758
|
+
lazyParagraph = void 0;
|
|
1838
1759
|
continue;
|
|
1839
1760
|
}
|
|
1761
|
+
lazyParagraph ??= context.endsWithParagraphLeaf(source, quoteLines, quoteLines.length - 1);
|
|
1840
1762
|
if (!lazyParagraph || markerOffset < 0 && isBlankLine(source, lines, index) || !lines.lazy(index) && context.startsInterruptingBlock(source, lines, index, markerOffset)) break;
|
|
1841
1763
|
quoteLines.pushLazy(lines, index);
|
|
1842
1764
|
}
|
|
1843
|
-
|
|
1844
|
-
context.scanLines(source, quoteLines,
|
|
1845
|
-
const end = quoteLines.
|
|
1846
|
-
|
|
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);
|
|
1847
1769
|
return index;
|
|
1848
1770
|
}
|
|
1849
1771
|
}]
|
|
@@ -1880,9 +1802,9 @@ const feature$15 = {
|
|
|
1880
1802
|
interrupt(source, lines, index, contentOffset) {
|
|
1881
1803
|
return isThematicBreak(source, lines, index, contentOffset);
|
|
1882
1804
|
},
|
|
1883
|
-
start(source, lines, start, contentOffset
|
|
1805
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
1884
1806
|
if (!isThematicBreak(source, lines, start, contentOffset)) return;
|
|
1885
|
-
|
|
1807
|
+
tokens.push(256, contentOffset, lines.end(start));
|
|
1886
1808
|
return start + 1;
|
|
1887
1809
|
}
|
|
1888
1810
|
}]
|
|
@@ -1890,10 +1812,14 @@ const feature$15 = {
|
|
|
1890
1812
|
inline: { builds: [{
|
|
1891
1813
|
kind: "leaf",
|
|
1892
1814
|
token: 128,
|
|
1893
|
-
build(tokenIndex,
|
|
1815
|
+
build(tokenIndex, position, context) {
|
|
1816
|
+
const lineStart = inlineTokenData(context.tokens, tokenIndex);
|
|
1894
1817
|
return {
|
|
1895
1818
|
type: "break",
|
|
1896
|
-
position:
|
|
1819
|
+
position: {
|
|
1820
|
+
start: position.start,
|
|
1821
|
+
end: context.locator.locationAt(context.view.mapOffset(lineStart - 1) + 1)
|
|
1822
|
+
}
|
|
1897
1823
|
};
|
|
1898
1824
|
}
|
|
1899
1825
|
}] }
|
|
@@ -1932,63 +1858,54 @@ function closesFence(source, lines, index, fence) {
|
|
|
1932
1858
|
while (source.charCodeAt(offset) === fence.marker) offset++;
|
|
1933
1859
|
if (offset < markerEnd) return false;
|
|
1934
1860
|
const lineEnd = lines.end(index);
|
|
1935
|
-
return
|
|
1936
|
-
}
|
|
1937
|
-
function fencedBlock(source, lines, index, end, fence, closed) {
|
|
1938
|
-
const lineEnd = lines.end(index);
|
|
1939
|
-
const infoStart = skipLineWhitespace(source, fence.offset + fence.length, lineEnd);
|
|
1940
|
-
let content;
|
|
1941
|
-
if (lines.physicallyContiguous()) {
|
|
1942
|
-
const contentStart = lines.next(index);
|
|
1943
|
-
const lastContentLine = end - (closed ? 2 : 1);
|
|
1944
|
-
content = source.slice(contentStart, lastContentLine > index ? lines.end(lastContentLine) : contentStart);
|
|
1945
|
-
}
|
|
1946
|
-
return {
|
|
1947
|
-
closed,
|
|
1948
|
-
content,
|
|
1949
|
-
indent: fence.indent,
|
|
1950
|
-
info: source.slice(infoStart, lineEnd),
|
|
1951
|
-
markerOffset: fence.offset - lines.start(index)
|
|
1952
|
-
};
|
|
1861
|
+
return trimLineWhitespaceStart(source, offset, lineEnd) === lineEnd;
|
|
1953
1862
|
}
|
|
1954
1863
|
const fenceSpaceIndent = [
|
|
1955
1864
|
/^(?<![\u2028\u2029]) /gm,
|
|
1956
1865
|
/^(?<![\u2028\u2029]) {1,2}/gm,
|
|
1957
1866
|
/^(?<![\u2028\u2029]) {1,3}/gm
|
|
1958
1867
|
];
|
|
1959
|
-
const
|
|
1868
|
+
const fenceTabIndent = [
|
|
1960
1869
|
/^(?<![\u2028\u2029])\t/gm,
|
|
1961
1870
|
/^(?<![\u2028\u2029]) ?\t/gm,
|
|
1962
1871
|
/^(?<![\u2028\u2029]) {0,2}\t/gm
|
|
1963
1872
|
];
|
|
1964
|
-
function
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
content
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
}
|
|
1974
|
-
function
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
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("");
|
|
1992
1909
|
}
|
|
1993
1910
|
// src/profile/features/code.ts
|
|
1994
1911
|
const codeFenceRule = {
|
|
@@ -2000,15 +1917,30 @@ const codeFenceRule = {
|
|
|
2000
1917
|
function codeFenceAt(source, lines, index, markerOffset) {
|
|
2001
1918
|
return fenceAt(source, lines, index, codeFenceRule, markerOffset);
|
|
2002
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");
|
|
1936
|
+
}
|
|
2003
1937
|
const feature$14 = {
|
|
2004
1938
|
block: {
|
|
2005
1939
|
builds: [{
|
|
2006
|
-
token:
|
|
1940
|
+
token: [258, 259],
|
|
2007
1941
|
build(tokenStart, context) {
|
|
2008
1942
|
const tokens = context.structure.tokens;
|
|
2009
|
-
const
|
|
2010
|
-
const source = context.locator.normalizeLineEndings(block.content ?? tokens.text(context.source, tokenStart));
|
|
2011
|
-
const rawInfo = semanticText(block.info);
|
|
1943
|
+
const rawInfo = semanticText(tokens.value(tokenStart) ?? "");
|
|
2012
1944
|
const langEnd = rawInfo.search(/[ \t]/);
|
|
2013
1945
|
const lang = rawInfo ? langEnd < 0 ? rawInfo : rawInfo.slice(0, langEnd) : null;
|
|
2014
1946
|
const metaStart = langEnd < 0 ? -1 : rawInfo.slice(langEnd).search(/[^ \t]/);
|
|
@@ -2016,34 +1948,19 @@ const feature$14 = {
|
|
|
2016
1948
|
type: "code",
|
|
2017
1949
|
lang,
|
|
2018
1950
|
meta: metaStart < 0 ? null : rawInfo.slice(langEnd + metaStart),
|
|
2019
|
-
value:
|
|
2020
|
-
position:
|
|
2021
|
-
};
|
|
2022
|
-
}
|
|
2023
|
-
}, {
|
|
2024
|
-
token: 258,
|
|
2025
|
-
build(tokenStart, context) {
|
|
2026
|
-
const tokens = context.structure.tokens;
|
|
2027
|
-
const offset = tokens.start(tokenStart);
|
|
2028
|
-
const contentLength = tokens.value(tokenStart);
|
|
2029
|
-
return {
|
|
2030
|
-
type: "code",
|
|
2031
|
-
lang: null,
|
|
2032
|
-
meta: null,
|
|
2033
|
-
value: context.locator.normalizeLineEndings(tokens.text(context.source, tokenStart)).replace(/^(?: {0,3}\t| {4}| {1,3}$)/gm, "").replace(/\n(?:[ \t]*\n)*[ \t]*$/, ""),
|
|
2034
|
-
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))
|
|
2035
1953
|
};
|
|
2036
1954
|
}
|
|
2037
1955
|
}],
|
|
2038
1956
|
starts: [{
|
|
2039
1957
|
codes: [-1],
|
|
2040
|
-
start(source, lines,
|
|
1958
|
+
start(source, lines, tokens, start) {
|
|
2041
1959
|
let end = start + 1;
|
|
2042
1960
|
while (end < lines.length && lineIndentOffset(source, lines, end) < 0) end++;
|
|
2043
1961
|
let contentEnd = end;
|
|
2044
1962
|
while (contentEnd > start && isBlankLine(source, lines, contentEnd - 1)) contentEnd--;
|
|
2045
|
-
|
|
2046
|
-
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) });
|
|
2047
1964
|
return end;
|
|
2048
1965
|
}
|
|
2049
1966
|
}, {
|
|
@@ -2051,14 +1968,14 @@ const feature$14 = {
|
|
|
2051
1968
|
interrupt(source, lines, index, contentOffset) {
|
|
2052
1969
|
return !!codeFenceAt(source, lines, index, contentOffset);
|
|
2053
1970
|
},
|
|
2054
|
-
start(source, lines, start, contentOffset
|
|
1971
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
2055
1972
|
const fence = codeFenceAt(source, lines, start, contentOffset);
|
|
2056
1973
|
if (!fence) return;
|
|
2057
1974
|
let end = start + 1;
|
|
2058
1975
|
while (end < lines.length && !closesFence(source, lines, end, fence)) end++;
|
|
2059
1976
|
const closed = end < lines.length;
|
|
2060
1977
|
if (end < lines.length) end++;
|
|
2061
|
-
|
|
1978
|
+
appendFencedToken(source, lines, tokens, 258, start, end, fence, closed, true);
|
|
2062
1979
|
return end;
|
|
2063
1980
|
}
|
|
2064
1981
|
}]
|
|
@@ -2067,8 +1984,8 @@ const feature$14 = {
|
|
|
2067
1984
|
scans: [{
|
|
2068
1985
|
marker: 96,
|
|
2069
1986
|
scan(source, start, tokens) {
|
|
2070
|
-
if (source.charCodeAt(start - 1) === 96) return start + 1;
|
|
2071
1987
|
const openEnd = inlineMarkerRunEnd(source, start);
|
|
1988
|
+
if (source.charCodeAt(start - 1) === 96) return openEnd;
|
|
2072
1989
|
const markerLength = openEnd - start;
|
|
2073
1990
|
let offset = openEnd;
|
|
2074
1991
|
while (offset < source.length) {
|
|
@@ -2081,20 +1998,20 @@ const feature$14 = {
|
|
|
2081
1998
|
}
|
|
2082
1999
|
offset = closeEnd;
|
|
2083
2000
|
}
|
|
2084
|
-
return
|
|
2001
|
+
return openEnd;
|
|
2085
2002
|
}
|
|
2086
2003
|
}],
|
|
2087
2004
|
builds: [{
|
|
2088
2005
|
kind: "leaf",
|
|
2089
2006
|
token: 129,
|
|
2090
|
-
build: (tokenIndex,
|
|
2007
|
+
build: (tokenIndex, position, context) => {
|
|
2091
2008
|
const markerLength = inlineTokenData(context.tokens, tokenIndex);
|
|
2092
2009
|
let value = context.locator.normalizeLineEndings(inlineTokenText(context.view.text, context.tokens, tokenIndex, markerLength));
|
|
2093
2010
|
if (/^[ \n]/.test(value) && /[ \n]$/.test(value) && /[^ \n]/.test(value)) value = value.slice(1, -1);
|
|
2094
2011
|
return {
|
|
2095
2012
|
type: "inlineCode",
|
|
2096
2013
|
value: context.tableCell ? value.replace(/\\\|/g, "|") : value,
|
|
2097
|
-
position
|
|
2014
|
+
position
|
|
2098
2015
|
};
|
|
2099
2016
|
}
|
|
2100
2017
|
}]
|
|
@@ -2105,34 +2022,21 @@ function createInlineOutput(children, cursor) {
|
|
|
2105
2022
|
return {
|
|
2106
2023
|
children,
|
|
2107
2024
|
cursor,
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2025
|
+
pendingText: void 0,
|
|
2026
|
+
pendingEnd: 0,
|
|
2027
|
+
pendingLiteral: ""
|
|
2111
2028
|
};
|
|
2112
2029
|
}
|
|
2113
|
-
function
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
const previousText = output.lastText;
|
|
2124
|
-
const mergeForward = previousText !== void 0 && !("attributes" in previousText);
|
|
2125
|
-
let offset = value.length;
|
|
2126
|
-
while (offset > 0) {
|
|
2127
|
-
const code = value.charCodeAt(offset - 1);
|
|
2128
|
-
if (code !== 32 && code !== 9) break;
|
|
2129
|
-
offset--;
|
|
2130
|
-
}
|
|
2131
|
-
const trailingSpaces = value.length - offset;
|
|
2132
|
-
output.trailingSpaces = trailingSpaces === value.length && mergeForward ? output.trailingSpaces + trailingSpaces : trailingSpaces;
|
|
2133
|
-
if (mergeForward) previousText.value += value;
|
|
2134
|
-
else {
|
|
2135
|
-
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));
|
|
2136
2040
|
const text = {
|
|
2137
2041
|
type: "text",
|
|
2138
2042
|
value,
|
|
@@ -2142,69 +2046,75 @@ function appendText(output, value, start, end, context) {
|
|
|
2142
2046
|
}
|
|
2143
2047
|
};
|
|
2144
2048
|
output.children.push(text);
|
|
2145
|
-
output.
|
|
2049
|
+
output.pendingText = text;
|
|
2050
|
+
output.pendingLiteral = literal ? value : "";
|
|
2051
|
+
} else {
|
|
2052
|
+
output.pendingText.value += value;
|
|
2053
|
+
output.pendingLiteral = literal ? output.pendingLiteral + value : "";
|
|
2146
2054
|
}
|
|
2147
|
-
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));
|
|
2148
2059
|
}
|
|
2149
|
-
function
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
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
|
+
}
|
|
2154
2070
|
}
|
|
2155
2071
|
}
|
|
2156
|
-
function appendGap(
|
|
2157
|
-
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);
|
|
2158
2074
|
}
|
|
2159
|
-
function appendLeaf(
|
|
2160
|
-
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);
|
|
2161
2077
|
const sourceStart = context.view.mapOffset(start);
|
|
2162
2078
|
const sourceEnd = start === end ? sourceStart : context.view.mapEnd(end);
|
|
2163
|
-
finishText(
|
|
2079
|
+
finishText(context, output);
|
|
2164
2080
|
output.children.push(build(token, context.locator.positionAt(sourceStart, sourceEnd), context));
|
|
2165
|
-
output.
|
|
2081
|
+
output.pendingText = void 0;
|
|
2166
2082
|
}
|
|
2167
|
-
function appendRange(
|
|
2083
|
+
function appendRange(profile, context, output, startToken, endToken) {
|
|
2168
2084
|
let index = startToken;
|
|
2169
2085
|
while (index < endToken) {
|
|
2170
2086
|
const kind = inlineTokenKind(context.tokens, index);
|
|
2171
2087
|
if (kind === 67) {
|
|
2172
2088
|
const endingStart = inlineTokenStart(context.tokens, index);
|
|
2173
|
-
const lineStart = inlineTokenData(context.tokens, index);
|
|
2174
2089
|
const contentStart = inlineTokenEnd(context.tokens, index);
|
|
2175
|
-
if (endingStart > output.cursor) appendGap(
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
else {
|
|
2179
|
-
trimTrailingText(output);
|
|
2180
|
-
appendText(output, "\n", context.view.mapOffset(endingStart), context.view.mapEnd(contentStart), context);
|
|
2181
|
-
}
|
|
2090
|
+
if (endingStart > output.cursor) appendGap(context, output, output.cursor, endingStart);
|
|
2091
|
+
trimTrailingText(context, output);
|
|
2092
|
+
appendText(context, output, "\n", endingStart, contentStart, false);
|
|
2182
2093
|
output.cursor = contentStart;
|
|
2183
2094
|
index++;
|
|
2184
2095
|
continue;
|
|
2185
2096
|
}
|
|
2186
|
-
if (kind === closeKind) break;
|
|
2187
2097
|
const build = profile.builders[kind];
|
|
2188
2098
|
const childStart = inlineTokenStart(context.tokens, index);
|
|
2189
2099
|
if (kind < 192) {
|
|
2190
2100
|
const childEnd = inlineTokenEnd(context.tokens, index);
|
|
2191
2101
|
if (kind < 128) {
|
|
2192
|
-
if (childStart > output.cursor) appendGap(
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
} else appendLeaf(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);
|
|
2196
2105
|
output.cursor = childEnd;
|
|
2197
2106
|
index++;
|
|
2198
2107
|
continue;
|
|
2199
2108
|
}
|
|
2200
2109
|
if (kind < 256) {
|
|
2201
|
-
if (
|
|
2202
|
-
|
|
2203
|
-
|
|
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);
|
|
2204
2114
|
continue;
|
|
2205
2115
|
}
|
|
2206
2116
|
const childEnd = inlineTokenEnd(context.tokens, index);
|
|
2207
|
-
finishText(
|
|
2117
|
+
finishText(context, output);
|
|
2208
2118
|
const sourceStart = context.view.mapOffset(childStart);
|
|
2209
2119
|
const sourceSpan = {
|
|
2210
2120
|
start: sourceStart,
|
|
@@ -2212,29 +2122,39 @@ function appendRange(startToken, endToken, profile, context, output, closeKind =
|
|
|
2212
2122
|
};
|
|
2213
2123
|
if (build(index, sourceSpan, context, output)) {
|
|
2214
2124
|
const previous = output.children.at(-1);
|
|
2215
|
-
output.
|
|
2125
|
+
output.pendingText = previous?.type === "text" ? previous : void 0;
|
|
2126
|
+
output.pendingEnd = childEnd;
|
|
2216
2127
|
output.cursor = childEnd;
|
|
2217
2128
|
}
|
|
2218
2129
|
index++;
|
|
2219
2130
|
}
|
|
2220
2131
|
const contentEnd = index < endToken ? inlineTokenStart(context.tokens, index) : context.view.text.length;
|
|
2221
|
-
if (contentEnd > output.cursor) appendGap(
|
|
2222
|
-
|
|
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);
|
|
2223
2138
|
return index;
|
|
2224
2139
|
}
|
|
2225
|
-
function appendPair(
|
|
2140
|
+
function appendPair(profile, context, output, openToken, endToken, build) {
|
|
2226
2141
|
const childStart = inlineTokenStart(context.tokens, openToken);
|
|
2227
2142
|
const positionStart = context.locator.locationAt(context.view.mapOffset(childStart));
|
|
2228
|
-
const
|
|
2229
|
-
const
|
|
2230
|
-
|
|
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);
|
|
2231
2151
|
const childEnd = inlineTokenEnd(context.tokens, closeToken);
|
|
2232
2152
|
const value = build(openToken, closeToken, {
|
|
2233
2153
|
start: positionStart,
|
|
2234
2154
|
end: context.locator.locationAt(context.view.mapEnd(childEnd))
|
|
2235
2155
|
}, children, context);
|
|
2236
2156
|
output.children.push(value);
|
|
2237
|
-
output.
|
|
2157
|
+
output.pendingText = void 0;
|
|
2238
2158
|
output.cursor = childEnd;
|
|
2239
2159
|
return closeToken + 1;
|
|
2240
2160
|
}
|
|
@@ -2248,9 +2168,12 @@ function buildInlineFragment(tokenStart, tableCell, context) {
|
|
|
2248
2168
|
view = region.view;
|
|
2249
2169
|
} else {
|
|
2250
2170
|
const blockTokens = context.structure.tokens;
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
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);
|
|
2254
2177
|
}
|
|
2255
2178
|
const inlineContext = context.inlineContext ??= {
|
|
2256
2179
|
locator: context.locator,
|
|
@@ -2261,25 +2184,17 @@ function buildInlineFragment(tokenStart, tableCell, context) {
|
|
|
2261
2184
|
inlineContext.tableCell = tableCell;
|
|
2262
2185
|
inlineContext.tokens = tokens;
|
|
2263
2186
|
inlineContext.view = view;
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
const removed = trimTrailingText(result);
|
|
2269
|
-
if (removed > 0) {
|
|
2270
|
-
last.position.end.offset -= removed;
|
|
2271
|
-
last.position.end.column -= removed;
|
|
2272
|
-
}
|
|
2273
|
-
if (!last.value) result.children.pop();
|
|
2274
|
-
}
|
|
2275
|
-
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;
|
|
2276
2191
|
}
|
|
2277
2192
|
// src/profile/features/frontmatter.ts
|
|
2278
2193
|
function frontmatterFenceAt(source, lines, index, marker) {
|
|
2279
2194
|
const start = lines.start(index);
|
|
2280
2195
|
if (source[start] !== marker || source[start + 1] !== marker || source[start + 2] !== marker) return false;
|
|
2281
2196
|
const end = lines.end(index);
|
|
2282
|
-
return
|
|
2197
|
+
return trimLineWhitespaceStart(source, start + 3, end) === end;
|
|
2283
2198
|
}
|
|
2284
2199
|
const buildYamlBlock = (tokenStart, context) => {
|
|
2285
2200
|
const tokens = context.structure.tokens;
|
|
@@ -2296,15 +2211,15 @@ const buildYamlBlock = (tokenStart, context) => {
|
|
|
2296
2211
|
function feature$13(marker) {
|
|
2297
2212
|
return { block: {
|
|
2298
2213
|
builds: [{
|
|
2299
|
-
token:
|
|
2214
|
+
token: 261,
|
|
2300
2215
|
build: buildYamlBlock
|
|
2301
2216
|
}],
|
|
2302
2217
|
starts: [{
|
|
2303
2218
|
codes: [marker.charCodeAt(0)],
|
|
2304
|
-
start(source, lines, start, contentOffset,
|
|
2219
|
+
start(source, lines, tokens, start, contentOffset, context) {
|
|
2305
2220
|
if (lines.start(start) !== 0 || !frontmatterFenceAt(source, lines, start, marker)) return;
|
|
2306
2221
|
for (let end = start + 1; end < lines.length; end++) if (frontmatterFenceAt(source, lines, end, marker)) {
|
|
2307
|
-
appendLogicalToken(
|
|
2222
|
+
appendLogicalToken(source, lines, tokens, 261, start, end + 1);
|
|
2308
2223
|
return end + 1;
|
|
2309
2224
|
}
|
|
2310
2225
|
context.retainLookahead(lines.next(lines.length - 1));
|
|
@@ -2348,11 +2263,14 @@ function normalizeComponentName(value) {
|
|
|
2348
2263
|
// src/profile/features/component/block.ts
|
|
2349
2264
|
function closingBracket(source, start, limit) {
|
|
2350
2265
|
let depth = 0;
|
|
2351
|
-
for (let offset = start + 1; offset < limit; offset++)
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
if (
|
|
2355
|
-
|
|
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
|
+
}
|
|
2356
2274
|
}
|
|
2357
2275
|
}
|
|
2358
2276
|
function lineValue(source, lines, index) {
|
|
@@ -2374,22 +2292,24 @@ function yamlPropsEnd(source, lines, start, end) {
|
|
|
2374
2292
|
for (let index = start + 1; index < end; index++) if (lineValue(source, lines, index) === marker) return index + 1;
|
|
2375
2293
|
}
|
|
2376
2294
|
function slotOpeningAt(source, lines, index, contentOffset) {
|
|
2377
|
-
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;
|
|
2378
2298
|
const nameEnd = componentNameEnd(source, contentOffset + 1, true);
|
|
2379
2299
|
const lineEnd = lines.end(index);
|
|
2380
2300
|
if (nameEnd === void 0 || nameEnd > lineEnd) return;
|
|
2381
|
-
let offset =
|
|
2301
|
+
let offset = trimLineWhitespaceStart(source, nameEnd, lineEnd);
|
|
2382
2302
|
let attributesStart;
|
|
2383
|
-
let
|
|
2384
|
-
if (source
|
|
2385
|
-
parsedAttributesEnd = attributesEnd(source, offset, lineEnd);
|
|
2386
|
-
if (parsedAttributesEnd === void 0) return;
|
|
2303
|
+
let attributesEndValue;
|
|
2304
|
+
if (source.charCodeAt(offset) === 123) {
|
|
2387
2305
|
attributesStart = offset;
|
|
2388
|
-
|
|
2306
|
+
attributesEndValue = attributesEnd(source, offset, lineEnd);
|
|
2307
|
+
if (attributesEndValue === void 0) return;
|
|
2308
|
+
offset = attributesEndValue;
|
|
2389
2309
|
}
|
|
2390
|
-
if (
|
|
2310
|
+
if (trimLineWhitespaceStart(source, offset, lineEnd) !== lineEnd) return;
|
|
2391
2311
|
return {
|
|
2392
|
-
attributesEnd:
|
|
2312
|
+
attributesEnd: attributesEndValue,
|
|
2393
2313
|
attributesStart,
|
|
2394
2314
|
nameEnd,
|
|
2395
2315
|
offset: contentOffset
|
|
@@ -2397,34 +2317,34 @@ function slotOpeningAt(source, lines, index, contentOffset) {
|
|
|
2397
2317
|
}
|
|
2398
2318
|
function blockOpeningAt(source, lines, index, contentOffset, shorthand) {
|
|
2399
2319
|
let offset = contentOffset;
|
|
2400
|
-
while (source
|
|
2320
|
+
while (source.charCodeAt(offset) === 58) offset++;
|
|
2401
2321
|
const fenceSize = offset - contentOffset;
|
|
2402
2322
|
if (shorthand ? fenceSize !== 1 : fenceSize < 2) return;
|
|
2403
2323
|
const lineEnd = lines.end(index);
|
|
2404
|
-
if (!shorthand) offset =
|
|
2324
|
+
if (!shorthand) offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
2405
2325
|
const nameEnd = componentNameEnd(source, offset, true);
|
|
2406
2326
|
if (nameEnd === void 0 || nameEnd > lineEnd) return;
|
|
2407
|
-
offset =
|
|
2327
|
+
offset = trimLineWhitespaceStart(source, nameEnd, lineEnd);
|
|
2408
2328
|
let labelStart;
|
|
2409
2329
|
let labelEnd;
|
|
2410
|
-
if (source
|
|
2330
|
+
if (source.charCodeAt(offset) === 91) {
|
|
2411
2331
|
const close = closingBracket(source, offset, lineEnd);
|
|
2412
2332
|
if (close === void 0) return;
|
|
2413
2333
|
labelStart = offset;
|
|
2414
2334
|
labelEnd = close + 1;
|
|
2415
|
-
offset =
|
|
2335
|
+
offset = trimLineWhitespaceStart(source, labelEnd, lineEnd);
|
|
2416
2336
|
}
|
|
2417
2337
|
let attributesStart;
|
|
2418
|
-
let
|
|
2419
|
-
if (source
|
|
2420
|
-
parsedAttributesEnd = attributesEnd(source, offset, lineEnd);
|
|
2421
|
-
if (parsedAttributesEnd === void 0) return;
|
|
2338
|
+
let attributesEndValue;
|
|
2339
|
+
if (source.charCodeAt(offset) === 123) {
|
|
2422
2340
|
attributesStart = offset;
|
|
2423
|
-
|
|
2341
|
+
attributesEndValue = attributesEnd(source, offset, lineEnd);
|
|
2342
|
+
if (attributesEndValue === void 0) return;
|
|
2343
|
+
offset = attributesEndValue;
|
|
2424
2344
|
}
|
|
2425
|
-
if (
|
|
2345
|
+
if (trimLineWhitespaceStart(source, offset, lineEnd) !== lineEnd) return;
|
|
2426
2346
|
return {
|
|
2427
|
-
attributesEnd:
|
|
2347
|
+
attributesEnd: attributesEndValue,
|
|
2428
2348
|
attributesStart,
|
|
2429
2349
|
fenceSize,
|
|
2430
2350
|
labelEnd,
|
|
@@ -2445,8 +2365,8 @@ function blockClose(source, lines, start, opening) {
|
|
|
2445
2365
|
codeFence = codeFenceAt(source, lines, index, contentOffset);
|
|
2446
2366
|
if (codeFence) continue;
|
|
2447
2367
|
let markerEnd = contentOffset;
|
|
2448
|
-
while (source
|
|
2449
|
-
if (markerEnd - contentOffset === opening.fenceSize &&
|
|
2368
|
+
while (source.charCodeAt(markerEnd) === 58) markerEnd++;
|
|
2369
|
+
if (markerEnd - contentOffset === opening.fenceSize && trimLineWhitespaceStart(source, markerEnd, lines.end(index)) === lines.end(index)) {
|
|
2450
2370
|
if (depth === 0) return {
|
|
2451
2371
|
index,
|
|
2452
2372
|
offset: contentOffset
|
|
@@ -2477,39 +2397,39 @@ function nextSlot(source, lines, start, end) {
|
|
|
2477
2397
|
if (nested) index = blockClose(source, lines, index, nested)?.index ?? index;
|
|
2478
2398
|
}
|
|
2479
2399
|
}
|
|
2480
|
-
function emitComponentBody(source, lines, start, end, closingOffset,
|
|
2400
|
+
function emitComponentBody(source, lines, tokens, start, end, closingOffset, context) {
|
|
2481
2401
|
let cursor = start;
|
|
2482
2402
|
const yamlEnd = cursor < end ? yamlPropsEnd(source, lines, cursor, end) : void 0;
|
|
2483
2403
|
if (yamlEnd !== void 0) {
|
|
2484
|
-
appendLogicalToken(
|
|
2404
|
+
appendLogicalToken(source, lines, tokens, 263, cursor, yamlEnd);
|
|
2485
2405
|
cursor = yamlEnd;
|
|
2486
2406
|
}
|
|
2487
2407
|
let slot = nextSlot(source, lines, cursor, end);
|
|
2488
2408
|
if (!slot) {
|
|
2489
|
-
context.scanLines(source, lines.
|
|
2409
|
+
context.scanLines(source, lines.view(cursor, end), tokens);
|
|
2490
2410
|
return;
|
|
2491
2411
|
}
|
|
2492
|
-
if (slot.index > cursor) context.scanLines(source, lines.
|
|
2412
|
+
if (slot.index > cursor) context.scanLines(source, lines.view(cursor, slot.index), tokens);
|
|
2493
2413
|
while (slot) {
|
|
2494
2414
|
const following = nextSlot(source, lines, slot.index + 1, end);
|
|
2495
2415
|
const next = following?.index ?? end;
|
|
2496
2416
|
const opening = slot.opening;
|
|
2497
|
-
|
|
2498
|
-
if (opening.attributesStart !== void 0 && opening.attributesEnd !== void 0)
|
|
2499
|
-
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);
|
|
2500
2420
|
const slotEnd = following ? following.opening.offset : closingOffset;
|
|
2501
|
-
|
|
2421
|
+
tokens.push(202, slotEnd, slotEnd);
|
|
2502
2422
|
slot = following;
|
|
2503
2423
|
}
|
|
2504
2424
|
}
|
|
2505
|
-
function emitOpening(contentOffset, opening
|
|
2506
|
-
|
|
2425
|
+
function emitOpening(tokens, contentOffset, opening) {
|
|
2426
|
+
tokens.push(83, contentOffset, opening.nameEnd);
|
|
2507
2427
|
if (opening.labelStart !== void 0 && opening.labelEnd !== void 0) {
|
|
2508
|
-
|
|
2509
|
-
if (opening.labelEnd > opening.labelStart + 2)
|
|
2510
|
-
|
|
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);
|
|
2511
2431
|
}
|
|
2512
|
-
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);
|
|
2513
2433
|
}
|
|
2514
2434
|
const buildBlockLabel = (tokenStart, context) => {
|
|
2515
2435
|
const tokens = context.structure.tokens;
|
|
@@ -2525,13 +2445,13 @@ const buildBlockLabel = (tokenStart, context) => {
|
|
|
2525
2445
|
};
|
|
2526
2446
|
};
|
|
2527
2447
|
function createBlockStart(shorthand) {
|
|
2528
|
-
return (source, lines, start, contentOffset,
|
|
2448
|
+
return (source, lines, tokens, start, contentOffset, context) => {
|
|
2529
2449
|
const opening = blockOpeningAt(source, lines, start, contentOffset, shorthand);
|
|
2530
2450
|
if (!opening) return;
|
|
2531
2451
|
if (shorthand) {
|
|
2532
|
-
emitOpening(contentOffset, opening
|
|
2452
|
+
emitOpening(tokens, contentOffset, opening);
|
|
2533
2453
|
const lineEnd = lines.end(start);
|
|
2534
|
-
|
|
2454
|
+
tokens.push(200, lineEnd, lineEnd);
|
|
2535
2455
|
return start + 1;
|
|
2536
2456
|
}
|
|
2537
2457
|
const closing = blockClose(source, lines, start, opening);
|
|
@@ -2539,30 +2459,35 @@ function createBlockStart(shorthand) {
|
|
|
2539
2459
|
context.retainLookahead(lines.next(lines.length - 1));
|
|
2540
2460
|
return;
|
|
2541
2461
|
}
|
|
2542
|
-
emitOpening(contentOffset, opening
|
|
2543
|
-
emitComponentBody(source, lines, start + 1, closing.index, closing.offset,
|
|
2544
|
-
|
|
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));
|
|
2545
2465
|
return closing.index + 1;
|
|
2546
2466
|
};
|
|
2547
2467
|
}
|
|
2548
2468
|
const blockBuilds$2 = [
|
|
2549
2469
|
{
|
|
2550
|
-
token:
|
|
2470
|
+
token: 85,
|
|
2471
|
+
build: buildBlockLabel
|
|
2472
|
+
},
|
|
2473
|
+
{
|
|
2474
|
+
token: 263,
|
|
2551
2475
|
build: buildYamlBlock
|
|
2552
2476
|
},
|
|
2553
2477
|
{
|
|
2554
|
-
token:
|
|
2478
|
+
token: 83,
|
|
2555
2479
|
build(tokenStart, context) {
|
|
2556
2480
|
const tokens = context.structure.tokens;
|
|
2557
2481
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
2558
2482
|
let openingToken = tokenStart + 1;
|
|
2559
|
-
|
|
2560
|
-
if (
|
|
2561
|
-
|
|
2562
|
-
|
|
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
|
+
}
|
|
2563
2489
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
2564
|
-
|
|
2565
|
-
if (label) children = [buildBlockLabel(label, context), ...children];
|
|
2490
|
+
const children = buildBlockChildren(tokenStart, context);
|
|
2566
2491
|
const opening = tokens.text(context.source, tokenStart);
|
|
2567
2492
|
return {
|
|
2568
2493
|
type: "blockComponent",
|
|
@@ -2577,25 +2502,24 @@ const blockBuilds$2 = [
|
|
|
2577
2502
|
}
|
|
2578
2503
|
},
|
|
2579
2504
|
{
|
|
2580
|
-
token:
|
|
2505
|
+
token: 84,
|
|
2581
2506
|
build(tokenStart, context) {
|
|
2582
2507
|
const tokens = context.structure.tokens;
|
|
2583
2508
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
2584
|
-
const attributesToken = tokens.kind(tokenStart + 1) ===
|
|
2509
|
+
const attributesToken = tokens.kind(tokenStart + 1) === 2 ? tokenStart + 1 : void 0;
|
|
2585
2510
|
const parsed = attributesToken !== void 0 ? parseAttributes(context.source, tokens.start(attributesToken)) : void 0;
|
|
2586
2511
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
2587
|
-
const children = buildBlockChildren(tokenStart, context);
|
|
2588
2512
|
return {
|
|
2589
2513
|
type: "blockComponent",
|
|
2590
2514
|
name: "template",
|
|
2591
|
-
|
|
2592
|
-
...parsed,
|
|
2593
|
-
name: normalizeComponentName(tokens.text(context.source, tokenStart).slice(1).trim())
|
|
2594
|
-
},
|
|
2595
|
-
children,
|
|
2515
|
+
children: buildBlockChildren(tokenStart, context),
|
|
2596
2516
|
position: {
|
|
2597
2517
|
start,
|
|
2598
2518
|
end: context.locator.locationAt(tokens.end(close))
|
|
2519
|
+
},
|
|
2520
|
+
attributes: {
|
|
2521
|
+
...parsed,
|
|
2522
|
+
name: normalizeComponentName(tokens.text(context.source, tokenStart).slice(1).trim())
|
|
2599
2523
|
}
|
|
2600
2524
|
};
|
|
2601
2525
|
}
|
|
@@ -2621,14 +2545,14 @@ const inlineScans = [{
|
|
|
2621
2545
|
return end;
|
|
2622
2546
|
}
|
|
2623
2547
|
}];
|
|
2624
|
-
const buildInlineComponent = (open, close,
|
|
2548
|
+
const buildInlineComponent = (open, close, position, children, context) => {
|
|
2625
2549
|
const nameEnd = inlineTokenEnd(context.tokens, open) - (inlineTokenKind(context.tokens, open) === 208 ? 1 : 0);
|
|
2626
2550
|
return {
|
|
2627
2551
|
type: "inlineComponent",
|
|
2628
2552
|
name: normalizeComponentName(context.view.text.slice(inlineTokenStart(context.tokens, open) + 1, nameEnd)),
|
|
2629
2553
|
attributes: {},
|
|
2630
2554
|
children,
|
|
2631
|
-
position
|
|
2555
|
+
position
|
|
2632
2556
|
};
|
|
2633
2557
|
};
|
|
2634
2558
|
// src/profile/features/component/index.ts
|
|
@@ -2643,8 +2567,8 @@ const feature$12 = {
|
|
|
2643
2567
|
{
|
|
2644
2568
|
kind: "leaf",
|
|
2645
2569
|
token: 137,
|
|
2646
|
-
build(token,
|
|
2647
|
-
return buildInlineComponent(token, token,
|
|
2570
|
+
build(token, position, context) {
|
|
2571
|
+
return buildInlineComponent(token, token, position, [], context);
|
|
2648
2572
|
}
|
|
2649
2573
|
},
|
|
2650
2574
|
{
|
|
@@ -2655,13 +2579,13 @@ const feature$12 = {
|
|
|
2655
2579
|
{
|
|
2656
2580
|
kind: "pair",
|
|
2657
2581
|
token: 206,
|
|
2658
|
-
build(open, close,
|
|
2582
|
+
build(open, close, position, children) {
|
|
2659
2583
|
return {
|
|
2660
2584
|
type: "inlineComponent",
|
|
2661
2585
|
name: "span",
|
|
2662
2586
|
attributes: {},
|
|
2663
2587
|
children,
|
|
2664
|
-
position
|
|
2588
|
+
position
|
|
2665
2589
|
};
|
|
2666
2590
|
}
|
|
2667
2591
|
}
|
|
@@ -2688,11 +2612,11 @@ const feature$11 = { inline: {
|
|
|
2688
2612
|
builds: [{
|
|
2689
2613
|
kind: "leaf",
|
|
2690
2614
|
token: 136,
|
|
2691
|
-
build(tokenIndex,
|
|
2615
|
+
build(tokenIndex, position, context) {
|
|
2692
2616
|
return {
|
|
2693
2617
|
type: "emoji",
|
|
2694
2618
|
value: inlineTokenText(context.view.text, context.tokens, tokenIndex),
|
|
2695
|
-
position
|
|
2619
|
+
position
|
|
2696
2620
|
};
|
|
2697
2621
|
}
|
|
2698
2622
|
}]
|
|
@@ -2735,7 +2659,7 @@ function definitionAt(source, lines, index, markerStart) {
|
|
|
2735
2659
|
const label = footnoteLabelAt(source, markerStart, lineEnd);
|
|
2736
2660
|
if (!label || source.charCodeAt(label.end) !== 58) return;
|
|
2737
2661
|
const markerEnd = label.end + 1;
|
|
2738
|
-
const contentOffset =
|
|
2662
|
+
const contentOffset = trimLineWhitespaceStart(source, markerEnd, lineEnd);
|
|
2739
2663
|
return {
|
|
2740
2664
|
...label,
|
|
2741
2665
|
contentOffset,
|
|
@@ -2746,12 +2670,13 @@ function definitionAt(source, lines, index, markerStart) {
|
|
|
2746
2670
|
const feature$10 = {
|
|
2747
2671
|
block: {
|
|
2748
2672
|
builds: [{
|
|
2749
|
-
token:
|
|
2673
|
+
token: 78,
|
|
2750
2674
|
build(tokenStart, context) {
|
|
2751
2675
|
const tokens = context.structure.tokens;
|
|
2752
|
-
const
|
|
2676
|
+
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
2753
2677
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
2754
2678
|
const children = buildBlockChildren(tokenStart, context);
|
|
2679
|
+
const fields = tokens.value(tokenStart);
|
|
2755
2680
|
return {
|
|
2756
2681
|
type: "footnoteDefinition",
|
|
2757
2682
|
identifier: fields.normalizedLabel,
|
|
@@ -2759,7 +2684,7 @@ const feature$10 = {
|
|
|
2759
2684
|
children,
|
|
2760
2685
|
position: {
|
|
2761
2686
|
start,
|
|
2762
|
-
end: context.locator.locationAt(
|
|
2687
|
+
end: context.locator.locationAt(tokens.end(close))
|
|
2763
2688
|
}
|
|
2764
2689
|
};
|
|
2765
2690
|
}
|
|
@@ -2775,12 +2700,12 @@ const feature$10 = {
|
|
|
2775
2700
|
interrupt(source, lines, index, contentOffset) {
|
|
2776
2701
|
return definitionAt(source, lines, index, contentOffset) !== void 0;
|
|
2777
2702
|
},
|
|
2778
|
-
start(source, lines, start, contentOffset,
|
|
2703
|
+
start(source, lines, tokens, start, contentOffset, context) {
|
|
2779
2704
|
const match = definitionAt(source, lines, start, contentOffset);
|
|
2780
2705
|
if (!match) return;
|
|
2781
2706
|
const definitionLines = context.createLineView(lines, start, match.contentOffset, 0);
|
|
2782
2707
|
let index = start + 1;
|
|
2783
|
-
let lazyParagraph
|
|
2708
|
+
let lazyParagraph;
|
|
2784
2709
|
while (index < lines.length) {
|
|
2785
2710
|
const line = definitionLines.pushAfterColumns(source, lines, index, 4);
|
|
2786
2711
|
if (line === 0) {
|
|
@@ -2790,25 +2715,26 @@ const feature$10 = {
|
|
|
2790
2715
|
continue;
|
|
2791
2716
|
}
|
|
2792
2717
|
if (line === 1) {
|
|
2793
|
-
lazyParagraph =
|
|
2718
|
+
lazyParagraph = void 0;
|
|
2794
2719
|
index++;
|
|
2795
2720
|
continue;
|
|
2796
2721
|
}
|
|
2722
|
+
lazyParagraph ??= context.endsWithParagraphLeaf(source, definitionLines, definitionLines.length - 1);
|
|
2797
2723
|
if (!lazyParagraph || !lines.lazy(index) && context.startsInterruptingBlock(source, lines, index)) break;
|
|
2798
2724
|
definitionLines.pushLazy(lines, index);
|
|
2799
2725
|
index++;
|
|
2800
2726
|
}
|
|
2801
2727
|
while (definitionLines.length > 0 && isBlankLine(source, definitionLines, definitionLines.length - 1)) definitionLines.pop();
|
|
2802
|
-
|
|
2728
|
+
tokens.push(78, contentOffset, match.markerEnd, {
|
|
2803
2729
|
definitionKey: match.definitionKey,
|
|
2804
2730
|
value: {
|
|
2805
2731
|
label: match.label,
|
|
2806
2732
|
normalizedLabel: match.normalizedLabel
|
|
2807
2733
|
}
|
|
2808
2734
|
});
|
|
2809
|
-
context.scanLines(source, definitionLines,
|
|
2735
|
+
context.scanLines(source, definitionLines, tokens);
|
|
2810
2736
|
const end = definitionLines.length > 0 ? definitionLines.next(definitionLines.length - 1) : match.markerEnd;
|
|
2811
|
-
|
|
2737
|
+
tokens.push(197, end, end);
|
|
2812
2738
|
return index;
|
|
2813
2739
|
}
|
|
2814
2740
|
}]
|
|
@@ -2816,154 +2742,90 @@ const feature$10 = {
|
|
|
2816
2742
|
inline: { builds: [{
|
|
2817
2743
|
kind: "leaf",
|
|
2818
2744
|
token: 133,
|
|
2819
|
-
build(tokenIndex,
|
|
2745
|
+
build(tokenIndex, position, context) {
|
|
2820
2746
|
const label = inlineTokenText(context.view.text, context.tokens, tokenIndex, 2, 1);
|
|
2821
2747
|
return {
|
|
2822
2748
|
type: "footnoteReference",
|
|
2823
2749
|
identifier: normalizeIdentifier(label),
|
|
2824
2750
|
label: semanticText(label),
|
|
2825
|
-
position
|
|
2751
|
+
position
|
|
2826
2752
|
};
|
|
2827
2753
|
}
|
|
2828
2754
|
}] }
|
|
2829
2755
|
};
|
|
2830
|
-
// src/profile/features/
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
scans: [{
|
|
2840
|
-
marker: 38,
|
|
2841
|
-
scan(source, start, tokens) {
|
|
2842
|
-
const matchEnd = matchInlinePatternEnd(entity, source, start);
|
|
2843
|
-
if (matchEnd < 0) return start + 1;
|
|
2844
|
-
appendInlineToken(tokens, 66, start, matchEnd);
|
|
2845
|
-
return matchEnd;
|
|
2846
|
-
}
|
|
2847
|
-
}, {
|
|
2848
|
-
marker: 92,
|
|
2849
|
-
scan(source, start, tokens) {
|
|
2850
|
-
const next = source.charCodeAt(start + 1);
|
|
2851
|
-
if (next === 10 || next === 13) {
|
|
2852
|
-
appendInlineToken(tokens, 128, start, start + 1);
|
|
2853
|
-
return start + 1;
|
|
2854
|
-
}
|
|
2855
|
-
if (isAsciiPunctuation(next)) {
|
|
2856
|
-
const end = start + 2;
|
|
2857
|
-
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);
|
|
2858
2765
|
return end;
|
|
2859
2766
|
}
|
|
2860
|
-
return start + (next === 32 || next === 9 ? 2 : 1);
|
|
2861
|
-
}
|
|
2862
|
-
}],
|
|
2863
|
-
builds: [
|
|
2864
|
-
{
|
|
2865
|
-
kind: "text",
|
|
2866
|
-
token: 64,
|
|
2867
|
-
build: buildInlineText
|
|
2868
2767
|
},
|
|
2869
|
-
{
|
|
2870
|
-
kind: "
|
|
2871
|
-
token:
|
|
2872
|
-
build:
|
|
2873
|
-
},
|
|
2874
|
-
{
|
|
2875
|
-
kind: "text",
|
|
2876
|
-
token: 66,
|
|
2877
|
-
build: buildDecodedInlineText
|
|
2878
|
-
}
|
|
2879
|
-
]
|
|
2880
|
-
} };
|
|
2881
|
-
// src/profile/features/formatting.ts
|
|
2882
|
-
const scanFormatting = (source, start, tokens) => {
|
|
2883
|
-
const code = source.charCodeAt(start);
|
|
2884
|
-
const end = inlineMarkerRunEnd(source, start);
|
|
2885
|
-
appendInlineToken(tokens, code === 42 ? 68 : code === 95 ? 69 : 70, start, end);
|
|
2886
|
-
return end;
|
|
2887
|
-
};
|
|
2888
|
-
function createFormattingPair(type, open, close) {
|
|
2889
|
-
return {
|
|
2890
|
-
kind: "pair",
|
|
2891
|
-
token: open,
|
|
2892
|
-
open,
|
|
2893
|
-
close,
|
|
2894
|
-
build(openToken, closeToken, sourceSpan, children) {
|
|
2895
|
-
return {
|
|
2768
|
+
builder: {
|
|
2769
|
+
kind: "pair",
|
|
2770
|
+
token: buildToken,
|
|
2771
|
+
build: (openToken, closeToken, position, children) => ({
|
|
2896
2772
|
type,
|
|
2897
2773
|
children,
|
|
2898
|
-
position
|
|
2899
|
-
}
|
|
2774
|
+
position
|
|
2775
|
+
})
|
|
2900
2776
|
}
|
|
2901
2777
|
};
|
|
2902
2778
|
}
|
|
2903
|
-
const
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
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
|
+
},
|
|
2910
2789
|
pairing: {
|
|
2911
2790
|
kind: "partial",
|
|
2912
2791
|
ruleOfThree: true
|
|
2913
2792
|
}
|
|
2914
|
-
};
|
|
2915
|
-
const
|
|
2916
|
-
token:
|
|
2917
|
-
single:
|
|
2918
|
-
|
|
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
|
+
},
|
|
2919
2804
|
pairing: {
|
|
2920
2805
|
kind: "partial",
|
|
2921
2806
|
ruleOfThree: true
|
|
2922
2807
|
},
|
|
2923
2808
|
allowIntraword: false
|
|
2924
|
-
};
|
|
2925
|
-
const
|
|
2926
|
-
token:
|
|
2927
|
-
double:
|
|
2809
|
+
});
|
|
2810
|
+
const formattingStrikethrough = createFormatting("delete", 126, 196, {
|
|
2811
|
+
token: 3,
|
|
2812
|
+
double: {
|
|
2813
|
+
open: 196,
|
|
2814
|
+
close: 197
|
|
2815
|
+
},
|
|
2928
2816
|
pairing: { kind: "whole" }
|
|
2929
|
-
};
|
|
2930
|
-
function feature$
|
|
2931
|
-
const
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
token: 68,
|
|
2935
|
-
build: buildInlineText
|
|
2936
|
-
},
|
|
2937
|
-
{
|
|
2938
|
-
kind: "text",
|
|
2939
|
-
token: 69,
|
|
2940
|
-
build: buildInlineText
|
|
2941
|
-
},
|
|
2942
|
-
emphasisPair,
|
|
2943
|
-
strongPair
|
|
2944
|
-
];
|
|
2945
|
-
const delimiters = [asteriskDelimiter, underscoreDelimiter];
|
|
2946
|
-
const scans = [{
|
|
2947
|
-
marker: 42,
|
|
2948
|
-
scan: scanFormatting
|
|
2949
|
-
}, {
|
|
2950
|
-
marker: 95,
|
|
2951
|
-
scan: scanFormatting
|
|
2952
|
-
}];
|
|
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];
|
|
2953
2822
|
if (strikethroughOptions) {
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
token: 70,
|
|
2957
|
-
build: buildInlineText
|
|
2958
|
-
}, deletePair);
|
|
2823
|
+
scans.push(formattingStrikethrough.scanner);
|
|
2824
|
+
builds.push(formattingStrikethrough.builder);
|
|
2959
2825
|
delimiters.push(typeof strikethroughOptions !== "object" || strikethroughOptions.singleTilde !== false ? {
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
} :
|
|
2963
|
-
scans.push({
|
|
2964
|
-
marker: 126,
|
|
2965
|
-
scan: scanFormatting
|
|
2966
|
-
});
|
|
2826
|
+
single: formattingStrikethrough.delimiter.double,
|
|
2827
|
+
...formattingStrikethrough.delimiter
|
|
2828
|
+
} : formattingStrikethrough.delimiter);
|
|
2967
2829
|
}
|
|
2968
2830
|
return { inline: {
|
|
2969
2831
|
scans,
|
|
@@ -2971,84 +2833,66 @@ function feature$8(strikethroughOptions) {
|
|
|
2971
2833
|
builds
|
|
2972
2834
|
} };
|
|
2973
2835
|
}
|
|
2974
|
-
// src/fragment/node.ts
|
|
2975
|
-
function cloneLocation(location) {
|
|
2976
|
-
return {
|
|
2977
|
-
line: location.line,
|
|
2978
|
-
column: location.column,
|
|
2979
|
-
offset: location.offset
|
|
2980
|
-
};
|
|
2981
|
-
}
|
|
2982
|
-
function firstChildStart(children) {
|
|
2983
|
-
const first = children[0];
|
|
2984
|
-
return cloneLocation(first.position.start);
|
|
2985
|
-
}
|
|
2986
|
-
function lastChildEnd(children) {
|
|
2987
|
-
const last = children.at(-1);
|
|
2988
|
-
return last ? cloneLocation(last.position.end) : void 0;
|
|
2989
|
-
}
|
|
2990
2836
|
// src/profile/features/heading.ts
|
|
2991
|
-
function
|
|
2837
|
+
function atxMarkerEnd(source, markerOffset, lineEnd) {
|
|
2992
2838
|
let markerEnd = markerOffset + 1;
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
let contentEnd = lineEnd;
|
|
2998
|
-
while (contentEnd > contentOffset && (source[contentEnd - 1] === " " || source[contentEnd - 1] === " ")) contentEnd--;
|
|
2999
|
-
let closer = contentEnd;
|
|
3000
|
-
while (closer > contentOffset && source[closer - 1] === "#") closer--;
|
|
3001
|
-
if (closer < contentEnd && (closer === contentOffset || source[closer - 1] === " " || source[closer - 1] === " ")) {
|
|
3002
|
-
contentEnd = closer;
|
|
3003
|
-
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;
|
|
3004
2843
|
}
|
|
3005
|
-
return
|
|
3006
|
-
markerEnd,
|
|
3007
|
-
contentOffset,
|
|
3008
|
-
contentEnd
|
|
3009
|
-
};
|
|
2844
|
+
return markerEnd;
|
|
3010
2845
|
}
|
|
3011
2846
|
function setextMarkerAt(source, lines, index, markerOffset) {
|
|
3012
|
-
const marker = source
|
|
3013
|
-
if (marker !==
|
|
2847
|
+
const marker = source.charCodeAt(markerOffset);
|
|
2848
|
+
if (marker !== 61 && marker !== 45) return;
|
|
3014
2849
|
const lineEnd = lines.end(index);
|
|
3015
2850
|
let offset = markerOffset + 1;
|
|
3016
|
-
while (offset < lineEnd && source
|
|
3017
|
-
offset =
|
|
2851
|
+
while (offset < lineEnd && source.charCodeAt(offset) === marker) offset++;
|
|
2852
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
3018
2853
|
return offset === lineEnd ? marker : void 0;
|
|
3019
2854
|
}
|
|
3020
|
-
const feature$
|
|
2855
|
+
const feature$8 = { block: {
|
|
3021
2856
|
builds: [{
|
|
3022
|
-
token:
|
|
2857
|
+
token: [
|
|
2858
|
+
64,
|
|
2859
|
+
65,
|
|
2860
|
+
66,
|
|
2861
|
+
67,
|
|
2862
|
+
68,
|
|
2863
|
+
69
|
|
2864
|
+
],
|
|
3023
2865
|
build(tokenStart, context) {
|
|
3024
2866
|
const tokens = context.structure.tokens;
|
|
2867
|
+
const kind = tokens.kind(tokenStart);
|
|
3025
2868
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
3026
2869
|
const inline = buildInlineFragment(tokenStart, false, context);
|
|
3027
2870
|
const result = {
|
|
3028
2871
|
type: "heading",
|
|
3029
|
-
depth:
|
|
2872
|
+
depth: kind - 64 + 1,
|
|
3030
2873
|
children: inline.children,
|
|
3031
2874
|
position: {
|
|
3032
2875
|
start,
|
|
3033
|
-
end: context.locator.locationAt(
|
|
2876
|
+
end: context.locator.locationAt(tokens.end(tokenStart))
|
|
3034
2877
|
}
|
|
3035
2878
|
};
|
|
3036
2879
|
if (inline.attributes) result.attributes = inline.attributes;
|
|
3037
2880
|
return result;
|
|
3038
2881
|
}
|
|
3039
2882
|
}, {
|
|
3040
|
-
token: [
|
|
2883
|
+
token: [70, 71],
|
|
3041
2884
|
build(tokenStart, context) {
|
|
3042
2885
|
const tokens = context.structure.tokens;
|
|
2886
|
+
const kind = tokens.kind(tokenStart);
|
|
2887
|
+
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
3043
2888
|
const inline = buildInlineFragment(tokenStart, false, context);
|
|
3044
|
-
const children = inline.children;
|
|
3045
2889
|
const result = {
|
|
3046
2890
|
type: "heading",
|
|
3047
|
-
depth:
|
|
3048
|
-
children,
|
|
2891
|
+
depth: kind - 70 + 1,
|
|
2892
|
+
children: inline.children,
|
|
3049
2893
|
position: {
|
|
3050
|
-
start
|
|
3051
|
-
end: context.locator.locationAt(tokens.
|
|
2894
|
+
start,
|
|
2895
|
+
end: context.locator.locationAt(tokens.end(tokenStart))
|
|
3052
2896
|
}
|
|
3053
2897
|
};
|
|
3054
2898
|
if (inline.attributes) result.attributes = inline.attributes;
|
|
@@ -3058,15 +2902,23 @@ const feature$7 = { block: {
|
|
|
3058
2902
|
starts: [{
|
|
3059
2903
|
codes: [35],
|
|
3060
2904
|
interrupt(source, lines, index, contentOffset) {
|
|
3061
|
-
return
|
|
2905
|
+
return atxMarkerEnd(source, contentOffset, lines.end(index)) > 0;
|
|
3062
2906
|
},
|
|
3063
|
-
start(source, lines, start, contentOffset
|
|
3064
|
-
const atx = atxAt(source, lines, start, contentOffset);
|
|
3065
|
-
if (!atx) return;
|
|
3066
|
-
out.push(96, contentOffset, atx.markerEnd);
|
|
3067
|
-
if (atx.contentEnd > atx.contentOffset) out.push(1, atx.contentOffset, atx.contentEnd);
|
|
2907
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
3068
2908
|
const lineEnd = lines.end(start);
|
|
3069
|
-
|
|
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);
|
|
3070
2922
|
return start + 1;
|
|
3071
2923
|
}
|
|
3072
2924
|
}]
|
|
@@ -3108,17 +2960,17 @@ function htmlStartAt(source, lines, index, contentOffset) {
|
|
|
3108
2960
|
if (tag && htmlBlockTags.has(tag)) return { interruptParagraph: true };
|
|
3109
2961
|
if (completeHtmlTag.test(body)) return { interruptParagraph: false };
|
|
3110
2962
|
}
|
|
3111
|
-
const buildInlineHtml = (tokenIndex,
|
|
2963
|
+
const buildInlineHtml = (tokenIndex, position, context) => {
|
|
3112
2964
|
return {
|
|
3113
2965
|
type: "html",
|
|
3114
2966
|
value: inlineTokenText(context.view.text, context.tokens, tokenIndex),
|
|
3115
|
-
position
|
|
2967
|
+
position
|
|
3116
2968
|
};
|
|
3117
2969
|
};
|
|
3118
|
-
const feature$
|
|
2970
|
+
const feature$7 = {
|
|
3119
2971
|
block: {
|
|
3120
2972
|
builds: [{
|
|
3121
|
-
token:
|
|
2973
|
+
token: 260,
|
|
3122
2974
|
build(tokenStart, context) {
|
|
3123
2975
|
const tokens = context.structure.tokens;
|
|
3124
2976
|
const offset = tokens.start(tokenStart);
|
|
@@ -3129,7 +2981,7 @@ const feature$6 = {
|
|
|
3129
2981
|
return {
|
|
3130
2982
|
type: "html",
|
|
3131
2983
|
value: html,
|
|
3132
|
-
position: context.locator.positionAt(offset, html.endsWith("\n") ? end :
|
|
2984
|
+
position: context.locator.positionAt(offset, html.endsWith("\n") ? end : tokens.contentEnd(context.source, tokenStart))
|
|
3133
2985
|
};
|
|
3134
2986
|
}
|
|
3135
2987
|
}],
|
|
@@ -3138,7 +2990,7 @@ const feature$6 = {
|
|
|
3138
2990
|
interrupt(source, lines, index, contentOffset) {
|
|
3139
2991
|
return !!htmlStartAt(source, lines, index, contentOffset)?.interruptParagraph;
|
|
3140
2992
|
},
|
|
3141
|
-
start(source, lines, start, contentOffset
|
|
2993
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
3142
2994
|
const htmlStart = htmlStartAt(source, lines, start, contentOffset);
|
|
3143
2995
|
if (!htmlStart) return;
|
|
3144
2996
|
let end = start;
|
|
@@ -3151,7 +3003,7 @@ const feature$6 = {
|
|
|
3151
3003
|
end++;
|
|
3152
3004
|
while (end < lines.length && !isBlankLine(source, lines, end)) end++;
|
|
3153
3005
|
}
|
|
3154
|
-
appendLogicalToken(
|
|
3006
|
+
appendLogicalToken(source, lines, tokens, 260, start, end, unterminated);
|
|
3155
3007
|
return end;
|
|
3156
3008
|
}
|
|
3157
3009
|
}]
|
|
@@ -3186,14 +3038,71 @@ const feature$6 = {
|
|
|
3186
3038
|
}]
|
|
3187
3039
|
}
|
|
3188
3040
|
};
|
|
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
|
+
} };
|
|
3189
3099
|
// src/profile/features/link.ts
|
|
3190
|
-
function skipWhitespace(source, start) {
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
end++;
|
|
3100
|
+
function skipWhitespace(source, start, end = source.length) {
|
|
3101
|
+
while (start < end) {
|
|
3102
|
+
if (!isMarkdownWhitespace(source.charCodeAt(start))) break;
|
|
3103
|
+
start++;
|
|
3195
3104
|
}
|
|
3196
|
-
return
|
|
3105
|
+
return start;
|
|
3197
3106
|
}
|
|
3198
3107
|
function linkDestinationEnd(source, start) {
|
|
3199
3108
|
if (source.charCodeAt(start) === 60) {
|
|
@@ -3255,7 +3164,7 @@ function scanLinkTail(source, start, tokens) {
|
|
|
3255
3164
|
simpleLinkTail.lastIndex = start + 1;
|
|
3256
3165
|
if (simpleLinkTail.test(source)) {
|
|
3257
3166
|
const end = simpleLinkTail.lastIndex;
|
|
3258
|
-
appendInlineToken(tokens,
|
|
3167
|
+
appendInlineToken(tokens, 68, start, end, end - start - 1);
|
|
3259
3168
|
return end;
|
|
3260
3169
|
}
|
|
3261
3170
|
if (source.charCodeAt(start + 1) !== 40) return -1;
|
|
@@ -3274,44 +3183,9 @@ function scanLinkTail(source, start, tokens) {
|
|
|
3274
3183
|
if (source.charCodeAt(offset) !== 41) return -1;
|
|
3275
3184
|
}
|
|
3276
3185
|
const end = offset + 1;
|
|
3277
|
-
appendInlineToken(tokens,
|
|
3186
|
+
appendInlineToken(tokens, 68, start, end, destinationEnd - start);
|
|
3278
3187
|
return end;
|
|
3279
3188
|
}
|
|
3280
|
-
function resourceAt(source, tokens, tokenIndex) {
|
|
3281
|
-
const tokenStart = inlineTokenStart(tokens, tokenIndex);
|
|
3282
|
-
const tokenEnd = inlineTokenEnd(tokens, tokenIndex);
|
|
3283
|
-
let start = tokenStart + 2;
|
|
3284
|
-
let end = tokenEnd - 1;
|
|
3285
|
-
while (start < end && isMarkdownWhitespace(source.charCodeAt(start))) start++;
|
|
3286
|
-
while (end > start && isMarkdownWhitespace(source.charCodeAt(end - 1))) end--;
|
|
3287
|
-
if (start === end) return {
|
|
3288
|
-
url: "",
|
|
3289
|
-
title: null
|
|
3290
|
-
};
|
|
3291
|
-
const resourceEnd = tokenStart + inlineTokenData(tokens, tokenIndex);
|
|
3292
|
-
let destinationStart = start;
|
|
3293
|
-
let destinationEnd = resourceEnd;
|
|
3294
|
-
if (source[start] === "<") {
|
|
3295
|
-
destinationStart++;
|
|
3296
|
-
destinationEnd--;
|
|
3297
|
-
}
|
|
3298
|
-
start = resourceEnd;
|
|
3299
|
-
while (start < end && isMarkdownWhitespace(source.charCodeAt(start))) start++;
|
|
3300
|
-
return {
|
|
3301
|
-
url: semanticText(source.slice(destinationStart, destinationEnd)),
|
|
3302
|
-
title: start < end ? semanticText(source.slice(start + 1, end - 1)) : null
|
|
3303
|
-
};
|
|
3304
|
-
}
|
|
3305
|
-
function reference(close, syntaxStart, syntaxEnd, context, image) {
|
|
3306
|
-
const closeText = inlineTokenText(context.view.text, context.tokens, close);
|
|
3307
|
-
const full = closeText.startsWith("][") && closeText !== "][]";
|
|
3308
|
-
const labelSource = full ? closeText.slice(2, -1) : context.view.text.slice(syntaxStart + (image ? 2 : 1), syntaxEnd - closeText.length);
|
|
3309
|
-
return {
|
|
3310
|
-
identifier: normalizeIdentifier(labelSource),
|
|
3311
|
-
label: semanticText(labelSource),
|
|
3312
|
-
referenceType: full ? "full" : closeText === "][]" ? "collapsed" : "shortcut"
|
|
3313
|
-
};
|
|
3314
|
-
}
|
|
3315
3189
|
function phrasingText(children) {
|
|
3316
3190
|
let result = "";
|
|
3317
3191
|
for (const child of children) if (child.type === "text" || child.type === "inlineCode" || child.type === "html") result += child.value;
|
|
@@ -3321,34 +3195,63 @@ function phrasingText(children) {
|
|
|
3321
3195
|
return result;
|
|
3322
3196
|
}
|
|
3323
3197
|
function createBuildMedia(media, resourceKind) {
|
|
3324
|
-
const
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
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
|
+
}
|
|
3340
3242
|
}
|
|
3341
|
-
|
|
3342
|
-
return image ? {
|
|
3243
|
+
return isImage ? {
|
|
3343
3244
|
type: "image",
|
|
3344
3245
|
alt: phrasingText(children),
|
|
3345
|
-
|
|
3346
|
-
|
|
3246
|
+
url,
|
|
3247
|
+
title,
|
|
3248
|
+
position
|
|
3347
3249
|
} : {
|
|
3348
3250
|
type: "link",
|
|
3349
3251
|
children,
|
|
3350
|
-
|
|
3351
|
-
|
|
3252
|
+
url,
|
|
3253
|
+
title,
|
|
3254
|
+
position
|
|
3352
3255
|
};
|
|
3353
3256
|
};
|
|
3354
3257
|
}
|
|
@@ -3363,7 +3266,7 @@ const feature$5 = { inline: {
|
|
|
3363
3266
|
scan(source, start, tokens) {
|
|
3364
3267
|
if (source.charCodeAt(start + 1) !== 91) return start + 1;
|
|
3365
3268
|
const end = start + 2;
|
|
3366
|
-
appendInlineToken(tokens,
|
|
3269
|
+
appendInlineToken(tokens, 4, start, end);
|
|
3367
3270
|
return end;
|
|
3368
3271
|
}
|
|
3369
3272
|
},
|
|
@@ -3371,7 +3274,7 @@ const feature$5 = { inline: {
|
|
|
3371
3274
|
marker: 91,
|
|
3372
3275
|
scan(source, start, tokens) {
|
|
3373
3276
|
const end = start + 1;
|
|
3374
|
-
appendInlineToken(tokens,
|
|
3277
|
+
appendInlineToken(tokens, 5, start, end);
|
|
3375
3278
|
return end;
|
|
3376
3279
|
}
|
|
3377
3280
|
},
|
|
@@ -3380,7 +3283,7 @@ const feature$5 = { inline: {
|
|
|
3380
3283
|
scan(source, start, tokens) {
|
|
3381
3284
|
const end = scanLinkTail(source, start, tokens);
|
|
3382
3285
|
if (end >= 0) return end;
|
|
3383
|
-
appendInlineToken(tokens,
|
|
3286
|
+
appendInlineToken(tokens, 6, start, start + 1);
|
|
3384
3287
|
return start + 1;
|
|
3385
3288
|
}
|
|
3386
3289
|
}
|
|
@@ -3409,7 +3312,7 @@ const feature$5 = { inline: {
|
|
|
3409
3312
|
{
|
|
3410
3313
|
kind: "leaf",
|
|
3411
3314
|
token: 132,
|
|
3412
|
-
build(tokenIndex,
|
|
3315
|
+
build(tokenIndex, position, context) {
|
|
3413
3316
|
const label = inlineTokenText(context.view.text, context.tokens, tokenIndex, 1);
|
|
3414
3317
|
return {
|
|
3415
3318
|
type: "link",
|
|
@@ -3420,40 +3323,25 @@ const feature$5 = { inline: {
|
|
|
3420
3323
|
value: label,
|
|
3421
3324
|
position: {
|
|
3422
3325
|
start: {
|
|
3423
|
-
line:
|
|
3424
|
-
column:
|
|
3425
|
-
offset:
|
|
3326
|
+
line: position.start.line,
|
|
3327
|
+
column: position.start.column + 1,
|
|
3328
|
+
offset: position.start.offset + 1
|
|
3426
3329
|
},
|
|
3427
3330
|
end: {
|
|
3428
|
-
line:
|
|
3429
|
-
column:
|
|
3430
|
-
offset:
|
|
3331
|
+
line: position.end.line,
|
|
3332
|
+
column: position.end.column - 1,
|
|
3333
|
+
offset: position.end.offset - 1
|
|
3431
3334
|
}
|
|
3432
3335
|
}
|
|
3433
3336
|
}],
|
|
3434
|
-
position
|
|
3337
|
+
position
|
|
3435
3338
|
};
|
|
3436
3339
|
}
|
|
3437
3340
|
},
|
|
3438
3341
|
{
|
|
3439
3342
|
kind: "text",
|
|
3440
|
-
token:
|
|
3441
|
-
build: buildInlineText
|
|
3442
|
-
},
|
|
3443
|
-
{
|
|
3444
|
-
kind: "text",
|
|
3445
|
-
token: 71,
|
|
3446
|
-
build: buildInlineText
|
|
3447
|
-
},
|
|
3448
|
-
{
|
|
3449
|
-
kind: "text",
|
|
3450
|
-
token: 73,
|
|
3343
|
+
token: 68,
|
|
3451
3344
|
build: buildDecodedInlineText
|
|
3452
|
-
},
|
|
3453
|
-
{
|
|
3454
|
-
kind: "text",
|
|
3455
|
-
token: 74,
|
|
3456
|
-
build: buildInlineText
|
|
3457
3345
|
}
|
|
3458
3346
|
]
|
|
3459
3347
|
} };
|
|
@@ -3540,7 +3428,8 @@ function taskListMarkerAt(source, start, end) {
|
|
|
3540
3428
|
};
|
|
3541
3429
|
}
|
|
3542
3430
|
function hasTaskListContent(source, tokens, firstChunk, contentStart) {
|
|
3543
|
-
|
|
3431
|
+
const tokenEnd = firstChunk - 1 + tokens.nodeLength(firstChunk - 1);
|
|
3432
|
+
for (let token = firstChunk; token < tokenEnd; token++) {
|
|
3544
3433
|
const start = token === firstChunk ? contentStart : tokens.start(token);
|
|
3545
3434
|
const end = tokens.end(token);
|
|
3546
3435
|
for (let offset = start; offset < end; offset++) if (!isTaskListWhitespace(source.charCodeAt(offset))) return true;
|
|
@@ -3550,47 +3439,49 @@ function hasTaskListContent(source, tokens, firstChunk, contentStart) {
|
|
|
3550
3439
|
const buildListItem = (tokenStart, context) => {
|
|
3551
3440
|
const tokens = context.structure.tokens;
|
|
3552
3441
|
const markerKind = tokens.kind(tokenStart);
|
|
3442
|
+
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
3553
3443
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
3554
3444
|
const children = buildBlockChildren(tokenStart, context);
|
|
3555
|
-
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
3556
3445
|
return {
|
|
3557
3446
|
type: "listItem",
|
|
3558
|
-
spread: tokens.
|
|
3559
|
-
checked: markerKind ===
|
|
3447
|
+
spread: tokens.kind(close) === 194,
|
|
3448
|
+
checked: markerKind === 77 ? true : markerKind === 76 ? false : null,
|
|
3560
3449
|
children,
|
|
3561
3450
|
position: {
|
|
3562
3451
|
start,
|
|
3563
|
-
end:
|
|
3452
|
+
end: children.length ? cloneLocation(children.at(-1).position.end) : context.locator.locationAt(tokens.end(close))
|
|
3564
3453
|
}
|
|
3565
3454
|
};
|
|
3566
3455
|
};
|
|
3456
|
+
function listStartNumber(source, tokens, tokenStart) {
|
|
3457
|
+
const digits = source.slice(tokens.start(tokenStart), tokens.end(tokenStart) - 1);
|
|
3458
|
+
return Number(digits);
|
|
3459
|
+
}
|
|
3567
3460
|
function createBuildList(ordered) {
|
|
3568
3461
|
return (tokenStart, context) => {
|
|
3569
3462
|
const tokens = context.structure.tokens;
|
|
3570
|
-
const items = [];
|
|
3571
3463
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
3572
|
-
|
|
3464
|
+
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
3465
|
+
const children = buildBlockChildren(tokenStart, context);
|
|
3573
3466
|
return {
|
|
3574
3467
|
type: "list",
|
|
3575
3468
|
ordered,
|
|
3576
|
-
start: ordered ? tokens
|
|
3577
|
-
spread: tokens.
|
|
3578
|
-
children
|
|
3469
|
+
start: ordered ? listStartNumber(context.source, tokens, tokenStart) : null,
|
|
3470
|
+
spread: tokens.kind(close) === 196,
|
|
3471
|
+
children,
|
|
3579
3472
|
position: {
|
|
3580
|
-
start
|
|
3581
|
-
end:
|
|
3473
|
+
start,
|
|
3474
|
+
end: cloneLocation(children.at(-1).position.end)
|
|
3582
3475
|
}
|
|
3583
3476
|
};
|
|
3584
3477
|
};
|
|
3585
3478
|
}
|
|
3586
|
-
const listStart = (source, lines, start, contentOffset,
|
|
3479
|
+
const listStart = (source, lines, tokens, start, contentOffset, context) => {
|
|
3587
3480
|
let marker = listMarkerAt(source, lines, start, contentOffset);
|
|
3588
3481
|
if (!marker) return;
|
|
3589
3482
|
const delimiter = marker.delimiter;
|
|
3590
|
-
const
|
|
3591
|
-
|
|
3592
|
-
const listClose = ordered ? 196 : 195;
|
|
3593
|
-
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);
|
|
3594
3485
|
let index = start;
|
|
3595
3486
|
let listEnd = marker.end;
|
|
3596
3487
|
let listSpread = false;
|
|
@@ -3599,7 +3490,7 @@ const listStart = (source, lines, start, contentOffset, out, context) => {
|
|
|
3599
3490
|
let sibling;
|
|
3600
3491
|
listSpread ||= trailingBlank;
|
|
3601
3492
|
trailingBlank = false;
|
|
3602
|
-
|
|
3493
|
+
tokens.push(75, marker.offset, marker.end);
|
|
3603
3494
|
const itemLines = context.createLineView(lines, index, marker.contentOffset, marker.contentPrefixColumns);
|
|
3604
3495
|
let hasContent = marker.hasContent;
|
|
3605
3496
|
let paragraphLeaf = hasContent ? 2 : 0;
|
|
@@ -3637,43 +3528,55 @@ const listStart = (source, lines, start, contentOffset, out, context) => {
|
|
|
3637
3528
|
itemLines.pushLazy(lines, index);
|
|
3638
3529
|
index++;
|
|
3639
3530
|
}
|
|
3640
|
-
const itemSpread = context.scanLines(source, itemLines,
|
|
3641
|
-
|
|
3642
|
-
|
|
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;
|
|
3643
3535
|
marker = sibling;
|
|
3644
3536
|
}
|
|
3645
|
-
|
|
3537
|
+
tokens.push(listSpread ? 196 : 195, listEnd, listEnd);
|
|
3646
3538
|
return index;
|
|
3647
3539
|
};
|
|
3648
|
-
const taskListStart = (source, lines, start, contentOffset,
|
|
3649
|
-
const listToken =
|
|
3650
|
-
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);
|
|
3651
3543
|
if (nextLine === void 0) return;
|
|
3652
|
-
for (let item = listToken + 1; item <
|
|
3544
|
+
for (let item = listToken + 1; item < tokens.length - 1; item += tokens.nodeLength(item)) {
|
|
3653
3545
|
let paragraph = item + 1;
|
|
3654
|
-
let contentKind =
|
|
3655
|
-
while (contentKind ===
|
|
3656
|
-
paragraph
|
|
3657
|
-
contentKind =
|
|
3546
|
+
let contentKind = tokens.kind(paragraph);
|
|
3547
|
+
while (contentKind === 257) {
|
|
3548
|
+
paragraph += tokens.nodeLength(paragraph);
|
|
3549
|
+
contentKind = tokens.kind(paragraph);
|
|
3658
3550
|
}
|
|
3659
|
-
if (contentKind !==
|
|
3551
|
+
if (contentKind !== 79) continue;
|
|
3660
3552
|
const firstChunk = paragraph + 1;
|
|
3661
|
-
const marker = taskListMarkerAt(source,
|
|
3662
|
-
if (!marker || !hasTaskListContent(source,
|
|
3663
|
-
|
|
3664
|
-
|
|
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);
|
|
3665
3557
|
}
|
|
3666
3558
|
return nextLine;
|
|
3667
3559
|
};
|
|
3668
3560
|
function feature$4(taskList = false) {
|
|
3669
3561
|
return { block: {
|
|
3670
|
-
builds: [
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
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
|
+
],
|
|
3677
3580
|
starts: [{
|
|
3678
3581
|
codes: [
|
|
3679
3582
|
42,
|
|
@@ -3711,16 +3614,14 @@ const mathFenceRule = {
|
|
|
3711
3614
|
minimumLength: 2
|
|
3712
3615
|
};
|
|
3713
3616
|
const blockBuilds = [{
|
|
3714
|
-
token:
|
|
3617
|
+
token: 262,
|
|
3715
3618
|
build(tokenStart, context) {
|
|
3716
3619
|
const tokens = context.structure.tokens;
|
|
3717
|
-
const block = tokens.value(tokenStart);
|
|
3718
|
-
const value = block.content ?? tokens.text(context.source, tokenStart);
|
|
3719
3620
|
return {
|
|
3720
3621
|
type: "math",
|
|
3721
|
-
meta: semanticText(
|
|
3722
|
-
value:
|
|
3723
|
-
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))
|
|
3724
3625
|
};
|
|
3725
3626
|
}
|
|
3726
3627
|
}];
|
|
@@ -3729,14 +3630,14 @@ const blockStarts = [{
|
|
|
3729
3630
|
interrupt(source, lines, index, contentOffset) {
|
|
3730
3631
|
return fenceAt(source, lines, index, mathFenceRule, contentOffset) !== void 0;
|
|
3731
3632
|
},
|
|
3732
|
-
start(source, lines, start, contentOffset
|
|
3633
|
+
start(source, lines, tokens, start, contentOffset) {
|
|
3733
3634
|
const fence = fenceAt(source, lines, start, mathFenceRule, contentOffset);
|
|
3734
3635
|
if (!fence) return;
|
|
3735
3636
|
let end = start + 1;
|
|
3736
3637
|
while (end < lines.length && !closesFence(source, lines, end, fence)) end++;
|
|
3737
3638
|
const closed = end < lines.length;
|
|
3738
3639
|
if (end < lines.length) end++;
|
|
3739
|
-
|
|
3640
|
+
appendFencedToken(source, lines, tokens, 262, start, end, fence, closed, false);
|
|
3740
3641
|
return end;
|
|
3741
3642
|
}
|
|
3742
3643
|
}];
|
|
@@ -3771,7 +3672,7 @@ function createMathScanRule(singleDollarTextMath) {
|
|
|
3771
3672
|
const inlineBuilds = [{
|
|
3772
3673
|
kind: "leaf",
|
|
3773
3674
|
token: 134,
|
|
3774
|
-
build(tokenIndex,
|
|
3675
|
+
build(tokenIndex, position, context) {
|
|
3775
3676
|
const markerLength = inlineTokenData(context.tokens, tokenIndex);
|
|
3776
3677
|
let value = inlineTokenText(context.view.text, context.tokens, tokenIndex, markerLength);
|
|
3777
3678
|
const startPadding = value.startsWith("\r\n") ? 2 : /^[ \r\n]/.test(value) ? 1 : 0;
|
|
@@ -3780,7 +3681,7 @@ const inlineBuilds = [{
|
|
|
3780
3681
|
return {
|
|
3781
3682
|
type: "inlineMath",
|
|
3782
3683
|
value,
|
|
3783
|
-
position
|
|
3684
|
+
position
|
|
3784
3685
|
};
|
|
3785
3686
|
}
|
|
3786
3687
|
}];
|
|
@@ -3800,46 +3701,59 @@ function feature$3(options) {
|
|
|
3800
3701
|
}
|
|
3801
3702
|
// src/profile/features/paragraph.ts
|
|
3802
3703
|
const feature$2 = { block: {
|
|
3803
|
-
fallbacks: [(source, lines, start, contentOffset,
|
|
3804
|
-
const openToken =
|
|
3805
|
-
|
|
3806
|
-
out.push(99, offset, offset);
|
|
3704
|
+
fallbacks: [(source, lines, tokens, start, contentOffset, context) => {
|
|
3705
|
+
const openToken = tokens.length;
|
|
3706
|
+
tokens.push(79, contentOffset, contentOffset);
|
|
3807
3707
|
let chunkOffset = contentOffset;
|
|
3708
|
+
let withBoundaryBreak = false;
|
|
3808
3709
|
let index = start + 1;
|
|
3809
3710
|
while (index < lines.length) {
|
|
3810
3711
|
const lineEnd = lines.end(index);
|
|
3811
|
-
const contentStart =
|
|
3712
|
+
const contentStart = trimLineWhitespaceStart(source, lines.start(index), lineEnd);
|
|
3812
3713
|
if (contentStart === lineEnd) break;
|
|
3813
3714
|
const chunkStart = indentOffset(source, lines, index);
|
|
3814
3715
|
if (!lines.lazy(index) && chunkStart === contentStart) {
|
|
3815
3716
|
const setext = setextMarkerAt(source, lines, index, contentStart);
|
|
3816
3717
|
if (setext) {
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3718
|
+
tokens.setKind(openToken, setext === 61 ? 70 : 71);
|
|
3719
|
+
tokens.setEnd(openToken, lineEnd);
|
|
3720
|
+
tokens.closeRange(chunkOffset, lines.end(index - 1));
|
|
3820
3721
|
return index + 1;
|
|
3821
3722
|
}
|
|
3822
3723
|
if (context.startsInterruptingBlock(source, lines, index, contentStart)) break;
|
|
3823
3724
|
}
|
|
3824
|
-
|
|
3825
|
-
|
|
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
|
+
}
|
|
3826
3738
|
index++;
|
|
3827
3739
|
}
|
|
3828
3740
|
const close = lines.end(index - 1);
|
|
3829
|
-
|
|
3830
|
-
out.push(194, close, close);
|
|
3741
|
+
tokens.closeRange(chunkOffset, close);
|
|
3831
3742
|
return index;
|
|
3832
3743
|
}],
|
|
3833
3744
|
builds: [{
|
|
3834
|
-
token:
|
|
3745
|
+
token: 79,
|
|
3835
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));
|
|
3836
3750
|
const inline = buildInlineFragment(tokenStart, false, context);
|
|
3837
3751
|
const result = {
|
|
3838
3752
|
type: "paragraph",
|
|
3839
3753
|
children: inline.children,
|
|
3840
3754
|
position: {
|
|
3841
|
-
start
|
|
3842
|
-
end: context.locator.locationAt(
|
|
3755
|
+
start,
|
|
3756
|
+
end: context.locator.locationAt(tokens.end(close))
|
|
3843
3757
|
}
|
|
3844
3758
|
};
|
|
3845
3759
|
if (inline.attributes) result.attributes = inline.attributes;
|
|
@@ -3895,7 +3809,7 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
3895
3809
|
if (!labelHasContent) break parseDefinition;
|
|
3896
3810
|
offset += 2;
|
|
3897
3811
|
let lineEnd = lines.end(lineIndex);
|
|
3898
|
-
offset =
|
|
3812
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
3899
3813
|
if (offset === lineEnd) {
|
|
3900
3814
|
const nextLine = lineIndex + 1;
|
|
3901
3815
|
lookaheadEnd = nextLine < lines.length ? lines.end(nextLine) : lines.next(lineIndex);
|
|
@@ -3903,18 +3817,20 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
3903
3817
|
lineIndex++;
|
|
3904
3818
|
offset = lines.start(lineIndex);
|
|
3905
3819
|
lineEnd = lines.end(lineIndex);
|
|
3906
|
-
offset =
|
|
3820
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
3907
3821
|
}
|
|
3908
3822
|
let destination;
|
|
3909
|
-
if (source
|
|
3823
|
+
if (source.charCodeAt(offset) === 60) {
|
|
3910
3824
|
offset++;
|
|
3825
|
+
let code = source.charCodeAt(offset);
|
|
3911
3826
|
const destinationStart = offset;
|
|
3912
|
-
while (offset < lineEnd &&
|
|
3913
|
-
if (
|
|
3914
|
-
if (
|
|
3827
|
+
while (offset < lineEnd && code !== 62) {
|
|
3828
|
+
if (code === 60) break parseDefinition;
|
|
3829
|
+
if (code === 92 && offset + 1 < lineEnd) offset += 2;
|
|
3915
3830
|
else offset++;
|
|
3831
|
+
code = source.charCodeAt(offset);
|
|
3916
3832
|
}
|
|
3917
|
-
if (
|
|
3833
|
+
if (code !== 62) break parseDefinition;
|
|
3918
3834
|
destination = source.slice(destinationStart, offset);
|
|
3919
3835
|
offset++;
|
|
3920
3836
|
} else {
|
|
@@ -3936,25 +3852,29 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
3936
3852
|
destination = source.slice(destinationStart, offset);
|
|
3937
3853
|
}
|
|
3938
3854
|
const destinationLine = lineIndex;
|
|
3939
|
-
if (offset < lineEnd
|
|
3940
|
-
|
|
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);
|
|
3941
3860
|
let titleOnNextLine = false;
|
|
3942
3861
|
if (offset === lineEnd && lineIndex + 1 < lines.length) {
|
|
3943
3862
|
lookaheadEnd = lines.end(lineIndex + 1);
|
|
3944
3863
|
lineIndex++;
|
|
3945
3864
|
offset = lines.start(lineIndex);
|
|
3946
3865
|
lineEnd = lines.end(lineIndex);
|
|
3947
|
-
offset =
|
|
3866
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
3948
3867
|
titleOnNextLine = true;
|
|
3949
3868
|
}
|
|
3950
|
-
const
|
|
3869
|
+
const code = source.charCodeAt(offset);
|
|
3870
|
+
const closer = code === 40 ? 41 : code === 34 || code === 39 ? code : void 0;
|
|
3951
3871
|
const definitionKey = normalizeIdentifier(label);
|
|
3952
3872
|
const fields = {
|
|
3953
3873
|
destination,
|
|
3954
3874
|
label,
|
|
3955
3875
|
title: void 0
|
|
3956
3876
|
};
|
|
3957
|
-
if (
|
|
3877
|
+
if (closer === void 0) return {
|
|
3958
3878
|
definitionKey,
|
|
3959
3879
|
end: destinationLine + 1,
|
|
3960
3880
|
fields
|
|
@@ -3966,11 +3886,12 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
3966
3886
|
while (lineIndex < lines.length) {
|
|
3967
3887
|
lineEnd = lines.end(lineIndex);
|
|
3968
3888
|
while (offset < lineEnd) {
|
|
3969
|
-
|
|
3889
|
+
const code = source.charCodeAt(offset);
|
|
3890
|
+
if (code === 92 && offset + 1 < lineEnd) {
|
|
3970
3891
|
offset += 2;
|
|
3971
3892
|
continue;
|
|
3972
3893
|
}
|
|
3973
|
-
if (
|
|
3894
|
+
if (code === closer) {
|
|
3974
3895
|
title += source.slice(titleStart, offset);
|
|
3975
3896
|
offset++;
|
|
3976
3897
|
closed = true;
|
|
@@ -3988,7 +3909,7 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
3988
3909
|
titleStart = offset;
|
|
3989
3910
|
}
|
|
3990
3911
|
if (closed) {
|
|
3991
|
-
offset =
|
|
3912
|
+
offset = trimLineWhitespaceStart(source, offset, lineEnd);
|
|
3992
3913
|
if (offset === lineEnd) {
|
|
3993
3914
|
fields.title = title;
|
|
3994
3915
|
return {
|
|
@@ -4010,7 +3931,7 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
4010
3931
|
}
|
|
4011
3932
|
const feature$1 = { block: {
|
|
4012
3933
|
builds: [{
|
|
4013
|
-
token:
|
|
3934
|
+
token: 257,
|
|
4014
3935
|
build(tokenStart, context) {
|
|
4015
3936
|
const tokens = context.structure.tokens;
|
|
4016
3937
|
const fields = tokens.value(tokenStart);
|
|
@@ -4026,67 +3947,47 @@ const feature$1 = { block: {
|
|
|
4026
3947
|
}],
|
|
4027
3948
|
starts: [{
|
|
4028
3949
|
codes: [91],
|
|
4029
|
-
start(source, lines, start, contentOffset,
|
|
3950
|
+
start(source, lines, tokens, start, contentOffset, context) {
|
|
4030
3951
|
const definition = linkDefinitionAt(source, lines, start, contentOffset, context);
|
|
4031
3952
|
if (!definition) return;
|
|
4032
|
-
|
|
3953
|
+
tokens.push(257, contentOffset, lines.end(definition.end - 1), {
|
|
4033
3954
|
definitionKey: definition.definitionKey,
|
|
4034
3955
|
value: definition.fields
|
|
4035
3956
|
});
|
|
4036
|
-
let definitionEnd = contentOffset;
|
|
4037
|
-
for (let definitionLine = start; definitionLine < definition.end; definitionLine++) {
|
|
4038
|
-
definitionEnd = definitionLine + 1 < definition.end ? lines.next(definitionLine) : lines.end(definitionLine);
|
|
4039
|
-
out.push(2, lines.start(definitionLine), definitionEnd);
|
|
4040
|
-
}
|
|
4041
|
-
out.push(198, definitionEnd, definitionEnd);
|
|
4042
3957
|
return definition.end;
|
|
4043
3958
|
}
|
|
4044
3959
|
}]
|
|
4045
3960
|
} };
|
|
4046
3961
|
// src/profile/features/table.ts
|
|
4047
3962
|
function appendTableCell(cells, source, start, contentStart, contentEnd) {
|
|
4048
|
-
contentStart =
|
|
4049
|
-
|
|
4050
|
-
const code = source.charCodeAt(contentEnd - 1);
|
|
4051
|
-
if (code !== 32 && code !== 9) break;
|
|
4052
|
-
contentEnd--;
|
|
4053
|
-
}
|
|
3963
|
+
contentStart = trimLineWhitespaceStart(source, contentStart, contentEnd);
|
|
3964
|
+
contentEnd = trimLineWhitespaceEnd(source, contentStart, contentEnd);
|
|
4054
3965
|
cells.push(start, contentStart, contentEnd);
|
|
4055
3966
|
}
|
|
4056
3967
|
function tableCellsAt(source, lines, index, requirePipe, contentOffset) {
|
|
4057
3968
|
if (contentOffset < 0) return;
|
|
4058
3969
|
const lineEnd = lines.end(index);
|
|
4059
3970
|
const row = source.slice(contentOffset, lineEnd);
|
|
4060
|
-
const
|
|
3971
|
+
const cells = [];
|
|
3972
|
+
let contentStart = contentOffset;
|
|
3973
|
+
let spanStart = contentOffset;
|
|
3974
|
+
let lastPipe;
|
|
4061
3975
|
for (let pipe = row.indexOf("|"); pipe >= 0; pipe = row.indexOf("|", pipe + 1)) {
|
|
4062
3976
|
let escapeStart = pipe;
|
|
4063
3977
|
while (escapeStart > 0 && row.charCodeAt(escapeStart - 1) === 92) escapeStart--;
|
|
4064
|
-
if ((pipe - escapeStart) % 2
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
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;
|
|
4072
3987
|
}
|
|
4073
|
-
|
|
4074
|
-
const
|
|
4075
|
-
|
|
4076
|
-
let contentStart = contentOffset;
|
|
4077
|
-
let spanStart = contentOffset;
|
|
4078
|
-
let pipeIndex = 0;
|
|
4079
|
-
if (leadingPipe) {
|
|
4080
|
-
contentStart++;
|
|
4081
|
-
pipeIndex++;
|
|
4082
|
-
}
|
|
4083
|
-
for (; pipeIndex < pipes.length; pipeIndex++) {
|
|
4084
|
-
const pipe = pipes[pipeIndex];
|
|
4085
|
-
appendTableCell(cells, source, spanStart, contentStart, pipe);
|
|
4086
|
-
spanStart = pipe;
|
|
4087
|
-
contentStart = pipe + 1;
|
|
4088
|
-
}
|
|
4089
|
-
if (!trailingPipe) appendTableCell(cells, source, spanStart, contentStart, lineEnd);
|
|
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);
|
|
4090
3991
|
return cells.length > 0 ? cells : void 0;
|
|
4091
3992
|
}
|
|
4092
3993
|
function alignmentAt(source, cells, cell) {
|
|
@@ -4096,9 +3997,9 @@ function alignmentAt(source, cells, cell) {
|
|
|
4096
3997
|
if (left) start++;
|
|
4097
3998
|
const right = source.charCodeAt(end - 1) === 58;
|
|
4098
3999
|
if (right) end--;
|
|
4099
|
-
if (start
|
|
4000
|
+
if (start >= end) return;
|
|
4100
4001
|
for (let offset = start; offset < end; offset++) if (source.charCodeAt(offset) !== 45) return;
|
|
4101
|
-
return left ? right ?
|
|
4002
|
+
return left ? right ? 267 : 265 : right ? 266 : 264;
|
|
4102
4003
|
}
|
|
4103
4004
|
function delimiterAt(source, lines, index, contentOffset) {
|
|
4104
4005
|
const first = source.charCodeAt(contentOffset);
|
|
@@ -4112,15 +4013,15 @@ function delimiterAt(source, lines, index, contentOffset) {
|
|
|
4112
4013
|
}
|
|
4113
4014
|
return cells;
|
|
4114
4015
|
}
|
|
4115
|
-
function emitTableRow(lines, index, cells
|
|
4116
|
-
|
|
4016
|
+
function emitTableRow(lines, tokens, index, cells) {
|
|
4017
|
+
tokens.push(81, cells[0], cells[0]);
|
|
4117
4018
|
for (let cell = 0; cell < cells.length; cell += 3) {
|
|
4118
4019
|
const start = cells[cell];
|
|
4119
|
-
|
|
4120
|
-
|
|
4020
|
+
tokens.push(82, start, start);
|
|
4021
|
+
tokens.closeRange(cells[cell + 1], cells[cell + 2]);
|
|
4121
4022
|
}
|
|
4122
4023
|
const lineEnd = lines.end(index);
|
|
4123
|
-
|
|
4024
|
+
tokens.push(199, lineEnd, lineEnd);
|
|
4124
4025
|
}
|
|
4125
4026
|
const buildTableCell = (tokenStart, context) => {
|
|
4126
4027
|
const tokens = context.structure.tokens;
|
|
@@ -4138,11 +4039,9 @@ const buildTableRow = (tokenStart, context) => {
|
|
|
4138
4039
|
const tokens = context.structure.tokens;
|
|
4139
4040
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
4140
4041
|
const start = context.locator.locationAt(tokens.start(tokenStart));
|
|
4141
|
-
const children = [];
|
|
4142
|
-
for (let cell = tokenStart + 1; cell < close; cell += tokens.nodeLength(cell)) children.push(buildTableCell(cell, context));
|
|
4143
4042
|
return {
|
|
4144
4043
|
type: "tableRow",
|
|
4145
|
-
children,
|
|
4044
|
+
children: buildBlockChildren(tokenStart, context),
|
|
4146
4045
|
position: {
|
|
4147
4046
|
start,
|
|
4148
4047
|
end: context.locator.locationAt(tokens.start(close))
|
|
@@ -4151,16 +4050,15 @@ const buildTableRow = (tokenStart, context) => {
|
|
|
4151
4050
|
};
|
|
4152
4051
|
function tableAlignment(tokenStart, context) {
|
|
4153
4052
|
const tokens = context.structure.tokens;
|
|
4154
|
-
const tokenEnd = tokenStart + tokens.nodeLength(tokenStart);
|
|
4155
4053
|
const result = [];
|
|
4156
|
-
for (let token = tokenStart; token
|
|
4054
|
+
for (let token = tokenStart; tokens.kind(token) !== 81 && tokens.kind(token) !== 198; token++) {
|
|
4157
4055
|
const kind = tokens.kind(token);
|
|
4158
|
-
result.push(kind ===
|
|
4056
|
+
result.push(kind === 265 ? "left" : kind === 266 ? "right" : kind === 267 ? "center" : null);
|
|
4159
4057
|
}
|
|
4160
4058
|
return result;
|
|
4161
4059
|
}
|
|
4162
4060
|
const feature = { block: {
|
|
4163
|
-
fallbacks: [(source, lines, start, contentOffset,
|
|
4061
|
+
fallbacks: [(source, lines, tokens, start, contentOffset, context) => {
|
|
4164
4062
|
const delimiterLine = start + 1;
|
|
4165
4063
|
if (delimiterLine >= lines.length) return;
|
|
4166
4064
|
const delimiterOffset = lineIndentOffset(source, lines, delimiterLine);
|
|
@@ -4169,44 +4067,51 @@ const feature = { block: {
|
|
|
4169
4067
|
if (!delimiter) return;
|
|
4170
4068
|
const header = tableCellsAt(source, lines, start, true, contentOffset);
|
|
4171
4069
|
if (header?.length !== delimiter.length) return;
|
|
4172
|
-
|
|
4173
|
-
emitTableRow(lines, start, header
|
|
4070
|
+
tokens.push(80, header[0], header[0]);
|
|
4071
|
+
emitTableRow(lines, tokens, start, header);
|
|
4174
4072
|
const delimiterEnd = lines.end(delimiterLine);
|
|
4175
|
-
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);
|
|
4176
4074
|
let end = start + 2;
|
|
4177
4075
|
while (end < lines.length) {
|
|
4178
4076
|
const contentOffset = lineIndentOffset(source, lines, end);
|
|
4179
4077
|
if (contentOffset < 0 || context.startsInterruptingBlock(source, lines, end, contentOffset)) break;
|
|
4180
4078
|
const cells = tableCellsAt(source, lines, end, false, contentOffset);
|
|
4181
4079
|
if (!cells) break;
|
|
4182
|
-
emitTableRow(lines, end, cells
|
|
4080
|
+
emitTableRow(lines, tokens, end, cells);
|
|
4183
4081
|
end++;
|
|
4184
4082
|
}
|
|
4185
4083
|
const tableEnd = lines.end(end - 1);
|
|
4186
|
-
|
|
4084
|
+
tokens.push(198, tableEnd, tableEnd);
|
|
4187
4085
|
return end;
|
|
4188
4086
|
}],
|
|
4189
|
-
builds: [
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
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
|
+
}
|
|
4208
4113
|
}
|
|
4209
|
-
|
|
4114
|
+
]
|
|
4210
4115
|
} };
|
|
4211
4116
|
// src/inline/delimiter.ts
|
|
4212
4117
|
const whitespace = /\s/u;
|
|
@@ -4242,36 +4147,31 @@ function canPair(opener, closer) {
|
|
|
4242
4147
|
if (!(closer.config.bits & 4) || !(opener.state & 2) && !(closer.state & 1)) return true;
|
|
4243
4148
|
return (opener.state & 12) + (closer.state & 12) !== 12;
|
|
4244
4149
|
}
|
|
4245
|
-
function unlinkRun(
|
|
4246
|
-
|
|
4247
|
-
if (run.
|
|
4248
|
-
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;
|
|
4249
4153
|
}
|
|
4250
|
-
function resolveDelimiterScope(
|
|
4154
|
+
function resolveDelimiterScope(first, replacements = []) {
|
|
4251
4155
|
const openersBottom = [];
|
|
4252
|
-
let
|
|
4253
|
-
while (
|
|
4254
|
-
const closer = runs[current];
|
|
4255
|
-
const next = closer.next;
|
|
4156
|
+
let closer = first;
|
|
4157
|
+
while (closer) {
|
|
4256
4158
|
if (!(closer.state & 2)) {
|
|
4257
|
-
|
|
4159
|
+
closer = closer.next;
|
|
4258
4160
|
continue;
|
|
4259
4161
|
}
|
|
4260
4162
|
const bottomSlot = (closer.config.bits >>> 3) + (closer.state & 1 ? 3 : 0) + (closer.state >> 2);
|
|
4261
|
-
const bottom = openersBottom[bottomSlot] ??
|
|
4262
|
-
let
|
|
4263
|
-
while (
|
|
4264
|
-
const opener = runs[openerIndex];
|
|
4163
|
+
const bottom = openersBottom[bottomSlot] ?? 0;
|
|
4164
|
+
let opener = closer.previous;
|
|
4165
|
+
while (opener && opener.tokenIndex >= bottom) {
|
|
4265
4166
|
if (opener.config === closer.config && canPair(opener, closer)) break;
|
|
4266
|
-
|
|
4167
|
+
opener = opener.previous;
|
|
4267
4168
|
}
|
|
4268
|
-
if (
|
|
4269
|
-
openersBottom[bottomSlot] = closer.
|
|
4270
|
-
if (!(closer.state & 1)) unlinkRun(
|
|
4271
|
-
|
|
4169
|
+
if (!opener || opener.tokenIndex < bottom) {
|
|
4170
|
+
openersBottom[bottomSlot] = closer.tokenIndex;
|
|
4171
|
+
if (!(closer.state & 1)) unlinkRun(closer);
|
|
4172
|
+
closer = closer.next;
|
|
4272
4173
|
continue;
|
|
4273
4174
|
}
|
|
4274
|
-
const opener = runs[openerIndex];
|
|
4275
4175
|
const use = opener.remaining >= 2 && closer.remaining >= 2 && closer.config.double ? 2 : 1;
|
|
4276
4176
|
const openEnd = opener.start + opener.remaining;
|
|
4277
4177
|
const openStart = openEnd - use;
|
|
@@ -4279,24 +4179,24 @@ function resolveDelimiterScope(runs, first, replacements = []) {
|
|
|
4279
4179
|
const closeEnd = closeStart + use;
|
|
4280
4180
|
const pair = use === 2 ? closer.config.double : closer.config.single;
|
|
4281
4181
|
(replacements[opener.tokenIndex] ??= []).push({
|
|
4282
|
-
|
|
4182
|
+
start: openStart,
|
|
4283
4183
|
end: openEnd,
|
|
4284
4184
|
kind: pair.open
|
|
4285
4185
|
});
|
|
4286
4186
|
(replacements[closer.tokenIndex] ??= []).push({
|
|
4287
|
-
|
|
4187
|
+
start: closeStart,
|
|
4288
4188
|
end: closeEnd,
|
|
4289
4189
|
kind: pair.close
|
|
4290
4190
|
});
|
|
4291
4191
|
opener.remaining -= use;
|
|
4292
4192
|
closer.start += use;
|
|
4293
4193
|
closer.remaining -= use;
|
|
4294
|
-
opener.next =
|
|
4295
|
-
closer.previous =
|
|
4296
|
-
if (opener.remaining === 0) unlinkRun(
|
|
4194
|
+
opener.next = closer;
|
|
4195
|
+
closer.previous = opener;
|
|
4196
|
+
if (opener.remaining === 0) unlinkRun(opener);
|
|
4297
4197
|
if (closer.remaining === 0) {
|
|
4298
|
-
unlinkRun(
|
|
4299
|
-
|
|
4198
|
+
unlinkRun(closer);
|
|
4199
|
+
closer = closer.next;
|
|
4300
4200
|
}
|
|
4301
4201
|
}
|
|
4302
4202
|
return replacements;
|
|
@@ -4312,27 +4212,22 @@ function delimiterRunAt(source, tokens, tokenIndex, config) {
|
|
|
4312
4212
|
config,
|
|
4313
4213
|
start: offset,
|
|
4314
4214
|
remaining: length,
|
|
4315
|
-
previous:
|
|
4316
|
-
next:
|
|
4215
|
+
previous: void 0,
|
|
4216
|
+
next: void 0,
|
|
4317
4217
|
state: delimiterFlanking | length % 3 << 2
|
|
4318
4218
|
};
|
|
4319
4219
|
}
|
|
4320
|
-
function
|
|
4220
|
+
function appendResolvedRawToken(result, tokens, tokenIndex, replacements) {
|
|
4321
4221
|
const matched = replacements[tokenIndex];
|
|
4322
|
-
if (
|
|
4323
|
-
|
|
4324
|
-
|
|
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);
|
|
4325
4225
|
}
|
|
4326
|
-
if (
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
if (replacement.offset > offset) appendInlineToken(result, kind, offset, replacement.offset);
|
|
4331
|
-
appendInlineToken(result, replacement.kind, replacement.offset, replacement.end);
|
|
4332
|
-
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);
|
|
4333
4230
|
}
|
|
4334
|
-
const end = inlineTokenEnd(tokens, tokenIndex);
|
|
4335
|
-
if (offset < end) appendInlineToken(result, kind, offset, end);
|
|
4336
4231
|
}
|
|
4337
4232
|
function compileDelimiterConfigs(delimiterConfigs) {
|
|
4338
4233
|
const delimiterByKind = [];
|
|
@@ -4346,22 +4241,16 @@ function compileDelimiterConfigs(delimiterConfigs) {
|
|
|
4346
4241
|
return delimiterByKind;
|
|
4347
4242
|
}
|
|
4348
4243
|
// src/profile/resolve.ts
|
|
4349
|
-
|
|
4350
|
-
const noBracketFrames = [0];
|
|
4351
|
-
function setFrameState(frames, frame, state) {
|
|
4352
|
-
frames[frame + 5] = state;
|
|
4353
|
-
frames[0] = 1;
|
|
4354
|
-
}
|
|
4355
|
-
function rewriteLinkCandidates(frames, top, bottom) {
|
|
4244
|
+
function rewriteLinkCandidates(top, bottom) {
|
|
4356
4245
|
let candidate = top;
|
|
4357
4246
|
top = bottom;
|
|
4358
|
-
while (candidate !== bottom) {
|
|
4359
|
-
const next =
|
|
4360
|
-
const state =
|
|
4361
|
-
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;
|
|
4362
4251
|
else {
|
|
4363
|
-
|
|
4364
|
-
|
|
4252
|
+
candidate.state = state | 16;
|
|
4253
|
+
candidate.candidateNext = top;
|
|
4365
4254
|
top = candidate;
|
|
4366
4255
|
}
|
|
4367
4256
|
candidate = next;
|
|
@@ -4404,70 +4293,80 @@ function acceptsShortcutLabel(source, start, end) {
|
|
|
4404
4293
|
}
|
|
4405
4294
|
return hasContent;
|
|
4406
4295
|
}
|
|
4407
|
-
function analyzeBrackets(source, tokens, definitions, options) {
|
|
4408
|
-
let
|
|
4409
|
-
let
|
|
4410
|
-
let
|
|
4411
|
-
|
|
4412
|
-
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++) {
|
|
4413
4302
|
const kind = inlineTokenKind(tokens, tokenIndex);
|
|
4414
|
-
if (kind >=
|
|
4415
|
-
const
|
|
4416
|
-
|
|
4417
|
-
|
|
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;
|
|
4418
4320
|
stackTop = frame;
|
|
4419
4321
|
continue;
|
|
4420
4322
|
}
|
|
4421
|
-
if (kind
|
|
4422
|
-
if (stackTop
|
|
4323
|
+
if (kind !== 68 && kind !== 6) continue;
|
|
4324
|
+
if (!stackTop) continue;
|
|
4423
4325
|
const frame = stackTop;
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
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;
|
|
4430
4331
|
const label = footnoteLabelAt(source, inlineTokenStart(tokens, openToken) + (image ? 1 : 0), source.length);
|
|
4431
|
-
if (label
|
|
4432
|
-
|
|
4433
|
-
candidateTop =
|
|
4332
|
+
if (label?.end === inlineTokenEnd(tokens, tokenIndex) && definitions.hasDefinition(label.definitionKey)) {
|
|
4333
|
+
frame.state = 1;
|
|
4334
|
+
candidateTop = frame.candidateBottom;
|
|
4434
4335
|
continue;
|
|
4435
4336
|
}
|
|
4436
4337
|
}
|
|
4437
4338
|
if (!options.component || image) continue;
|
|
4438
|
-
if (kind ===
|
|
4439
|
-
const openToken =
|
|
4339
|
+
if (kind === 68) candidateTop = rewriteLinkCandidates(candidateTop, frame.candidateBottom);
|
|
4340
|
+
const openToken = frame.open;
|
|
4440
4341
|
const componentToken = openToken - 1;
|
|
4441
4342
|
if (componentToken >= 0 && inlineTokenKind(tokens, componentToken) === 137 && inlineTokenEnd(tokens, componentToken) === inlineTokenStart(tokens, openToken)) {
|
|
4442
|
-
|
|
4443
|
-
|
|
4343
|
+
frame.state = 2;
|
|
4344
|
+
frame.candidateNext = candidateTop;
|
|
4444
4345
|
candidateTop = frame;
|
|
4445
4346
|
continue;
|
|
4446
4347
|
}
|
|
4447
4348
|
const suffixStart = inlineTokenStart(tokens, tokenIndex) + 1;
|
|
4448
4349
|
const trailing = source.charCodeAt(suffixStart);
|
|
4449
4350
|
if (trailing === 40 || trailing === 91) continue;
|
|
4450
|
-
|
|
4451
|
-
|
|
4351
|
+
frame.state = trailing === 123 && attributesEnd(source, suffixStart) !== void 0 ? 4 : 3;
|
|
4352
|
+
frame.candidateNext = candidateTop;
|
|
4452
4353
|
candidateTop = frame;
|
|
4453
4354
|
}
|
|
4454
|
-
return
|
|
4355
|
+
return first;
|
|
4455
4356
|
}
|
|
4456
|
-
function resolvePairedSyntax(source, tokens,
|
|
4457
|
-
const hasDefinitions =
|
|
4458
|
-
let
|
|
4459
|
-
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;
|
|
4460
4361
|
let replacements;
|
|
4461
|
-
let rawTop
|
|
4462
|
-
let logicalTop
|
|
4463
|
-
let frameCursor = frameHeaderSize;
|
|
4362
|
+
let rawTop;
|
|
4363
|
+
let logicalTop;
|
|
4464
4364
|
let consumedEnd = -1;
|
|
4465
4365
|
let consumeFrames = false;
|
|
4466
4366
|
let inactiveBefore = 0;
|
|
4467
4367
|
let lastVisibleOpener = -1;
|
|
4468
4368
|
let literalDepth = 0;
|
|
4469
|
-
|
|
4470
|
-
for (let tokenIndex = 0; tokenIndex < count; tokenIndex++) {
|
|
4369
|
+
for (let tokenIndex = start; tokenIndex < end; tokenIndex++) {
|
|
4471
4370
|
const kind = inlineTokenKind(tokens, tokenIndex);
|
|
4472
4371
|
const tokenStart = inlineTokenStart(tokens, tokenIndex);
|
|
4473
4372
|
if (consumedEnd >= 0 && tokenStart >= consumedEnd) {
|
|
@@ -4479,28 +4378,25 @@ function resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKin
|
|
|
4479
4378
|
if (!consuming && delimiter) {
|
|
4480
4379
|
const run = delimiterRunAt(source, tokens, tokenIndex, delimiter);
|
|
4481
4380
|
if (run) {
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
arena[runIndex - 1].next = runIndex;
|
|
4487
|
-
}
|
|
4488
|
-
arena[runIndex] = run;
|
|
4381
|
+
run.previous = lastRun;
|
|
4382
|
+
if (lastRun) lastRun.next = run;
|
|
4383
|
+
else firstRun = run;
|
|
4384
|
+
lastRun = run;
|
|
4489
4385
|
}
|
|
4490
4386
|
}
|
|
4491
|
-
if (kind >=
|
|
4492
|
-
const frame =
|
|
4493
|
-
|
|
4387
|
+
if (kind >= 4 && kind <= 5) {
|
|
4388
|
+
const frame = nextFrame;
|
|
4389
|
+
nextFrame = frame.next;
|
|
4494
4390
|
rawTop = frame;
|
|
4495
4391
|
if (consuming) {
|
|
4496
|
-
if (consumeFrames)
|
|
4392
|
+
if (consumeFrames) frame.state = 7;
|
|
4497
4393
|
continue;
|
|
4498
4394
|
}
|
|
4499
|
-
|
|
4500
|
-
const state =
|
|
4395
|
+
frame.delimiterBottom = lastRun;
|
|
4396
|
+
const state = frame.state;
|
|
4501
4397
|
const claim = state & 7;
|
|
4502
4398
|
if (claim === 1) {
|
|
4503
|
-
const closeToken =
|
|
4399
|
+
const closeToken = frame.close;
|
|
4504
4400
|
consumedEnd = inlineTokenEnd(tokens, closeToken);
|
|
4505
4401
|
continue;
|
|
4506
4402
|
}
|
|
@@ -4508,38 +4404,38 @@ function resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKin
|
|
|
4508
4404
|
if (state & 16) literalDepth++;
|
|
4509
4405
|
continue;
|
|
4510
4406
|
}
|
|
4511
|
-
if (literalDepth > 0 && !(kind ===
|
|
4512
|
-
|
|
4407
|
+
if (literalDepth > 0 && !(kind === 4)) {
|
|
4408
|
+
frame.state = state | 32;
|
|
4513
4409
|
continue;
|
|
4514
4410
|
}
|
|
4515
|
-
|
|
4411
|
+
frame.logicalParent = logicalTop;
|
|
4516
4412
|
logicalTop = frame;
|
|
4517
4413
|
lastVisibleOpener = tokenIndex;
|
|
4518
4414
|
continue;
|
|
4519
4415
|
}
|
|
4520
|
-
if (kind
|
|
4416
|
+
if (kind !== 68 && kind !== 6) continue;
|
|
4521
4417
|
const rawFrame = rawTop;
|
|
4522
|
-
if (rawFrame
|
|
4418
|
+
if (rawFrame !== void 0) rawTop = rawFrame.parent;
|
|
4523
4419
|
if (consuming) {
|
|
4524
|
-
if (consumeFrames && rawFrame
|
|
4420
|
+
if (consumeFrames && rawFrame !== void 0) rawFrame.state = 7;
|
|
4525
4421
|
continue;
|
|
4526
4422
|
}
|
|
4527
|
-
const rawState = rawFrame
|
|
4423
|
+
const rawState = rawFrame === void 0 ? 0 : rawFrame.state;
|
|
4528
4424
|
const rawClaim = rawState & 7;
|
|
4529
|
-
let
|
|
4530
|
-
if (
|
|
4425
|
+
let scopeFrame = rawClaim >= 1 && rawClaim <= 4 ? rawFrame : void 0;
|
|
4426
|
+
if (scopeFrame === void 0 && (literalDepth <= 0 || rawFrame === void 0 || (rawState & 8) !== 0)) {
|
|
4531
4427
|
const frame = logicalTop;
|
|
4532
|
-
if (frame
|
|
4533
|
-
if (frame
|
|
4534
|
-
const openToken =
|
|
4535
|
-
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;
|
|
4536
4432
|
if (image || openToken + 1 >= inactiveBefore) {
|
|
4537
4433
|
const contentStart = inlineTokenEnd(tokens, openToken);
|
|
4538
4434
|
const contentEnd = tokenStart;
|
|
4539
4435
|
const tokenEnd = inlineTokenEnd(tokens, tokenIndex);
|
|
4540
4436
|
let closeEnd = tokenEnd;
|
|
4541
4437
|
let reference = false;
|
|
4542
|
-
let matched = kind ===
|
|
4438
|
+
let matched = kind === 68;
|
|
4543
4439
|
if (!matched) {
|
|
4544
4440
|
const labelEnd = referenceLabelEnd(source, closeEnd);
|
|
4545
4441
|
if (labelEnd > 0) {
|
|
@@ -4555,10 +4451,11 @@ function resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKin
|
|
|
4555
4451
|
}
|
|
4556
4452
|
}
|
|
4557
4453
|
if (matched) {
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4454
|
+
frame.state = (reference ? 6 : 5) | (image ? 8 : 0);
|
|
4455
|
+
frame.close = tokenIndex;
|
|
4456
|
+
frame.resolvedEnd = closeEnd;
|
|
4457
|
+
rawFrame.closingLink = frame;
|
|
4458
|
+
scopeFrame = frame;
|
|
4562
4459
|
if (!image) inactiveBefore = openToken + 1;
|
|
4563
4460
|
if (closeEnd > tokenEnd) {
|
|
4564
4461
|
consumedEnd = closeEnd;
|
|
@@ -4569,86 +4466,85 @@ function resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKin
|
|
|
4569
4466
|
}
|
|
4570
4467
|
}
|
|
4571
4468
|
if (rawState & 16) literalDepth--;
|
|
4572
|
-
if (
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
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;
|
|
4579
4477
|
}
|
|
4580
4478
|
}
|
|
4581
|
-
if (
|
|
4479
|
+
if (firstRun) replacements = resolveDelimiterScope(firstRun, replacements);
|
|
4582
4480
|
return replacements ?? emptyArray;
|
|
4583
4481
|
}
|
|
4584
|
-
function appendReferenceBoundary(result, tokens,
|
|
4585
|
-
const token =
|
|
4586
|
-
const state =
|
|
4482
|
+
function appendReferenceBoundary(result, tokens, frame, close) {
|
|
4483
|
+
const token = close ? frame.close : frame.open;
|
|
4484
|
+
const state = frame.state;
|
|
4587
4485
|
const kind = ((state & 7) === 6 ? 202 : 198) + (state & 8 ? 2 : 0) + (close ? 1 : 0);
|
|
4588
|
-
const end = close ?
|
|
4486
|
+
const end = close ? frame.resolvedEnd : inlineTokenEnd(tokens, token);
|
|
4589
4487
|
appendInlineToken(result, kind, inlineTokenStart(tokens, token), end, inlineTokenData(tokens, token));
|
|
4590
4488
|
return end;
|
|
4591
4489
|
}
|
|
4592
|
-
function emitResolvedTokens(tokens,
|
|
4593
|
-
const result = [];
|
|
4594
|
-
let rawTop
|
|
4595
|
-
let referenceTop = -1;
|
|
4596
|
-
let frameCursor = frameHeaderSize;
|
|
4490
|
+
function emitResolvedTokens(tokens, nextFrame, replacements, start, end) {
|
|
4491
|
+
const result = start ? tokens.slice(0, start * 4) : [];
|
|
4492
|
+
let rawTop;
|
|
4597
4493
|
let skipEnd = -1;
|
|
4598
|
-
|
|
4599
|
-
for (let tokenIndex = 0; tokenIndex < count; tokenIndex++) {
|
|
4494
|
+
for (let tokenIndex = start; tokenIndex < end; tokenIndex++) {
|
|
4600
4495
|
const kind = inlineTokenKind(tokens, tokenIndex);
|
|
4601
4496
|
const tokenStart = inlineTokenStart(tokens, tokenIndex);
|
|
4602
4497
|
if (skipEnd >= 0 && tokenStart >= skipEnd) skipEnd = -1;
|
|
4603
4498
|
const skipping = skipEnd >= 0;
|
|
4604
|
-
if (kind >=
|
|
4605
|
-
const frame =
|
|
4606
|
-
|
|
4499
|
+
if (kind >= 4 && kind <= 5) {
|
|
4500
|
+
const frame = nextFrame;
|
|
4501
|
+
nextFrame = frame.next;
|
|
4607
4502
|
rawTop = frame;
|
|
4608
|
-
const state =
|
|
4503
|
+
const state = frame.state;
|
|
4609
4504
|
const claim = state & 7;
|
|
4610
4505
|
if (!skipping) {
|
|
4611
4506
|
if (claim === 1) {
|
|
4612
|
-
const closeToken =
|
|
4613
|
-
const start = inlineTokenStart(tokens, tokenIndex) + (kind ===
|
|
4507
|
+
const closeToken = frame.close;
|
|
4508
|
+
const start = inlineTokenStart(tokens, tokenIndex) + (kind === 4 ? 1 : 0);
|
|
4614
4509
|
skipEnd = inlineTokenEnd(tokens, closeToken);
|
|
4615
4510
|
appendInlineToken(result, 133, start, skipEnd);
|
|
4616
4511
|
} else if (claim === 2) {
|
|
4617
|
-
const closeToken =
|
|
4512
|
+
const closeToken = frame.close;
|
|
4618
4513
|
const openEnd = inlineTokenEnd(tokens, tokenIndex);
|
|
4619
4514
|
if (openEnd < inlineTokenStart(tokens, closeToken)) rewriteInlineTokenTail(result, 208, openEnd);
|
|
4620
4515
|
} else if (claim >= 3 && claim <= 4) appendInlineToken(result, 206, inlineTokenStart(tokens, tokenIndex), inlineTokenEnd(tokens, tokenIndex));
|
|
4621
|
-
else if (claim === 5 || claim === 6)
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
referenceTop = frame;
|
|
4625
|
-
} else if (claim === 7) skipEnd = inlineTokenEnd(tokens, frames[frame + 1]);
|
|
4626
|
-
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);
|
|
4627
4519
|
}
|
|
4628
4520
|
continue;
|
|
4629
4521
|
}
|
|
4630
|
-
if (kind
|
|
4522
|
+
if (kind === 68 || kind === 6) {
|
|
4631
4523
|
const rawFrame = rawTop;
|
|
4632
|
-
if (rawFrame
|
|
4633
|
-
const
|
|
4634
|
-
|
|
4635
|
-
if (
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
skipEnd = appendReferenceBoundary(result, tokens, frames, referenceFrame, true);
|
|
4639
|
-
} else if (rawFrame >= 0) {
|
|
4640
|
-
const state = frames[rawFrame + 5];
|
|
4641
|
-
const claim = state & 7;
|
|
4642
|
-
if (claim === 2) {
|
|
4643
|
-
const openToken = frames[rawFrame + 0];
|
|
4644
|
-
if (inlineTokenEnd(tokens, openToken) < tokenStart) appendInlineToken(result, 209, tokenStart, tokenStart + 1);
|
|
4645
|
-
} else if (claim >= 3 && claim <= 4) appendInlineToken(result, 207, tokenStart, tokenStart + 1);
|
|
4646
|
-
else if (claim !== 1 && !(state & 32)) appendResolvedDelimiterToken(result, tokens, tokenIndex, replacements);
|
|
4647
|
-
} 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;
|
|
4648
4530
|
}
|
|
4649
|
-
|
|
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);
|
|
4650
4547
|
}
|
|
4651
|
-
if (!skipping) appendResolvedDelimiterToken(result, tokens, tokenIndex, replacements);
|
|
4652
4548
|
}
|
|
4653
4549
|
return result;
|
|
4654
4550
|
}
|
|
@@ -4656,33 +4552,30 @@ function compileInlineResolver(options) {
|
|
|
4656
4552
|
return (delimiterConfigs) => {
|
|
4657
4553
|
const delimiterByKind = compileDelimiterConfigs(delimiterConfigs);
|
|
4658
4554
|
return (source, tokens, definitions) => {
|
|
4659
|
-
let
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
const frames = analyzeBrackets(source, tokens, definitions, options);
|
|
4666
|
-
const replacements = resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKind);
|
|
4667
|
-
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);
|
|
4668
4561
|
};
|
|
4669
4562
|
};
|
|
4670
4563
|
}
|
|
4671
4564
|
// src/profile/index.ts
|
|
4672
4565
|
function compileProfile(options = {}) {
|
|
4673
4566
|
const features = [
|
|
4674
|
-
feature$
|
|
4567
|
+
feature$8,
|
|
4675
4568
|
feature$15,
|
|
4676
4569
|
feature$16,
|
|
4677
4570
|
feature$4(options.taskList),
|
|
4678
4571
|
feature$14,
|
|
4679
|
-
feature$
|
|
4572
|
+
feature$7
|
|
4680
4573
|
];
|
|
4681
4574
|
if (options.footnote) features.push(feature$10);
|
|
4682
4575
|
if (options.frontmatter) features.unshift(feature$13(typeof options.frontmatter === "object" ? options.frontmatter.marker : "-"));
|
|
4683
4576
|
if (options.table) features.push(feature);
|
|
4684
4577
|
if (options.math) features.push(feature$3(options.math));
|
|
4685
|
-
features.push(feature$2, feature$
|
|
4578
|
+
features.push(feature$2, feature$6, feature$9(options.strikethrough), feature$5);
|
|
4686
4579
|
if (options.attributes) features.push(feature$18);
|
|
4687
4580
|
if (options.binding) features.push(feature$17);
|
|
4688
4581
|
if (options.emoji) features.push(feature$11);
|