satorigear 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -12
- package/dist/index.d.mts +10 -24
- package/dist/index.mjs +111 -171
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,11 +65,12 @@ const mdast = document.tree;
|
|
|
65
65
|
|
|
66
66
|
## Performance
|
|
67
67
|
|
|
68
|
-
Benchmarked against Sätteri <sup>0.
|
|
68
|
+
Benchmarked against Sätteri <sup>0.11.6</sup> and Remark (`mdast-util-from-markdown@2.0.3`), which also produce MDAST, with feature sets kept as equivalent as possible for each profile.
|
|
69
69
|
|
|
70
70
|
<!-- benchmark:start environment -->
|
|
71
71
|
|
|
72
|
-
> Median of 4 isolated mean-time runs at commit [`
|
|
72
|
+
> Median of 4 isolated mean-time runs at commit [`5775eef`](https://github.com/KazariEX/satorigear/commit/5775eefff0cf3351a7fe26b3a2a4fff1f9bb83b9) on Apple M3, node 26.5.0, arm64-darwin.
|
|
73
|
+
> SatoriGear and Sätteri run in paired AB/BA order; comparisons are normalized to SatoriGear (↑ faster, ↓ slower). Lower time and higher throughput are better.
|
|
73
74
|
|
|
74
75
|
<!-- benchmark:end -->
|
|
75
76
|
|
|
@@ -81,17 +82,17 @@ Benchmarked against Sätteri <sup>0.10.5</sup> and Remark (`mdast-util-from-mark
|
|
|
81
82
|
|
|
82
83
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
83
84
|
| --- | ---: | ---: | ---: |
|
|
84
|
-
| **SatoriGear** |
|
|
85
|
-
| Sätteri |
|
|
86
|
-
| Remark |
|
|
85
|
+
| **SatoriGear** | 869 µs | baseline | 225 MiB/s |
|
|
86
|
+
| Sätteri | 916 µs | ↓ 1.05× | 214 MiB/s |
|
|
87
|
+
| Remark | 60.6 ms | ↓ 69.75× | 3.23 MiB/s |
|
|
87
88
|
|
|
88
89
|
#### CommonMark 0.31.2 examples, 14919 bytes, 652 documents
|
|
89
90
|
|
|
90
91
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
91
92
|
| --- | ---: | ---: | ---: |
|
|
92
|
-
| **SatoriGear** |
|
|
93
|
-
| Sätteri |
|
|
94
|
-
| Remark | 25.
|
|
93
|
+
| **SatoriGear** | 521 µs | baseline | 27.3 MiB/s |
|
|
94
|
+
| Sätteri | 1.42 ms | ↓ 2.72× | 10.0 MiB/s |
|
|
95
|
+
| Remark | 25.2 ms | ↓ 48.44× | 0.56 MiB/s |
|
|
95
96
|
|
|
96
97
|
### Built-in features
|
|
97
98
|
|
|
@@ -99,14 +100,14 @@ Benchmarked against Sätteri <sup>0.10.5</sup> and Remark (`mdast-util-from-mark
|
|
|
99
100
|
|
|
100
101
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
101
102
|
| --- | ---: | ---: | ---: |
|
|
102
|
-
| **SatoriGear** | 12.9 ms | baseline | 67.
|
|
103
|
-
| Sätteri |
|
|
103
|
+
| **SatoriGear** | 12.9 ms | baseline | 67.5 MiB/s |
|
|
104
|
+
| Sätteri | 12.7 ms | ↑ 1.01× | 68.4 MiB/s |
|
|
104
105
|
|
|
105
106
|
#### Public APIs README, 232580 bytes, 1 document
|
|
106
107
|
|
|
107
108
|
| Engine | Mean time | vs. SatoriGear | Throughput |
|
|
108
109
|
| --- | ---: | ---: | ---: |
|
|
109
|
-
| **SatoriGear** |
|
|
110
|
-
| Sätteri | 3.
|
|
110
|
+
| **SatoriGear** | 2.82 ms | baseline | 78.8 MiB/s |
|
|
111
|
+
| Sätteri | 3.30 ms | ↓ 1.17× | 67.2 MiB/s |
|
|
111
112
|
|
|
112
113
|
<!-- benchmark:end -->
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Literal, Node, PhrasingContent, Root, RootContent } from "mdast";
|
|
2
|
-
//#region src/source-view.d.ts
|
|
3
2
|
interface SourceSpan {
|
|
4
3
|
end: number;
|
|
5
4
|
start: number;
|
|
6
5
|
}
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/document.d.ts
|
|
9
6
|
interface TextEdit extends SourceSpan {
|
|
10
7
|
text: string;
|
|
11
8
|
}
|
|
@@ -18,19 +15,13 @@ interface Document {
|
|
|
18
15
|
readonly tree: Root;
|
|
19
16
|
edit: (edits: readonly TextEdit[]) => EditResult;
|
|
20
17
|
}
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/profile/features/formatting.d.ts
|
|
23
18
|
interface StrikethroughOptions {
|
|
24
19
|
singleTilde?: boolean;
|
|
25
20
|
}
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/profile/features/frontmatter.d.ts
|
|
28
21
|
type FrontmatterMarker = "+" | "-";
|
|
29
22
|
interface FrontmatterOptions {
|
|
30
23
|
marker: FrontmatterMarker;
|
|
31
24
|
}
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/profile/features/math/types.d.ts
|
|
34
25
|
interface MathOptions {
|
|
35
26
|
singleDollarTextMath?: boolean;
|
|
36
27
|
}
|
|
@@ -53,8 +44,6 @@ declare module "mdast" {
|
|
|
53
44
|
math: Math;
|
|
54
45
|
}
|
|
55
46
|
}
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/profile/index.d.ts
|
|
58
47
|
interface FeatureOptions {
|
|
59
48
|
attributes?: boolean;
|
|
60
49
|
binding?: boolean;
|
|
@@ -67,18 +56,14 @@ interface FeatureOptions {
|
|
|
67
56
|
table?: boolean;
|
|
68
57
|
taskList?: boolean;
|
|
69
58
|
}
|
|
70
|
-
|
|
71
|
-
//#region src/parser.d.ts
|
|
72
|
-
interface Parser {
|
|
59
|
+
export interface Parser {
|
|
73
60
|
createDocument: (source: string) => Document;
|
|
74
61
|
parse: (source: string) => Root;
|
|
75
62
|
}
|
|
76
|
-
interface ParserOptions {
|
|
63
|
+
export interface ParserOptions {
|
|
77
64
|
features?: FeatureOptions;
|
|
78
65
|
}
|
|
79
|
-
declare function createParser(options?: ParserOptions): Parser;
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/profile/features/attributes/types.d.ts
|
|
66
|
+
export declare function createParser(options?: ParserOptions): Parser;
|
|
82
67
|
type AttributeValue = string | number | boolean | null | AttributeValue[] | {
|
|
83
68
|
[key: string]: AttributeValue;
|
|
84
69
|
};
|
|
@@ -88,8 +73,6 @@ declare module "mdast" {
|
|
|
88
73
|
attributes?: Attributes;
|
|
89
74
|
}
|
|
90
75
|
}
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region src/profile/features/component/types.d.ts
|
|
93
76
|
interface BlockComponent extends Node {
|
|
94
77
|
type: "blockComponent";
|
|
95
78
|
name: string;
|
|
@@ -114,8 +97,6 @@ declare module "mdast" {
|
|
|
114
97
|
inlineComponent: InlineComponent;
|
|
115
98
|
}
|
|
116
99
|
}
|
|
117
|
-
//#endregion
|
|
118
|
-
//#region src/profile/features/emoji/types.d.ts
|
|
119
100
|
interface Emoji extends Literal {
|
|
120
101
|
type: "emoji";
|
|
121
102
|
/** Complete shortcode source, including both colons. */
|
|
@@ -129,5 +110,10 @@ declare module "mdast" {
|
|
|
129
110
|
emoji: Emoji;
|
|
130
111
|
}
|
|
131
112
|
}
|
|
132
|
-
|
|
133
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Fast replacement of [`micromark-util-normalize-identifier`](
|
|
115
|
+
* https://github.com/micromark/micromark/tree/main/packages/micromark-util-normalize-identifier
|
|
116
|
+
* ).
|
|
117
|
+
*/
|
|
118
|
+
export declare function normalizeIdentifier(identifier: string): string;
|
|
119
|
+
export type { AttributeValue, Attributes, BlockComponent, Document, EditResult, Emoji, FeatureOptions, FrontmatterMarker, FrontmatterOptions, InlineComponent, InlineMath, Math, MathOptions, StrikethroughOptions, TextEdit };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decodeString } from "micromark-util-decode-string";
|
|
2
2
|
import { htmlBlockNames, htmlRawNames } from "micromark-util-html-tag-name";
|
|
3
|
-
|
|
3
|
+
// src/block/lines.ts
|
|
4
4
|
var BlockLines = class BlockLines {
|
|
5
5
|
#fields;
|
|
6
6
|
#length = 0;
|
|
@@ -12,7 +12,7 @@ var BlockLines = class BlockLines {
|
|
|
12
12
|
this.#sourceLength = sourceLength;
|
|
13
13
|
this.#fields = new Int32Array(lineCapacity * 4);
|
|
14
14
|
}
|
|
15
|
-
static from(source, start
|
|
15
|
+
static from(source, start, limit) {
|
|
16
16
|
const sourceLength = source.length;
|
|
17
17
|
if (start > 0 || limit < sourceLength) source = source.slice(start, limit);
|
|
18
18
|
const lines = new BlockLines(sourceLength, Math.min(source.length + 15 >>> 4, 16384));
|
|
@@ -132,7 +132,7 @@ var BlockLines = class BlockLines {
|
|
|
132
132
|
physicallyContiguous() {
|
|
133
133
|
return this.#sourceLength > 0;
|
|
134
134
|
}
|
|
135
|
-
push(start, end, next, prefixColumns
|
|
135
|
+
push(start, end, next, prefixColumns, lazy) {
|
|
136
136
|
const field = this.#length * 4;
|
|
137
137
|
let fields = this.#fields;
|
|
138
138
|
if (field >= fields.length) {
|
|
@@ -338,12 +338,10 @@ function logicalLine(source, lines, index) {
|
|
|
338
338
|
}
|
|
339
339
|
return result + source.slice(offset, lines.next(index));
|
|
340
340
|
}
|
|
341
|
-
|
|
342
|
-
//#region src/primitives.ts
|
|
341
|
+
// src/primitives.ts
|
|
343
342
|
const emptyArray = [];
|
|
344
343
|
const emptySet = new Set();
|
|
345
|
-
|
|
346
|
-
//#region src/block/tokens.ts
|
|
344
|
+
// src/block/tokens.ts
|
|
347
345
|
function copyMetadata(target, source, start, end, targetStart) {
|
|
348
346
|
end = Math.min(end, source.length);
|
|
349
347
|
for (let read = start, write = targetStart; read < end; read++, write++) {
|
|
@@ -549,9 +547,7 @@ var BlockTokenStream = class {
|
|
|
549
547
|
return this.#position(this.#fields[index * 4 + 2]);
|
|
550
548
|
}
|
|
551
549
|
contentEnd(source, index) {
|
|
552
|
-
|
|
553
|
-
const last = source.charCodeAt(end - 1);
|
|
554
|
-
return last === 10 ? end - (source.charCodeAt(end - 2) === 13 ? 2 : 1) : last === 13 ? end - 1 : end;
|
|
550
|
+
return lineContentEnd(source, this.start(index), this.end(index));
|
|
555
551
|
}
|
|
556
552
|
text(source, index) {
|
|
557
553
|
return this.#metadata?.[index]?.text ?? source.slice(this.start(index), this.end(index));
|
|
@@ -615,8 +611,7 @@ function appendLogicalToken(out, kind, source, lines, start, end, value) {
|
|
|
615
611
|
value
|
|
616
612
|
});
|
|
617
613
|
}
|
|
618
|
-
|
|
619
|
-
//#region src/block/scanner.ts
|
|
614
|
+
// src/block/scanner.ts
|
|
620
615
|
function sameShiftedBlock(previous, record, next, tokenStart, tokenEnd, delta) {
|
|
621
616
|
const length = previous.nodeLength(record.tokenStart);
|
|
622
617
|
if (length !== tokenEnd - tokenStart) return false;
|
|
@@ -688,7 +683,7 @@ var BlockScanContext = class {
|
|
|
688
683
|
const lineStart = index;
|
|
689
684
|
const tokenStart = out.length;
|
|
690
685
|
index = profile.dispatch(source, lines, index, contentOffset, out, this);
|
|
691
|
-
if (visit(lineStart, index, tokenStart, out.length)) return;
|
|
686
|
+
if (visit?.(lineStart, index, tokenStart, out.length)) return;
|
|
692
687
|
}
|
|
693
688
|
}
|
|
694
689
|
scanLines(source, lines, out) {
|
|
@@ -720,14 +715,18 @@ var BlockScanner = class {
|
|
|
720
715
|
this.#context = new BlockScanContext(profile);
|
|
721
716
|
this.builds = profile.builds;
|
|
722
717
|
}
|
|
723
|
-
scan(source) {
|
|
718
|
+
scan(source, indexed) {
|
|
724
719
|
const lines = this.#lines.scan(source);
|
|
720
|
+
const context = this.#context;
|
|
725
721
|
const tokens = this.#tokens;
|
|
722
|
+
context.resetLookahead();
|
|
726
723
|
tokens.reset(source.length);
|
|
724
|
+
if (!indexed) {
|
|
725
|
+
context.scanBlockLines(source, lines, tokens);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
727
728
|
const records = this.#records;
|
|
728
|
-
const context = this.#context;
|
|
729
729
|
let recordIndex = 0;
|
|
730
|
-
context.resetLookahead();
|
|
731
730
|
context.scanBlockLines(source, lines, tokens, (lineStart, lineEnd, tokenStart) => {
|
|
732
731
|
const end = lines.next(lineEnd - 1);
|
|
733
732
|
const dependencyEnd = Math.max(end, context.consumeLookahead());
|
|
@@ -843,8 +842,7 @@ var BlockScanner = class {
|
|
|
843
842
|
};
|
|
844
843
|
}
|
|
845
844
|
};
|
|
846
|
-
|
|
847
|
-
//#region src/fragment/block.ts
|
|
845
|
+
// src/fragment/block.ts
|
|
848
846
|
function blockEnd(tokenStart, context) {
|
|
849
847
|
const tokens = context.structure.tokens;
|
|
850
848
|
const close = tokenStart + tokens.nodeLength(tokenStart) - 1;
|
|
@@ -881,8 +879,7 @@ function buildBlockChildren(tokenStart, context) {
|
|
|
881
879
|
}
|
|
882
880
|
return children;
|
|
883
881
|
}
|
|
884
|
-
|
|
885
|
-
//#region src/source-view.ts
|
|
882
|
+
// src/source-view.ts
|
|
886
883
|
function containingSegment(segments, offset) {
|
|
887
884
|
let low = 0;
|
|
888
885
|
let high = segments.length >>> 1;
|
|
@@ -946,8 +943,7 @@ var SourceView = class {
|
|
|
946
943
|
for (let index = 0; index < segments.length; index += 2) segments[index] += delta;
|
|
947
944
|
}
|
|
948
945
|
};
|
|
949
|
-
|
|
950
|
-
//#region src/inline/region.ts
|
|
946
|
+
// src/inline/region.ts
|
|
951
947
|
const definitionAny = Symbol();
|
|
952
948
|
var TrackedDefinitionLookup = class {
|
|
953
949
|
definitions;
|
|
@@ -1118,8 +1114,7 @@ var InlineRegionCursor = class {
|
|
|
1118
1114
|
return region;
|
|
1119
1115
|
}
|
|
1120
1116
|
};
|
|
1121
|
-
|
|
1122
|
-
//#region src/document.ts
|
|
1117
|
+
// src/document.ts
|
|
1123
1118
|
function applyEdits(source, edits) {
|
|
1124
1119
|
const parts = [];
|
|
1125
1120
|
let cursor = 0;
|
|
@@ -1169,7 +1164,7 @@ var DocumentImpl = class {
|
|
|
1169
1164
|
this.#profile = profile;
|
|
1170
1165
|
this.#source = source;
|
|
1171
1166
|
this.#blockScanner = new BlockScanner(profile.block);
|
|
1172
|
-
this.#blockScanner.scan(source);
|
|
1167
|
+
this.#blockScanner.scan(source, true);
|
|
1173
1168
|
this.#regionState = new InlineRegionState(profile.inline, this.#blockScanner);
|
|
1174
1169
|
this.#updateTree(this.#regionState.update(source));
|
|
1175
1170
|
}
|
|
@@ -1267,9 +1262,9 @@ var DocumentImpl = class {
|
|
|
1267
1262
|
source
|
|
1268
1263
|
};
|
|
1269
1264
|
const start = locator.locationAt(0);
|
|
1270
|
-
const
|
|
1271
|
-
const children =
|
|
1272
|
-
for (let
|
|
1265
|
+
const tokens = blockScanner.tokens;
|
|
1266
|
+
const children = [];
|
|
1267
|
+
for (let token = 0; token < tokens.length; token += tokens.nodeLength(token)) children.push(buildBlockNode(token, context));
|
|
1273
1268
|
return {
|
|
1274
1269
|
type: "root",
|
|
1275
1270
|
children,
|
|
@@ -1280,8 +1275,7 @@ var DocumentImpl = class {
|
|
|
1280
1275
|
};
|
|
1281
1276
|
}
|
|
1282
1277
|
};
|
|
1283
|
-
|
|
1284
|
-
//#region src/block/profile.ts
|
|
1278
|
+
// src/block/profile.ts
|
|
1285
1279
|
function generateBlockDispatch(starts, fallbacks) {
|
|
1286
1280
|
try {
|
|
1287
1281
|
const resolvers = [];
|
|
@@ -1352,8 +1346,7 @@ function compileBlockProfile(features) {
|
|
|
1352
1346
|
lazyContinuationUnwrappers
|
|
1353
1347
|
};
|
|
1354
1348
|
}
|
|
1355
|
-
|
|
1356
|
-
//#region src/inline/lexer.ts
|
|
1349
|
+
// src/inline/lexer.ts
|
|
1357
1350
|
const tokenizerFactories = new Map();
|
|
1358
1351
|
function matchInlinePatternEnd(pattern, source, start) {
|
|
1359
1352
|
pattern.lastIndex = start;
|
|
@@ -1439,10 +1432,9 @@ function compileInlineTokenizer(rules) {
|
|
|
1439
1432
|
return (source) => tokenize(source, textBoundary, scannerByCode);
|
|
1440
1433
|
}
|
|
1441
1434
|
}
|
|
1442
|
-
|
|
1443
|
-
//#region src/inline/profile.ts
|
|
1435
|
+
// src/inline/profile.ts
|
|
1444
1436
|
function compileInlineProfile(features, compileInlineResolver) {
|
|
1445
|
-
const
|
|
1437
|
+
const builders = [];
|
|
1446
1438
|
const delimiters = [];
|
|
1447
1439
|
const scanRules = [];
|
|
1448
1440
|
for (const feature of features) {
|
|
@@ -1452,21 +1444,20 @@ function compileInlineProfile(features, compileInlineResolver) {
|
|
|
1452
1444
|
if (!build) continue;
|
|
1453
1445
|
for (const rule of build) switch (rule.kind) {
|
|
1454
1446
|
case "decorate":
|
|
1455
|
-
|
|
1447
|
+
builders[rule.token] = rule.apply;
|
|
1456
1448
|
break;
|
|
1457
1449
|
case "leaf":
|
|
1458
1450
|
case "text":
|
|
1459
|
-
case "pair":
|
|
1451
|
+
case "pair": builders[rule.token] = rule.build;
|
|
1460
1452
|
}
|
|
1461
1453
|
}
|
|
1462
1454
|
return {
|
|
1463
|
-
|
|
1455
|
+
builders,
|
|
1464
1456
|
resolve: compileInlineResolver(delimiters),
|
|
1465
1457
|
tokenize: compileInlineTokenizer(scanRules)
|
|
1466
1458
|
};
|
|
1467
1459
|
}
|
|
1468
|
-
|
|
1469
|
-
//#region src/profile/features/attributes/block.ts
|
|
1460
|
+
// src/profile/features/attributes/block.ts
|
|
1470
1461
|
const blockDecorators = [{
|
|
1471
1462
|
token: [65, 66],
|
|
1472
1463
|
decorate(build) {
|
|
@@ -1496,8 +1487,7 @@ const blockDecorators = [{
|
|
|
1496
1487
|
};
|
|
1497
1488
|
}
|
|
1498
1489
|
}];
|
|
1499
|
-
|
|
1500
|
-
//#region src/inline/tokens.ts
|
|
1490
|
+
// src/inline/tokens.ts
|
|
1501
1491
|
function inlineTokenCount(tokens) {
|
|
1502
1492
|
return tokens.length / 4;
|
|
1503
1493
|
}
|
|
@@ -1531,14 +1521,16 @@ function copyInlineToken(target, tokens, index) {
|
|
|
1531
1521
|
const offset = index * 4;
|
|
1532
1522
|
target.push(tokens[offset], tokens[offset + 1], tokens[offset + 2], tokens[offset + 3]);
|
|
1533
1523
|
}
|
|
1534
|
-
|
|
1535
|
-
//#region src/profile/utils.ts
|
|
1524
|
+
// src/profile/utils.ts
|
|
1536
1525
|
const inlineColonBoundary = /[ \t\n\r\p{sc=Han}\p{sc=Hira}\p{sc=Kana}\p{sc=Hang}\p{P}]/u;
|
|
1526
|
+
function isAsciiDigit(code) {
|
|
1527
|
+
return code >= 48 && code <= 57;
|
|
1528
|
+
}
|
|
1537
1529
|
function isAsciiLetter(code) {
|
|
1538
1530
|
return code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
1539
1531
|
}
|
|
1540
|
-
function
|
|
1541
|
-
return code >=
|
|
1532
|
+
function isAsciiPunctuation(code) {
|
|
1533
|
+
return code >= 33 && code <= 47 || code >= 58 && code <= 64 || code >= 91 && code <= 96 || code >= 123 && code <= 126;
|
|
1542
1534
|
}
|
|
1543
1535
|
function isMarkdownWhitespace(code) {
|
|
1544
1536
|
return code === 9 || code === 10 || code === 13 || code === 32;
|
|
@@ -1551,24 +1543,23 @@ function hasInlineColonBoundary(source, start) {
|
|
|
1551
1543
|
function semanticText(value) {
|
|
1552
1544
|
return value.includes("\\") || value.includes("&") ? decodeString(value) : value;
|
|
1553
1545
|
}
|
|
1554
|
-
function
|
|
1546
|
+
function normalizeIdentifier(identifier) {
|
|
1555
1547
|
scan: {
|
|
1556
1548
|
let hasUppercase = false;
|
|
1557
|
-
for (let index = 0; index <
|
|
1558
|
-
const code =
|
|
1549
|
+
for (let index = 0; index < identifier.length; index++) {
|
|
1550
|
+
const code = identifier.charCodeAt(index);
|
|
1559
1551
|
if (code === 32) {
|
|
1560
|
-
if (index === 0 || index + 1 ===
|
|
1552
|
+
if (index === 0 || index + 1 === identifier.length || identifier.charCodeAt(index + 1) === 32) break scan;
|
|
1561
1553
|
continue;
|
|
1562
1554
|
}
|
|
1563
1555
|
if (code < 32 || code > 126) break scan;
|
|
1564
1556
|
if (code >= 65 && code <= 90) hasUppercase = true;
|
|
1565
1557
|
}
|
|
1566
|
-
return hasUppercase ?
|
|
1558
|
+
return hasUppercase ? identifier.toLowerCase() : identifier;
|
|
1567
1559
|
}
|
|
1568
|
-
return
|
|
1560
|
+
return identifier.trim().replace(/[ \t\r\n]+/g, " ").toLowerCase().toUpperCase().toLowerCase();
|
|
1569
1561
|
}
|
|
1570
|
-
|
|
1571
|
-
//#region src/profile/features/attributes/shared.ts
|
|
1562
|
+
// src/profile/features/attributes/shared.ts
|
|
1572
1563
|
const brackets = {
|
|
1573
1564
|
"[": "]",
|
|
1574
1565
|
"{": "}",
|
|
@@ -1685,8 +1676,7 @@ function parseAttributes(source, start) {
|
|
|
1685
1676
|
scanAttributes(source, start, attributes);
|
|
1686
1677
|
return attributes;
|
|
1687
1678
|
}
|
|
1688
|
-
|
|
1689
|
-
//#region src/profile/features/attributes/inline.ts
|
|
1679
|
+
// src/profile/features/attributes/inline.ts
|
|
1690
1680
|
function hasVisibleText(source, start, end) {
|
|
1691
1681
|
for (let offset = start; offset < end; offset++) if (!isMarkdownWhitespace(source.charCodeAt(offset))) return true;
|
|
1692
1682
|
return false;
|
|
@@ -1694,8 +1684,7 @@ function hasVisibleText(source, start, end) {
|
|
|
1694
1684
|
function attributeEndAt(source, start) {
|
|
1695
1685
|
return source[start + 1] === "{" || source[start - 1] === "{" || source[start - 1] === "$" ? void 0 : attributesEnd(source, start);
|
|
1696
1686
|
}
|
|
1697
|
-
|
|
1698
|
-
//#region src/profile/features/attributes/index.ts
|
|
1687
|
+
// src/profile/features/attributes/index.ts
|
|
1699
1688
|
const feature$18 = {
|
|
1700
1689
|
block: { decorators: blockDecorators },
|
|
1701
1690
|
inline: {
|
|
@@ -1754,8 +1743,7 @@ const feature$18 = {
|
|
|
1754
1743
|
}]
|
|
1755
1744
|
}
|
|
1756
1745
|
};
|
|
1757
|
-
|
|
1758
|
-
//#region src/profile/features/binding.ts
|
|
1746
|
+
// src/profile/features/binding.ts
|
|
1759
1747
|
const feature$17 = { inline: {
|
|
1760
1748
|
scans: [{
|
|
1761
1749
|
marker: 123,
|
|
@@ -1794,8 +1782,7 @@ const feature$17 = { inline: {
|
|
|
1794
1782
|
}
|
|
1795
1783
|
}]
|
|
1796
1784
|
} };
|
|
1797
|
-
|
|
1798
|
-
//#region src/profile/features/blockquote.ts
|
|
1785
|
+
// src/profile/features/blockquote.ts
|
|
1799
1786
|
function blockQuoteOffset(source, lines, index, markerOffset) {
|
|
1800
1787
|
if (markerOffset < 0 || source[markerOffset] !== ">") return;
|
|
1801
1788
|
let offset = markerOffset + 1;
|
|
@@ -1861,8 +1848,7 @@ const feature$16 = { block: {
|
|
|
1861
1848
|
}
|
|
1862
1849
|
}]
|
|
1863
1850
|
} };
|
|
1864
|
-
|
|
1865
|
-
//#region src/profile/features/break.ts
|
|
1851
|
+
// src/profile/features/break.ts
|
|
1866
1852
|
function isThematicBreak(source, lines, index, contentOffset) {
|
|
1867
1853
|
const marker = source.charCodeAt(contentOffset);
|
|
1868
1854
|
if (marker !== 42 && marker !== 45 && marker !== 95) return false;
|
|
@@ -1912,9 +1898,8 @@ const feature$15 = {
|
|
|
1912
1898
|
}
|
|
1913
1899
|
}] }
|
|
1914
1900
|
};
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
function fenceAt$1(source, lines, index, rule, markerOffset) {
|
|
1901
|
+
// src/block/fence.ts
|
|
1902
|
+
function fenceAt(source, lines, index, rule, markerOffset) {
|
|
1918
1903
|
const marker = source.charCodeAt(markerOffset);
|
|
1919
1904
|
if (marker !== rule.marker && marker !== rule.alternateMarker) return;
|
|
1920
1905
|
let offset = markerOffset + 1;
|
|
@@ -2005,8 +1990,7 @@ function sourceColumnFenceContent(source, block) {
|
|
|
2005
1990
|
}
|
|
2006
1991
|
return content;
|
|
2007
1992
|
}
|
|
2008
|
-
|
|
2009
|
-
//#region src/profile/features/code.ts
|
|
1993
|
+
// src/profile/features/code.ts
|
|
2010
1994
|
const codeFenceRule = {
|
|
2011
1995
|
alternateMarker: 126,
|
|
2012
1996
|
forbiddenInfoMarker: 96,
|
|
@@ -2014,7 +1998,7 @@ const codeFenceRule = {
|
|
|
2014
1998
|
minimumLength: 3
|
|
2015
1999
|
};
|
|
2016
2000
|
function codeFenceAt(source, lines, index, markerOffset) {
|
|
2017
|
-
return fenceAt
|
|
2001
|
+
return fenceAt(source, lines, index, codeFenceRule, markerOffset);
|
|
2018
2002
|
}
|
|
2019
2003
|
const feature$14 = {
|
|
2020
2004
|
block: {
|
|
@@ -2116,8 +2100,7 @@ const feature$14 = {
|
|
|
2116
2100
|
}]
|
|
2117
2101
|
}
|
|
2118
2102
|
};
|
|
2119
|
-
|
|
2120
|
-
//#region src/fragment/inline.ts
|
|
2103
|
+
// src/fragment/inline.ts
|
|
2121
2104
|
function createInlineOutput(children, cursor) {
|
|
2122
2105
|
return {
|
|
2123
2106
|
children,
|
|
@@ -2173,7 +2156,7 @@ function finishText(output, context) {
|
|
|
2173
2156
|
function appendGap(output, context, start, end) {
|
|
2174
2157
|
appendText(output, context.view.text.slice(start, end), context.view.mapOffset(start), context.view.mapEnd(end), context);
|
|
2175
2158
|
}
|
|
2176
|
-
function
|
|
2159
|
+
function appendLeaf(output, context, token, start, end, build) {
|
|
2177
2160
|
if (start > output.cursor) appendGap(output, context, output.cursor, start);
|
|
2178
2161
|
const sourceStart = context.view.mapOffset(start);
|
|
2179
2162
|
const sourceEnd = start === end ? sourceStart : context.view.mapEnd(end);
|
|
@@ -2190,7 +2173,7 @@ function appendRange(startToken, endToken, profile, context, output, closeKind =
|
|
|
2190
2173
|
const lineStart = inlineTokenData(context.tokens, index);
|
|
2191
2174
|
const contentStart = inlineTokenEnd(context.tokens, index);
|
|
2192
2175
|
if (endingStart > output.cursor) appendGap(output, context, output.cursor, endingStart);
|
|
2193
|
-
const previous = output.children.at(-1);
|
|
2176
|
+
const previous = output.lastText === void 0 ? output.children.at(-1) : void 0;
|
|
2194
2177
|
if (previous?.type === "break") previous.position.end = context.locator.locationAt(context.view.mapOffset(lineStart - 1) + 1);
|
|
2195
2178
|
else {
|
|
2196
2179
|
trimTrailingText(output);
|
|
@@ -2201,7 +2184,7 @@ function appendRange(startToken, endToken, profile, context, output, closeKind =
|
|
|
2201
2184
|
continue;
|
|
2202
2185
|
}
|
|
2203
2186
|
if (kind === closeKind) break;
|
|
2204
|
-
const build = profile.
|
|
2187
|
+
const build = profile.builders[kind];
|
|
2205
2188
|
const childStart = inlineTokenStart(context.tokens, index);
|
|
2206
2189
|
if (kind < 192) {
|
|
2207
2190
|
const childEnd = inlineTokenEnd(context.tokens, index);
|
|
@@ -2209,7 +2192,7 @@ function appendRange(startToken, endToken, profile, context, output, closeKind =
|
|
|
2209
2192
|
if (childStart > output.cursor) appendGap(output, context, output.cursor, childStart);
|
|
2210
2193
|
const sourceStart = context.view.mapOffset(childStart);
|
|
2211
2194
|
appendText(output, build(index, context), sourceStart, childStart === childEnd ? sourceStart : context.view.mapEnd(childEnd), context);
|
|
2212
|
-
} else
|
|
2195
|
+
} else appendLeaf(output, context, index, childStart, childEnd, build);
|
|
2213
2196
|
output.cursor = childEnd;
|
|
2214
2197
|
index++;
|
|
2215
2198
|
continue;
|
|
@@ -2217,7 +2200,7 @@ function appendRange(startToken, endToken, profile, context, output, closeKind =
|
|
|
2217
2200
|
if (kind < 256) {
|
|
2218
2201
|
if (childStart > output.cursor) appendGap(output, context, output.cursor, childStart);
|
|
2219
2202
|
finishText(output, context);
|
|
2220
|
-
index =
|
|
2203
|
+
index = appendPair(index, endToken, profile, context, output, build, kind + 1);
|
|
2221
2204
|
continue;
|
|
2222
2205
|
}
|
|
2223
2206
|
const childEnd = inlineTokenEnd(context.tokens, index);
|
|
@@ -2234,14 +2217,12 @@ function appendRange(startToken, endToken, profile, context, output, closeKind =
|
|
|
2234
2217
|
}
|
|
2235
2218
|
index++;
|
|
2236
2219
|
}
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
if (contentEnd > output.cursor) appendGap(output, context, output.cursor, contentEnd);
|
|
2240
|
-
} else if (context.view.text.length > output.cursor) appendGap(output, context, output.cursor, context.view.text.length);
|
|
2220
|
+
const contentEnd = index < endToken ? inlineTokenStart(context.tokens, index) : context.view.text.length;
|
|
2221
|
+
if (contentEnd > output.cursor) appendGap(output, context, output.cursor, contentEnd);
|
|
2241
2222
|
finishText(output, context);
|
|
2242
2223
|
return index;
|
|
2243
2224
|
}
|
|
2244
|
-
function
|
|
2225
|
+
function appendPair(openToken, endToken, profile, context, output, build, closeKind) {
|
|
2245
2226
|
const childStart = inlineTokenStart(context.tokens, openToken);
|
|
2246
2227
|
const positionStart = context.locator.locationAt(context.view.mapOffset(childStart));
|
|
2247
2228
|
const children = [];
|
|
@@ -2293,8 +2274,7 @@ function buildInlineFragment(tokenStart, tableCell, context) {
|
|
|
2293
2274
|
}
|
|
2294
2275
|
return result;
|
|
2295
2276
|
}
|
|
2296
|
-
|
|
2297
|
-
//#region src/profile/features/frontmatter.ts
|
|
2277
|
+
// src/profile/features/frontmatter.ts
|
|
2298
2278
|
function frontmatterFenceAt(source, lines, index, marker) {
|
|
2299
2279
|
const start = lines.start(index);
|
|
2300
2280
|
if (source[start] !== marker || source[start + 1] !== marker || source[start + 2] !== marker) return false;
|
|
@@ -2332,8 +2312,7 @@ function feature$13(marker) {
|
|
|
2332
2312
|
}]
|
|
2333
2313
|
} };
|
|
2334
2314
|
}
|
|
2335
|
-
|
|
2336
|
-
//#region src/profile/features/component/shared.ts
|
|
2315
|
+
// src/profile/features/component/shared.ts
|
|
2337
2316
|
function componentNameEnd(source, start, block) {
|
|
2338
2317
|
let code = source.charCodeAt(start);
|
|
2339
2318
|
if (!isAsciiLetter(code) && code !== 36) return;
|
|
@@ -2366,8 +2345,7 @@ function normalizeComponentName(value) {
|
|
|
2366
2345
|
}
|
|
2367
2346
|
return result.toLowerCase();
|
|
2368
2347
|
}
|
|
2369
|
-
|
|
2370
|
-
//#region src/profile/features/component/block.ts
|
|
2348
|
+
// src/profile/features/component/block.ts
|
|
2371
2349
|
function closingBracket(source, start, limit) {
|
|
2372
2350
|
let depth = 0;
|
|
2373
2351
|
for (let offset = start + 1; offset < limit; offset++) if (source[offset] === "\\" && offset + 1 < limit) offset++;
|
|
@@ -2454,13 +2432,6 @@ function blockOpeningAt(source, lines, index, contentOffset, shorthand) {
|
|
|
2454
2432
|
nameEnd
|
|
2455
2433
|
};
|
|
2456
2434
|
}
|
|
2457
|
-
function fenceAt(source, lines, index, size, contentOffset) {
|
|
2458
|
-
let offset = contentOffset;
|
|
2459
|
-
while (source[offset] === ":") offset++;
|
|
2460
|
-
const lineEnd = lines.end(index);
|
|
2461
|
-
if (offset - contentOffset !== size || skipLineWhitespace(source, offset, lineEnd) !== lineEnd) return;
|
|
2462
|
-
return contentOffset;
|
|
2463
|
-
}
|
|
2464
2435
|
function blockClose(source, lines, start, opening) {
|
|
2465
2436
|
let codeFence;
|
|
2466
2437
|
let depth = 0;
|
|
@@ -2473,11 +2444,12 @@ function blockClose(source, lines, start, opening) {
|
|
|
2473
2444
|
if (contentOffset < 0) continue;
|
|
2474
2445
|
codeFence = codeFenceAt(source, lines, index, contentOffset);
|
|
2475
2446
|
if (codeFence) continue;
|
|
2476
|
-
|
|
2477
|
-
|
|
2447
|
+
let markerEnd = contentOffset;
|
|
2448
|
+
while (source[markerEnd] === ":") markerEnd++;
|
|
2449
|
+
if (markerEnd - contentOffset === opening.fenceSize && skipLineWhitespace(source, markerEnd, lines.end(index)) === lines.end(index)) {
|
|
2478
2450
|
if (depth === 0) return {
|
|
2479
2451
|
index,
|
|
2480
|
-
offset:
|
|
2452
|
+
offset: contentOffset
|
|
2481
2453
|
};
|
|
2482
2454
|
depth--;
|
|
2483
2455
|
continue;
|
|
@@ -2639,8 +2611,7 @@ const blockStarts$2 = [{
|
|
|
2639
2611
|
codes: [58],
|
|
2640
2612
|
start: createBlockStart(true)
|
|
2641
2613
|
}];
|
|
2642
|
-
|
|
2643
|
-
//#region src/profile/features/component/inline.ts
|
|
2614
|
+
// src/profile/features/component/inline.ts
|
|
2644
2615
|
const inlineScans = [{
|
|
2645
2616
|
marker: 58,
|
|
2646
2617
|
scan(source, start, tokens) {
|
|
@@ -2660,8 +2631,7 @@ const buildInlineComponent = (open, close, sourceSpan, children, context) => {
|
|
|
2660
2631
|
position: sourceSpan
|
|
2661
2632
|
};
|
|
2662
2633
|
};
|
|
2663
|
-
|
|
2664
|
-
//#region src/profile/features/component/index.ts
|
|
2634
|
+
// src/profile/features/component/index.ts
|
|
2665
2635
|
const feature$12 = {
|
|
2666
2636
|
block: {
|
|
2667
2637
|
builds: blockBuilds$2,
|
|
@@ -2698,8 +2668,7 @@ const feature$12 = {
|
|
|
2698
2668
|
]
|
|
2699
2669
|
}
|
|
2700
2670
|
};
|
|
2701
|
-
|
|
2702
|
-
//#region src/profile/features/emoji/index.ts
|
|
2671
|
+
// src/profile/features/emoji/index.ts
|
|
2703
2672
|
function isShortcodeCharacter(code) {
|
|
2704
2673
|
return isAsciiLetter(code) || isAsciiDigit(code) || code === 43 || code === 45 || code === 95;
|
|
2705
2674
|
}
|
|
@@ -2728,8 +2697,7 @@ const feature$11 = { inline: {
|
|
|
2728
2697
|
}
|
|
2729
2698
|
}]
|
|
2730
2699
|
} };
|
|
2731
|
-
|
|
2732
|
-
//#region src/profile/features/footnote/shared.ts
|
|
2700
|
+
// src/profile/features/footnote/shared.ts
|
|
2733
2701
|
const footnoteDefinitionPrefix = "footnote\0";
|
|
2734
2702
|
function footnoteLabelAt(source, start, limit) {
|
|
2735
2703
|
if (source.charCodeAt(start) !== 91 || source.charCodeAt(start + 1) !== 94) return;
|
|
@@ -2746,7 +2714,7 @@ function footnoteLabelAt(source, start, limit) {
|
|
|
2746
2714
|
} else if (code === 93) {
|
|
2747
2715
|
if (length === 0) return;
|
|
2748
2716
|
const label = source.slice(labelStart, offset);
|
|
2749
|
-
const normalizedLabel =
|
|
2717
|
+
const normalizedLabel = normalizeIdentifier(label);
|
|
2750
2718
|
return {
|
|
2751
2719
|
definitionKey: footnoteDefinitionPrefix + normalizedLabel,
|
|
2752
2720
|
end: offset + 1,
|
|
@@ -2761,8 +2729,7 @@ function footnoteLabelAt(source, start, limit) {
|
|
|
2761
2729
|
if (length > 999) return;
|
|
2762
2730
|
}
|
|
2763
2731
|
}
|
|
2764
|
-
|
|
2765
|
-
//#region src/profile/features/footnote/block.ts
|
|
2732
|
+
// src/profile/features/footnote/block.ts
|
|
2766
2733
|
function definitionAt(source, lines, index, markerStart) {
|
|
2767
2734
|
const lineEnd = lines.end(index);
|
|
2768
2735
|
const label = footnoteLabelAt(source, markerStart, lineEnd);
|
|
@@ -2775,8 +2742,7 @@ function definitionAt(source, lines, index, markerStart) {
|
|
|
2775
2742
|
markerEnd
|
|
2776
2743
|
};
|
|
2777
2744
|
}
|
|
2778
|
-
|
|
2779
|
-
//#region src/profile/features/footnote/index.ts
|
|
2745
|
+
// src/profile/features/footnote/index.ts
|
|
2780
2746
|
const feature$10 = {
|
|
2781
2747
|
block: {
|
|
2782
2748
|
builds: [{
|
|
@@ -2854,19 +2820,15 @@ const feature$10 = {
|
|
|
2854
2820
|
const label = inlineTokenText(context.view.text, context.tokens, tokenIndex, 2, 1);
|
|
2855
2821
|
return {
|
|
2856
2822
|
type: "footnoteReference",
|
|
2857
|
-
identifier:
|
|
2823
|
+
identifier: normalizeIdentifier(label),
|
|
2858
2824
|
label: semanticText(label),
|
|
2859
2825
|
position: sourceSpan
|
|
2860
2826
|
};
|
|
2861
2827
|
}
|
|
2862
2828
|
}] }
|
|
2863
2829
|
};
|
|
2864
|
-
|
|
2865
|
-
//#region src/profile/features/text.ts
|
|
2830
|
+
// src/profile/features/text.ts
|
|
2866
2831
|
const entity = /&(?:#x[0-9A-F]{1,6}|#\d{1,7}|[A-Z][A-Z0-9]{0,30});/iy;
|
|
2867
|
-
function isAsciiPunctuation(code) {
|
|
2868
|
-
return code >= 33 && code <= 47 || code >= 58 && code <= 64 || code >= 91 && code <= 96 || code >= 123 && code <= 126;
|
|
2869
|
-
}
|
|
2870
2832
|
const buildInlineText = (tokenIndex, context) => {
|
|
2871
2833
|
return inlineTokenText(context.view.text, context.tokens, tokenIndex);
|
|
2872
2834
|
};
|
|
@@ -2916,8 +2878,7 @@ const feature$9 = { inline: {
|
|
|
2916
2878
|
}
|
|
2917
2879
|
]
|
|
2918
2880
|
} };
|
|
2919
|
-
|
|
2920
|
-
//#region src/profile/features/formatting.ts
|
|
2881
|
+
// src/profile/features/formatting.ts
|
|
2921
2882
|
const scanFormatting = (source, start, tokens) => {
|
|
2922
2883
|
const code = source.charCodeAt(start);
|
|
2923
2884
|
const end = inlineMarkerRunEnd(source, start);
|
|
@@ -3010,8 +2971,7 @@ function feature$8(strikethroughOptions) {
|
|
|
3010
2971
|
builds
|
|
3011
2972
|
} };
|
|
3012
2973
|
}
|
|
3013
|
-
|
|
3014
|
-
//#region src/fragment/node.ts
|
|
2974
|
+
// src/fragment/node.ts
|
|
3015
2975
|
function cloneLocation(location) {
|
|
3016
2976
|
return {
|
|
3017
2977
|
line: location.line,
|
|
@@ -3027,8 +2987,7 @@ function lastChildEnd(children) {
|
|
|
3027
2987
|
const last = children.at(-1);
|
|
3028
2988
|
return last ? cloneLocation(last.position.end) : void 0;
|
|
3029
2989
|
}
|
|
3030
|
-
|
|
3031
|
-
//#region src/profile/features/heading.ts
|
|
2990
|
+
// src/profile/features/heading.ts
|
|
3032
2991
|
function atxAt(source, lines, index, markerOffset) {
|
|
3033
2992
|
let markerEnd = markerOffset + 1;
|
|
3034
2993
|
const lineEnd = lines.end(index);
|
|
@@ -3112,8 +3071,7 @@ const feature$7 = { block: {
|
|
|
3112
3071
|
}
|
|
3113
3072
|
}]
|
|
3114
3073
|
} };
|
|
3115
|
-
|
|
3116
|
-
//#region src/profile/features/html.ts
|
|
3074
|
+
// src/profile/features/html.ts
|
|
3117
3075
|
const htmlBlockTags = new Set(htmlBlockNames);
|
|
3118
3076
|
const htmlTagName = "[a-z][a-z0-9-]*";
|
|
3119
3077
|
const completeHtmlTag = new RegExp(`^(?:<${htmlTagName}(?:\\s+[a-z_:][\\w.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'|"[^"]*"))?)*\\s*/?>|</${htmlTagName}\\s*>)[ \\t]*$`, "i");
|
|
@@ -3228,8 +3186,7 @@ const feature$6 = {
|
|
|
3228
3186
|
}]
|
|
3229
3187
|
}
|
|
3230
3188
|
};
|
|
3231
|
-
|
|
3232
|
-
//#region src/profile/features/link.ts
|
|
3189
|
+
// src/profile/features/link.ts
|
|
3233
3190
|
function skipWhitespace(source, start) {
|
|
3234
3191
|
let end = start;
|
|
3235
3192
|
while (end < source.length) {
|
|
@@ -3350,7 +3307,7 @@ function reference(close, syntaxStart, syntaxEnd, context, image) {
|
|
|
3350
3307
|
const full = closeText.startsWith("][") && closeText !== "][]";
|
|
3351
3308
|
const labelSource = full ? closeText.slice(2, -1) : context.view.text.slice(syntaxStart + (image ? 2 : 1), syntaxEnd - closeText.length);
|
|
3352
3309
|
return {
|
|
3353
|
-
identifier:
|
|
3310
|
+
identifier: normalizeIdentifier(labelSource),
|
|
3354
3311
|
label: semanticText(labelSource),
|
|
3355
3312
|
referenceType: full ? "full" : closeText === "][]" ? "collapsed" : "shortcut"
|
|
3356
3313
|
};
|
|
@@ -3500,8 +3457,7 @@ const feature$5 = { inline: {
|
|
|
3500
3457
|
}
|
|
3501
3458
|
]
|
|
3502
3459
|
} };
|
|
3503
|
-
|
|
3504
|
-
//#region src/profile/features/list.ts
|
|
3460
|
+
// src/profile/features/list.ts
|
|
3505
3461
|
function listMarkerAt(source, lines, index, contentOffset) {
|
|
3506
3462
|
if (contentOffset < 0) return;
|
|
3507
3463
|
const indent = lines.prefixColumns(index) + contentOffset - lines.start(index);
|
|
@@ -3748,8 +3704,7 @@ function feature$4(taskList = false) {
|
|
|
3748
3704
|
}]
|
|
3749
3705
|
} };
|
|
3750
3706
|
}
|
|
3751
|
-
|
|
3752
|
-
//#region src/profile/features/math/block.ts
|
|
3707
|
+
// src/profile/features/math/block.ts
|
|
3753
3708
|
const mathFenceRule = {
|
|
3754
3709
|
forbiddenInfoMarker: 36,
|
|
3755
3710
|
marker: 36,
|
|
@@ -3772,10 +3727,10 @@ const blockBuilds = [{
|
|
|
3772
3727
|
const blockStarts = [{
|
|
3773
3728
|
codes: [36],
|
|
3774
3729
|
interrupt(source, lines, index, contentOffset) {
|
|
3775
|
-
return fenceAt
|
|
3730
|
+
return fenceAt(source, lines, index, mathFenceRule, contentOffset) !== void 0;
|
|
3776
3731
|
},
|
|
3777
3732
|
start(source, lines, start, contentOffset, out) {
|
|
3778
|
-
const fence = fenceAt
|
|
3733
|
+
const fence = fenceAt(source, lines, start, mathFenceRule, contentOffset);
|
|
3779
3734
|
if (!fence) return;
|
|
3780
3735
|
let end = start + 1;
|
|
3781
3736
|
while (end < lines.length && !closesFence(source, lines, end, fence)) end++;
|
|
@@ -3785,8 +3740,7 @@ const blockStarts = [{
|
|
|
3785
3740
|
return end;
|
|
3786
3741
|
}
|
|
3787
3742
|
}];
|
|
3788
|
-
|
|
3789
|
-
//#region src/profile/features/math/inline.ts
|
|
3743
|
+
// src/profile/features/math/inline.ts
|
|
3790
3744
|
function createMathScanRule(singleDollarTextMath) {
|
|
3791
3745
|
const minimum = singleDollarTextMath ? 1 : 2;
|
|
3792
3746
|
return {
|
|
@@ -3830,8 +3784,7 @@ const inlineBuilds = [{
|
|
|
3830
3784
|
};
|
|
3831
3785
|
}
|
|
3832
3786
|
}];
|
|
3833
|
-
|
|
3834
|
-
//#region src/profile/features/math/index.ts
|
|
3787
|
+
// src/profile/features/math/index.ts
|
|
3835
3788
|
function feature$3(options) {
|
|
3836
3789
|
const singleDollarTextMath = typeof options !== "object" || options.singleDollarTextMath !== false;
|
|
3837
3790
|
return {
|
|
@@ -3845,8 +3798,7 @@ function feature$3(options) {
|
|
|
3845
3798
|
}
|
|
3846
3799
|
};
|
|
3847
3800
|
}
|
|
3848
|
-
|
|
3849
|
-
//#region src/profile/features/paragraph.ts
|
|
3801
|
+
// src/profile/features/paragraph.ts
|
|
3850
3802
|
const feature$2 = { block: {
|
|
3851
3803
|
fallbacks: [(source, lines, start, contentOffset, out, context) => {
|
|
3852
3804
|
const openToken = out.length;
|
|
@@ -3895,8 +3847,7 @@ const feature$2 = { block: {
|
|
|
3895
3847
|
}
|
|
3896
3848
|
}]
|
|
3897
3849
|
} };
|
|
3898
|
-
|
|
3899
|
-
//#region src/profile/features/reference.ts
|
|
3850
|
+
// src/profile/features/reference.ts
|
|
3900
3851
|
function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
3901
3852
|
let offset = contentOffset + 1;
|
|
3902
3853
|
const labelClose = source.indexOf("]", offset);
|
|
@@ -3997,7 +3948,7 @@ function linkDefinitionAt(source, lines, startIndex, contentOffset, context) {
|
|
|
3997
3948
|
titleOnNextLine = true;
|
|
3998
3949
|
}
|
|
3999
3950
|
const closer = source[offset] === "(" ? ")" : source[offset] === "\"" || source[offset] === "'" ? source[offset] : void 0;
|
|
4000
|
-
const definitionKey =
|
|
3951
|
+
const definitionKey = normalizeIdentifier(label);
|
|
4001
3952
|
const fields = {
|
|
4002
3953
|
destination,
|
|
4003
3954
|
label,
|
|
@@ -4092,8 +4043,7 @@ const feature$1 = { block: {
|
|
|
4092
4043
|
}
|
|
4093
4044
|
}]
|
|
4094
4045
|
} };
|
|
4095
|
-
|
|
4096
|
-
//#region src/profile/features/table.ts
|
|
4046
|
+
// src/profile/features/table.ts
|
|
4097
4047
|
function appendTableCell(cells, source, start, contentStart, contentEnd) {
|
|
4098
4048
|
contentStart = skipLineWhitespace(source, contentStart, contentEnd);
|
|
4099
4049
|
while (contentEnd > contentStart) {
|
|
@@ -4105,17 +4055,13 @@ function appendTableCell(cells, source, start, contentStart, contentEnd) {
|
|
|
4105
4055
|
}
|
|
4106
4056
|
function tableCellsAt(source, lines, index, requirePipe, contentOffset) {
|
|
4107
4057
|
if (contentOffset < 0) return;
|
|
4108
|
-
const pipes = [];
|
|
4109
|
-
let backslashes = 0;
|
|
4110
4058
|
const lineEnd = lines.end(index);
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
if (code === 124 && backslashes % 2 === 0) pipes.push(offset);
|
|
4118
|
-
backslashes = 0;
|
|
4059
|
+
const row = source.slice(contentOffset, lineEnd);
|
|
4060
|
+
const pipes = [];
|
|
4061
|
+
for (let pipe = row.indexOf("|"); pipe >= 0; pipe = row.indexOf("|", pipe + 1)) {
|
|
4062
|
+
let escapeStart = pipe;
|
|
4063
|
+
while (escapeStart > 0 && row.charCodeAt(escapeStart - 1) === 92) escapeStart--;
|
|
4064
|
+
if ((pipe - escapeStart) % 2 === 0) pipes.push(contentOffset + pipe);
|
|
4119
4065
|
}
|
|
4120
4066
|
if (requirePipe && pipes.length === 0) return;
|
|
4121
4067
|
let visibleEnd = lineEnd;
|
|
@@ -4262,8 +4208,7 @@ const feature = { block: {
|
|
|
4262
4208
|
}
|
|
4263
4209
|
}]
|
|
4264
4210
|
} };
|
|
4265
|
-
|
|
4266
|
-
//#region src/inline/delimiter.ts
|
|
4211
|
+
// src/inline/delimiter.ts
|
|
4267
4212
|
const whitespace = /\s/u;
|
|
4268
4213
|
const punctuation = /[\p{P}\p{S}]/u;
|
|
4269
4214
|
function codePointBefore(source, offset) {
|
|
@@ -4278,7 +4223,7 @@ function codePointBefore(source, offset) {
|
|
|
4278
4223
|
function delimiterCharacterClass(code) {
|
|
4279
4224
|
if (code <= 127) {
|
|
4280
4225
|
if (code === 32 || code >= 9 && code <= 13) return 1;
|
|
4281
|
-
return code
|
|
4226
|
+
return isAsciiPunctuation(code) ? 2 : 0;
|
|
4282
4227
|
}
|
|
4283
4228
|
const character = String.fromCodePoint(code);
|
|
4284
4229
|
return whitespace.test(character) ? 1 : punctuation.test(character) ? 2 : 0;
|
|
@@ -4400,11 +4345,9 @@ function compileDelimiterConfigs(delimiterConfigs) {
|
|
|
4400
4345
|
});
|
|
4401
4346
|
return delimiterByKind;
|
|
4402
4347
|
}
|
|
4403
|
-
|
|
4404
|
-
//#region src/profile/resolve.ts
|
|
4348
|
+
// src/profile/resolve.ts
|
|
4405
4349
|
const frameHeaderSize = 1;
|
|
4406
4350
|
const noBracketFrames = [0];
|
|
4407
|
-
const noDelimiterReplacements = [];
|
|
4408
4351
|
function setFrameState(frames, frame, state) {
|
|
4409
4352
|
frames[frame + 5] = state;
|
|
4410
4353
|
frames[0] = 1;
|
|
@@ -4601,12 +4544,12 @@ function resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKin
|
|
|
4601
4544
|
const labelEnd = referenceLabelEnd(source, closeEnd);
|
|
4602
4545
|
if (labelEnd > 0) {
|
|
4603
4546
|
const label = source.slice(closeEnd + 1, labelEnd - 1) || source.slice(contentStart, contentEnd);
|
|
4604
|
-
matched = definitions.hasDefinition(
|
|
4547
|
+
matched = definitions.hasDefinition(normalizeIdentifier(label));
|
|
4605
4548
|
if (matched) {
|
|
4606
4549
|
closeEnd = labelEnd;
|
|
4607
4550
|
reference = true;
|
|
4608
4551
|
}
|
|
4609
|
-
} else if (lastVisibleOpener <= openToken && acceptsShortcutLabel(source, contentStart, contentEnd) && definitions.hasDefinition(
|
|
4552
|
+
} else if (lastVisibleOpener <= openToken && acceptsShortcutLabel(source, contentStart, contentEnd) && definitions.hasDefinition(normalizeIdentifier(source.slice(contentStart, contentEnd)))) {
|
|
4610
4553
|
matched = true;
|
|
4611
4554
|
reference = true;
|
|
4612
4555
|
}
|
|
@@ -4636,7 +4579,7 @@ function resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKin
|
|
|
4636
4579
|
}
|
|
4637
4580
|
}
|
|
4638
4581
|
if (runCount > 0) replacements = resolveDelimiterScope(runs, 0, replacements);
|
|
4639
|
-
return replacements;
|
|
4582
|
+
return replacements ?? emptyArray;
|
|
4640
4583
|
}
|
|
4641
4584
|
function appendReferenceBoundary(result, tokens, frames, frame, close) {
|
|
4642
4585
|
const token = frames[frame + (close ? 1 : 0)];
|
|
@@ -4720,13 +4663,12 @@ function compileInlineResolver(options) {
|
|
|
4720
4663
|
}
|
|
4721
4664
|
if (tokenIndex < 0) return tokens;
|
|
4722
4665
|
const frames = analyzeBrackets(source, tokens, definitions, options);
|
|
4723
|
-
const replacements = resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKind)
|
|
4666
|
+
const replacements = resolvePairedSyntax(source, tokens, frames, definitions, delimiterByKind);
|
|
4724
4667
|
return frames[0] & 1 || replacements.length > 0 ? emitResolvedTokens(tokens, frames, replacements) : tokens;
|
|
4725
4668
|
};
|
|
4726
4669
|
};
|
|
4727
4670
|
}
|
|
4728
|
-
|
|
4729
|
-
//#region src/profile/index.ts
|
|
4671
|
+
// src/profile/index.ts
|
|
4730
4672
|
function compileProfile(options = {}) {
|
|
4731
4673
|
const features = [
|
|
4732
4674
|
feature$7,
|
|
@@ -4760,8 +4702,7 @@ function compileProfile(options = {}) {
|
|
|
4760
4702
|
}))
|
|
4761
4703
|
};
|
|
4762
4704
|
}
|
|
4763
|
-
|
|
4764
|
-
//#region src/parser.ts
|
|
4705
|
+
// src/parser.ts
|
|
4765
4706
|
function createParser(options) {
|
|
4766
4707
|
const profile = compileProfile(options?.features);
|
|
4767
4708
|
let blockScanner;
|
|
@@ -4770,5 +4711,4 @@ function createParser(options) {
|
|
|
4770
4711
|
parse: (source) => DocumentImpl.parse(source, profile, blockScanner ??= new BlockScanner(profile.block))
|
|
4771
4712
|
};
|
|
4772
4713
|
}
|
|
4773
|
-
|
|
4774
|
-
export { createParser };
|
|
4714
|
+
export { createParser, normalizeIdentifier };
|