markmap-lib 0.17.3-alpha.3 → 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 +724 -612
- package/dist/browser/index.mjs +9 -5
- 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,
|
|
@@ -2646,7 +2648,7 @@
|
|
|
2646
2648
|
function isQuote(c) {
|
|
2647
2649
|
return c === 39 || c === 34;
|
|
2648
2650
|
}
|
|
2649
|
-
function isWhitespace$
|
|
2651
|
+
function isWhitespace$2(c) {
|
|
2650
2652
|
return c === 32 || c === 9 || c === 10 || c === 12 || c === 13;
|
|
2651
2653
|
}
|
|
2652
2654
|
function parse$5(selector) {
|
|
@@ -2670,7 +2672,7 @@
|
|
|
2670
2672
|
}
|
|
2671
2673
|
function stripWhitespace(offset) {
|
|
2672
2674
|
selectorIndex += offset;
|
|
2673
|
-
while (selectorIndex < selector.length && isWhitespace$
|
|
2675
|
+
while (selectorIndex < selector.length && isWhitespace$2(selector.charCodeAt(selectorIndex))) {
|
|
2674
2676
|
selectorIndex++;
|
|
2675
2677
|
}
|
|
2676
2678
|
}
|
|
@@ -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;
|
|
@@ -2820,7 +2825,7 @@
|
|
|
2820
2825
|
selectorIndex = sectionEnd + 1;
|
|
2821
2826
|
} else {
|
|
2822
2827
|
const valueStart = selectorIndex;
|
|
2823
|
-
while (selectorIndex < selector.length && (!isWhitespace$
|
|
2828
|
+
while (selectorIndex < selector.length && (!isWhitespace$2(selector.charCodeAt(selectorIndex)) && selector.charCodeAt(selectorIndex) !== 93 || isEscaped(selectorIndex))) {
|
|
2824
2829
|
selectorIndex += 1;
|
|
2825
2830
|
}
|
|
2826
2831
|
value = unescapeCSS(selector.slice(valueStart, selectorIndex));
|
|
@@ -2937,19 +2942,26 @@
|
|
|
2937
2942
|
finalizeSubselector();
|
|
2938
2943
|
return selectorIndex;
|
|
2939
2944
|
}
|
|
2940
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
2941
2945
|
function getDefaultExportFromCjs(x) {
|
|
2942
2946
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
2943
2947
|
}
|
|
2944
|
-
var boolbase
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
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);
|
|
2953
2965
|
const procedure = /* @__PURE__ */ new Map([
|
|
2954
2966
|
[SelectorType.Universal, 50],
|
|
2955
2967
|
[SelectorType.Tag, 30],
|
|
@@ -3099,7 +3111,7 @@
|
|
|
3099
3111
|
const { adapter: adapter2 } = options;
|
|
3100
3112
|
const { name: name2, value } = data2;
|
|
3101
3113
|
if (/\s/.test(value)) {
|
|
3102
|
-
return boolbase
|
|
3114
|
+
return boolbase.falseFunc;
|
|
3103
3115
|
}
|
|
3104
3116
|
const regex2 = new RegExp(`(?:^|\\s)${escapeRegex(value)}(?:$|\\s)`, shouldIgnoreCase(data2, options) ? "i" : "");
|
|
3105
3117
|
return function element(elem) {
|
|
@@ -3116,7 +3128,7 @@
|
|
|
3116
3128
|
let { value } = data2;
|
|
3117
3129
|
const len = value.length;
|
|
3118
3130
|
if (len === 0) {
|
|
3119
|
-
return boolbase
|
|
3131
|
+
return boolbase.falseFunc;
|
|
3120
3132
|
}
|
|
3121
3133
|
if (shouldIgnoreCase(data2, options)) {
|
|
3122
3134
|
value = value.toLowerCase();
|
|
@@ -3136,7 +3148,7 @@
|
|
|
3136
3148
|
let { value } = data2;
|
|
3137
3149
|
const len = -value.length;
|
|
3138
3150
|
if (len === 0) {
|
|
3139
|
-
return boolbase
|
|
3151
|
+
return boolbase.falseFunc;
|
|
3140
3152
|
}
|
|
3141
3153
|
if (shouldIgnoreCase(data2, options)) {
|
|
3142
3154
|
value = value.toLowerCase();
|
|
@@ -3154,7 +3166,7 @@
|
|
|
3154
3166
|
const { adapter: adapter2 } = options;
|
|
3155
3167
|
const { name: name2, value } = data2;
|
|
3156
3168
|
if (value === "") {
|
|
3157
|
-
return boolbase
|
|
3169
|
+
return boolbase.falseFunc;
|
|
3158
3170
|
}
|
|
3159
3171
|
if (shouldIgnoreCase(data2, options)) {
|
|
3160
3172
|
const regex2 = new RegExp(escapeRegex(value), "i");
|
|
@@ -3243,13 +3255,13 @@
|
|
|
3243
3255
|
const a = parsed[0];
|
|
3244
3256
|
const b = parsed[1] - 1;
|
|
3245
3257
|
if (b < 0 && a <= 0)
|
|
3246
|
-
return boolbase
|
|
3258
|
+
return boolbase.falseFunc;
|
|
3247
3259
|
if (a === -1)
|
|
3248
3260
|
return (index2) => index2 <= b;
|
|
3249
3261
|
if (a === 0)
|
|
3250
3262
|
return (index2) => index2 === b;
|
|
3251
3263
|
if (a === 1)
|
|
3252
|
-
return b < 0 ? boolbase
|
|
3264
|
+
return b < 0 ? boolbase.trueFunc : (index2) => index2 >= b;
|
|
3253
3265
|
const absA = Math.abs(a);
|
|
3254
3266
|
const bMod = (b % absA + absA) % absA;
|
|
3255
3267
|
return a > 1 ? (index2) => index2 >= b && index2 % absA === bMod : (index2) => index2 <= b && index2 % absA === bMod;
|
|
@@ -3278,9 +3290,9 @@
|
|
|
3278
3290
|
// Location specific methods
|
|
3279
3291
|
"nth-child"(next2, rule, { adapter: adapter2, equals }) {
|
|
3280
3292
|
const func = nthCheck(rule);
|
|
3281
|
-
if (func === boolbase
|
|
3282
|
-
return boolbase
|
|
3283
|
-
if (func === boolbase
|
|
3293
|
+
if (func === boolbase.falseFunc)
|
|
3294
|
+
return boolbase.falseFunc;
|
|
3295
|
+
if (func === boolbase.trueFunc)
|
|
3284
3296
|
return getChildFunc(next2, adapter2);
|
|
3285
3297
|
return function nthChild(elem) {
|
|
3286
3298
|
const siblings2 = adapter2.getSiblings(elem);
|
|
@@ -3297,9 +3309,9 @@
|
|
|
3297
3309
|
},
|
|
3298
3310
|
"nth-last-child"(next2, rule, { adapter: adapter2, equals }) {
|
|
3299
3311
|
const func = nthCheck(rule);
|
|
3300
|
-
if (func === boolbase
|
|
3301
|
-
return boolbase
|
|
3302
|
-
if (func === boolbase
|
|
3312
|
+
if (func === boolbase.falseFunc)
|
|
3313
|
+
return boolbase.falseFunc;
|
|
3314
|
+
if (func === boolbase.trueFunc)
|
|
3303
3315
|
return getChildFunc(next2, adapter2);
|
|
3304
3316
|
return function nthLastChild(elem) {
|
|
3305
3317
|
const siblings2 = adapter2.getSiblings(elem);
|
|
@@ -3316,9 +3328,9 @@
|
|
|
3316
3328
|
},
|
|
3317
3329
|
"nth-of-type"(next2, rule, { adapter: adapter2, equals }) {
|
|
3318
3330
|
const func = nthCheck(rule);
|
|
3319
|
-
if (func === boolbase
|
|
3320
|
-
return boolbase
|
|
3321
|
-
if (func === boolbase
|
|
3331
|
+
if (func === boolbase.falseFunc)
|
|
3332
|
+
return boolbase.falseFunc;
|
|
3333
|
+
if (func === boolbase.trueFunc)
|
|
3322
3334
|
return getChildFunc(next2, adapter2);
|
|
3323
3335
|
return function nthOfType(elem) {
|
|
3324
3336
|
const siblings2 = adapter2.getSiblings(elem);
|
|
@@ -3336,9 +3348,9 @@
|
|
|
3336
3348
|
},
|
|
3337
3349
|
"nth-last-of-type"(next2, rule, { adapter: adapter2, equals }) {
|
|
3338
3350
|
const func = nthCheck(rule);
|
|
3339
|
-
if (func === boolbase
|
|
3340
|
-
return boolbase
|
|
3341
|
-
if (func === boolbase
|
|
3351
|
+
if (func === boolbase.falseFunc)
|
|
3352
|
+
return boolbase.falseFunc;
|
|
3353
|
+
if (func === boolbase.trueFunc)
|
|
3342
3354
|
return getChildFunc(next2, adapter2);
|
|
3343
3355
|
return function nthLastOfType(elem) {
|
|
3344
3356
|
const siblings2 = adapter2.getSiblings(elem);
|
|
@@ -3379,7 +3391,7 @@
|
|
|
3379
3391
|
return function dynamicPseudo(next2, _rule, { adapter: adapter2 }) {
|
|
3380
3392
|
const func = adapter2[name2];
|
|
3381
3393
|
if (typeof func !== "function") {
|
|
3382
|
-
return boolbase
|
|
3394
|
+
return boolbase.falseFunc;
|
|
3383
3395
|
}
|
|
3384
3396
|
return function active(elem) {
|
|
3385
3397
|
return func(elem) && next2(elem);
|
|
@@ -3486,8 +3498,8 @@
|
|
|
3486
3498
|
};
|
|
3487
3499
|
const PLACEHOLDER_ELEMENT = {};
|
|
3488
3500
|
function ensureIsTag(next2, adapter2) {
|
|
3489
|
-
if (next2 === boolbase
|
|
3490
|
-
return boolbase
|
|
3501
|
+
if (next2 === boolbase.falseFunc)
|
|
3502
|
+
return boolbase.falseFunc;
|
|
3491
3503
|
return (elem) => adapter2.isTag(elem) && next2(elem);
|
|
3492
3504
|
}
|
|
3493
3505
|
function getNextSiblings(elem, adapter2) {
|
|
@@ -3513,7 +3525,7 @@
|
|
|
3513
3525
|
}
|
|
3514
3526
|
const is$2 = (next2, token, options, context, compileToken2) => {
|
|
3515
3527
|
const func = compileToken2(token, copyOptions(options), context);
|
|
3516
|
-
return func === boolbase
|
|
3528
|
+
return func === boolbase.trueFunc ? next2 : func === boolbase.falseFunc ? boolbase.falseFunc : (elem) => func(elem) && next2(elem);
|
|
3517
3529
|
};
|
|
3518
3530
|
const subselects = {
|
|
3519
3531
|
is: is$2,
|
|
@@ -3524,7 +3536,7 @@
|
|
|
3524
3536
|
where: is$2,
|
|
3525
3537
|
not(next2, token, options, context, compileToken2) {
|
|
3526
3538
|
const func = compileToken2(token, copyOptions(options), context);
|
|
3527
|
-
return func === boolbase
|
|
3539
|
+
return func === boolbase.falseFunc ? next2 : func === boolbase.trueFunc ? boolbase.falseFunc : (elem) => !func(elem) && next2(elem);
|
|
3528
3540
|
},
|
|
3529
3541
|
has(next2, subselect, options, _context, compileToken2) {
|
|
3530
3542
|
const { adapter: adapter2 } = options;
|
|
@@ -3535,10 +3547,10 @@
|
|
|
3535
3547
|
[PLACEHOLDER_ELEMENT]
|
|
3536
3548
|
) : void 0;
|
|
3537
3549
|
const compiled = compileToken2(subselect, opts, context);
|
|
3538
|
-
if (compiled === boolbase
|
|
3539
|
-
return boolbase
|
|
3550
|
+
if (compiled === boolbase.falseFunc)
|
|
3551
|
+
return boolbase.falseFunc;
|
|
3540
3552
|
const hasElement = ensureIsTag(compiled, adapter2);
|
|
3541
|
-
if (context && compiled !== boolbase
|
|
3553
|
+
if (context && compiled !== boolbase.trueFunc) {
|
|
3542
3554
|
const { shouldTestNextSiblings = false } = compiled;
|
|
3543
3555
|
return (elem) => {
|
|
3544
3556
|
if (!next2(elem))
|
|
@@ -3612,6 +3624,7 @@
|
|
|
3612
3624
|
case SelectorType.Pseudo: {
|
|
3613
3625
|
return compilePseudoSelector(next2, selector, options, context, compileToken2);
|
|
3614
3626
|
}
|
|
3627
|
+
// Tags
|
|
3615
3628
|
case SelectorType.Tag: {
|
|
3616
3629
|
if (selector.namespace != null) {
|
|
3617
3630
|
throw new Error("Namespaced tag names are not yet supported by css-select");
|
|
@@ -3624,6 +3637,7 @@
|
|
|
3624
3637
|
return adapter2.getName(elem) === name2 && next2(elem);
|
|
3625
3638
|
};
|
|
3626
3639
|
}
|
|
3640
|
+
// Traversal
|
|
3627
3641
|
case SelectorType.Descendant: {
|
|
3628
3642
|
if (options.cacheResults === false || typeof WeakSet === "undefined") {
|
|
3629
3643
|
return function descendant(elem) {
|
|
@@ -3764,19 +3778,19 @@
|
|
|
3764
3778
|
}
|
|
3765
3779
|
}
|
|
3766
3780
|
return compileRules(rules, options, finalContext);
|
|
3767
|
-
}).reduce(reduceRules, boolbase
|
|
3781
|
+
}).reduce(reduceRules, boolbase.falseFunc);
|
|
3768
3782
|
query.shouldTestNextSiblings = shouldTestNextSiblings;
|
|
3769
3783
|
return query;
|
|
3770
3784
|
}
|
|
3771
3785
|
function compileRules(rules, options, context) {
|
|
3772
3786
|
var _a2;
|
|
3773
|
-
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);
|
|
3774
3788
|
}
|
|
3775
3789
|
function reduceRules(a, b) {
|
|
3776
|
-
if (b === boolbase
|
|
3790
|
+
if (b === boolbase.falseFunc || a === boolbase.trueFunc) {
|
|
3777
3791
|
return a;
|
|
3778
3792
|
}
|
|
3779
|
-
if (a === boolbase
|
|
3793
|
+
if (a === boolbase.falseFunc || b === boolbase.trueFunc) {
|
|
3780
3794
|
return b;
|
|
3781
3795
|
}
|
|
3782
3796
|
return function combine(elem) {
|
|
@@ -4016,8 +4030,8 @@
|
|
|
4016
4030
|
*/
|
|
4017
4031
|
rootFunc: (el) => result.includes(el)
|
|
4018
4032
|
};
|
|
4019
|
-
} else if (options.rootFunc && options.rootFunc !==
|
|
4020
|
-
options = { ...options, rootFunc:
|
|
4033
|
+
} else if (options.rootFunc && options.rootFunc !== boolbaseExports.trueFunc) {
|
|
4034
|
+
options = { ...options, rootFunc: boolbaseExports.trueFunc };
|
|
4021
4035
|
}
|
|
4022
4036
|
return remainingSelector.some(isFilter) ? findFilterElements(result, remainingSelector, options, false, totalLimit) : remainingHasTraversal ? (
|
|
4023
4037
|
// Query existing elements to resolve traversal.
|
|
@@ -4040,7 +4054,7 @@
|
|
|
4040
4054
|
if (els.length === 0)
|
|
4041
4055
|
return els;
|
|
4042
4056
|
const query = _compileToken(sel, options);
|
|
4043
|
-
return query ===
|
|
4057
|
+
return query === boolbaseExports.trueFunc ? els : els.filter(query);
|
|
4044
4058
|
}
|
|
4045
4059
|
const reSiblingSelector = /^\s*[+~]/;
|
|
4046
4060
|
function find(selectorOrHaystack) {
|
|
@@ -5975,14 +5989,14 @@
|
|
|
5975
5989
|
function toAsciiLower(cp) {
|
|
5976
5990
|
return cp + 32;
|
|
5977
5991
|
}
|
|
5978
|
-
function isWhitespace$
|
|
5992
|
+
function isWhitespace$1(cp) {
|
|
5979
5993
|
return cp === CODE_POINTS.SPACE || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.TABULATION || cp === CODE_POINTS.FORM_FEED;
|
|
5980
5994
|
}
|
|
5981
5995
|
function isEntityInAttributeInvalidEnd(nextCp) {
|
|
5982
5996
|
return nextCp === CODE_POINTS.EQUALS_SIGN || isAsciiAlphaNumeric(nextCp);
|
|
5983
5997
|
}
|
|
5984
5998
|
function isScriptDataDoubleEscapeSequenceEnd(cp) {
|
|
5985
|
-
return isWhitespace$
|
|
5999
|
+
return isWhitespace$1(cp) || cp === CODE_POINTS.SOLIDUS || cp === CODE_POINTS.GREATER_THAN_SIGN;
|
|
5986
6000
|
}
|
|
5987
6001
|
let Tokenizer$1 = class Tokenizer {
|
|
5988
6002
|
constructor(options, handler) {
|
|
@@ -6273,7 +6287,7 @@
|
|
|
6273
6287
|
this._createCharacterToken(type, ch);
|
|
6274
6288
|
}
|
|
6275
6289
|
_emitCodePoint(cp) {
|
|
6276
|
-
const type = isWhitespace$
|
|
6290
|
+
const type = isWhitespace$1(cp) ? TokenType.WHITESPACE_CHARACTER : cp === CODE_POINTS.NULL ? TokenType.NULL_CHARACTER : TokenType.CHARACTER;
|
|
6277
6291
|
this._appendCharToCurrentCharacterToken(type, String.fromCodePoint(cp));
|
|
6278
6292
|
}
|
|
6279
6293
|
//NOTE: used when we emit characters explicitly.
|
|
@@ -12244,6 +12258,7 @@
|
|
|
12244
12258
|
}
|
|
12245
12259
|
function startTagInTemplate(p, token) {
|
|
12246
12260
|
switch (token.tagID) {
|
|
12261
|
+
// First, handle tags that can start without a mode change
|
|
12247
12262
|
case TAG_ID.BASE:
|
|
12248
12263
|
case TAG_ID.BASEFONT:
|
|
12249
12264
|
case TAG_ID.BGSOUND:
|
|
@@ -12257,6 +12272,7 @@
|
|
|
12257
12272
|
startTagInHead(p, token);
|
|
12258
12273
|
break;
|
|
12259
12274
|
}
|
|
12275
|
+
// Re-process the token in the appropriate mode
|
|
12260
12276
|
case TAG_ID.CAPTION:
|
|
12261
12277
|
case TAG_ID.COLGROUP:
|
|
12262
12278
|
case TAG_ID.TBODY:
|
|
@@ -12865,11 +12881,11 @@
|
|
|
12865
12881
|
State2[State2["InSpecialTag"] = 25] = "InSpecialTag";
|
|
12866
12882
|
State2[State2["InEntity"] = 26] = "InEntity";
|
|
12867
12883
|
})(State || (State = {}));
|
|
12868
|
-
function isWhitespace
|
|
12884
|
+
function isWhitespace(c) {
|
|
12869
12885
|
return c === CharCodes.Space || c === CharCodes.NewLine || c === CharCodes.Tab || c === CharCodes.FormFeed || c === CharCodes.CarriageReturn;
|
|
12870
12886
|
}
|
|
12871
12887
|
function isEndOfTagSection(c) {
|
|
12872
|
-
return c === CharCodes.Slash || c === CharCodes.Gt || isWhitespace
|
|
12888
|
+
return c === CharCodes.Slash || c === CharCodes.Gt || isWhitespace(c);
|
|
12873
12889
|
}
|
|
12874
12890
|
function isASCIIAlpha(c) {
|
|
12875
12891
|
return c >= CharCodes.LowerA && c <= CharCodes.LowerZ || c >= CharCodes.UpperA && c <= CharCodes.UpperZ;
|
|
@@ -12987,7 +13003,7 @@
|
|
|
12987
13003
|
/** Look for an end tag. For <title> tags, also decode entities. */
|
|
12988
13004
|
stateInSpecialTag(c) {
|
|
12989
13005
|
if (this.sequenceIndex === this.currentSequence.length) {
|
|
12990
|
-
if (c === CharCodes.Gt || isWhitespace
|
|
13006
|
+
if (c === CharCodes.Gt || isWhitespace(c)) {
|
|
12991
13007
|
const endOfText = this.index - this.currentSequence.length;
|
|
12992
13008
|
if (this.sectionStart < endOfText) {
|
|
12993
13009
|
const actualIndex = this.index;
|
|
@@ -13123,7 +13139,7 @@
|
|
|
13123
13139
|
}
|
|
13124
13140
|
}
|
|
13125
13141
|
stateBeforeClosingTagName(c) {
|
|
13126
|
-
if (isWhitespace
|
|
13142
|
+
if (isWhitespace(c)) ;
|
|
13127
13143
|
else if (c === CharCodes.Gt) {
|
|
13128
13144
|
this.state = State.Text;
|
|
13129
13145
|
} else {
|
|
@@ -13132,7 +13148,7 @@
|
|
|
13132
13148
|
}
|
|
13133
13149
|
}
|
|
13134
13150
|
stateInClosingTagName(c) {
|
|
13135
|
-
if (c === CharCodes.Gt || isWhitespace
|
|
13151
|
+
if (c === CharCodes.Gt || isWhitespace(c)) {
|
|
13136
13152
|
this.cbs.onclosetag(this.sectionStart, this.index);
|
|
13137
13153
|
this.sectionStart = -1;
|
|
13138
13154
|
this.state = State.AfterClosingTagName;
|
|
@@ -13157,7 +13173,7 @@
|
|
|
13157
13173
|
this.sectionStart = this.index + 1;
|
|
13158
13174
|
} else if (c === CharCodes.Slash) {
|
|
13159
13175
|
this.state = State.InSelfClosingTag;
|
|
13160
|
-
} else if (!isWhitespace
|
|
13176
|
+
} else if (!isWhitespace(c)) {
|
|
13161
13177
|
this.state = State.InAttributeName;
|
|
13162
13178
|
this.sectionStart = this.index;
|
|
13163
13179
|
}
|
|
@@ -13168,7 +13184,7 @@
|
|
|
13168
13184
|
this.state = State.Text;
|
|
13169
13185
|
this.sectionStart = this.index + 1;
|
|
13170
13186
|
this.isSpecial = false;
|
|
13171
|
-
} else if (!isWhitespace
|
|
13187
|
+
} else if (!isWhitespace(c)) {
|
|
13172
13188
|
this.state = State.BeforeAttributeName;
|
|
13173
13189
|
this.stateBeforeAttributeName(c);
|
|
13174
13190
|
}
|
|
@@ -13189,7 +13205,7 @@
|
|
|
13189
13205
|
this.sectionStart = -1;
|
|
13190
13206
|
this.state = State.BeforeAttributeName;
|
|
13191
13207
|
this.stateBeforeAttributeName(c);
|
|
13192
|
-
} else if (!isWhitespace
|
|
13208
|
+
} else if (!isWhitespace(c)) {
|
|
13193
13209
|
this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
|
|
13194
13210
|
this.state = State.InAttributeName;
|
|
13195
13211
|
this.sectionStart = this.index;
|
|
@@ -13202,7 +13218,7 @@
|
|
|
13202
13218
|
} else if (c === CharCodes.SingleQuote) {
|
|
13203
13219
|
this.state = State.InAttributeValueSq;
|
|
13204
13220
|
this.sectionStart = this.index + 1;
|
|
13205
|
-
} else if (!isWhitespace
|
|
13221
|
+
} else if (!isWhitespace(c)) {
|
|
13206
13222
|
this.sectionStart = this.index;
|
|
13207
13223
|
this.state = State.InAttributeValueNq;
|
|
13208
13224
|
this.stateInAttributeValueNoQuotes(c);
|
|
@@ -13225,7 +13241,7 @@
|
|
|
13225
13241
|
this.handleInAttributeValue(c, CharCodes.SingleQuote);
|
|
13226
13242
|
}
|
|
13227
13243
|
stateInAttributeValueNoQuotes(c) {
|
|
13228
|
-
if (isWhitespace
|
|
13244
|
+
if (isWhitespace(c) || c === CharCodes.Gt) {
|
|
13229
13245
|
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
13230
13246
|
this.sectionStart = -1;
|
|
13231
13247
|
this.cbs.onattribend(QuoteType.Unquoted, this.index);
|
|
@@ -14614,7 +14630,7 @@
|
|
|
14614
14630
|
function replaceUnsafeChar(ch) {
|
|
14615
14631
|
return HTML_REPLACEMENTS[ch];
|
|
14616
14632
|
}
|
|
14617
|
-
function escapeHtml
|
|
14633
|
+
function escapeHtml(str) {
|
|
14618
14634
|
if (HTML_ESCAPE_TEST_RE.test(str)) {
|
|
14619
14635
|
return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
|
|
14620
14636
|
}
|
|
@@ -14638,10 +14654,15 @@
|
|
|
14638
14654
|
}
|
|
14639
14655
|
switch (code2) {
|
|
14640
14656
|
case 9:
|
|
14657
|
+
// \t
|
|
14641
14658
|
case 10:
|
|
14659
|
+
// \n
|
|
14642
14660
|
case 11:
|
|
14661
|
+
// \v
|
|
14643
14662
|
case 12:
|
|
14663
|
+
// \f
|
|
14644
14664
|
case 13:
|
|
14665
|
+
// \r
|
|
14645
14666
|
case 32:
|
|
14646
14667
|
case 160:
|
|
14647
14668
|
case 5760:
|
|
@@ -14706,7 +14727,7 @@
|
|
|
14706
14727
|
__proto__: null,
|
|
14707
14728
|
arrayReplaceAt,
|
|
14708
14729
|
assign: assign$1,
|
|
14709
|
-
escapeHtml
|
|
14730
|
+
escapeHtml,
|
|
14710
14731
|
escapeRE: escapeRE$1,
|
|
14711
14732
|
fromCodePoint,
|
|
14712
14733
|
has,
|
|
@@ -14887,11 +14908,11 @@
|
|
|
14887
14908
|
const default_rules = {};
|
|
14888
14909
|
default_rules.code_inline = function(tokens, idx, options, env, slf) {
|
|
14889
14910
|
const token = tokens[idx];
|
|
14890
|
-
return "<code" + slf.renderAttrs(token) + ">" + escapeHtml
|
|
14911
|
+
return "<code" + slf.renderAttrs(token) + ">" + escapeHtml(token.content) + "</code>";
|
|
14891
14912
|
};
|
|
14892
14913
|
default_rules.code_block = function(tokens, idx, options, env, slf) {
|
|
14893
14914
|
const token = tokens[idx];
|
|
14894
|
-
return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml
|
|
14915
|
+
return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml(tokens[idx].content) + "</code></pre>\n";
|
|
14895
14916
|
};
|
|
14896
14917
|
default_rules.fence = function(tokens, idx, options, env, slf) {
|
|
14897
14918
|
const token = tokens[idx];
|
|
@@ -14905,9 +14926,9 @@
|
|
|
14905
14926
|
}
|
|
14906
14927
|
let highlighted;
|
|
14907
14928
|
if (options.highlight) {
|
|
14908
|
-
highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml
|
|
14929
|
+
highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content);
|
|
14909
14930
|
} else {
|
|
14910
|
-
highlighted = escapeHtml
|
|
14931
|
+
highlighted = escapeHtml(token.content);
|
|
14911
14932
|
}
|
|
14912
14933
|
if (highlighted.indexOf("<pre") === 0) {
|
|
14913
14934
|
return highlighted + "\n";
|
|
@@ -14942,7 +14963,7 @@
|
|
|
14942
14963
|
return options.breaks ? options.xhtmlOut ? "<br />\n" : "<br>\n" : "\n";
|
|
14943
14964
|
};
|
|
14944
14965
|
default_rules.text = function(tokens, idx) {
|
|
14945
|
-
return escapeHtml
|
|
14966
|
+
return escapeHtml(tokens[idx].content);
|
|
14946
14967
|
};
|
|
14947
14968
|
default_rules.html_block = function(tokens, idx) {
|
|
14948
14969
|
return tokens[idx].content;
|
|
@@ -14960,7 +14981,7 @@
|
|
|
14960
14981
|
}
|
|
14961
14982
|
result = "";
|
|
14962
14983
|
for (i = 0, l = token.attrs.length; i < l; i++) {
|
|
14963
|
-
result += " " + escapeHtml
|
|
14984
|
+
result += " " + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
|
|
14964
14985
|
}
|
|
14965
14986
|
return result;
|
|
14966
14987
|
};
|
|
@@ -15058,9 +15079,9 @@
|
|
|
15058
15079
|
return -1;
|
|
15059
15080
|
};
|
|
15060
15081
|
Ruler.prototype.__compile__ = function() {
|
|
15061
|
-
const
|
|
15082
|
+
const self = this;
|
|
15062
15083
|
const chains = [""];
|
|
15063
|
-
|
|
15084
|
+
self.__rules__.forEach(function(rule) {
|
|
15064
15085
|
if (!rule.enabled) {
|
|
15065
15086
|
return;
|
|
15066
15087
|
}
|
|
@@ -15070,17 +15091,17 @@
|
|
|
15070
15091
|
}
|
|
15071
15092
|
});
|
|
15072
15093
|
});
|
|
15073
|
-
|
|
15094
|
+
self.__cache__ = {};
|
|
15074
15095
|
chains.forEach(function(chain) {
|
|
15075
|
-
|
|
15076
|
-
|
|
15096
|
+
self.__cache__[chain] = [];
|
|
15097
|
+
self.__rules__.forEach(function(rule) {
|
|
15077
15098
|
if (!rule.enabled) {
|
|
15078
15099
|
return;
|
|
15079
15100
|
}
|
|
15080
15101
|
if (chain && rule.alt.indexOf(chain) < 0) {
|
|
15081
15102
|
return;
|
|
15082
15103
|
}
|
|
15083
|
-
|
|
15104
|
+
self.__cache__[chain].push(rule.fn);
|
|
15084
15105
|
});
|
|
15085
15106
|
});
|
|
15086
15107
|
};
|
|
@@ -18025,16 +18046,16 @@
|
|
|
18025
18046
|
}
|
|
18026
18047
|
const defaultSchemas = {
|
|
18027
18048
|
"http:": {
|
|
18028
|
-
validate: function(text2, pos,
|
|
18049
|
+
validate: function(text2, pos, self) {
|
|
18029
18050
|
const tail = text2.slice(pos);
|
|
18030
|
-
if (!
|
|
18031
|
-
|
|
18032
|
-
"^\\/\\/" +
|
|
18051
|
+
if (!self.re.http) {
|
|
18052
|
+
self.re.http = new RegExp(
|
|
18053
|
+
"^\\/\\/" + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path,
|
|
18033
18054
|
"i"
|
|
18034
18055
|
);
|
|
18035
18056
|
}
|
|
18036
|
-
if (
|
|
18037
|
-
return tail.match(
|
|
18057
|
+
if (self.re.http.test(tail)) {
|
|
18058
|
+
return tail.match(self.re.http)[0].length;
|
|
18038
18059
|
}
|
|
18039
18060
|
return 0;
|
|
18040
18061
|
}
|
|
@@ -18042,39 +18063,39 @@
|
|
|
18042
18063
|
"https:": "http:",
|
|
18043
18064
|
"ftp:": "http:",
|
|
18044
18065
|
"//": {
|
|
18045
|
-
validate: function(text2, pos,
|
|
18066
|
+
validate: function(text2, pos, self) {
|
|
18046
18067
|
const tail = text2.slice(pos);
|
|
18047
|
-
if (!
|
|
18048
|
-
|
|
18049
|
-
"^" +
|
|
18068
|
+
if (!self.re.no_http) {
|
|
18069
|
+
self.re.no_http = new RegExp(
|
|
18070
|
+
"^" + self.re.src_auth + // Don't allow single-level domains, because of false positives like '//test'
|
|
18050
18071
|
// with code comments
|
|
18051
|
-
"(?:localhost|(?:(?:" +
|
|
18072
|
+
"(?:localhost|(?:(?:" + self.re.src_domain + ")\\.)+" + self.re.src_domain_root + ")" + self.re.src_port + self.re.src_host_terminator + self.re.src_path,
|
|
18052
18073
|
"i"
|
|
18053
18074
|
);
|
|
18054
18075
|
}
|
|
18055
|
-
if (
|
|
18076
|
+
if (self.re.no_http.test(tail)) {
|
|
18056
18077
|
if (pos >= 3 && text2[pos - 3] === ":") {
|
|
18057
18078
|
return 0;
|
|
18058
18079
|
}
|
|
18059
18080
|
if (pos >= 3 && text2[pos - 3] === "/") {
|
|
18060
18081
|
return 0;
|
|
18061
18082
|
}
|
|
18062
|
-
return tail.match(
|
|
18083
|
+
return tail.match(self.re.no_http)[0].length;
|
|
18063
18084
|
}
|
|
18064
18085
|
return 0;
|
|
18065
18086
|
}
|
|
18066
18087
|
},
|
|
18067
18088
|
"mailto:": {
|
|
18068
|
-
validate: function(text2, pos,
|
|
18089
|
+
validate: function(text2, pos, self) {
|
|
18069
18090
|
const tail = text2.slice(pos);
|
|
18070
|
-
if (!
|
|
18071
|
-
|
|
18072
|
-
"^" +
|
|
18091
|
+
if (!self.re.mailto) {
|
|
18092
|
+
self.re.mailto = new RegExp(
|
|
18093
|
+
"^" + self.re.src_email_name + "@" + self.re.src_host_strict,
|
|
18073
18094
|
"i"
|
|
18074
18095
|
);
|
|
18075
18096
|
}
|
|
18076
|
-
if (
|
|
18077
|
-
return tail.match(
|
|
18097
|
+
if (self.re.mailto.test(tail)) {
|
|
18098
|
+
return tail.match(self.re.mailto)[0].length;
|
|
18078
18099
|
}
|
|
18079
18100
|
return 0;
|
|
18080
18101
|
}
|
|
@@ -18082,9 +18103,9 @@
|
|
|
18082
18103
|
};
|
|
18083
18104
|
const tlds_2ch_src_re = "a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]";
|
|
18084
18105
|
const tlds_default = "biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");
|
|
18085
|
-
function resetScanCache(
|
|
18086
|
-
|
|
18087
|
-
|
|
18106
|
+
function resetScanCache(self) {
|
|
18107
|
+
self.__index__ = -1;
|
|
18108
|
+
self.__text_cache__ = "";
|
|
18088
18109
|
}
|
|
18089
18110
|
function createValidator(re) {
|
|
18090
18111
|
return function(text2, pos) {
|
|
@@ -18096,15 +18117,15 @@
|
|
|
18096
18117
|
};
|
|
18097
18118
|
}
|
|
18098
18119
|
function createNormalizer() {
|
|
18099
|
-
return function(match,
|
|
18100
|
-
|
|
18120
|
+
return function(match, self) {
|
|
18121
|
+
self.normalize(match);
|
|
18101
18122
|
};
|
|
18102
18123
|
}
|
|
18103
|
-
function compile(
|
|
18104
|
-
const re =
|
|
18105
|
-
const tlds =
|
|
18106
|
-
|
|
18107
|
-
if (!
|
|
18124
|
+
function compile(self) {
|
|
18125
|
+
const re = self.re = reFactory(self.__opts__);
|
|
18126
|
+
const tlds = self.__tlds__.slice();
|
|
18127
|
+
self.onCompile();
|
|
18128
|
+
if (!self.__tlds_replaced__) {
|
|
18108
18129
|
tlds.push(tlds_2ch_src_re);
|
|
18109
18130
|
}
|
|
18110
18131
|
tlds.push(re.src_xn);
|
|
@@ -18117,17 +18138,17 @@
|
|
|
18117
18138
|
re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), "i");
|
|
18118
18139
|
re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), "i");
|
|
18119
18140
|
const aliases2 = [];
|
|
18120
|
-
|
|
18141
|
+
self.__compiled__ = {};
|
|
18121
18142
|
function schemaError(name2, val2) {
|
|
18122
18143
|
throw new Error('(LinkifyIt) Invalid schema "' + name2 + '": ' + val2);
|
|
18123
18144
|
}
|
|
18124
|
-
Object.keys(
|
|
18125
|
-
const val2 =
|
|
18145
|
+
Object.keys(self.__schemas__).forEach(function(name2) {
|
|
18146
|
+
const val2 = self.__schemas__[name2];
|
|
18126
18147
|
if (val2 === null) {
|
|
18127
18148
|
return;
|
|
18128
18149
|
}
|
|
18129
18150
|
const compiled = { validate: null, link: null };
|
|
18130
|
-
|
|
18151
|
+
self.__compiled__[name2] = compiled;
|
|
18131
18152
|
if (isObject(val2)) {
|
|
18132
18153
|
if (isRegExp(val2.validate)) {
|
|
18133
18154
|
compiled.validate = createValidator(val2.validate);
|
|
@@ -18152,39 +18173,39 @@
|
|
|
18152
18173
|
schemaError(name2, val2);
|
|
18153
18174
|
});
|
|
18154
18175
|
aliases2.forEach(function(alias) {
|
|
18155
|
-
if (!
|
|
18176
|
+
if (!self.__compiled__[self.__schemas__[alias]]) {
|
|
18156
18177
|
return;
|
|
18157
18178
|
}
|
|
18158
|
-
|
|
18159
|
-
|
|
18179
|
+
self.__compiled__[alias].validate = self.__compiled__[self.__schemas__[alias]].validate;
|
|
18180
|
+
self.__compiled__[alias].normalize = self.__compiled__[self.__schemas__[alias]].normalize;
|
|
18160
18181
|
});
|
|
18161
|
-
|
|
18162
|
-
const slist = Object.keys(
|
|
18163
|
-
return name2.length > 0 &&
|
|
18182
|
+
self.__compiled__[""] = { validate: null, normalize: createNormalizer() };
|
|
18183
|
+
const slist = Object.keys(self.__compiled__).filter(function(name2) {
|
|
18184
|
+
return name2.length > 0 && self.__compiled__[name2];
|
|
18164
18185
|
}).map(escapeRE).join("|");
|
|
18165
|
-
|
|
18166
|
-
|
|
18167
|
-
|
|
18168
|
-
|
|
18169
|
-
"(" +
|
|
18186
|
+
self.re.schema_test = RegExp("(^|(?!_)(?:[><|]|" + re.src_ZPCc + "))(" + slist + ")", "i");
|
|
18187
|
+
self.re.schema_search = RegExp("(^|(?!_)(?:[><|]|" + re.src_ZPCc + "))(" + slist + ")", "ig");
|
|
18188
|
+
self.re.schema_at_start = RegExp("^" + self.re.schema_search.source, "i");
|
|
18189
|
+
self.re.pretest = RegExp(
|
|
18190
|
+
"(" + self.re.schema_test.source + ")|(" + self.re.host_fuzzy_test.source + ")|@",
|
|
18170
18191
|
"i"
|
|
18171
18192
|
);
|
|
18172
|
-
resetScanCache(
|
|
18193
|
+
resetScanCache(self);
|
|
18173
18194
|
}
|
|
18174
|
-
function Match(
|
|
18175
|
-
const start =
|
|
18176
|
-
const end2 =
|
|
18177
|
-
const text2 =
|
|
18178
|
-
this.schema =
|
|
18195
|
+
function Match(self, shift) {
|
|
18196
|
+
const start = self.__index__;
|
|
18197
|
+
const end2 = self.__last_index__;
|
|
18198
|
+
const text2 = self.__text_cache__.slice(start, end2);
|
|
18199
|
+
this.schema = self.__schema__.toLowerCase();
|
|
18179
18200
|
this.index = start + shift;
|
|
18180
18201
|
this.lastIndex = end2 + shift;
|
|
18181
18202
|
this.raw = text2;
|
|
18182
18203
|
this.text = text2;
|
|
18183
18204
|
this.url = text2;
|
|
18184
18205
|
}
|
|
18185
|
-
function createMatch(
|
|
18186
|
-
const match = new Match(
|
|
18187
|
-
|
|
18206
|
+
function createMatch(self, shift) {
|
|
18207
|
+
const match = new Match(self, shift);
|
|
18208
|
+
self.__compiled__[match.schema].normalize(match, self);
|
|
18188
18209
|
return match;
|
|
18189
18210
|
}
|
|
18190
18211
|
function LinkifyIt(schemas2, options) {
|
|
@@ -18799,7 +18820,7 @@
|
|
|
18799
18820
|
return this;
|
|
18800
18821
|
};
|
|
18801
18822
|
MarkdownIt.prototype.configure = function(presets) {
|
|
18802
|
-
const
|
|
18823
|
+
const self = this;
|
|
18803
18824
|
if (isString$1(presets)) {
|
|
18804
18825
|
const presetName = presets;
|
|
18805
18826
|
presets = config$2[presetName];
|
|
@@ -18811,15 +18832,15 @@
|
|
|
18811
18832
|
throw new Error("Wrong `markdown-it` preset, can't be empty");
|
|
18812
18833
|
}
|
|
18813
18834
|
if (presets.options) {
|
|
18814
|
-
|
|
18835
|
+
self.set(presets.options);
|
|
18815
18836
|
}
|
|
18816
18837
|
if (presets.components) {
|
|
18817
18838
|
Object.keys(presets.components).forEach(function(name2) {
|
|
18818
18839
|
if (presets.components[name2].rules) {
|
|
18819
|
-
|
|
18840
|
+
self[name2].ruler.enableOnly(presets.components[name2].rules);
|
|
18820
18841
|
}
|
|
18821
18842
|
if (presets.components[name2].rules2) {
|
|
18822
|
-
|
|
18843
|
+
self[name2].ruler2.enableOnly(presets.components[name2].rules2);
|
|
18823
18844
|
}
|
|
18824
18845
|
});
|
|
18825
18846
|
}
|
|
@@ -20294,21 +20315,29 @@ ${indent}`) + "'";
|
|
|
20294
20315
|
start = start.replace(/\n+/g, `$&${indent}`);
|
|
20295
20316
|
}
|
|
20296
20317
|
const indentSize = indent ? "2" : "1";
|
|
20297
|
-
let header = (
|
|
20318
|
+
let header = (startWithSpace ? indentSize : "") + chomp;
|
|
20298
20319
|
if (comment2) {
|
|
20299
20320
|
header += " " + commentString(comment2.replace(/ ?[\r\n]+/g, " "));
|
|
20300
20321
|
if (onComment)
|
|
20301
20322
|
onComment();
|
|
20302
20323
|
}
|
|
20303
|
-
if (literal) {
|
|
20304
|
-
|
|
20305
|
-
|
|
20306
|
-
|
|
20307
|
-
|
|
20308
|
-
|
|
20309
|
-
|
|
20310
|
-
|
|
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}
|
|
20311
20336
|
${indent}${body}`;
|
|
20337
|
+
}
|
|
20338
|
+
value = value.replace(/\n+/g, `$&${indent}`);
|
|
20339
|
+
return `|${header}
|
|
20340
|
+
${indent}${start}${value}${end2}`;
|
|
20312
20341
|
}
|
|
20313
20342
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
20314
20343
|
const { type, value } = item;
|
|
@@ -20428,10 +20457,15 @@ ${indent}`);
|
|
|
20428
20457
|
let obj;
|
|
20429
20458
|
if (isScalar(item)) {
|
|
20430
20459
|
obj = item.value;
|
|
20431
|
-
|
|
20460
|
+
let match = tags.filter((t) => {
|
|
20432
20461
|
var _a3;
|
|
20433
20462
|
return (_a3 = t.identify) == null ? void 0 : _a3.call(t, obj);
|
|
20434
20463
|
});
|
|
20464
|
+
if (match.length > 1) {
|
|
20465
|
+
const testMatch = match.filter((t) => t.test);
|
|
20466
|
+
if (testMatch.length > 0)
|
|
20467
|
+
match = testMatch;
|
|
20468
|
+
}
|
|
20435
20469
|
tagObj = match.find((t) => t.format === item.format) ?? match.find((t) => !t.format);
|
|
20436
20470
|
} else {
|
|
20437
20471
|
obj = item;
|
|
@@ -20617,41 +20651,29 @@ ${ctx.indent}`;
|
|
|
20617
20651
|
}
|
|
20618
20652
|
}
|
|
20619
20653
|
const MERGE_KEY = "<<";
|
|
20620
|
-
|
|
20621
|
-
|
|
20622
|
-
|
|
20623
|
-
|
|
20624
|
-
|
|
20625
|
-
|
|
20626
|
-
|
|
20627
|
-
|
|
20628
|
-
|
|
20629
|
-
|
|
20630
|
-
|
|
20631
|
-
|
|
20632
|
-
|
|
20633
|
-
|
|
20634
|
-
|
|
20635
|
-
|
|
20636
|
-
|
|
20637
|
-
|
|
20638
|
-
|
|
20639
|
-
|
|
20640
|
-
|
|
20641
|
-
Object.defineProperty(map2, stringKey, {
|
|
20642
|
-
value: jsValue,
|
|
20643
|
-
writable: true,
|
|
20644
|
-
enumerable: true,
|
|
20645
|
-
configurable: true
|
|
20646
|
-
});
|
|
20647
|
-
else
|
|
20648
|
-
map2[stringKey] = jsValue;
|
|
20649
|
-
}
|
|
20650
|
-
}
|
|
20651
|
-
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);
|
|
20652
20675
|
}
|
|
20653
|
-
|
|
20654
|
-
function mergeToJSMap(ctx, map2, value) {
|
|
20676
|
+
function mergeValue(ctx, map2, value) {
|
|
20655
20677
|
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
20656
20678
|
if (!isMap(source))
|
|
20657
20679
|
throw new Error("Merge sources must be maps or map aliases");
|
|
@@ -20673,6 +20695,33 @@ ${ctx.indent}`;
|
|
|
20673
20695
|
}
|
|
20674
20696
|
return map2;
|
|
20675
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
|
+
}
|
|
20676
20725
|
function stringifyKey(key, jsKey, ctx) {
|
|
20677
20726
|
if (jsKey === null)
|
|
20678
20727
|
return "";
|
|
@@ -21272,7 +21321,7 @@ ${indent}${end2}`;
|
|
|
21272
21321
|
identify: (value) => typeof value === "boolean",
|
|
21273
21322
|
default: true,
|
|
21274
21323
|
tag: "tag:yaml.org,2002:bool",
|
|
21275
|
-
test: /^true
|
|
21324
|
+
test: /^true$|^false$/,
|
|
21276
21325
|
resolve: (str) => str === "true",
|
|
21277
21326
|
stringify: stringifyJSON
|
|
21278
21327
|
},
|
|
@@ -21763,7 +21812,7 @@ ${cn.comment}` : item.comment;
|
|
|
21763
21812
|
}
|
|
21764
21813
|
return new Date(date);
|
|
21765
21814
|
},
|
|
21766
|
-
stringify: ({ value }) => value.toISOString().replace(/(
|
|
21815
|
+
stringify: ({ value }) => value.toISOString().replace(/(T00:00:00)?\.000Z$/, "")
|
|
21767
21816
|
};
|
|
21768
21817
|
const schema = [
|
|
21769
21818
|
map,
|
|
@@ -21780,6 +21829,7 @@ ${cn.comment}` : item.comment;
|
|
|
21780
21829
|
floatExp,
|
|
21781
21830
|
float,
|
|
21782
21831
|
binary,
|
|
21832
|
+
merge,
|
|
21783
21833
|
omap,
|
|
21784
21834
|
pairs,
|
|
21785
21835
|
set,
|
|
@@ -21806,6 +21856,7 @@ ${cn.comment}` : item.comment;
|
|
|
21806
21856
|
intOct: intOct$1,
|
|
21807
21857
|
intTime,
|
|
21808
21858
|
map,
|
|
21859
|
+
merge,
|
|
21809
21860
|
null: nullTag,
|
|
21810
21861
|
omap,
|
|
21811
21862
|
pairs,
|
|
@@ -21815,13 +21866,18 @@ ${cn.comment}` : item.comment;
|
|
|
21815
21866
|
};
|
|
21816
21867
|
const coreKnownTags = {
|
|
21817
21868
|
"tag:yaml.org,2002:binary": binary,
|
|
21869
|
+
"tag:yaml.org,2002:merge": merge,
|
|
21818
21870
|
"tag:yaml.org,2002:omap": omap,
|
|
21819
21871
|
"tag:yaml.org,2002:pairs": pairs,
|
|
21820
21872
|
"tag:yaml.org,2002:set": set,
|
|
21821
21873
|
"tag:yaml.org,2002:timestamp": timestamp
|
|
21822
21874
|
};
|
|
21823
|
-
function getTags(customTags, schemaName) {
|
|
21824
|
-
|
|
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;
|
|
21825
21881
|
if (!tags) {
|
|
21826
21882
|
if (Array.isArray(customTags))
|
|
21827
21883
|
tags = [];
|
|
@@ -21836,24 +21892,27 @@ ${cn.comment}` : item.comment;
|
|
|
21836
21892
|
} else if (typeof customTags === "function") {
|
|
21837
21893
|
tags = customTags(tags.slice());
|
|
21838
21894
|
}
|
|
21839
|
-
|
|
21840
|
-
|
|
21841
|
-
|
|
21842
|
-
const tagObj = tagsByName[tag];
|
|
21843
|
-
if (tagObj)
|
|
21844
|
-
|
|
21845
|
-
|
|
21846
|
-
|
|
21847
|
-
|
|
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
|
+
}, []);
|
|
21848
21908
|
}
|
|
21849
21909
|
const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
21850
21910
|
class Schema {
|
|
21851
21911
|
constructor({ compat, customTags, merge: merge2, resolveKnownTags, schema: schema2, sortMapEntries, toStringDefaults }) {
|
|
21852
21912
|
this.compat = Array.isArray(compat) ? getTags(compat, "compat") : compat ? getTags(null, compat) : null;
|
|
21853
|
-
this.merge = !!merge2;
|
|
21854
21913
|
this.name = typeof schema2 === "string" && schema2 || "core";
|
|
21855
21914
|
this.knownTags = resolveKnownTags ? coreKnownTags : {};
|
|
21856
|
-
this.tags = getTags(customTags, this.name);
|
|
21915
|
+
this.tags = getTags(customTags, this.name, merge2);
|
|
21857
21916
|
this.toStringOptions = toStringDefaults ?? null;
|
|
21858
21917
|
Object.defineProperty(this, MAP, { value: map });
|
|
21859
21918
|
Object.defineProperty(this, SCALAR$1, { value: string });
|
|
@@ -21956,6 +22015,7 @@ ${cn.comment}` : item.comment;
|
|
|
21956
22015
|
logLevel: "warn",
|
|
21957
22016
|
prettyErrors: true,
|
|
21958
22017
|
strict: true,
|
|
22018
|
+
stringKeys: false,
|
|
21959
22019
|
uniqueKeys: true,
|
|
21960
22020
|
version: "1.2"
|
|
21961
22021
|
}, options);
|
|
@@ -22157,7 +22217,7 @@ ${cn.comment}` : item.comment;
|
|
|
22157
22217
|
this.directives.yaml.version = "1.1";
|
|
22158
22218
|
else
|
|
22159
22219
|
this.directives = new Directives({ version: "1.1" });
|
|
22160
|
-
opt = {
|
|
22220
|
+
opt = { resolveKnownTags: false, schema: "yaml-1.1" };
|
|
22161
22221
|
break;
|
|
22162
22222
|
case "1.2":
|
|
22163
22223
|
case "next":
|
|
@@ -22165,7 +22225,7 @@ ${cn.comment}` : item.comment;
|
|
|
22165
22225
|
this.directives.yaml.version = version;
|
|
22166
22226
|
else
|
|
22167
22227
|
this.directives = new Directives({ version });
|
|
22168
|
-
opt = {
|
|
22228
|
+
opt = { resolveKnownTags: true, schema: "core" };
|
|
22169
22229
|
break;
|
|
22170
22230
|
case null:
|
|
22171
22231
|
if (this.directives)
|
|
@@ -22380,6 +22440,7 @@ ${pointer}
|
|
|
22380
22440
|
hasSpace = false;
|
|
22381
22441
|
break;
|
|
22382
22442
|
}
|
|
22443
|
+
// else fallthrough
|
|
22383
22444
|
default:
|
|
22384
22445
|
onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.type} token`);
|
|
22385
22446
|
atNewline = false;
|
|
@@ -22453,7 +22514,7 @@ ${pointer}
|
|
|
22453
22514
|
const { uniqueKeys } = ctx.options;
|
|
22454
22515
|
if (uniqueKeys === false)
|
|
22455
22516
|
return false;
|
|
22456
|
-
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;
|
|
22457
22518
|
return items.some((pair) => isEqual(pair.key, search));
|
|
22458
22519
|
}
|
|
22459
22520
|
const startColMsg = "All mapping items must start at the same column";
|
|
@@ -22499,10 +22560,12 @@ ${pointer}
|
|
|
22499
22560
|
} else if (((_a2 = keyProps.found) == null ? void 0 : _a2.indent) !== bm.indent) {
|
|
22500
22561
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
22501
22562
|
}
|
|
22563
|
+
ctx.atKey = true;
|
|
22502
22564
|
const keyStart = keyProps.end;
|
|
22503
22565
|
const keyNode = key ? composeNode2(ctx, key, keyProps, onError) : composeEmptyNode2(ctx, keyStart, start, null, keyProps, onError);
|
|
22504
22566
|
if (ctx.schema.compat)
|
|
22505
22567
|
flowIndentCheck(bm.indent, key, onError);
|
|
22568
|
+
ctx.atKey = false;
|
|
22506
22569
|
if (mapIncludes(ctx, map2.items, keyNode))
|
|
22507
22570
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
22508
22571
|
const valueProps = resolveProps(sep ?? [], {
|
|
@@ -22554,6 +22617,8 @@ ${pointer}
|
|
|
22554
22617
|
const seq2 = new NodeClass(ctx.schema);
|
|
22555
22618
|
if (ctx.atRoot)
|
|
22556
22619
|
ctx.atRoot = false;
|
|
22620
|
+
if (ctx.atKey)
|
|
22621
|
+
ctx.atKey = false;
|
|
22557
22622
|
let offset = bs.offset;
|
|
22558
22623
|
let commentEnd = null;
|
|
22559
22624
|
for (const { start, value } of bs.items) {
|
|
@@ -22633,6 +22698,8 @@ ${pointer}
|
|
|
22633
22698
|
const atRoot = ctx.atRoot;
|
|
22634
22699
|
if (atRoot)
|
|
22635
22700
|
ctx.atRoot = false;
|
|
22701
|
+
if (ctx.atKey)
|
|
22702
|
+
ctx.atKey = false;
|
|
22636
22703
|
let offset = fc.offset + fc.start.source.length;
|
|
22637
22704
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
22638
22705
|
const collItem = fc.items[i];
|
|
@@ -22708,10 +22775,12 @@ ${pointer}
|
|
|
22708
22775
|
if (isBlock(value))
|
|
22709
22776
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
22710
22777
|
} else {
|
|
22778
|
+
ctx.atKey = true;
|
|
22711
22779
|
const keyStart = props.end;
|
|
22712
22780
|
const keyNode = key ? composeNode2(ctx, key, props, onError) : composeEmptyNode2(ctx, keyStart, start, null, props, onError);
|
|
22713
22781
|
if (isBlock(key))
|
|
22714
22782
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
22783
|
+
ctx.atKey = false;
|
|
22715
22784
|
const valueProps = resolveProps(sep ?? [], {
|
|
22716
22785
|
flow: fcName,
|
|
22717
22786
|
indicator: "map-value-ind",
|
|
@@ -22983,6 +23052,7 @@ ${pointer}
|
|
|
22983
23052
|
switch (token.type) {
|
|
22984
23053
|
case "space":
|
|
22985
23054
|
hasSpace = true;
|
|
23055
|
+
// fallthrough
|
|
22986
23056
|
case "newline":
|
|
22987
23057
|
length += token.source.length;
|
|
22988
23058
|
break;
|
|
@@ -22998,6 +23068,7 @@ ${pointer}
|
|
|
22998
23068
|
onError(token, "UNEXPECTED_TOKEN", token.message);
|
|
22999
23069
|
length += token.source.length;
|
|
23000
23070
|
break;
|
|
23071
|
+
/* istanbul ignore next should not happen */
|
|
23001
23072
|
default: {
|
|
23002
23073
|
const message = `Unexpected token in block scalar header: ${token.type}`;
|
|
23003
23074
|
onError(token, "UNEXPECTED_TOKEN", message);
|
|
@@ -23037,6 +23108,7 @@ ${pointer}
|
|
|
23037
23108
|
_type = Scalar.QUOTE_DOUBLE;
|
|
23038
23109
|
value = doubleQuotedValue(source, _onError);
|
|
23039
23110
|
break;
|
|
23111
|
+
/* istanbul ignore next should not happen */
|
|
23040
23112
|
default:
|
|
23041
23113
|
onError(scalar, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`);
|
|
23042
23114
|
return {
|
|
@@ -23058,6 +23130,7 @@ ${pointer}
|
|
|
23058
23130
|
function plainValue(source, onError) {
|
|
23059
23131
|
let badChar = "";
|
|
23060
23132
|
switch (source[0]) {
|
|
23133
|
+
/* istanbul ignore next should not happen */
|
|
23061
23134
|
case " ":
|
|
23062
23135
|
badChar = "a tab character";
|
|
23063
23136
|
break;
|
|
@@ -23229,7 +23302,15 @@ ${pointer}
|
|
|
23229
23302
|
function composeScalar(ctx, token, tagToken, onError) {
|
|
23230
23303
|
const { value, type, comment: comment2, range } = token.type === "block-scalar" ? resolveBlockScalar(ctx, token, onError) : resolveFlowScalar(token, ctx.options.strict, onError);
|
|
23231
23304
|
const tagName = tagToken ? ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)) : null;
|
|
23232
|
-
|
|
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];
|
|
23233
23314
|
let scalar;
|
|
23234
23315
|
try {
|
|
23235
23316
|
const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
|
|
@@ -23275,10 +23356,10 @@ ${pointer}
|
|
|
23275
23356
|
onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, tagName !== "tag:yaml.org,2002:str");
|
|
23276
23357
|
return schema2[SCALAR$1];
|
|
23277
23358
|
}
|
|
23278
|
-
function findScalarTagByTest({ directives, schema: schema2 }, value, token, onError) {
|
|
23359
|
+
function findScalarTagByTest({ atKey, directives, schema: schema2 }, value, token, onError) {
|
|
23279
23360
|
const tag = schema2.tags.find((tag2) => {
|
|
23280
23361
|
var _a2;
|
|
23281
|
-
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));
|
|
23282
23363
|
}) || schema2[SCALAR$1];
|
|
23283
23364
|
if (schema2.compat) {
|
|
23284
23365
|
const compat = schema2.compat.find((tag2) => {
|
|
@@ -23319,6 +23400,7 @@ ${pointer}
|
|
|
23319
23400
|
}
|
|
23320
23401
|
const CN = { composeNode, composeEmptyNode };
|
|
23321
23402
|
function composeNode(ctx, token, props, onError) {
|
|
23403
|
+
const atKey = ctx.atKey;
|
|
23322
23404
|
const { spaceBefore, comment: comment2, anchor, tag } = props;
|
|
23323
23405
|
let node;
|
|
23324
23406
|
let isSrcToken = true;
|
|
@@ -23352,6 +23434,10 @@ ${pointer}
|
|
|
23352
23434
|
}
|
|
23353
23435
|
if (anchor && node.anchor === "")
|
|
23354
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
|
+
}
|
|
23355
23441
|
if (spaceBefore)
|
|
23356
23442
|
node.spaceBefore = true;
|
|
23357
23443
|
if (comment2) {
|
|
@@ -23402,6 +23488,7 @@ ${pointer}
|
|
|
23402
23488
|
const opts = Object.assign({ _directives: directives }, options);
|
|
23403
23489
|
const doc = new Document(void 0, opts);
|
|
23404
23490
|
const ctx = {
|
|
23491
|
+
atKey: false,
|
|
23405
23492
|
atRoot: true,
|
|
23406
23493
|
directives: doc.directives,
|
|
23407
23494
|
options: doc.options,
|
|
@@ -23891,6 +23978,7 @@ ${end2.comment}` : end2.comment;
|
|
|
23891
23978
|
switch (line[n]) {
|
|
23892
23979
|
case "#":
|
|
23893
23980
|
yield* this.pushCount(line.length - n);
|
|
23981
|
+
// fallthrough
|
|
23894
23982
|
case void 0:
|
|
23895
23983
|
yield* this.pushNewline();
|
|
23896
23984
|
return yield* this.parseLineStart();
|
|
@@ -23986,6 +24074,7 @@ ${end2.comment}` : end2.comment;
|
|
|
23986
24074
|
return "flow";
|
|
23987
24075
|
}
|
|
23988
24076
|
}
|
|
24077
|
+
// fallthrough
|
|
23989
24078
|
default:
|
|
23990
24079
|
this.flowKey = false;
|
|
23991
24080
|
return yield* this.parsePlainScalar();
|
|
@@ -24063,6 +24152,7 @@ ${end2.comment}` : end2.comment;
|
|
|
24063
24152
|
if (next2 === "\n")
|
|
24064
24153
|
break;
|
|
24065
24154
|
}
|
|
24155
|
+
// fallthrough
|
|
24066
24156
|
default:
|
|
24067
24157
|
break loop;
|
|
24068
24158
|
}
|
|
@@ -24180,7 +24270,9 @@ ${end2.comment}` : end2.comment;
|
|
|
24180
24270
|
case "&":
|
|
24181
24271
|
return (yield* this.pushUntil(isNotAnchorChar)) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators());
|
|
24182
24272
|
case "-":
|
|
24273
|
+
// this is an error
|
|
24183
24274
|
case "?":
|
|
24275
|
+
// this is an error outside flow collections
|
|
24184
24276
|
case ":": {
|
|
24185
24277
|
const inFlow = this.flowLevel > 0;
|
|
24186
24278
|
const ch1 = this.charAt(1);
|
|
@@ -24310,6 +24402,7 @@ ${end2.comment}` : end2.comment;
|
|
|
24310
24402
|
}
|
|
24311
24403
|
case "block-seq":
|
|
24312
24404
|
return parent2.items[parent2.items.length - 1].start;
|
|
24405
|
+
/* istanbul ignore next should not happen */
|
|
24313
24406
|
default:
|
|
24314
24407
|
return [];
|
|
24315
24408
|
}
|
|
@@ -24542,6 +24635,7 @@ ${end2.comment}` : end2.comment;
|
|
|
24542
24635
|
Object.assign(it, { key: token, sep: [] });
|
|
24543
24636
|
return;
|
|
24544
24637
|
}
|
|
24638
|
+
/* istanbul ignore next should not happen */
|
|
24545
24639
|
default:
|
|
24546
24640
|
yield* this.pop();
|
|
24547
24641
|
yield* this.pop(token);
|
|
@@ -24663,6 +24757,7 @@ ${end2.comment}` : end2.comment;
|
|
|
24663
24757
|
}
|
|
24664
24758
|
yield* this.pop();
|
|
24665
24759
|
break;
|
|
24760
|
+
/* istanbul ignore next should not happen */
|
|
24666
24761
|
default:
|
|
24667
24762
|
yield* this.pop();
|
|
24668
24763
|
yield* this.step();
|
|
@@ -25100,6 +25195,7 @@ ${end2.comment}` : end2.comment;
|
|
|
25100
25195
|
break;
|
|
25101
25196
|
case "newline":
|
|
25102
25197
|
this.onKeyLine = false;
|
|
25198
|
+
// fallthrough
|
|
25103
25199
|
case "space":
|
|
25104
25200
|
case "comment":
|
|
25105
25201
|
default:
|
|
@@ -25281,416 +25377,6 @@ ${end2.comment}` : end2.comment;
|
|
|
25281
25377
|
};
|
|
25282
25378
|
}
|
|
25283
25379
|
});
|
|
25284
|
-
var dist = {};
|
|
25285
|
-
var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) {
|
|
25286
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
25287
|
-
};
|
|
25288
|
-
Object.defineProperty(dist, "__esModule", { value: true });
|
|
25289
|
-
const katex_1 = __importDefault(require$$0);
|
|
25290
|
-
function isValidInlineDelim(state, pos) {
|
|
25291
|
-
const prevChar = state.src[pos - 1];
|
|
25292
|
-
const char = state.src[pos];
|
|
25293
|
-
const nextChar = state.src[pos + 1];
|
|
25294
|
-
if (char !== "$") {
|
|
25295
|
-
return { can_open: false, can_close: false };
|
|
25296
|
-
}
|
|
25297
|
-
let canOpen = false;
|
|
25298
|
-
let canClose = false;
|
|
25299
|
-
if (prevChar !== "$" && prevChar !== "\\" && (prevChar === void 0 || isWhitespace(prevChar) || !isWordCharacterOrNumber(prevChar))) {
|
|
25300
|
-
canOpen = true;
|
|
25301
|
-
}
|
|
25302
|
-
if (nextChar !== "$" && (nextChar == void 0 || isWhitespace(nextChar) || !isWordCharacterOrNumber(nextChar))) {
|
|
25303
|
-
canClose = true;
|
|
25304
|
-
}
|
|
25305
|
-
return { can_open: canOpen, can_close: canClose };
|
|
25306
|
-
}
|
|
25307
|
-
function isWhitespace(char) {
|
|
25308
|
-
return /^\s$/u.test(char);
|
|
25309
|
-
}
|
|
25310
|
-
function isWordCharacterOrNumber(char) {
|
|
25311
|
-
return /^[\w\d]$/u.test(char);
|
|
25312
|
-
}
|
|
25313
|
-
function isValidBlockDelim(state, pos) {
|
|
25314
|
-
const prevChar = state.src[pos - 1];
|
|
25315
|
-
const char = state.src[pos];
|
|
25316
|
-
const nextChar = state.src[pos + 1];
|
|
25317
|
-
const nextCharPlus1 = state.src[pos + 2];
|
|
25318
|
-
if (char === "$" && prevChar !== "$" && prevChar !== "\\" && nextChar === "$" && nextCharPlus1 !== "$") {
|
|
25319
|
-
return { can_open: true, can_close: true };
|
|
25320
|
-
}
|
|
25321
|
-
return { can_open: false, can_close: false };
|
|
25322
|
-
}
|
|
25323
|
-
function inlineMath(state, silent) {
|
|
25324
|
-
if (state.src[state.pos] !== "$") {
|
|
25325
|
-
return false;
|
|
25326
|
-
}
|
|
25327
|
-
const lastToken = state.tokens.at(-1);
|
|
25328
|
-
if ((lastToken == null ? void 0 : lastToken.type) === "html_inline") {
|
|
25329
|
-
if (/^<\w+.+[^/]>$/.test(lastToken.content)) {
|
|
25330
|
-
return false;
|
|
25331
|
-
}
|
|
25332
|
-
}
|
|
25333
|
-
let res = isValidInlineDelim(state, state.pos);
|
|
25334
|
-
if (!res.can_open) {
|
|
25335
|
-
if (!silent) {
|
|
25336
|
-
state.pending += "$";
|
|
25337
|
-
}
|
|
25338
|
-
state.pos += 1;
|
|
25339
|
-
return true;
|
|
25340
|
-
}
|
|
25341
|
-
let start = state.pos + 1;
|
|
25342
|
-
let match = start;
|
|
25343
|
-
let pos;
|
|
25344
|
-
while ((match = state.src.indexOf("$", match)) !== -1) {
|
|
25345
|
-
pos = match - 1;
|
|
25346
|
-
while (state.src[pos] === "\\") {
|
|
25347
|
-
pos -= 1;
|
|
25348
|
-
}
|
|
25349
|
-
if ((match - pos) % 2 == 1) {
|
|
25350
|
-
break;
|
|
25351
|
-
}
|
|
25352
|
-
match += 1;
|
|
25353
|
-
}
|
|
25354
|
-
if (match === -1) {
|
|
25355
|
-
if (!silent) {
|
|
25356
|
-
state.pending += "$";
|
|
25357
|
-
}
|
|
25358
|
-
state.pos = start;
|
|
25359
|
-
return true;
|
|
25360
|
-
}
|
|
25361
|
-
if (match - start === 0) {
|
|
25362
|
-
if (!silent) {
|
|
25363
|
-
state.pending += "$$";
|
|
25364
|
-
}
|
|
25365
|
-
state.pos = start + 1;
|
|
25366
|
-
return true;
|
|
25367
|
-
}
|
|
25368
|
-
res = isValidInlineDelim(state, match);
|
|
25369
|
-
if (!res.can_close) {
|
|
25370
|
-
if (!silent) {
|
|
25371
|
-
state.pending += "$";
|
|
25372
|
-
}
|
|
25373
|
-
state.pos = start;
|
|
25374
|
-
return true;
|
|
25375
|
-
}
|
|
25376
|
-
if (!silent) {
|
|
25377
|
-
const token = state.push("math_inline", "math", 0);
|
|
25378
|
-
token.markup = "$";
|
|
25379
|
-
token.content = state.src.slice(start, match);
|
|
25380
|
-
}
|
|
25381
|
-
state.pos = match + 1;
|
|
25382
|
-
return true;
|
|
25383
|
-
}
|
|
25384
|
-
function blockMath(state, start, end2, silent) {
|
|
25385
|
-
var lastLine, next2, lastPos, found = false, token, pos = state.bMarks[start] + state.tShift[start], max = state.eMarks[start];
|
|
25386
|
-
if (pos + 2 > max) {
|
|
25387
|
-
return false;
|
|
25388
|
-
}
|
|
25389
|
-
if (state.src.slice(pos, pos + 2) !== "$$") {
|
|
25390
|
-
return false;
|
|
25391
|
-
}
|
|
25392
|
-
pos += 2;
|
|
25393
|
-
let firstLine = state.src.slice(pos, max);
|
|
25394
|
-
if (silent) {
|
|
25395
|
-
return true;
|
|
25396
|
-
}
|
|
25397
|
-
if (firstLine.trim().slice(-2) === "$$") {
|
|
25398
|
-
firstLine = firstLine.trim().slice(0, -2);
|
|
25399
|
-
found = true;
|
|
25400
|
-
}
|
|
25401
|
-
for (next2 = start; !found; ) {
|
|
25402
|
-
next2++;
|
|
25403
|
-
if (next2 >= end2) {
|
|
25404
|
-
break;
|
|
25405
|
-
}
|
|
25406
|
-
pos = state.bMarks[next2] + state.tShift[next2];
|
|
25407
|
-
max = state.eMarks[next2];
|
|
25408
|
-
if (pos < max && state.tShift[next2] < state.blkIndent) {
|
|
25409
|
-
break;
|
|
25410
|
-
}
|
|
25411
|
-
if (state.src.slice(pos, max).trim().slice(-2) === "$$") {
|
|
25412
|
-
lastPos = state.src.slice(0, max).lastIndexOf("$$");
|
|
25413
|
-
lastLine = state.src.slice(pos, lastPos);
|
|
25414
|
-
found = true;
|
|
25415
|
-
} else if (state.src.slice(pos, max).trim().includes("$$")) {
|
|
25416
|
-
lastPos = state.src.slice(0, max).trim().indexOf("$$");
|
|
25417
|
-
lastLine = state.src.slice(pos, lastPos);
|
|
25418
|
-
found = true;
|
|
25419
|
-
}
|
|
25420
|
-
}
|
|
25421
|
-
state.line = next2 + 1;
|
|
25422
|
-
token = state.push("math_block", "math", 0);
|
|
25423
|
-
token.block = true;
|
|
25424
|
-
token.content = (firstLine && firstLine.trim() ? firstLine + "\n" : "") + state.getLines(start + 1, next2, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
25425
|
-
token.map = [start, state.line];
|
|
25426
|
-
token.markup = "$$";
|
|
25427
|
-
return true;
|
|
25428
|
-
}
|
|
25429
|
-
function blockBareMath(state, start, end2, silent) {
|
|
25430
|
-
const startPos = state.bMarks[start] + state.tShift[start];
|
|
25431
|
-
const startMax = state.eMarks[start];
|
|
25432
|
-
const firstLine = state.src.slice(startPos, startMax);
|
|
25433
|
-
const beginMatch = firstLine.match(/^\s*\\begin\s*\{([^{}]+)\}/);
|
|
25434
|
-
if (!beginMatch) {
|
|
25435
|
-
return false;
|
|
25436
|
-
}
|
|
25437
|
-
if (start > 0) {
|
|
25438
|
-
const previousStart = state.bMarks[start - 1] + state.tShift[start - 1];
|
|
25439
|
-
const previousEnd = state.eMarks[start - 1];
|
|
25440
|
-
const previousLine = state.src.slice(previousStart, previousEnd);
|
|
25441
|
-
if (!/^\s*$/.test(previousLine)) {
|
|
25442
|
-
return false;
|
|
25443
|
-
}
|
|
25444
|
-
}
|
|
25445
|
-
if (silent) {
|
|
25446
|
-
return true;
|
|
25447
|
-
}
|
|
25448
|
-
const beginEndStack = [];
|
|
25449
|
-
let next2 = start;
|
|
25450
|
-
let lastLine;
|
|
25451
|
-
let found = false;
|
|
25452
|
-
outer: for (; !found; next2++) {
|
|
25453
|
-
if (next2 >= end2) {
|
|
25454
|
-
break;
|
|
25455
|
-
}
|
|
25456
|
-
const pos = state.bMarks[next2] + state.tShift[next2];
|
|
25457
|
-
const max = state.eMarks[next2];
|
|
25458
|
-
if (pos < max && state.tShift[next2] < state.blkIndent) {
|
|
25459
|
-
break;
|
|
25460
|
-
}
|
|
25461
|
-
const line = state.src.slice(pos, max);
|
|
25462
|
-
for (const match of line.matchAll(/(\\begin|\\end)\s*\{([^{}]+)\}/g)) {
|
|
25463
|
-
if (match[1] === "\\begin") {
|
|
25464
|
-
beginEndStack.push(match[2].trim());
|
|
25465
|
-
} else if (match[1] === "\\end") {
|
|
25466
|
-
beginEndStack.pop();
|
|
25467
|
-
if (!beginEndStack.length) {
|
|
25468
|
-
lastLine = state.src.slice(pos, max);
|
|
25469
|
-
found = true;
|
|
25470
|
-
break outer;
|
|
25471
|
-
}
|
|
25472
|
-
}
|
|
25473
|
-
}
|
|
25474
|
-
}
|
|
25475
|
-
state.line = next2 + 1;
|
|
25476
|
-
const token = state.push("math_block", "math", 0);
|
|
25477
|
-
token.block = true;
|
|
25478
|
-
token.content = (state.getLines(start, next2, state.tShift[start], true) + (lastLine ?? "")).trim();
|
|
25479
|
-
token.map = [start, state.line];
|
|
25480
|
-
token.markup = "$$";
|
|
25481
|
-
return true;
|
|
25482
|
-
}
|
|
25483
|
-
function inlineMathBlock(state, silent) {
|
|
25484
|
-
var start, match, token, res, pos;
|
|
25485
|
-
if (state.src.slice(state.pos, state.pos + 2) !== "$$") {
|
|
25486
|
-
return false;
|
|
25487
|
-
}
|
|
25488
|
-
res = isValidBlockDelim(state, state.pos);
|
|
25489
|
-
if (!res.can_open) {
|
|
25490
|
-
if (!silent) {
|
|
25491
|
-
state.pending += "$$";
|
|
25492
|
-
}
|
|
25493
|
-
state.pos += 2;
|
|
25494
|
-
return true;
|
|
25495
|
-
}
|
|
25496
|
-
start = state.pos + 2;
|
|
25497
|
-
match = start;
|
|
25498
|
-
while ((match = state.src.indexOf("$$", match)) !== -1) {
|
|
25499
|
-
pos = match - 1;
|
|
25500
|
-
while (state.src[pos] === "\\") {
|
|
25501
|
-
pos -= 1;
|
|
25502
|
-
}
|
|
25503
|
-
if ((match - pos) % 2 == 1) {
|
|
25504
|
-
break;
|
|
25505
|
-
}
|
|
25506
|
-
match += 2;
|
|
25507
|
-
}
|
|
25508
|
-
if (match === -1) {
|
|
25509
|
-
if (!silent) {
|
|
25510
|
-
state.pending += "$$";
|
|
25511
|
-
}
|
|
25512
|
-
state.pos = start;
|
|
25513
|
-
return true;
|
|
25514
|
-
}
|
|
25515
|
-
if (match - start === 0) {
|
|
25516
|
-
if (!silent) {
|
|
25517
|
-
state.pending += "$$$$";
|
|
25518
|
-
}
|
|
25519
|
-
state.pos = start + 2;
|
|
25520
|
-
return true;
|
|
25521
|
-
}
|
|
25522
|
-
res = isValidBlockDelim(state, match);
|
|
25523
|
-
if (!res.can_close) {
|
|
25524
|
-
if (!silent) {
|
|
25525
|
-
state.pending += "$$";
|
|
25526
|
-
}
|
|
25527
|
-
state.pos = start;
|
|
25528
|
-
return true;
|
|
25529
|
-
}
|
|
25530
|
-
if (!silent) {
|
|
25531
|
-
token = state.push("math_block", "math", 0);
|
|
25532
|
-
token.block = true;
|
|
25533
|
-
token.markup = "$$";
|
|
25534
|
-
token.content = state.src.slice(start, match);
|
|
25535
|
-
}
|
|
25536
|
-
state.pos = match + 2;
|
|
25537
|
-
return true;
|
|
25538
|
-
}
|
|
25539
|
-
function inlineBareBlock(state, silent) {
|
|
25540
|
-
const text2 = state.src.slice(state.pos);
|
|
25541
|
-
if (!/^\n\\begin/.test(text2)) {
|
|
25542
|
-
return false;
|
|
25543
|
-
}
|
|
25544
|
-
state.pos += 1;
|
|
25545
|
-
if (silent) {
|
|
25546
|
-
return true;
|
|
25547
|
-
}
|
|
25548
|
-
const lines = text2.split(/\n/g).slice(1);
|
|
25549
|
-
let foundLine;
|
|
25550
|
-
const beginEndStack = [];
|
|
25551
|
-
outer: for (var i = 0; i < lines.length; ++i) {
|
|
25552
|
-
const line = lines[i];
|
|
25553
|
-
for (const match of line.matchAll(/(\\begin|\\end)\s*\{([^{}]+)\}/g)) {
|
|
25554
|
-
if (match[1] === "\\begin") {
|
|
25555
|
-
beginEndStack.push(match[2].trim());
|
|
25556
|
-
} else if (match[1] === "\\end") {
|
|
25557
|
-
beginEndStack.pop();
|
|
25558
|
-
if (!beginEndStack.length) {
|
|
25559
|
-
foundLine = i;
|
|
25560
|
-
break outer;
|
|
25561
|
-
}
|
|
25562
|
-
}
|
|
25563
|
-
}
|
|
25564
|
-
}
|
|
25565
|
-
if (typeof foundLine === "undefined") {
|
|
25566
|
-
return false;
|
|
25567
|
-
}
|
|
25568
|
-
const endIndex = lines.slice(0, foundLine + 1).reduce((p, c) => p + c.length, 0) + foundLine + 1;
|
|
25569
|
-
const token = state.push("math_inline_bare_block", "math", 0);
|
|
25570
|
-
token.block = true;
|
|
25571
|
-
token.markup = "$$";
|
|
25572
|
-
token.content = text2.slice(1, endIndex);
|
|
25573
|
-
state.pos = state.pos + endIndex;
|
|
25574
|
-
return true;
|
|
25575
|
-
}
|
|
25576
|
-
function handleMathInHtml(state, mathType, mathMarkup, mathRegex) {
|
|
25577
|
-
const tokens = state.tokens;
|
|
25578
|
-
for (let index2 = tokens.length - 1; index2 >= 0; index2--) {
|
|
25579
|
-
const currentToken = tokens[index2];
|
|
25580
|
-
const newTokens = [];
|
|
25581
|
-
if (currentToken.type !== "html_block") {
|
|
25582
|
-
continue;
|
|
25583
|
-
}
|
|
25584
|
-
const content = currentToken.content;
|
|
25585
|
-
for (const match of content.matchAll(mathRegex)) {
|
|
25586
|
-
if (!match.groups) {
|
|
25587
|
-
continue;
|
|
25588
|
-
}
|
|
25589
|
-
const html_before_math = match.groups.html_before_math;
|
|
25590
|
-
const math = match.groups.math;
|
|
25591
|
-
const html_after_math = match.groups.html_after_math;
|
|
25592
|
-
if (html_before_math) {
|
|
25593
|
-
newTokens.push({ ...currentToken, type: "html_block", map: null, content: html_before_math });
|
|
25594
|
-
}
|
|
25595
|
-
if (math) {
|
|
25596
|
-
newTokens.push({
|
|
25597
|
-
...currentToken,
|
|
25598
|
-
type: mathType,
|
|
25599
|
-
map: null,
|
|
25600
|
-
content: math,
|
|
25601
|
-
markup: mathMarkup,
|
|
25602
|
-
block: true,
|
|
25603
|
-
tag: "math"
|
|
25604
|
-
});
|
|
25605
|
-
}
|
|
25606
|
-
if (html_after_math) {
|
|
25607
|
-
newTokens.push({ ...currentToken, type: "html_block", map: null, content: html_after_math });
|
|
25608
|
-
}
|
|
25609
|
-
}
|
|
25610
|
-
if (newTokens.length > 0) {
|
|
25611
|
-
tokens.splice(index2, 1, ...newTokens);
|
|
25612
|
-
}
|
|
25613
|
-
}
|
|
25614
|
-
return true;
|
|
25615
|
-
}
|
|
25616
|
-
function escapeHtml(unsafe) {
|
|
25617
|
-
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
25618
|
-
}
|
|
25619
|
-
function default_1(md, options) {
|
|
25620
|
-
const enableBareBlocks = options == null ? void 0 : options.enableBareBlocks;
|
|
25621
|
-
const enableMathBlockInHtml = options == null ? void 0 : options.enableMathBlockInHtml;
|
|
25622
|
-
const enableMathInlineInHtml = options == null ? void 0 : options.enableMathInlineInHtml;
|
|
25623
|
-
const enableFencedBlocks = options == null ? void 0 : options.enableFencedBlocks;
|
|
25624
|
-
md.inline.ruler.after("escape", "math_inline", inlineMath);
|
|
25625
|
-
md.inline.ruler.after("escape", "math_inline_block", inlineMathBlock);
|
|
25626
|
-
if (enableBareBlocks) {
|
|
25627
|
-
md.inline.ruler.before("text", "math_inline_bare_block", inlineBareBlock);
|
|
25628
|
-
}
|
|
25629
|
-
md.block.ruler.after("blockquote", "math_block", (state, start, end2, silent) => {
|
|
25630
|
-
if (enableBareBlocks && blockBareMath(state, start, end2, silent)) {
|
|
25631
|
-
return true;
|
|
25632
|
-
}
|
|
25633
|
-
return blockMath(state, start, end2, silent);
|
|
25634
|
-
}, {
|
|
25635
|
-
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
25636
|
-
});
|
|
25637
|
-
const math_block_within_html_regex = /(?<html_before_math>[\s\S]*?)\$\$(?<math>[\s\S]+?)\$\$(?<html_after_math>(?:(?!\$\$[\s\S]+?\$\$)[\s\S])*)/gm;
|
|
25638
|
-
const math_inline_within_html_regex = /(?<html_before_math>[\s\S]*?)\$(?<math>.*?)\$(?<html_after_math>(?:(?!\$.*?\$)[\s\S])*)/gm;
|
|
25639
|
-
if (enableMathBlockInHtml) {
|
|
25640
|
-
md.core.ruler.push("math_block_in_html_block", (state) => {
|
|
25641
|
-
return handleMathInHtml(state, "math_block", "$$", math_block_within_html_regex);
|
|
25642
|
-
});
|
|
25643
|
-
}
|
|
25644
|
-
if (enableMathInlineInHtml) {
|
|
25645
|
-
md.core.ruler.push("math_inline_in_html_block", (state) => {
|
|
25646
|
-
return handleMathInHtml(state, "math_inline", "$", math_inline_within_html_regex);
|
|
25647
|
-
});
|
|
25648
|
-
}
|
|
25649
|
-
const katexInline = (latex) => {
|
|
25650
|
-
const displayMode = /\\begin\{(align|equation|gather|cd|alignat)\}/ig.test(latex);
|
|
25651
|
-
try {
|
|
25652
|
-
return katex_1.default.renderToString(latex, { ...options, displayMode });
|
|
25653
|
-
} catch (error2) {
|
|
25654
|
-
if (options == null ? void 0 : options.throwOnError) {
|
|
25655
|
-
console.log(error2);
|
|
25656
|
-
}
|
|
25657
|
-
return `<span class="katex-error" title="${escapeHtml(latex)}">${escapeHtml(error2 + "")}</span>`;
|
|
25658
|
-
}
|
|
25659
|
-
};
|
|
25660
|
-
const inlineRenderer = (tokens, idx) => {
|
|
25661
|
-
return katexInline(tokens[idx].content);
|
|
25662
|
-
};
|
|
25663
|
-
const katexBlockRenderer = (latex) => {
|
|
25664
|
-
try {
|
|
25665
|
-
return `<p class="katex-block">${katex_1.default.renderToString(latex, { ...options, displayMode: true })}</p>`;
|
|
25666
|
-
} catch (error2) {
|
|
25667
|
-
if (options == null ? void 0 : options.throwOnError) {
|
|
25668
|
-
console.log(error2);
|
|
25669
|
-
}
|
|
25670
|
-
return `<p class="katex-block katex-error" title="${escapeHtml(latex)}">${escapeHtml(error2 + "")}</p>`;
|
|
25671
|
-
}
|
|
25672
|
-
};
|
|
25673
|
-
const blockRenderer = (tokens, idx) => {
|
|
25674
|
-
return katexBlockRenderer(tokens[idx].content) + "\n";
|
|
25675
|
-
};
|
|
25676
|
-
md.renderer.rules.math_inline = inlineRenderer;
|
|
25677
|
-
md.renderer.rules.math_inline_block = blockRenderer;
|
|
25678
|
-
md.renderer.rules.math_inline_bare_block = blockRenderer;
|
|
25679
|
-
md.renderer.rules.math_block = blockRenderer;
|
|
25680
|
-
if (enableFencedBlocks) {
|
|
25681
|
-
const mathLanguageId = "math";
|
|
25682
|
-
const originalFenceRenderer = md.renderer.rules.fence;
|
|
25683
|
-
md.renderer.rules.fence = function(tokens, idx, options2, env, self2) {
|
|
25684
|
-
const token = tokens[idx];
|
|
25685
|
-
if (token.info.trim().toLowerCase() === mathLanguageId && enableFencedBlocks) {
|
|
25686
|
-
return katexBlockRenderer(token.content) + "\n";
|
|
25687
|
-
} else {
|
|
25688
|
-
return (originalFenceRenderer == null ? void 0 : originalFenceRenderer.call(this, tokens, idx, options2, env, self2)) || "";
|
|
25689
|
-
}
|
|
25690
|
-
};
|
|
25691
|
-
}
|
|
25692
|
-
}
|
|
25693
|
-
var _default = dist.default = default_1;
|
|
25694
25380
|
function addDefaultVersions(paths, name2, version) {
|
|
25695
25381
|
return paths.map((path) => {
|
|
25696
25382
|
if (typeof path === "string" && !path.includes("://")) {
|
|
@@ -25709,18 +25395,18 @@ ${end2.comment}` : end2.comment;
|
|
|
25709
25395
|
}
|
|
25710
25396
|
const name$2 = "katex";
|
|
25711
25397
|
const preloadScripts = [
|
|
25712
|
-
`katex@${"0.16.
|
|
25398
|
+
`katex@${"0.16.15"}/dist/katex.min.js`
|
|
25713
25399
|
].map((path) => buildJSItem(path));
|
|
25714
25400
|
const webfontloader = buildJSItem(
|
|
25715
25401
|
`webfontloader@${"1.6.28"}/webfontloader.js`
|
|
25716
25402
|
);
|
|
25717
25403
|
webfontloader.data.defer = true;
|
|
25718
|
-
const styles = [`katex@${"0.16.
|
|
25404
|
+
const styles = [`katex@${"0.16.15"}/dist/katex.min.css`].map(
|
|
25719
25405
|
(path) => buildCSSItem(path)
|
|
25720
25406
|
);
|
|
25721
25407
|
const config = {
|
|
25722
25408
|
versions: {
|
|
25723
|
-
katex: "0.16.
|
|
25409
|
+
katex: "0.16.15",
|
|
25724
25410
|
webfontloader: "1.6.28"
|
|
25725
25411
|
},
|
|
25726
25412
|
preloadScripts,
|
|
@@ -25760,6 +25446,432 @@ ${end2.comment}` : end2.comment;
|
|
|
25760
25446
|
],
|
|
25761
25447
|
styles
|
|
25762
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);
|
|
25763
25875
|
const plugin$1 = definePlugin({
|
|
25764
25876
|
name: name$2,
|
|
25765
25877
|
config,
|
|
@@ -25788,7 +25900,7 @@ ${end2.comment}` : end2.comment;
|
|
|
25788
25900
|
};
|
|
25789
25901
|
let enableFeature = noop;
|
|
25790
25902
|
transformHooks.parser.tap((md) => {
|
|
25791
|
-
md.use(
|
|
25903
|
+
md.use(katexPlugin);
|
|
25792
25904
|
["math_block", "math_inline"].forEach((key) => {
|
|
25793
25905
|
const fn = (tokens, idx) => {
|
|
25794
25906
|
enableFeature();
|
|
@@ -25954,7 +26066,7 @@ ${end2.comment}` : end2.comment;
|
|
|
25954
26066
|
}
|
|
25955
26067
|
}
|
|
25956
26068
|
const transformerVersions = {
|
|
25957
|
-
"markmap-lib": "0.17.3-alpha.
|
|
26069
|
+
"markmap-lib": "0.17.3-alpha.4"
|
|
25958
26070
|
};
|
|
25959
26071
|
exports.Transformer = Transformer;
|
|
25960
26072
|
exports.builtInPlugins = builtInPlugins;
|