markmap-lib 0.17.3-alpha.2 → 0.17.3-alpha.4
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/dist/browser/index.iife.js +647 -277
- package/dist/browser/index.mjs +12 -164
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.no-plugins.js +1 -1
- package/dist/index.no-plugins.mjs +1 -1
- package/dist/plugins/katex/vendor.d.ts +2 -0
- package/dist/plugins.js +8 -4
- package/dist/plugins.mjs +8 -4
- package/package.json +7 -7
|
@@ -1116,6 +1116,7 @@
|
|
|
1116
1116
|
case EntityDecoderState.NamedEntity: {
|
|
1117
1117
|
return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
|
|
1118
1118
|
}
|
|
1119
|
+
// Otherwise, emit a numeric entity if we have one.
|
|
1119
1120
|
case EntityDecoderState.NumericDecimal: {
|
|
1120
1121
|
return this.emitNumericEntity(0, 2);
|
|
1121
1122
|
}
|
|
@@ -1410,6 +1411,7 @@
|
|
|
1410
1411
|
switch (node.type) {
|
|
1411
1412
|
case Root:
|
|
1412
1413
|
return render$1(node.children, options);
|
|
1414
|
+
// @ts-expect-error We don't use `Doctype` yet
|
|
1413
1415
|
case Doctype:
|
|
1414
1416
|
case Directive:
|
|
1415
1417
|
return renderDirective(node);
|
|
@@ -2117,7 +2119,7 @@
|
|
|
2117
2119
|
function extract$1(map2) {
|
|
2118
2120
|
return this.root().extract(map2);
|
|
2119
2121
|
}
|
|
2120
|
-
function merge(arr1, arr2) {
|
|
2122
|
+
function merge$1(arr1, arr2) {
|
|
2121
2123
|
if (!isArrayLike(arr1) || !isArrayLike(arr2)) {
|
|
2122
2124
|
return;
|
|
2123
2125
|
}
|
|
@@ -2148,7 +2150,7 @@
|
|
|
2148
2150
|
contains,
|
|
2149
2151
|
extract: extract$1,
|
|
2150
2152
|
html: html$1,
|
|
2151
|
-
merge,
|
|
2153
|
+
merge: merge$1,
|
|
2152
2154
|
parseHTML,
|
|
2153
2155
|
root,
|
|
2154
2156
|
text: text$2,
|
|
@@ -2735,6 +2737,7 @@
|
|
|
2735
2737
|
loop: while (selectorIndex < selector.length) {
|
|
2736
2738
|
const firstChar = selector.charCodeAt(selectorIndex);
|
|
2737
2739
|
switch (firstChar) {
|
|
2740
|
+
// Whitespace
|
|
2738
2741
|
case 32:
|
|
2739
2742
|
case 9:
|
|
2740
2743
|
case 10:
|
|
@@ -2747,6 +2750,7 @@
|
|
|
2747
2750
|
stripWhitespace(1);
|
|
2748
2751
|
break;
|
|
2749
2752
|
}
|
|
2753
|
+
// Traversals
|
|
2750
2754
|
case 62: {
|
|
2751
2755
|
addTraversal(SelectorType.Child);
|
|
2752
2756
|
stripWhitespace(1);
|
|
@@ -2767,6 +2771,7 @@
|
|
|
2767
2771
|
stripWhitespace(1);
|
|
2768
2772
|
break;
|
|
2769
2773
|
}
|
|
2774
|
+
// Special attribute selectors: .class, #id
|
|
2770
2775
|
case 46: {
|
|
2771
2776
|
addSpecialAttribute("class", AttributeAction.Element);
|
|
2772
2777
|
break;
|
|
@@ -2940,15 +2945,23 @@
|
|
|
2940
2945
|
function getDefaultExportFromCjs(x) {
|
|
2941
2946
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
2942
2947
|
}
|
|
2943
|
-
var boolbase
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2948
|
+
var boolbase$1;
|
|
2949
|
+
var hasRequiredBoolbase;
|
|
2950
|
+
function requireBoolbase() {
|
|
2951
|
+
if (hasRequiredBoolbase) return boolbase$1;
|
|
2952
|
+
hasRequiredBoolbase = 1;
|
|
2953
|
+
boolbase$1 = {
|
|
2954
|
+
trueFunc: function trueFunc() {
|
|
2955
|
+
return true;
|
|
2956
|
+
},
|
|
2957
|
+
falseFunc: function falseFunc() {
|
|
2958
|
+
return false;
|
|
2959
|
+
}
|
|
2960
|
+
};
|
|
2961
|
+
return boolbase$1;
|
|
2962
|
+
}
|
|
2963
|
+
var boolbaseExports = requireBoolbase();
|
|
2964
|
+
const boolbase = /* @__PURE__ */ getDefaultExportFromCjs(boolbaseExports);
|
|
2952
2965
|
const procedure = /* @__PURE__ */ new Map([
|
|
2953
2966
|
[SelectorType.Universal, 50],
|
|
2954
2967
|
[SelectorType.Tag, 30],
|
|
@@ -3098,7 +3111,7 @@
|
|
|
3098
3111
|
const { adapter: adapter2 } = options;
|
|
3099
3112
|
const { name: name2, value } = data2;
|
|
3100
3113
|
if (/\s/.test(value)) {
|
|
3101
|
-
return boolbase
|
|
3114
|
+
return boolbase.falseFunc;
|
|
3102
3115
|
}
|
|
3103
3116
|
const regex2 = new RegExp(`(?:^|\\s)${escapeRegex(value)}(?:$|\\s)`, shouldIgnoreCase(data2, options) ? "i" : "");
|
|
3104
3117
|
return function element(elem) {
|
|
@@ -3115,7 +3128,7 @@
|
|
|
3115
3128
|
let { value } = data2;
|
|
3116
3129
|
const len = value.length;
|
|
3117
3130
|
if (len === 0) {
|
|
3118
|
-
return boolbase
|
|
3131
|
+
return boolbase.falseFunc;
|
|
3119
3132
|
}
|
|
3120
3133
|
if (shouldIgnoreCase(data2, options)) {
|
|
3121
3134
|
value = value.toLowerCase();
|
|
@@ -3135,7 +3148,7 @@
|
|
|
3135
3148
|
let { value } = data2;
|
|
3136
3149
|
const len = -value.length;
|
|
3137
3150
|
if (len === 0) {
|
|
3138
|
-
return boolbase
|
|
3151
|
+
return boolbase.falseFunc;
|
|
3139
3152
|
}
|
|
3140
3153
|
if (shouldIgnoreCase(data2, options)) {
|
|
3141
3154
|
value = value.toLowerCase();
|
|
@@ -3153,7 +3166,7 @@
|
|
|
3153
3166
|
const { adapter: adapter2 } = options;
|
|
3154
3167
|
const { name: name2, value } = data2;
|
|
3155
3168
|
if (value === "") {
|
|
3156
|
-
return boolbase
|
|
3169
|
+
return boolbase.falseFunc;
|
|
3157
3170
|
}
|
|
3158
3171
|
if (shouldIgnoreCase(data2, options)) {
|
|
3159
3172
|
const regex2 = new RegExp(escapeRegex(value), "i");
|
|
@@ -3242,13 +3255,13 @@
|
|
|
3242
3255
|
const a = parsed[0];
|
|
3243
3256
|
const b = parsed[1] - 1;
|
|
3244
3257
|
if (b < 0 && a <= 0)
|
|
3245
|
-
return boolbase
|
|
3258
|
+
return boolbase.falseFunc;
|
|
3246
3259
|
if (a === -1)
|
|
3247
3260
|
return (index2) => index2 <= b;
|
|
3248
3261
|
if (a === 0)
|
|
3249
3262
|
return (index2) => index2 === b;
|
|
3250
3263
|
if (a === 1)
|
|
3251
|
-
return b < 0 ? boolbase
|
|
3264
|
+
return b < 0 ? boolbase.trueFunc : (index2) => index2 >= b;
|
|
3252
3265
|
const absA = Math.abs(a);
|
|
3253
3266
|
const bMod = (b % absA + absA) % absA;
|
|
3254
3267
|
return a > 1 ? (index2) => index2 >= b && index2 % absA === bMod : (index2) => index2 <= b && index2 % absA === bMod;
|
|
@@ -3277,9 +3290,9 @@
|
|
|
3277
3290
|
// Location specific methods
|
|
3278
3291
|
"nth-child"(next2, rule, { adapter: adapter2, equals }) {
|
|
3279
3292
|
const func = nthCheck(rule);
|
|
3280
|
-
if (func === boolbase
|
|
3281
|
-
return boolbase
|
|
3282
|
-
if (func === boolbase
|
|
3293
|
+
if (func === boolbase.falseFunc)
|
|
3294
|
+
return boolbase.falseFunc;
|
|
3295
|
+
if (func === boolbase.trueFunc)
|
|
3283
3296
|
return getChildFunc(next2, adapter2);
|
|
3284
3297
|
return function nthChild(elem) {
|
|
3285
3298
|
const siblings2 = adapter2.getSiblings(elem);
|
|
@@ -3296,9 +3309,9 @@
|
|
|
3296
3309
|
},
|
|
3297
3310
|
"nth-last-child"(next2, rule, { adapter: adapter2, equals }) {
|
|
3298
3311
|
const func = nthCheck(rule);
|
|
3299
|
-
if (func === boolbase
|
|
3300
|
-
return boolbase
|
|
3301
|
-
if (func === boolbase
|
|
3312
|
+
if (func === boolbase.falseFunc)
|
|
3313
|
+
return boolbase.falseFunc;
|
|
3314
|
+
if (func === boolbase.trueFunc)
|
|
3302
3315
|
return getChildFunc(next2, adapter2);
|
|
3303
3316
|
return function nthLastChild(elem) {
|
|
3304
3317
|
const siblings2 = adapter2.getSiblings(elem);
|
|
@@ -3315,9 +3328,9 @@
|
|
|
3315
3328
|
},
|
|
3316
3329
|
"nth-of-type"(next2, rule, { adapter: adapter2, equals }) {
|
|
3317
3330
|
const func = nthCheck(rule);
|
|
3318
|
-
if (func === boolbase
|
|
3319
|
-
return boolbase
|
|
3320
|
-
if (func === boolbase
|
|
3331
|
+
if (func === boolbase.falseFunc)
|
|
3332
|
+
return boolbase.falseFunc;
|
|
3333
|
+
if (func === boolbase.trueFunc)
|
|
3321
3334
|
return getChildFunc(next2, adapter2);
|
|
3322
3335
|
return function nthOfType(elem) {
|
|
3323
3336
|
const siblings2 = adapter2.getSiblings(elem);
|
|
@@ -3335,9 +3348,9 @@
|
|
|
3335
3348
|
},
|
|
3336
3349
|
"nth-last-of-type"(next2, rule, { adapter: adapter2, equals }) {
|
|
3337
3350
|
const func = nthCheck(rule);
|
|
3338
|
-
if (func === boolbase
|
|
3339
|
-
return boolbase
|
|
3340
|
-
if (func === boolbase
|
|
3351
|
+
if (func === boolbase.falseFunc)
|
|
3352
|
+
return boolbase.falseFunc;
|
|
3353
|
+
if (func === boolbase.trueFunc)
|
|
3341
3354
|
return getChildFunc(next2, adapter2);
|
|
3342
3355
|
return function nthLastOfType(elem) {
|
|
3343
3356
|
const siblings2 = adapter2.getSiblings(elem);
|
|
@@ -3378,7 +3391,7 @@
|
|
|
3378
3391
|
return function dynamicPseudo(next2, _rule, { adapter: adapter2 }) {
|
|
3379
3392
|
const func = adapter2[name2];
|
|
3380
3393
|
if (typeof func !== "function") {
|
|
3381
|
-
return boolbase
|
|
3394
|
+
return boolbase.falseFunc;
|
|
3382
3395
|
}
|
|
3383
3396
|
return function active(elem) {
|
|
3384
3397
|
return func(elem) && next2(elem);
|
|
@@ -3485,8 +3498,8 @@
|
|
|
3485
3498
|
};
|
|
3486
3499
|
const PLACEHOLDER_ELEMENT = {};
|
|
3487
3500
|
function ensureIsTag(next2, adapter2) {
|
|
3488
|
-
if (next2 === boolbase
|
|
3489
|
-
return boolbase
|
|
3501
|
+
if (next2 === boolbase.falseFunc)
|
|
3502
|
+
return boolbase.falseFunc;
|
|
3490
3503
|
return (elem) => adapter2.isTag(elem) && next2(elem);
|
|
3491
3504
|
}
|
|
3492
3505
|
function getNextSiblings(elem, adapter2) {
|
|
@@ -3512,7 +3525,7 @@
|
|
|
3512
3525
|
}
|
|
3513
3526
|
const is$2 = (next2, token, options, context, compileToken2) => {
|
|
3514
3527
|
const func = compileToken2(token, copyOptions(options), context);
|
|
3515
|
-
return func === boolbase
|
|
3528
|
+
return func === boolbase.trueFunc ? next2 : func === boolbase.falseFunc ? boolbase.falseFunc : (elem) => func(elem) && next2(elem);
|
|
3516
3529
|
};
|
|
3517
3530
|
const subselects = {
|
|
3518
3531
|
is: is$2,
|
|
@@ -3523,7 +3536,7 @@
|
|
|
3523
3536
|
where: is$2,
|
|
3524
3537
|
not(next2, token, options, context, compileToken2) {
|
|
3525
3538
|
const func = compileToken2(token, copyOptions(options), context);
|
|
3526
|
-
return func === boolbase
|
|
3539
|
+
return func === boolbase.falseFunc ? next2 : func === boolbase.trueFunc ? boolbase.falseFunc : (elem) => !func(elem) && next2(elem);
|
|
3527
3540
|
},
|
|
3528
3541
|
has(next2, subselect, options, _context, compileToken2) {
|
|
3529
3542
|
const { adapter: adapter2 } = options;
|
|
@@ -3534,10 +3547,10 @@
|
|
|
3534
3547
|
[PLACEHOLDER_ELEMENT]
|
|
3535
3548
|
) : void 0;
|
|
3536
3549
|
const compiled = compileToken2(subselect, opts, context);
|
|
3537
|
-
if (compiled === boolbase
|
|
3538
|
-
return boolbase
|
|
3550
|
+
if (compiled === boolbase.falseFunc)
|
|
3551
|
+
return boolbase.falseFunc;
|
|
3539
3552
|
const hasElement = ensureIsTag(compiled, adapter2);
|
|
3540
|
-
if (context && compiled !== boolbase
|
|
3553
|
+
if (context && compiled !== boolbase.trueFunc) {
|
|
3541
3554
|
const { shouldTestNextSiblings = false } = compiled;
|
|
3542
3555
|
return (elem) => {
|
|
3543
3556
|
if (!next2(elem))
|
|
@@ -3611,6 +3624,7 @@
|
|
|
3611
3624
|
case SelectorType.Pseudo: {
|
|
3612
3625
|
return compilePseudoSelector(next2, selector, options, context, compileToken2);
|
|
3613
3626
|
}
|
|
3627
|
+
// Tags
|
|
3614
3628
|
case SelectorType.Tag: {
|
|
3615
3629
|
if (selector.namespace != null) {
|
|
3616
3630
|
throw new Error("Namespaced tag names are not yet supported by css-select");
|
|
@@ -3623,6 +3637,7 @@
|
|
|
3623
3637
|
return adapter2.getName(elem) === name2 && next2(elem);
|
|
3624
3638
|
};
|
|
3625
3639
|
}
|
|
3640
|
+
// Traversal
|
|
3626
3641
|
case SelectorType.Descendant: {
|
|
3627
3642
|
if (options.cacheResults === false || typeof WeakSet === "undefined") {
|
|
3628
3643
|
return function descendant(elem) {
|
|
@@ -3763,19 +3778,19 @@
|
|
|
3763
3778
|
}
|
|
3764
3779
|
}
|
|
3765
3780
|
return compileRules(rules, options, finalContext);
|
|
3766
|
-
}).reduce(reduceRules, boolbase
|
|
3781
|
+
}).reduce(reduceRules, boolbase.falseFunc);
|
|
3767
3782
|
query.shouldTestNextSiblings = shouldTestNextSiblings;
|
|
3768
3783
|
return query;
|
|
3769
3784
|
}
|
|
3770
3785
|
function compileRules(rules, options, context) {
|
|
3771
3786
|
var _a2;
|
|
3772
|
-
return rules.reduce((previous, rule) => previous === boolbase
|
|
3787
|
+
return rules.reduce((previous, rule) => previous === boolbase.falseFunc ? boolbase.falseFunc : compileGeneralSelector(previous, rule, options, context, compileToken), (_a2 = options.rootFunc) !== null && _a2 !== void 0 ? _a2 : boolbase.trueFunc);
|
|
3773
3788
|
}
|
|
3774
3789
|
function reduceRules(a, b) {
|
|
3775
|
-
if (b === boolbase
|
|
3790
|
+
if (b === boolbase.falseFunc || a === boolbase.trueFunc) {
|
|
3776
3791
|
return a;
|
|
3777
3792
|
}
|
|
3778
|
-
if (a === boolbase
|
|
3793
|
+
if (a === boolbase.falseFunc || b === boolbase.trueFunc) {
|
|
3779
3794
|
return b;
|
|
3780
3795
|
}
|
|
3781
3796
|
return function combine(elem) {
|
|
@@ -4015,8 +4030,8 @@
|
|
|
4015
4030
|
*/
|
|
4016
4031
|
rootFunc: (el) => result.includes(el)
|
|
4017
4032
|
};
|
|
4018
|
-
} else if (options.rootFunc && options.rootFunc !==
|
|
4019
|
-
options = { ...options, rootFunc:
|
|
4033
|
+
} else if (options.rootFunc && options.rootFunc !== boolbaseExports.trueFunc) {
|
|
4034
|
+
options = { ...options, rootFunc: boolbaseExports.trueFunc };
|
|
4020
4035
|
}
|
|
4021
4036
|
return remainingSelector.some(isFilter) ? findFilterElements(result, remainingSelector, options, false, totalLimit) : remainingHasTraversal ? (
|
|
4022
4037
|
// Query existing elements to resolve traversal.
|
|
@@ -4039,7 +4054,7 @@
|
|
|
4039
4054
|
if (els.length === 0)
|
|
4040
4055
|
return els;
|
|
4041
4056
|
const query = _compileToken(sel, options);
|
|
4042
|
-
return query ===
|
|
4057
|
+
return query === boolbaseExports.trueFunc ? els : els.filter(query);
|
|
4043
4058
|
}
|
|
4044
4059
|
const reSiblingSelector = /^\s*[+~]/;
|
|
4045
4060
|
function find(selectorOrHaystack) {
|
|
@@ -12243,6 +12258,7 @@
|
|
|
12243
12258
|
}
|
|
12244
12259
|
function startTagInTemplate(p, token) {
|
|
12245
12260
|
switch (token.tagID) {
|
|
12261
|
+
// First, handle tags that can start without a mode change
|
|
12246
12262
|
case TAG_ID.BASE:
|
|
12247
12263
|
case TAG_ID.BASEFONT:
|
|
12248
12264
|
case TAG_ID.BGSOUND:
|
|
@@ -12256,6 +12272,7 @@
|
|
|
12256
12272
|
startTagInHead(p, token);
|
|
12257
12273
|
break;
|
|
12258
12274
|
}
|
|
12275
|
+
// Re-process the token in the appropriate mode
|
|
12259
12276
|
case TAG_ID.CAPTION:
|
|
12260
12277
|
case TAG_ID.COLGROUP:
|
|
12261
12278
|
case TAG_ID.TBODY:
|
|
@@ -14613,7 +14630,7 @@
|
|
|
14613
14630
|
function replaceUnsafeChar(ch) {
|
|
14614
14631
|
return HTML_REPLACEMENTS[ch];
|
|
14615
14632
|
}
|
|
14616
|
-
function escapeHtml
|
|
14633
|
+
function escapeHtml(str) {
|
|
14617
14634
|
if (HTML_ESCAPE_TEST_RE.test(str)) {
|
|
14618
14635
|
return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
|
|
14619
14636
|
}
|
|
@@ -14637,10 +14654,15 @@
|
|
|
14637
14654
|
}
|
|
14638
14655
|
switch (code2) {
|
|
14639
14656
|
case 9:
|
|
14657
|
+
// \t
|
|
14640
14658
|
case 10:
|
|
14659
|
+
// \n
|
|
14641
14660
|
case 11:
|
|
14661
|
+
// \v
|
|
14642
14662
|
case 12:
|
|
14663
|
+
// \f
|
|
14643
14664
|
case 13:
|
|
14665
|
+
// \r
|
|
14644
14666
|
case 32:
|
|
14645
14667
|
case 160:
|
|
14646
14668
|
case 5760:
|
|
@@ -14705,7 +14727,7 @@
|
|
|
14705
14727
|
__proto__: null,
|
|
14706
14728
|
arrayReplaceAt,
|
|
14707
14729
|
assign: assign$1,
|
|
14708
|
-
escapeHtml
|
|
14730
|
+
escapeHtml,
|
|
14709
14731
|
escapeRE: escapeRE$1,
|
|
14710
14732
|
fromCodePoint,
|
|
14711
14733
|
has,
|
|
@@ -14886,11 +14908,11 @@
|
|
|
14886
14908
|
const default_rules = {};
|
|
14887
14909
|
default_rules.code_inline = function(tokens, idx, options, env, slf) {
|
|
14888
14910
|
const token = tokens[idx];
|
|
14889
|
-
return "<code" + slf.renderAttrs(token) + ">" + escapeHtml
|
|
14911
|
+
return "<code" + slf.renderAttrs(token) + ">" + escapeHtml(token.content) + "</code>";
|
|
14890
14912
|
};
|
|
14891
14913
|
default_rules.code_block = function(tokens, idx, options, env, slf) {
|
|
14892
14914
|
const token = tokens[idx];
|
|
14893
|
-
return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml
|
|
14915
|
+
return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml(tokens[idx].content) + "</code></pre>\n";
|
|
14894
14916
|
};
|
|
14895
14917
|
default_rules.fence = function(tokens, idx, options, env, slf) {
|
|
14896
14918
|
const token = tokens[idx];
|
|
@@ -14904,9 +14926,9 @@
|
|
|
14904
14926
|
}
|
|
14905
14927
|
let highlighted;
|
|
14906
14928
|
if (options.highlight) {
|
|
14907
|
-
highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml
|
|
14929
|
+
highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content);
|
|
14908
14930
|
} else {
|
|
14909
|
-
highlighted = escapeHtml
|
|
14931
|
+
highlighted = escapeHtml(token.content);
|
|
14910
14932
|
}
|
|
14911
14933
|
if (highlighted.indexOf("<pre") === 0) {
|
|
14912
14934
|
return highlighted + "\n";
|
|
@@ -14941,7 +14963,7 @@
|
|
|
14941
14963
|
return options.breaks ? options.xhtmlOut ? "<br />\n" : "<br>\n" : "\n";
|
|
14942
14964
|
};
|
|
14943
14965
|
default_rules.text = function(tokens, idx) {
|
|
14944
|
-
return escapeHtml
|
|
14966
|
+
return escapeHtml(tokens[idx].content);
|
|
14945
14967
|
};
|
|
14946
14968
|
default_rules.html_block = function(tokens, idx) {
|
|
14947
14969
|
return tokens[idx].content;
|
|
@@ -14959,7 +14981,7 @@
|
|
|
14959
14981
|
}
|
|
14960
14982
|
result = "";
|
|
14961
14983
|
for (i = 0, l = token.attrs.length; i < l; i++) {
|
|
14962
|
-
result += " " + escapeHtml
|
|
14984
|
+
result += " " + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
|
|
14963
14985
|
}
|
|
14964
14986
|
return result;
|
|
14965
14987
|
};
|
|
@@ -20293,21 +20315,29 @@ ${indent}`) + "'";
|
|
|
20293
20315
|
start = start.replace(/\n+/g, `$&${indent}`);
|
|
20294
20316
|
}
|
|
20295
20317
|
const indentSize = indent ? "2" : "1";
|
|
20296
|
-
let header = (
|
|
20318
|
+
let header = (startWithSpace ? indentSize : "") + chomp;
|
|
20297
20319
|
if (comment2) {
|
|
20298
20320
|
header += " " + commentString(comment2.replace(/ ?[\r\n]+/g, " "));
|
|
20299
20321
|
if (onComment)
|
|
20300
20322
|
onComment();
|
|
20301
20323
|
}
|
|
20302
|
-
if (literal) {
|
|
20303
|
-
|
|
20304
|
-
|
|
20305
|
-
|
|
20306
|
-
|
|
20307
|
-
|
|
20308
|
-
|
|
20309
|
-
|
|
20324
|
+
if (!literal) {
|
|
20325
|
+
const foldedValue = value.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${indent}`);
|
|
20326
|
+
let literalFallback = false;
|
|
20327
|
+
const foldOptions = getFoldOptions(ctx, true);
|
|
20328
|
+
if (blockQuote !== "folded" && type !== Scalar.BLOCK_FOLDED) {
|
|
20329
|
+
foldOptions.onOverflow = () => {
|
|
20330
|
+
literalFallback = true;
|
|
20331
|
+
};
|
|
20332
|
+
}
|
|
20333
|
+
const body = foldFlowLines(`${start}${foldedValue}${end2}`, indent, FOLD_BLOCK, foldOptions);
|
|
20334
|
+
if (!literalFallback)
|
|
20335
|
+
return `>${header}
|
|
20310
20336
|
${indent}${body}`;
|
|
20337
|
+
}
|
|
20338
|
+
value = value.replace(/\n+/g, `$&${indent}`);
|
|
20339
|
+
return `|${header}
|
|
20340
|
+
${indent}${start}${value}${end2}`;
|
|
20311
20341
|
}
|
|
20312
20342
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
20313
20343
|
const { type, value } = item;
|
|
@@ -20427,10 +20457,15 @@ ${indent}`);
|
|
|
20427
20457
|
let obj;
|
|
20428
20458
|
if (isScalar(item)) {
|
|
20429
20459
|
obj = item.value;
|
|
20430
|
-
|
|
20460
|
+
let match = tags.filter((t) => {
|
|
20431
20461
|
var _a3;
|
|
20432
20462
|
return (_a3 = t.identify) == null ? void 0 : _a3.call(t, obj);
|
|
20433
20463
|
});
|
|
20464
|
+
if (match.length > 1) {
|
|
20465
|
+
const testMatch = match.filter((t) => t.test);
|
|
20466
|
+
if (testMatch.length > 0)
|
|
20467
|
+
match = testMatch;
|
|
20468
|
+
}
|
|
20434
20469
|
tagObj = match.find((t) => t.format === item.format) ?? match.find((t) => !t.format);
|
|
20435
20470
|
} else {
|
|
20436
20471
|
obj = item;
|
|
@@ -20616,41 +20651,29 @@ ${ctx.indent}`;
|
|
|
20616
20651
|
}
|
|
20617
20652
|
}
|
|
20618
20653
|
const MERGE_KEY = "<<";
|
|
20619
|
-
|
|
20620
|
-
|
|
20621
|
-
|
|
20622
|
-
|
|
20623
|
-
|
|
20624
|
-
|
|
20625
|
-
|
|
20626
|
-
|
|
20627
|
-
|
|
20628
|
-
|
|
20629
|
-
|
|
20630
|
-
|
|
20631
|
-
|
|
20632
|
-
|
|
20633
|
-
|
|
20634
|
-
|
|
20635
|
-
|
|
20636
|
-
|
|
20637
|
-
|
|
20638
|
-
|
|
20639
|
-
|
|
20640
|
-
Object.defineProperty(map2, stringKey, {
|
|
20641
|
-
value: jsValue,
|
|
20642
|
-
writable: true,
|
|
20643
|
-
enumerable: true,
|
|
20644
|
-
configurable: true
|
|
20645
|
-
});
|
|
20646
|
-
else
|
|
20647
|
-
map2[stringKey] = jsValue;
|
|
20648
|
-
}
|
|
20649
|
-
}
|
|
20650
|
-
return map2;
|
|
20654
|
+
const merge = {
|
|
20655
|
+
identify: (value) => value === MERGE_KEY || typeof value === "symbol" && value.description === MERGE_KEY,
|
|
20656
|
+
default: "key",
|
|
20657
|
+
tag: "tag:yaml.org,2002:merge",
|
|
20658
|
+
test: /^<<$/,
|
|
20659
|
+
resolve: () => Object.assign(new Scalar(Symbol(MERGE_KEY)), {
|
|
20660
|
+
addToJSMap: addMergeToJSMap
|
|
20661
|
+
}),
|
|
20662
|
+
stringify: () => MERGE_KEY
|
|
20663
|
+
};
|
|
20664
|
+
const isMergeKey = (ctx, key) => (merge.identify(key) || isScalar(key) && (!key.type || key.type === Scalar.PLAIN) && merge.identify(key.value)) && (ctx == null ? void 0 : ctx.doc.schema.tags.some((tag) => tag.tag === merge.tag && tag.default));
|
|
20665
|
+
function addMergeToJSMap(ctx, map2, value) {
|
|
20666
|
+
value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
20667
|
+
if (isSeq(value))
|
|
20668
|
+
for (const it of value.items)
|
|
20669
|
+
mergeValue(ctx, map2, it);
|
|
20670
|
+
else if (Array.isArray(value))
|
|
20671
|
+
for (const it of value)
|
|
20672
|
+
mergeValue(ctx, map2, it);
|
|
20673
|
+
else
|
|
20674
|
+
mergeValue(ctx, map2, value);
|
|
20651
20675
|
}
|
|
20652
|
-
|
|
20653
|
-
function mergeToJSMap(ctx, map2, value) {
|
|
20676
|
+
function mergeValue(ctx, map2, value) {
|
|
20654
20677
|
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
20655
20678
|
if (!isMap(source))
|
|
20656
20679
|
throw new Error("Merge sources must be maps or map aliases");
|
|
@@ -20672,6 +20695,33 @@ ${ctx.indent}`;
|
|
|
20672
20695
|
}
|
|
20673
20696
|
return map2;
|
|
20674
20697
|
}
|
|
20698
|
+
function addPairToJSMap(ctx, map2, { key, value }) {
|
|
20699
|
+
if (isNode(key) && key.addToJSMap)
|
|
20700
|
+
key.addToJSMap(ctx, map2, value);
|
|
20701
|
+
else if (isMergeKey(ctx, key))
|
|
20702
|
+
addMergeToJSMap(ctx, map2, value);
|
|
20703
|
+
else {
|
|
20704
|
+
const jsKey = toJS(key, "", ctx);
|
|
20705
|
+
if (map2 instanceof Map) {
|
|
20706
|
+
map2.set(jsKey, toJS(value, jsKey, ctx));
|
|
20707
|
+
} else if (map2 instanceof Set) {
|
|
20708
|
+
map2.add(jsKey);
|
|
20709
|
+
} else {
|
|
20710
|
+
const stringKey = stringifyKey(key, jsKey, ctx);
|
|
20711
|
+
const jsValue = toJS(value, stringKey, ctx);
|
|
20712
|
+
if (stringKey in map2)
|
|
20713
|
+
Object.defineProperty(map2, stringKey, {
|
|
20714
|
+
value: jsValue,
|
|
20715
|
+
writable: true,
|
|
20716
|
+
enumerable: true,
|
|
20717
|
+
configurable: true
|
|
20718
|
+
});
|
|
20719
|
+
else
|
|
20720
|
+
map2[stringKey] = jsValue;
|
|
20721
|
+
}
|
|
20722
|
+
}
|
|
20723
|
+
return map2;
|
|
20724
|
+
}
|
|
20675
20725
|
function stringifyKey(key, jsKey, ctx) {
|
|
20676
20726
|
if (jsKey === null)
|
|
20677
20727
|
return "";
|
|
@@ -21271,7 +21321,7 @@ ${indent}${end2}`;
|
|
|
21271
21321
|
identify: (value) => typeof value === "boolean",
|
|
21272
21322
|
default: true,
|
|
21273
21323
|
tag: "tag:yaml.org,2002:bool",
|
|
21274
|
-
test: /^true
|
|
21324
|
+
test: /^true$|^false$/,
|
|
21275
21325
|
resolve: (str) => str === "true",
|
|
21276
21326
|
stringify: stringifyJSON
|
|
21277
21327
|
},
|
|
@@ -21762,7 +21812,7 @@ ${cn.comment}` : item.comment;
|
|
|
21762
21812
|
}
|
|
21763
21813
|
return new Date(date);
|
|
21764
21814
|
},
|
|
21765
|
-
stringify: ({ value }) => value.toISOString().replace(/(
|
|
21815
|
+
stringify: ({ value }) => value.toISOString().replace(/(T00:00:00)?\.000Z$/, "")
|
|
21766
21816
|
};
|
|
21767
21817
|
const schema = [
|
|
21768
21818
|
map,
|
|
@@ -21779,6 +21829,7 @@ ${cn.comment}` : item.comment;
|
|
|
21779
21829
|
floatExp,
|
|
21780
21830
|
float,
|
|
21781
21831
|
binary,
|
|
21832
|
+
merge,
|
|
21782
21833
|
omap,
|
|
21783
21834
|
pairs,
|
|
21784
21835
|
set,
|
|
@@ -21805,6 +21856,7 @@ ${cn.comment}` : item.comment;
|
|
|
21805
21856
|
intOct: intOct$1,
|
|
21806
21857
|
intTime,
|
|
21807
21858
|
map,
|
|
21859
|
+
merge,
|
|
21808
21860
|
null: nullTag,
|
|
21809
21861
|
omap,
|
|
21810
21862
|
pairs,
|
|
@@ -21814,13 +21866,18 @@ ${cn.comment}` : item.comment;
|
|
|
21814
21866
|
};
|
|
21815
21867
|
const coreKnownTags = {
|
|
21816
21868
|
"tag:yaml.org,2002:binary": binary,
|
|
21869
|
+
"tag:yaml.org,2002:merge": merge,
|
|
21817
21870
|
"tag:yaml.org,2002:omap": omap,
|
|
21818
21871
|
"tag:yaml.org,2002:pairs": pairs,
|
|
21819
21872
|
"tag:yaml.org,2002:set": set,
|
|
21820
21873
|
"tag:yaml.org,2002:timestamp": timestamp
|
|
21821
21874
|
};
|
|
21822
|
-
function getTags(customTags, schemaName) {
|
|
21823
|
-
|
|
21875
|
+
function getTags(customTags, schemaName, addMergeTag) {
|
|
21876
|
+
const schemaTags = schemas.get(schemaName);
|
|
21877
|
+
if (schemaTags && !customTags) {
|
|
21878
|
+
return addMergeTag && !schemaTags.includes(merge) ? schemaTags.concat(merge) : schemaTags.slice();
|
|
21879
|
+
}
|
|
21880
|
+
let tags = schemaTags;
|
|
21824
21881
|
if (!tags) {
|
|
21825
21882
|
if (Array.isArray(customTags))
|
|
21826
21883
|
tags = [];
|
|
@@ -21835,24 +21892,27 @@ ${cn.comment}` : item.comment;
|
|
|
21835
21892
|
} else if (typeof customTags === "function") {
|
|
21836
21893
|
tags = customTags(tags.slice());
|
|
21837
21894
|
}
|
|
21838
|
-
|
|
21839
|
-
|
|
21840
|
-
|
|
21841
|
-
const tagObj = tagsByName[tag];
|
|
21842
|
-
if (tagObj)
|
|
21843
|
-
|
|
21844
|
-
|
|
21845
|
-
|
|
21846
|
-
|
|
21895
|
+
if (addMergeTag)
|
|
21896
|
+
tags = tags.concat(merge);
|
|
21897
|
+
return tags.reduce((tags2, tag) => {
|
|
21898
|
+
const tagObj = typeof tag === "string" ? tagsByName[tag] : tag;
|
|
21899
|
+
if (!tagObj) {
|
|
21900
|
+
const tagName = JSON.stringify(tag);
|
|
21901
|
+
const keys = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", ");
|
|
21902
|
+
throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
|
|
21903
|
+
}
|
|
21904
|
+
if (!tags2.includes(tagObj))
|
|
21905
|
+
tags2.push(tagObj);
|
|
21906
|
+
return tags2;
|
|
21907
|
+
}, []);
|
|
21847
21908
|
}
|
|
21848
21909
|
const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
21849
21910
|
class Schema {
|
|
21850
21911
|
constructor({ compat, customTags, merge: merge2, resolveKnownTags, schema: schema2, sortMapEntries, toStringDefaults }) {
|
|
21851
21912
|
this.compat = Array.isArray(compat) ? getTags(compat, "compat") : compat ? getTags(null, compat) : null;
|
|
21852
|
-
this.merge = !!merge2;
|
|
21853
21913
|
this.name = typeof schema2 === "string" && schema2 || "core";
|
|
21854
21914
|
this.knownTags = resolveKnownTags ? coreKnownTags : {};
|
|
21855
|
-
this.tags = getTags(customTags, this.name);
|
|
21915
|
+
this.tags = getTags(customTags, this.name, merge2);
|
|
21856
21916
|
this.toStringOptions = toStringDefaults ?? null;
|
|
21857
21917
|
Object.defineProperty(this, MAP, { value: map });
|
|
21858
21918
|
Object.defineProperty(this, SCALAR$1, { value: string });
|
|
@@ -21955,6 +22015,7 @@ ${cn.comment}` : item.comment;
|
|
|
21955
22015
|
logLevel: "warn",
|
|
21956
22016
|
prettyErrors: true,
|
|
21957
22017
|
strict: true,
|
|
22018
|
+
stringKeys: false,
|
|
21958
22019
|
uniqueKeys: true,
|
|
21959
22020
|
version: "1.2"
|
|
21960
22021
|
}, options);
|
|
@@ -22156,7 +22217,7 @@ ${cn.comment}` : item.comment;
|
|
|
22156
22217
|
this.directives.yaml.version = "1.1";
|
|
22157
22218
|
else
|
|
22158
22219
|
this.directives = new Directives({ version: "1.1" });
|
|
22159
|
-
opt = {
|
|
22220
|
+
opt = { resolveKnownTags: false, schema: "yaml-1.1" };
|
|
22160
22221
|
break;
|
|
22161
22222
|
case "1.2":
|
|
22162
22223
|
case "next":
|
|
@@ -22164,7 +22225,7 @@ ${cn.comment}` : item.comment;
|
|
|
22164
22225
|
this.directives.yaml.version = version;
|
|
22165
22226
|
else
|
|
22166
22227
|
this.directives = new Directives({ version });
|
|
22167
|
-
opt = {
|
|
22228
|
+
opt = { resolveKnownTags: true, schema: "core" };
|
|
22168
22229
|
break;
|
|
22169
22230
|
case null:
|
|
22170
22231
|
if (this.directives)
|
|
@@ -22379,6 +22440,7 @@ ${pointer}
|
|
|
22379
22440
|
hasSpace = false;
|
|
22380
22441
|
break;
|
|
22381
22442
|
}
|
|
22443
|
+
// else fallthrough
|
|
22382
22444
|
default:
|
|
22383
22445
|
onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.type} token`);
|
|
22384
22446
|
atNewline = false;
|
|
@@ -22452,7 +22514,7 @@ ${pointer}
|
|
|
22452
22514
|
const { uniqueKeys } = ctx.options;
|
|
22453
22515
|
if (uniqueKeys === false)
|
|
22454
22516
|
return false;
|
|
22455
|
-
const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a, b) => a === b || isScalar(a) && isScalar(b) && a.value === b.value
|
|
22517
|
+
const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a, b) => a === b || isScalar(a) && isScalar(b) && a.value === b.value;
|
|
22456
22518
|
return items.some((pair) => isEqual(pair.key, search));
|
|
22457
22519
|
}
|
|
22458
22520
|
const startColMsg = "All mapping items must start at the same column";
|
|
@@ -22498,10 +22560,12 @@ ${pointer}
|
|
|
22498
22560
|
} else if (((_a2 = keyProps.found) == null ? void 0 : _a2.indent) !== bm.indent) {
|
|
22499
22561
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
22500
22562
|
}
|
|
22563
|
+
ctx.atKey = true;
|
|
22501
22564
|
const keyStart = keyProps.end;
|
|
22502
22565
|
const keyNode = key ? composeNode2(ctx, key, keyProps, onError) : composeEmptyNode2(ctx, keyStart, start, null, keyProps, onError);
|
|
22503
22566
|
if (ctx.schema.compat)
|
|
22504
22567
|
flowIndentCheck(bm.indent, key, onError);
|
|
22568
|
+
ctx.atKey = false;
|
|
22505
22569
|
if (mapIncludes(ctx, map2.items, keyNode))
|
|
22506
22570
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
22507
22571
|
const valueProps = resolveProps(sep ?? [], {
|
|
@@ -22553,6 +22617,8 @@ ${pointer}
|
|
|
22553
22617
|
const seq2 = new NodeClass(ctx.schema);
|
|
22554
22618
|
if (ctx.atRoot)
|
|
22555
22619
|
ctx.atRoot = false;
|
|
22620
|
+
if (ctx.atKey)
|
|
22621
|
+
ctx.atKey = false;
|
|
22556
22622
|
let offset = bs.offset;
|
|
22557
22623
|
let commentEnd = null;
|
|
22558
22624
|
for (const { start, value } of bs.items) {
|
|
@@ -22632,6 +22698,8 @@ ${pointer}
|
|
|
22632
22698
|
const atRoot = ctx.atRoot;
|
|
22633
22699
|
if (atRoot)
|
|
22634
22700
|
ctx.atRoot = false;
|
|
22701
|
+
if (ctx.atKey)
|
|
22702
|
+
ctx.atKey = false;
|
|
22635
22703
|
let offset = fc.offset + fc.start.source.length;
|
|
22636
22704
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
22637
22705
|
const collItem = fc.items[i];
|
|
@@ -22707,10 +22775,12 @@ ${pointer}
|
|
|
22707
22775
|
if (isBlock(value))
|
|
22708
22776
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
22709
22777
|
} else {
|
|
22778
|
+
ctx.atKey = true;
|
|
22710
22779
|
const keyStart = props.end;
|
|
22711
22780
|
const keyNode = key ? composeNode2(ctx, key, props, onError) : composeEmptyNode2(ctx, keyStart, start, null, props, onError);
|
|
22712
22781
|
if (isBlock(key))
|
|
22713
22782
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
22783
|
+
ctx.atKey = false;
|
|
22714
22784
|
const valueProps = resolveProps(sep ?? [], {
|
|
22715
22785
|
flow: fcName,
|
|
22716
22786
|
indicator: "map-value-ind",
|
|
@@ -22982,6 +23052,7 @@ ${pointer}
|
|
|
22982
23052
|
switch (token.type) {
|
|
22983
23053
|
case "space":
|
|
22984
23054
|
hasSpace = true;
|
|
23055
|
+
// fallthrough
|
|
22985
23056
|
case "newline":
|
|
22986
23057
|
length += token.source.length;
|
|
22987
23058
|
break;
|
|
@@ -22997,6 +23068,7 @@ ${pointer}
|
|
|
22997
23068
|
onError(token, "UNEXPECTED_TOKEN", token.message);
|
|
22998
23069
|
length += token.source.length;
|
|
22999
23070
|
break;
|
|
23071
|
+
/* istanbul ignore next should not happen */
|
|
23000
23072
|
default: {
|
|
23001
23073
|
const message = `Unexpected token in block scalar header: ${token.type}`;
|
|
23002
23074
|
onError(token, "UNEXPECTED_TOKEN", message);
|
|
@@ -23036,6 +23108,7 @@ ${pointer}
|
|
|
23036
23108
|
_type = Scalar.QUOTE_DOUBLE;
|
|
23037
23109
|
value = doubleQuotedValue(source, _onError);
|
|
23038
23110
|
break;
|
|
23111
|
+
/* istanbul ignore next should not happen */
|
|
23039
23112
|
default:
|
|
23040
23113
|
onError(scalar, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`);
|
|
23041
23114
|
return {
|
|
@@ -23057,6 +23130,7 @@ ${pointer}
|
|
|
23057
23130
|
function plainValue(source, onError) {
|
|
23058
23131
|
let badChar = "";
|
|
23059
23132
|
switch (source[0]) {
|
|
23133
|
+
/* istanbul ignore next should not happen */
|
|
23060
23134
|
case " ":
|
|
23061
23135
|
badChar = "a tab character";
|
|
23062
23136
|
break;
|
|
@@ -23228,7 +23302,15 @@ ${pointer}
|
|
|
23228
23302
|
function composeScalar(ctx, token, tagToken, onError) {
|
|
23229
23303
|
const { value, type, comment: comment2, range } = token.type === "block-scalar" ? resolveBlockScalar(ctx, token, onError) : resolveFlowScalar(token, ctx.options.strict, onError);
|
|
23230
23304
|
const tagName = tagToken ? ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)) : null;
|
|
23231
|
-
|
|
23305
|
+
let tag;
|
|
23306
|
+
if (ctx.options.stringKeys && ctx.atKey) {
|
|
23307
|
+
tag = ctx.schema[SCALAR$1];
|
|
23308
|
+
} else if (tagName)
|
|
23309
|
+
tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
|
|
23310
|
+
else if (token.type === "scalar")
|
|
23311
|
+
tag = findScalarTagByTest(ctx, value, token, onError);
|
|
23312
|
+
else
|
|
23313
|
+
tag = ctx.schema[SCALAR$1];
|
|
23232
23314
|
let scalar;
|
|
23233
23315
|
try {
|
|
23234
23316
|
const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
|
|
@@ -23274,10 +23356,10 @@ ${pointer}
|
|
|
23274
23356
|
onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, tagName !== "tag:yaml.org,2002:str");
|
|
23275
23357
|
return schema2[SCALAR$1];
|
|
23276
23358
|
}
|
|
23277
|
-
function findScalarTagByTest({ directives, schema: schema2 }, value, token, onError) {
|
|
23359
|
+
function findScalarTagByTest({ atKey, directives, schema: schema2 }, value, token, onError) {
|
|
23278
23360
|
const tag = schema2.tags.find((tag2) => {
|
|
23279
23361
|
var _a2;
|
|
23280
|
-
return tag2.default && ((_a2 = tag2.test) == null ? void 0 : _a2.test(value));
|
|
23362
|
+
return (tag2.default === true || atKey && tag2.default === "key") && ((_a2 = tag2.test) == null ? void 0 : _a2.test(value));
|
|
23281
23363
|
}) || schema2[SCALAR$1];
|
|
23282
23364
|
if (schema2.compat) {
|
|
23283
23365
|
const compat = schema2.compat.find((tag2) => {
|
|
@@ -23318,6 +23400,7 @@ ${pointer}
|
|
|
23318
23400
|
}
|
|
23319
23401
|
const CN = { composeNode, composeEmptyNode };
|
|
23320
23402
|
function composeNode(ctx, token, props, onError) {
|
|
23403
|
+
const atKey = ctx.atKey;
|
|
23321
23404
|
const { spaceBefore, comment: comment2, anchor, tag } = props;
|
|
23322
23405
|
let node;
|
|
23323
23406
|
let isSrcToken = true;
|
|
@@ -23351,6 +23434,10 @@ ${pointer}
|
|
|
23351
23434
|
}
|
|
23352
23435
|
if (anchor && node.anchor === "")
|
|
23353
23436
|
onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string");
|
|
23437
|
+
if (atKey && ctx.options.stringKeys && (!isScalar(node) || typeof node.value !== "string" || node.tag && node.tag !== "tag:yaml.org,2002:str")) {
|
|
23438
|
+
const msg = "With stringKeys, all keys must be strings";
|
|
23439
|
+
onError(tag ?? token, "NON_STRING_KEY", msg);
|
|
23440
|
+
}
|
|
23354
23441
|
if (spaceBefore)
|
|
23355
23442
|
node.spaceBefore = true;
|
|
23356
23443
|
if (comment2) {
|
|
@@ -23401,6 +23488,7 @@ ${pointer}
|
|
|
23401
23488
|
const opts = Object.assign({ _directives: directives }, options);
|
|
23402
23489
|
const doc = new Document(void 0, opts);
|
|
23403
23490
|
const ctx = {
|
|
23491
|
+
atKey: false,
|
|
23404
23492
|
atRoot: true,
|
|
23405
23493
|
directives: doc.directives,
|
|
23406
23494
|
options: doc.options,
|
|
@@ -23890,6 +23978,7 @@ ${end2.comment}` : end2.comment;
|
|
|
23890
23978
|
switch (line[n]) {
|
|
23891
23979
|
case "#":
|
|
23892
23980
|
yield* this.pushCount(line.length - n);
|
|
23981
|
+
// fallthrough
|
|
23893
23982
|
case void 0:
|
|
23894
23983
|
yield* this.pushNewline();
|
|
23895
23984
|
return yield* this.parseLineStart();
|
|
@@ -23985,6 +24074,7 @@ ${end2.comment}` : end2.comment;
|
|
|
23985
24074
|
return "flow";
|
|
23986
24075
|
}
|
|
23987
24076
|
}
|
|
24077
|
+
// fallthrough
|
|
23988
24078
|
default:
|
|
23989
24079
|
this.flowKey = false;
|
|
23990
24080
|
return yield* this.parsePlainScalar();
|
|
@@ -24062,6 +24152,7 @@ ${end2.comment}` : end2.comment;
|
|
|
24062
24152
|
if (next2 === "\n")
|
|
24063
24153
|
break;
|
|
24064
24154
|
}
|
|
24155
|
+
// fallthrough
|
|
24065
24156
|
default:
|
|
24066
24157
|
break loop;
|
|
24067
24158
|
}
|
|
@@ -24179,7 +24270,9 @@ ${end2.comment}` : end2.comment;
|
|
|
24179
24270
|
case "&":
|
|
24180
24271
|
return (yield* this.pushUntil(isNotAnchorChar)) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators());
|
|
24181
24272
|
case "-":
|
|
24273
|
+
// this is an error
|
|
24182
24274
|
case "?":
|
|
24275
|
+
// this is an error outside flow collections
|
|
24183
24276
|
case ":": {
|
|
24184
24277
|
const inFlow = this.flowLevel > 0;
|
|
24185
24278
|
const ch1 = this.charAt(1);
|
|
@@ -24309,6 +24402,7 @@ ${end2.comment}` : end2.comment;
|
|
|
24309
24402
|
}
|
|
24310
24403
|
case "block-seq":
|
|
24311
24404
|
return parent2.items[parent2.items.length - 1].start;
|
|
24405
|
+
/* istanbul ignore next should not happen */
|
|
24312
24406
|
default:
|
|
24313
24407
|
return [];
|
|
24314
24408
|
}
|
|
@@ -24541,6 +24635,7 @@ ${end2.comment}` : end2.comment;
|
|
|
24541
24635
|
Object.assign(it, { key: token, sep: [] });
|
|
24542
24636
|
return;
|
|
24543
24637
|
}
|
|
24638
|
+
/* istanbul ignore next should not happen */
|
|
24544
24639
|
default:
|
|
24545
24640
|
yield* this.pop();
|
|
24546
24641
|
yield* this.pop(token);
|
|
@@ -24662,6 +24757,7 @@ ${end2.comment}` : end2.comment;
|
|
|
24662
24757
|
}
|
|
24663
24758
|
yield* this.pop();
|
|
24664
24759
|
break;
|
|
24760
|
+
/* istanbul ignore next should not happen */
|
|
24665
24761
|
default:
|
|
24666
24762
|
yield* this.pop();
|
|
24667
24763
|
yield* this.step();
|
|
@@ -25099,6 +25195,7 @@ ${end2.comment}` : end2.comment;
|
|
|
25099
25195
|
break;
|
|
25100
25196
|
case "newline":
|
|
25101
25197
|
this.onKeyLine = false;
|
|
25198
|
+
// fallthrough
|
|
25102
25199
|
case "space":
|
|
25103
25200
|
case "comment":
|
|
25104
25201
|
default:
|
|
@@ -25280,159 +25377,6 @@ ${end2.comment}` : end2.comment;
|
|
|
25280
25377
|
};
|
|
25281
25378
|
}
|
|
25282
25379
|
});
|
|
25283
|
-
var katex = require$$0;
|
|
25284
|
-
function isValidDelim(state, pos) {
|
|
25285
|
-
var prevChar, nextChar, max = state.posMax, can_open = true, can_close = true;
|
|
25286
|
-
prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1;
|
|
25287
|
-
nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1;
|
|
25288
|
-
if (prevChar === 32 || prevChar === 9 || nextChar >= 48 && nextChar <= 57) {
|
|
25289
|
-
can_close = false;
|
|
25290
|
-
}
|
|
25291
|
-
if (nextChar === 32 || nextChar === 9) {
|
|
25292
|
-
can_open = false;
|
|
25293
|
-
}
|
|
25294
|
-
return {
|
|
25295
|
-
can_open,
|
|
25296
|
-
can_close
|
|
25297
|
-
};
|
|
25298
|
-
}
|
|
25299
|
-
function math_inline(state, silent) {
|
|
25300
|
-
var start, match, token, res, pos;
|
|
25301
|
-
if (state.src[state.pos] !== "$") {
|
|
25302
|
-
return false;
|
|
25303
|
-
}
|
|
25304
|
-
res = isValidDelim(state, state.pos);
|
|
25305
|
-
if (!res.can_open) {
|
|
25306
|
-
if (!silent) {
|
|
25307
|
-
state.pending += "$";
|
|
25308
|
-
}
|
|
25309
|
-
state.pos += 1;
|
|
25310
|
-
return true;
|
|
25311
|
-
}
|
|
25312
|
-
start = state.pos + 1;
|
|
25313
|
-
match = start;
|
|
25314
|
-
while ((match = state.src.indexOf("$", match)) !== -1) {
|
|
25315
|
-
pos = match - 1;
|
|
25316
|
-
while (state.src[pos] === "\\") {
|
|
25317
|
-
pos -= 1;
|
|
25318
|
-
}
|
|
25319
|
-
if ((match - pos) % 2 == 1) {
|
|
25320
|
-
break;
|
|
25321
|
-
}
|
|
25322
|
-
match += 1;
|
|
25323
|
-
}
|
|
25324
|
-
if (match === -1) {
|
|
25325
|
-
if (!silent) {
|
|
25326
|
-
state.pending += "$";
|
|
25327
|
-
}
|
|
25328
|
-
state.pos = start;
|
|
25329
|
-
return true;
|
|
25330
|
-
}
|
|
25331
|
-
if (match - start === 0) {
|
|
25332
|
-
if (!silent) {
|
|
25333
|
-
state.pending += "$$";
|
|
25334
|
-
}
|
|
25335
|
-
state.pos = start + 1;
|
|
25336
|
-
return true;
|
|
25337
|
-
}
|
|
25338
|
-
res = isValidDelim(state, match);
|
|
25339
|
-
if (!res.can_close) {
|
|
25340
|
-
if (!silent) {
|
|
25341
|
-
state.pending += "$";
|
|
25342
|
-
}
|
|
25343
|
-
state.pos = start;
|
|
25344
|
-
return true;
|
|
25345
|
-
}
|
|
25346
|
-
if (!silent) {
|
|
25347
|
-
token = state.push("math_inline", "math", 0);
|
|
25348
|
-
token.markup = "$";
|
|
25349
|
-
token.content = state.src.slice(start, match);
|
|
25350
|
-
}
|
|
25351
|
-
state.pos = match + 1;
|
|
25352
|
-
return true;
|
|
25353
|
-
}
|
|
25354
|
-
function math_block(state, start, end2, silent) {
|
|
25355
|
-
var firstLine, lastLine, next2, lastPos, found = false, token, pos = state.bMarks[start] + state.tShift[start], max = state.eMarks[start];
|
|
25356
|
-
if (pos + 2 > max) {
|
|
25357
|
-
return false;
|
|
25358
|
-
}
|
|
25359
|
-
if (state.src.slice(pos, pos + 2) !== "$$") {
|
|
25360
|
-
return false;
|
|
25361
|
-
}
|
|
25362
|
-
pos += 2;
|
|
25363
|
-
firstLine = state.src.slice(pos, max);
|
|
25364
|
-
if (silent) {
|
|
25365
|
-
return true;
|
|
25366
|
-
}
|
|
25367
|
-
if (firstLine.trim().slice(-2) === "$$") {
|
|
25368
|
-
firstLine = firstLine.trim().slice(0, -2);
|
|
25369
|
-
found = true;
|
|
25370
|
-
}
|
|
25371
|
-
for (next2 = start; !found; ) {
|
|
25372
|
-
next2++;
|
|
25373
|
-
if (next2 >= end2) {
|
|
25374
|
-
break;
|
|
25375
|
-
}
|
|
25376
|
-
pos = state.bMarks[next2] + state.tShift[next2];
|
|
25377
|
-
max = state.eMarks[next2];
|
|
25378
|
-
if (pos < max && state.tShift[next2] < state.blkIndent) {
|
|
25379
|
-
break;
|
|
25380
|
-
}
|
|
25381
|
-
if (state.src.slice(pos, max).trim().slice(-2) === "$$") {
|
|
25382
|
-
lastPos = state.src.slice(0, max).lastIndexOf("$$");
|
|
25383
|
-
lastLine = state.src.slice(pos, lastPos);
|
|
25384
|
-
found = true;
|
|
25385
|
-
}
|
|
25386
|
-
}
|
|
25387
|
-
state.line = next2 + 1;
|
|
25388
|
-
token = state.push("math_block", "math", 0);
|
|
25389
|
-
token.block = true;
|
|
25390
|
-
token.content = (firstLine && firstLine.trim() ? firstLine + "\n" : "") + state.getLines(start + 1, next2, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
25391
|
-
token.map = [start, state.line];
|
|
25392
|
-
token.markup = "$$";
|
|
25393
|
-
return true;
|
|
25394
|
-
}
|
|
25395
|
-
function escapeHtml(unsafe) {
|
|
25396
|
-
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
25397
|
-
}
|
|
25398
|
-
var markdownItKatex = function math_plugin(md, options) {
|
|
25399
|
-
options = options || {};
|
|
25400
|
-
var katexInline = function(latex) {
|
|
25401
|
-
options.displayMode = false;
|
|
25402
|
-
try {
|
|
25403
|
-
return katex.renderToString(latex, options);
|
|
25404
|
-
} catch (error2) {
|
|
25405
|
-
if (options.throwOnError) {
|
|
25406
|
-
console.log(error2);
|
|
25407
|
-
}
|
|
25408
|
-
return `<span class='katex-error' title='${escapeHtml(error2.toString())}'>${escapeHtml(latex)}</span>`;
|
|
25409
|
-
}
|
|
25410
|
-
};
|
|
25411
|
-
var inlineRenderer = function(tokens, idx) {
|
|
25412
|
-
return katexInline(tokens[idx].content);
|
|
25413
|
-
};
|
|
25414
|
-
var katexBlock = function(latex) {
|
|
25415
|
-
options.displayMode = true;
|
|
25416
|
-
try {
|
|
25417
|
-
return "<p class='katex-block'>" + katex.renderToString(latex, options) + "</p>";
|
|
25418
|
-
} catch (error2) {
|
|
25419
|
-
if (options.throwOnError) {
|
|
25420
|
-
console.log(error2);
|
|
25421
|
-
}
|
|
25422
|
-
return `<p class='katex-block katex-error' title='${escapeHtml(error2.toString())}'>${escapeHtml(latex)}</p>`;
|
|
25423
|
-
}
|
|
25424
|
-
};
|
|
25425
|
-
var blockRenderer = function(tokens, idx) {
|
|
25426
|
-
return katexBlock(tokens[idx].content) + "\n";
|
|
25427
|
-
};
|
|
25428
|
-
md.inline.ruler.after("escape", "math_inline", math_inline);
|
|
25429
|
-
md.block.ruler.after("blockquote", "math_block", math_block, {
|
|
25430
|
-
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
25431
|
-
});
|
|
25432
|
-
md.renderer.rules.math_inline = inlineRenderer;
|
|
25433
|
-
md.renderer.rules.math_block = blockRenderer;
|
|
25434
|
-
};
|
|
25435
|
-
const katexPlugin = /* @__PURE__ */ getDefaultExportFromCjs(markdownItKatex);
|
|
25436
25380
|
function addDefaultVersions(paths, name2, version) {
|
|
25437
25381
|
return paths.map((path) => {
|
|
25438
25382
|
if (typeof path === "string" && !path.includes("://")) {
|
|
@@ -25451,18 +25395,18 @@ ${end2.comment}` : end2.comment;
|
|
|
25451
25395
|
}
|
|
25452
25396
|
const name$2 = "katex";
|
|
25453
25397
|
const preloadScripts = [
|
|
25454
|
-
`katex@${"0.16.
|
|
25398
|
+
`katex@${"0.16.15"}/dist/katex.min.js`
|
|
25455
25399
|
].map((path) => buildJSItem(path));
|
|
25456
25400
|
const webfontloader = buildJSItem(
|
|
25457
25401
|
`webfontloader@${"1.6.28"}/webfontloader.js`
|
|
25458
25402
|
);
|
|
25459
25403
|
webfontloader.data.defer = true;
|
|
25460
|
-
const styles = [`katex@${"0.16.
|
|
25404
|
+
const styles = [`katex@${"0.16.15"}/dist/katex.min.css`].map(
|
|
25461
25405
|
(path) => buildCSSItem(path)
|
|
25462
25406
|
);
|
|
25463
25407
|
const config = {
|
|
25464
25408
|
versions: {
|
|
25465
|
-
katex: "0.16.
|
|
25409
|
+
katex: "0.16.15",
|
|
25466
25410
|
webfontloader: "1.6.28"
|
|
25467
25411
|
},
|
|
25468
25412
|
preloadScripts,
|
|
@@ -25502,6 +25446,432 @@ ${end2.comment}` : end2.comment;
|
|
|
25502
25446
|
],
|
|
25503
25447
|
styles
|
|
25504
25448
|
};
|
|
25449
|
+
var dist = {};
|
|
25450
|
+
var hasRequiredDist;
|
|
25451
|
+
function requireDist() {
|
|
25452
|
+
if (hasRequiredDist) return dist;
|
|
25453
|
+
hasRequiredDist = 1;
|
|
25454
|
+
var __importDefault = dist && dist.__importDefault || function(mod) {
|
|
25455
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
25456
|
+
};
|
|
25457
|
+
Object.defineProperty(dist, "__esModule", { value: true });
|
|
25458
|
+
const katex_1 = __importDefault(require$$0);
|
|
25459
|
+
function isValidInlineDelim(state, pos) {
|
|
25460
|
+
const prevChar = state.src[pos - 1];
|
|
25461
|
+
const char = state.src[pos];
|
|
25462
|
+
const nextChar = state.src[pos + 1];
|
|
25463
|
+
if (char !== "$") {
|
|
25464
|
+
return { can_open: false, can_close: false };
|
|
25465
|
+
}
|
|
25466
|
+
let canOpen = false;
|
|
25467
|
+
let canClose = false;
|
|
25468
|
+
if (prevChar !== "$" && prevChar !== "\\" && (prevChar === void 0 || isWhitespace2(prevChar) || !isWordCharacterOrNumber(prevChar))) {
|
|
25469
|
+
canOpen = true;
|
|
25470
|
+
}
|
|
25471
|
+
if (nextChar !== "$" && (nextChar == void 0 || isWhitespace2(nextChar) || !isWordCharacterOrNumber(nextChar))) {
|
|
25472
|
+
canClose = true;
|
|
25473
|
+
}
|
|
25474
|
+
return { can_open: canOpen, can_close: canClose };
|
|
25475
|
+
}
|
|
25476
|
+
function isWhitespace2(char) {
|
|
25477
|
+
return /^\s$/u.test(char);
|
|
25478
|
+
}
|
|
25479
|
+
function isWordCharacterOrNumber(char) {
|
|
25480
|
+
return /^[\w\d]$/u.test(char);
|
|
25481
|
+
}
|
|
25482
|
+
function isValidBlockDelim(state, pos) {
|
|
25483
|
+
const prevChar = state.src[pos - 1];
|
|
25484
|
+
const char = state.src[pos];
|
|
25485
|
+
const nextChar = state.src[pos + 1];
|
|
25486
|
+
const nextCharPlus1 = state.src[pos + 2];
|
|
25487
|
+
if (char === "$" && prevChar !== "$" && prevChar !== "\\" && nextChar === "$" && nextCharPlus1 !== "$") {
|
|
25488
|
+
return { can_open: true, can_close: true };
|
|
25489
|
+
}
|
|
25490
|
+
return { can_open: false, can_close: false };
|
|
25491
|
+
}
|
|
25492
|
+
function inlineMath(state, silent) {
|
|
25493
|
+
if (state.src[state.pos] !== "$") {
|
|
25494
|
+
return false;
|
|
25495
|
+
}
|
|
25496
|
+
const lastToken = state.tokens.at(-1);
|
|
25497
|
+
if ((lastToken == null ? void 0 : lastToken.type) === "html_inline") {
|
|
25498
|
+
if (/^<\w+.+[^/]>$/.test(lastToken.content)) {
|
|
25499
|
+
return false;
|
|
25500
|
+
}
|
|
25501
|
+
}
|
|
25502
|
+
let res = isValidInlineDelim(state, state.pos);
|
|
25503
|
+
if (!res.can_open) {
|
|
25504
|
+
if (!silent) {
|
|
25505
|
+
state.pending += "$";
|
|
25506
|
+
}
|
|
25507
|
+
state.pos += 1;
|
|
25508
|
+
return true;
|
|
25509
|
+
}
|
|
25510
|
+
let start = state.pos + 1;
|
|
25511
|
+
let match = start;
|
|
25512
|
+
let pos;
|
|
25513
|
+
while ((match = state.src.indexOf("$", match)) !== -1) {
|
|
25514
|
+
pos = match - 1;
|
|
25515
|
+
while (state.src[pos] === "\\") {
|
|
25516
|
+
pos -= 1;
|
|
25517
|
+
}
|
|
25518
|
+
if ((match - pos) % 2 == 1) {
|
|
25519
|
+
break;
|
|
25520
|
+
}
|
|
25521
|
+
match += 1;
|
|
25522
|
+
}
|
|
25523
|
+
if (match === -1) {
|
|
25524
|
+
if (!silent) {
|
|
25525
|
+
state.pending += "$";
|
|
25526
|
+
}
|
|
25527
|
+
state.pos = start;
|
|
25528
|
+
return true;
|
|
25529
|
+
}
|
|
25530
|
+
if (match - start === 0) {
|
|
25531
|
+
if (!silent) {
|
|
25532
|
+
state.pending += "$$";
|
|
25533
|
+
}
|
|
25534
|
+
state.pos = start + 1;
|
|
25535
|
+
return true;
|
|
25536
|
+
}
|
|
25537
|
+
res = isValidInlineDelim(state, match);
|
|
25538
|
+
if (!res.can_close) {
|
|
25539
|
+
if (!silent) {
|
|
25540
|
+
state.pending += "$";
|
|
25541
|
+
}
|
|
25542
|
+
state.pos = start;
|
|
25543
|
+
return true;
|
|
25544
|
+
}
|
|
25545
|
+
if (!silent) {
|
|
25546
|
+
const token = state.push("math_inline", "math", 0);
|
|
25547
|
+
token.markup = "$";
|
|
25548
|
+
token.content = state.src.slice(start, match);
|
|
25549
|
+
}
|
|
25550
|
+
state.pos = match + 1;
|
|
25551
|
+
return true;
|
|
25552
|
+
}
|
|
25553
|
+
function blockMath(state, start, end2, silent) {
|
|
25554
|
+
var lastLine, next2, lastPos, found = false, token, pos = state.bMarks[start] + state.tShift[start], max = state.eMarks[start];
|
|
25555
|
+
if (pos + 2 > max) {
|
|
25556
|
+
return false;
|
|
25557
|
+
}
|
|
25558
|
+
if (state.src.slice(pos, pos + 2) !== "$$") {
|
|
25559
|
+
return false;
|
|
25560
|
+
}
|
|
25561
|
+
pos += 2;
|
|
25562
|
+
let firstLine = state.src.slice(pos, max);
|
|
25563
|
+
if (silent) {
|
|
25564
|
+
return true;
|
|
25565
|
+
}
|
|
25566
|
+
if (firstLine.trim().slice(-2) === "$$") {
|
|
25567
|
+
firstLine = firstLine.trim().slice(0, -2);
|
|
25568
|
+
found = true;
|
|
25569
|
+
}
|
|
25570
|
+
for (next2 = start; !found; ) {
|
|
25571
|
+
next2++;
|
|
25572
|
+
if (next2 >= end2) {
|
|
25573
|
+
break;
|
|
25574
|
+
}
|
|
25575
|
+
pos = state.bMarks[next2] + state.tShift[next2];
|
|
25576
|
+
max = state.eMarks[next2];
|
|
25577
|
+
if (pos < max && state.tShift[next2] < state.blkIndent) {
|
|
25578
|
+
break;
|
|
25579
|
+
}
|
|
25580
|
+
if (state.src.slice(pos, max).trim().slice(-2) === "$$") {
|
|
25581
|
+
lastPos = state.src.slice(0, max).lastIndexOf("$$");
|
|
25582
|
+
lastLine = state.src.slice(pos, lastPos);
|
|
25583
|
+
found = true;
|
|
25584
|
+
} else if (state.src.slice(pos, max).trim().includes("$$")) {
|
|
25585
|
+
lastPos = state.src.slice(0, max).trim().indexOf("$$");
|
|
25586
|
+
lastLine = state.src.slice(pos, lastPos);
|
|
25587
|
+
found = true;
|
|
25588
|
+
}
|
|
25589
|
+
}
|
|
25590
|
+
state.line = next2 + 1;
|
|
25591
|
+
token = state.push("math_block", "math", 0);
|
|
25592
|
+
token.block = true;
|
|
25593
|
+
token.content = (firstLine && firstLine.trim() ? firstLine + "\n" : "") + state.getLines(start + 1, next2, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
25594
|
+
token.map = [start, state.line];
|
|
25595
|
+
token.markup = "$$";
|
|
25596
|
+
return true;
|
|
25597
|
+
}
|
|
25598
|
+
function blockBareMath(state, start, end2, silent) {
|
|
25599
|
+
const startPos = state.bMarks[start] + state.tShift[start];
|
|
25600
|
+
const startMax = state.eMarks[start];
|
|
25601
|
+
const firstLine = state.src.slice(startPos, startMax);
|
|
25602
|
+
const beginMatch = firstLine.match(/^\s*\\begin\s*\{([^{}]+)\}/);
|
|
25603
|
+
if (!beginMatch) {
|
|
25604
|
+
return false;
|
|
25605
|
+
}
|
|
25606
|
+
if (start > 0) {
|
|
25607
|
+
const previousStart = state.bMarks[start - 1] + state.tShift[start - 1];
|
|
25608
|
+
const previousEnd = state.eMarks[start - 1];
|
|
25609
|
+
const previousLine = state.src.slice(previousStart, previousEnd);
|
|
25610
|
+
if (!/^\s*$/.test(previousLine)) {
|
|
25611
|
+
return false;
|
|
25612
|
+
}
|
|
25613
|
+
}
|
|
25614
|
+
if (silent) {
|
|
25615
|
+
return true;
|
|
25616
|
+
}
|
|
25617
|
+
const beginEndStack = [];
|
|
25618
|
+
let next2 = start;
|
|
25619
|
+
let lastLine;
|
|
25620
|
+
let found = false;
|
|
25621
|
+
outer: for (; !found; next2++) {
|
|
25622
|
+
if (next2 >= end2) {
|
|
25623
|
+
break;
|
|
25624
|
+
}
|
|
25625
|
+
const pos = state.bMarks[next2] + state.tShift[next2];
|
|
25626
|
+
const max = state.eMarks[next2];
|
|
25627
|
+
if (pos < max && state.tShift[next2] < state.blkIndent) {
|
|
25628
|
+
break;
|
|
25629
|
+
}
|
|
25630
|
+
const line = state.src.slice(pos, max);
|
|
25631
|
+
for (const match of line.matchAll(/(\\begin|\\end)\s*\{([^{}]+)\}/g)) {
|
|
25632
|
+
if (match[1] === "\\begin") {
|
|
25633
|
+
beginEndStack.push(match[2].trim());
|
|
25634
|
+
} else if (match[1] === "\\end") {
|
|
25635
|
+
beginEndStack.pop();
|
|
25636
|
+
if (!beginEndStack.length) {
|
|
25637
|
+
lastLine = state.src.slice(pos, max);
|
|
25638
|
+
found = true;
|
|
25639
|
+
break outer;
|
|
25640
|
+
}
|
|
25641
|
+
}
|
|
25642
|
+
}
|
|
25643
|
+
}
|
|
25644
|
+
state.line = next2 + 1;
|
|
25645
|
+
const token = state.push("math_block", "math", 0);
|
|
25646
|
+
token.block = true;
|
|
25647
|
+
token.content = (state.getLines(start, next2, state.tShift[start], true) + (lastLine ?? "")).trim();
|
|
25648
|
+
token.map = [start, state.line];
|
|
25649
|
+
token.markup = "$$";
|
|
25650
|
+
return true;
|
|
25651
|
+
}
|
|
25652
|
+
function inlineMathBlock(state, silent) {
|
|
25653
|
+
var start, match, token, res, pos;
|
|
25654
|
+
if (state.src.slice(state.pos, state.pos + 2) !== "$$") {
|
|
25655
|
+
return false;
|
|
25656
|
+
}
|
|
25657
|
+
res = isValidBlockDelim(state, state.pos);
|
|
25658
|
+
if (!res.can_open) {
|
|
25659
|
+
if (!silent) {
|
|
25660
|
+
state.pending += "$$";
|
|
25661
|
+
}
|
|
25662
|
+
state.pos += 2;
|
|
25663
|
+
return true;
|
|
25664
|
+
}
|
|
25665
|
+
start = state.pos + 2;
|
|
25666
|
+
match = start;
|
|
25667
|
+
while ((match = state.src.indexOf("$$", match)) !== -1) {
|
|
25668
|
+
pos = match - 1;
|
|
25669
|
+
while (state.src[pos] === "\\") {
|
|
25670
|
+
pos -= 1;
|
|
25671
|
+
}
|
|
25672
|
+
if ((match - pos) % 2 == 1) {
|
|
25673
|
+
break;
|
|
25674
|
+
}
|
|
25675
|
+
match += 2;
|
|
25676
|
+
}
|
|
25677
|
+
if (match === -1) {
|
|
25678
|
+
if (!silent) {
|
|
25679
|
+
state.pending += "$$";
|
|
25680
|
+
}
|
|
25681
|
+
state.pos = start;
|
|
25682
|
+
return true;
|
|
25683
|
+
}
|
|
25684
|
+
if (match - start === 0) {
|
|
25685
|
+
if (!silent) {
|
|
25686
|
+
state.pending += "$$$$";
|
|
25687
|
+
}
|
|
25688
|
+
state.pos = start + 2;
|
|
25689
|
+
return true;
|
|
25690
|
+
}
|
|
25691
|
+
res = isValidBlockDelim(state, match);
|
|
25692
|
+
if (!res.can_close) {
|
|
25693
|
+
if (!silent) {
|
|
25694
|
+
state.pending += "$$";
|
|
25695
|
+
}
|
|
25696
|
+
state.pos = start;
|
|
25697
|
+
return true;
|
|
25698
|
+
}
|
|
25699
|
+
if (!silent) {
|
|
25700
|
+
token = state.push("math_block", "math", 0);
|
|
25701
|
+
token.block = true;
|
|
25702
|
+
token.markup = "$$";
|
|
25703
|
+
token.content = state.src.slice(start, match);
|
|
25704
|
+
}
|
|
25705
|
+
state.pos = match + 2;
|
|
25706
|
+
return true;
|
|
25707
|
+
}
|
|
25708
|
+
function inlineBareBlock(state, silent) {
|
|
25709
|
+
const text2 = state.src.slice(state.pos);
|
|
25710
|
+
if (!/^\n\\begin/.test(text2)) {
|
|
25711
|
+
return false;
|
|
25712
|
+
}
|
|
25713
|
+
state.pos += 1;
|
|
25714
|
+
if (silent) {
|
|
25715
|
+
return true;
|
|
25716
|
+
}
|
|
25717
|
+
const lines = text2.split(/\n/g).slice(1);
|
|
25718
|
+
let foundLine;
|
|
25719
|
+
const beginEndStack = [];
|
|
25720
|
+
outer: for (var i = 0; i < lines.length; ++i) {
|
|
25721
|
+
const line = lines[i];
|
|
25722
|
+
for (const match of line.matchAll(/(\\begin|\\end)\s*\{([^{}]+)\}/g)) {
|
|
25723
|
+
if (match[1] === "\\begin") {
|
|
25724
|
+
beginEndStack.push(match[2].trim());
|
|
25725
|
+
} else if (match[1] === "\\end") {
|
|
25726
|
+
beginEndStack.pop();
|
|
25727
|
+
if (!beginEndStack.length) {
|
|
25728
|
+
foundLine = i;
|
|
25729
|
+
break outer;
|
|
25730
|
+
}
|
|
25731
|
+
}
|
|
25732
|
+
}
|
|
25733
|
+
}
|
|
25734
|
+
if (typeof foundLine === "undefined") {
|
|
25735
|
+
return false;
|
|
25736
|
+
}
|
|
25737
|
+
const endIndex = lines.slice(0, foundLine + 1).reduce((p, c) => p + c.length, 0) + foundLine + 1;
|
|
25738
|
+
const token = state.push("math_inline_bare_block", "math", 0);
|
|
25739
|
+
token.block = true;
|
|
25740
|
+
token.markup = "$$";
|
|
25741
|
+
token.content = text2.slice(1, endIndex);
|
|
25742
|
+
state.pos = state.pos + endIndex;
|
|
25743
|
+
return true;
|
|
25744
|
+
}
|
|
25745
|
+
function handleMathInHtml(state, mathType, mathMarkup, mathRegex) {
|
|
25746
|
+
const tokens = state.tokens;
|
|
25747
|
+
for (let index2 = tokens.length - 1; index2 >= 0; index2--) {
|
|
25748
|
+
const currentToken = tokens[index2];
|
|
25749
|
+
const newTokens = [];
|
|
25750
|
+
if (currentToken.type !== "html_block") {
|
|
25751
|
+
continue;
|
|
25752
|
+
}
|
|
25753
|
+
const content = currentToken.content;
|
|
25754
|
+
for (const match of content.matchAll(mathRegex)) {
|
|
25755
|
+
if (!match.groups) {
|
|
25756
|
+
continue;
|
|
25757
|
+
}
|
|
25758
|
+
const html_before_math = match.groups.html_before_math;
|
|
25759
|
+
const math = match.groups.math;
|
|
25760
|
+
const html_after_math = match.groups.html_after_math;
|
|
25761
|
+
if (html_before_math) {
|
|
25762
|
+
newTokens.push({ ...currentToken, type: "html_block", map: null, content: html_before_math });
|
|
25763
|
+
}
|
|
25764
|
+
if (math) {
|
|
25765
|
+
newTokens.push({
|
|
25766
|
+
...currentToken,
|
|
25767
|
+
type: mathType,
|
|
25768
|
+
map: null,
|
|
25769
|
+
content: math,
|
|
25770
|
+
markup: mathMarkup,
|
|
25771
|
+
block: true,
|
|
25772
|
+
tag: "math"
|
|
25773
|
+
});
|
|
25774
|
+
}
|
|
25775
|
+
if (html_after_math) {
|
|
25776
|
+
newTokens.push({ ...currentToken, type: "html_block", map: null, content: html_after_math });
|
|
25777
|
+
}
|
|
25778
|
+
}
|
|
25779
|
+
if (newTokens.length > 0) {
|
|
25780
|
+
tokens.splice(index2, 1, ...newTokens);
|
|
25781
|
+
}
|
|
25782
|
+
}
|
|
25783
|
+
return true;
|
|
25784
|
+
}
|
|
25785
|
+
function escapeHtml2(unsafe) {
|
|
25786
|
+
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
25787
|
+
}
|
|
25788
|
+
function default_1(md, options) {
|
|
25789
|
+
const katex = (options == null ? void 0 : options.katex) ?? katex_1.default;
|
|
25790
|
+
const enableBareBlocks = options == null ? void 0 : options.enableBareBlocks;
|
|
25791
|
+
const enableMathBlockInHtml = options == null ? void 0 : options.enableMathBlockInHtml;
|
|
25792
|
+
const enableMathInlineInHtml = options == null ? void 0 : options.enableMathInlineInHtml;
|
|
25793
|
+
const enableFencedBlocks = options == null ? void 0 : options.enableFencedBlocks;
|
|
25794
|
+
md.inline.ruler.after("escape", "math_inline", inlineMath);
|
|
25795
|
+
md.inline.ruler.after("escape", "math_inline_block", inlineMathBlock);
|
|
25796
|
+
if (enableBareBlocks) {
|
|
25797
|
+
md.inline.ruler.before("text", "math_inline_bare_block", inlineBareBlock);
|
|
25798
|
+
}
|
|
25799
|
+
md.block.ruler.after("blockquote", "math_block", (state, start, end2, silent) => {
|
|
25800
|
+
if (enableBareBlocks && blockBareMath(state, start, end2, silent)) {
|
|
25801
|
+
return true;
|
|
25802
|
+
}
|
|
25803
|
+
return blockMath(state, start, end2, silent);
|
|
25804
|
+
}, {
|
|
25805
|
+
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
25806
|
+
});
|
|
25807
|
+
const math_block_within_html_regex = /(?<html_before_math>[\s\S]*?)\$\$(?<math>[\s\S]+?)\$\$(?<html_after_math>(?:(?!\$\$[\s\S]+?\$\$)[\s\S])*)/gm;
|
|
25808
|
+
const math_inline_within_html_regex = /(?<html_before_math>[\s\S]*?)\$(?<math>.*?)\$(?<html_after_math>(?:(?!\$.*?\$)[\s\S])*)/gm;
|
|
25809
|
+
if (enableMathBlockInHtml) {
|
|
25810
|
+
md.core.ruler.push("math_block_in_html_block", (state) => {
|
|
25811
|
+
return handleMathInHtml(state, "math_block", "$$", math_block_within_html_regex);
|
|
25812
|
+
});
|
|
25813
|
+
}
|
|
25814
|
+
if (enableMathInlineInHtml) {
|
|
25815
|
+
md.core.ruler.push("math_inline_in_html_block", (state) => {
|
|
25816
|
+
return handleMathInHtml(state, "math_inline", "$", math_inline_within_html_regex);
|
|
25817
|
+
});
|
|
25818
|
+
}
|
|
25819
|
+
const katexInline = (latex) => {
|
|
25820
|
+
const displayMode = /\\begin\{(align|equation|gather|cd|alignat)\}/ig.test(latex);
|
|
25821
|
+
try {
|
|
25822
|
+
return katex.renderToString(latex, { ...options, displayMode });
|
|
25823
|
+
} catch (error2) {
|
|
25824
|
+
if (options == null ? void 0 : options.throwOnError) {
|
|
25825
|
+
console.log(error2);
|
|
25826
|
+
}
|
|
25827
|
+
return `<span class="katex-error" title="${escapeHtml2(latex)}">${escapeHtml2(error2 + "")}</span>`;
|
|
25828
|
+
}
|
|
25829
|
+
};
|
|
25830
|
+
const inlineRenderer = (tokens, idx) => {
|
|
25831
|
+
const content = tokens[idx].content;
|
|
25832
|
+
const hasBacktick = content.length > 2 && content[0] === "`" && content[content.length - 1] === "`";
|
|
25833
|
+
const sanitized = hasBacktick ? content.slice(1, -1) : content;
|
|
25834
|
+
return katexInline(sanitized);
|
|
25835
|
+
};
|
|
25836
|
+
const katexBlockRenderer = (latex) => {
|
|
25837
|
+
try {
|
|
25838
|
+
return `<p class="katex-block">${katex.renderToString(latex, { ...options, displayMode: true })}</p>`;
|
|
25839
|
+
} catch (error2) {
|
|
25840
|
+
if (options == null ? void 0 : options.throwOnError) {
|
|
25841
|
+
console.log(error2);
|
|
25842
|
+
}
|
|
25843
|
+
return `<p class="katex-block katex-error" title="${escapeHtml2(latex)}">${escapeHtml2(error2 + "")}</p>`;
|
|
25844
|
+
}
|
|
25845
|
+
};
|
|
25846
|
+
const blockRenderer = (tokens, idx) => {
|
|
25847
|
+
return katexBlockRenderer(tokens[idx].content) + "\n";
|
|
25848
|
+
};
|
|
25849
|
+
md.renderer.rules.math_inline = inlineRenderer;
|
|
25850
|
+
md.renderer.rules.math_inline_block = blockRenderer;
|
|
25851
|
+
md.renderer.rules.math_inline_bare_block = blockRenderer;
|
|
25852
|
+
md.renderer.rules.math_block = blockRenderer;
|
|
25853
|
+
if (enableFencedBlocks) {
|
|
25854
|
+
const mathLanguageId = "math";
|
|
25855
|
+
const originalFenceRenderer = md.renderer.rules.fence;
|
|
25856
|
+
md.renderer.rules.fence = function(tokens, idx, options2, env, self) {
|
|
25857
|
+
const token = tokens[idx];
|
|
25858
|
+
if (token.info.trim().toLowerCase() === mathLanguageId && enableFencedBlocks) {
|
|
25859
|
+
return katexBlockRenderer(token.content) + "\n";
|
|
25860
|
+
} else {
|
|
25861
|
+
return (originalFenceRenderer == null ? void 0 : originalFenceRenderer.call(this, tokens, idx, options2, env, self)) || "";
|
|
25862
|
+
}
|
|
25863
|
+
};
|
|
25864
|
+
}
|
|
25865
|
+
}
|
|
25866
|
+
dist.default = default_1;
|
|
25867
|
+
return dist;
|
|
25868
|
+
}
|
|
25869
|
+
var distExports = requireDist();
|
|
25870
|
+
const katexPluginModule = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
|
|
25871
|
+
function interop(mod) {
|
|
25872
|
+
return mod.default || mod;
|
|
25873
|
+
}
|
|
25874
|
+
const katexPlugin = interop(katexPluginModule);
|
|
25505
25875
|
const plugin$1 = definePlugin({
|
|
25506
25876
|
name: name$2,
|
|
25507
25877
|
config,
|
|
@@ -25516,9 +25886,9 @@ ${end2.comment}` : end2.comment;
|
|
|
25516
25886
|
return loading;
|
|
25517
25887
|
};
|
|
25518
25888
|
const renderKatex = (source, displayMode) => {
|
|
25519
|
-
const { katex
|
|
25520
|
-
if (
|
|
25521
|
-
return
|
|
25889
|
+
const { katex } = window;
|
|
25890
|
+
if (katex) {
|
|
25891
|
+
return katex.renderToString(source, {
|
|
25522
25892
|
displayMode,
|
|
25523
25893
|
throwOnError: false
|
|
25524
25894
|
});
|
|
@@ -25696,7 +26066,7 @@ ${end2.comment}` : end2.comment;
|
|
|
25696
26066
|
}
|
|
25697
26067
|
}
|
|
25698
26068
|
const transformerVersions = {
|
|
25699
|
-
"markmap-lib": "0.17.3-alpha.
|
|
26069
|
+
"markmap-lib": "0.17.3-alpha.4"
|
|
25700
26070
|
};
|
|
25701
26071
|
exports.Transformer = Transformer;
|
|
25702
26072
|
exports.builtInPlugins = builtInPlugins;
|