markmap-lib 0.17.3-beta.3 → 0.18.0

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.
@@ -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$3(c) {
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$3(selector.charCodeAt(selectorIndex))) {
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$3(selector.charCodeAt(selectorIndex)) && selector.charCodeAt(selectorIndex) !== 93 || isEscaped(selectorIndex))) {
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
- trueFunc: function trueFunc() {
2946
- return true;
2947
- },
2948
- falseFunc: function falseFunc() {
2949
- return false;
2950
- }
2951
- };
2952
- const boolbase$1 = /* @__PURE__ */ getDefaultExportFromCjs(boolbase);
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$1.falseFunc;
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$1.falseFunc;
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$1.falseFunc;
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$1.falseFunc;
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$1.falseFunc;
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$1.trueFunc : (index2) => index2 >= b;
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$1.falseFunc)
3282
- return boolbase$1.falseFunc;
3283
- if (func === boolbase$1.trueFunc)
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$1.falseFunc)
3301
- return boolbase$1.falseFunc;
3302
- if (func === boolbase$1.trueFunc)
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$1.falseFunc)
3320
- return boolbase$1.falseFunc;
3321
- if (func === boolbase$1.trueFunc)
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$1.falseFunc)
3340
- return boolbase$1.falseFunc;
3341
- if (func === boolbase$1.trueFunc)
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$1.falseFunc;
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$1.falseFunc)
3490
- return boolbase$1.falseFunc;
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$1.trueFunc ? next2 : func === boolbase$1.falseFunc ? boolbase$1.falseFunc : (elem) => func(elem) && next2(elem);
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$1.falseFunc ? next2 : func === boolbase$1.trueFunc ? boolbase$1.falseFunc : (elem) => !func(elem) && next2(elem);
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$1.falseFunc)
3539
- return boolbase$1.falseFunc;
3550
+ if (compiled === boolbase.falseFunc)
3551
+ return boolbase.falseFunc;
3540
3552
  const hasElement = ensureIsTag(compiled, adapter2);
3541
- if (context && compiled !== boolbase$1.trueFunc) {
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$1.falseFunc);
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$1.falseFunc ? boolbase$1.falseFunc : compileGeneralSelector(previous, rule, options, context, compileToken), (_a2 = options.rootFunc) !== null && _a2 !== void 0 ? _a2 : boolbase$1.trueFunc);
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$1.falseFunc || a === boolbase$1.trueFunc) {
3790
+ if (b === boolbase.falseFunc || a === boolbase.trueFunc) {
3777
3791
  return a;
3778
3792
  }
3779
- if (a === boolbase$1.falseFunc || b === boolbase$1.trueFunc) {
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 !== boolbase.trueFunc) {
4020
- options = { ...options, rootFunc: boolbase.trueFunc };
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 === boolbase.trueFunc ? els : els.filter(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$2(cp) {
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$2(cp) || cp === CODE_POINTS.SOLIDUS || cp === CODE_POINTS.GREATER_THAN_SIGN;
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$2(cp) ? TokenType.WHITESPACE_CHARACTER : cp === CODE_POINTS.NULL ? TokenType.NULL_CHARACTER : TokenType.CHARACTER;
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$1(c) {
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$1(c);
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$1(c)) {
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$1(c)) ;
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$1(c)) {
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$1(c)) {
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$1(c)) {
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$1(c)) {
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$1(c)) {
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$1(c) || c === CharCodes.Gt) {
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);
@@ -14042,7 +14058,7 @@
14042
14058
  }
14043
14059
  function getCurrentHeading(level) {
14044
14060
  let heading2;
14045
- while ((heading2 = headingStack.at(-1)) && heading2.level >= level) {
14061
+ while ((heading2 = headingStack[headingStack.length - 1]) && heading2.level >= level) {
14046
14062
  headingStack.pop();
14047
14063
  }
14048
14064
  return heading2 || rootNode;
@@ -14129,6 +14145,7 @@
14129
14145
  };
14130
14146
  if (htmlNode.data) {
14131
14147
  node.payload = {
14148
+ tag: htmlNode.tag,
14132
14149
  ...htmlNode.data
14133
14150
  };
14134
14151
  }
@@ -14614,7 +14631,7 @@
14614
14631
  function replaceUnsafeChar(ch) {
14615
14632
  return HTML_REPLACEMENTS[ch];
14616
14633
  }
14617
- function escapeHtml$1(str) {
14634
+ function escapeHtml(str) {
14618
14635
  if (HTML_ESCAPE_TEST_RE.test(str)) {
14619
14636
  return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
14620
14637
  }
@@ -14638,10 +14655,15 @@
14638
14655
  }
14639
14656
  switch (code2) {
14640
14657
  case 9:
14658
+ // \t
14641
14659
  case 10:
14660
+ // \n
14642
14661
  case 11:
14662
+ // \v
14643
14663
  case 12:
14664
+ // \f
14644
14665
  case 13:
14666
+ // \r
14645
14667
  case 32:
14646
14668
  case 160:
14647
14669
  case 5760:
@@ -14706,7 +14728,7 @@
14706
14728
  __proto__: null,
14707
14729
  arrayReplaceAt,
14708
14730
  assign: assign$1,
14709
- escapeHtml: escapeHtml$1,
14731
+ escapeHtml,
14710
14732
  escapeRE: escapeRE$1,
14711
14733
  fromCodePoint,
14712
14734
  has,
@@ -14887,11 +14909,11 @@
14887
14909
  const default_rules = {};
14888
14910
  default_rules.code_inline = function(tokens, idx, options, env, slf) {
14889
14911
  const token = tokens[idx];
14890
- return "<code" + slf.renderAttrs(token) + ">" + escapeHtml$1(token.content) + "</code>";
14912
+ return "<code" + slf.renderAttrs(token) + ">" + escapeHtml(token.content) + "</code>";
14891
14913
  };
14892
14914
  default_rules.code_block = function(tokens, idx, options, env, slf) {
14893
14915
  const token = tokens[idx];
14894
- return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml$1(tokens[idx].content) + "</code></pre>\n";
14916
+ return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml(tokens[idx].content) + "</code></pre>\n";
14895
14917
  };
14896
14918
  default_rules.fence = function(tokens, idx, options, env, slf) {
14897
14919
  const token = tokens[idx];
@@ -14905,9 +14927,9 @@
14905
14927
  }
14906
14928
  let highlighted;
14907
14929
  if (options.highlight) {
14908
- highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml$1(token.content);
14930
+ highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content);
14909
14931
  } else {
14910
- highlighted = escapeHtml$1(token.content);
14932
+ highlighted = escapeHtml(token.content);
14911
14933
  }
14912
14934
  if (highlighted.indexOf("<pre") === 0) {
14913
14935
  return highlighted + "\n";
@@ -14942,7 +14964,7 @@
14942
14964
  return options.breaks ? options.xhtmlOut ? "<br />\n" : "<br>\n" : "\n";
14943
14965
  };
14944
14966
  default_rules.text = function(tokens, idx) {
14945
- return escapeHtml$1(tokens[idx].content);
14967
+ return escapeHtml(tokens[idx].content);
14946
14968
  };
14947
14969
  default_rules.html_block = function(tokens, idx) {
14948
14970
  return tokens[idx].content;
@@ -14960,7 +14982,7 @@
14960
14982
  }
14961
14983
  result = "";
14962
14984
  for (i = 0, l = token.attrs.length; i < l; i++) {
14963
- result += " " + escapeHtml$1(token.attrs[i][0]) + '="' + escapeHtml$1(token.attrs[i][1]) + '"';
14985
+ result += " " + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
14964
14986
  }
14965
14987
  return result;
14966
14988
  };
@@ -15058,9 +15080,9 @@
15058
15080
  return -1;
15059
15081
  };
15060
15082
  Ruler.prototype.__compile__ = function() {
15061
- const self2 = this;
15083
+ const self = this;
15062
15084
  const chains = [""];
15063
- self2.__rules__.forEach(function(rule) {
15085
+ self.__rules__.forEach(function(rule) {
15064
15086
  if (!rule.enabled) {
15065
15087
  return;
15066
15088
  }
@@ -15070,17 +15092,17 @@
15070
15092
  }
15071
15093
  });
15072
15094
  });
15073
- self2.__cache__ = {};
15095
+ self.__cache__ = {};
15074
15096
  chains.forEach(function(chain) {
15075
- self2.__cache__[chain] = [];
15076
- self2.__rules__.forEach(function(rule) {
15097
+ self.__cache__[chain] = [];
15098
+ self.__rules__.forEach(function(rule) {
15077
15099
  if (!rule.enabled) {
15078
15100
  return;
15079
15101
  }
15080
15102
  if (chain && rule.alt.indexOf(chain) < 0) {
15081
15103
  return;
15082
15104
  }
15083
- self2.__cache__[chain].push(rule.fn);
15105
+ self.__cache__[chain].push(rule.fn);
15084
15106
  });
15085
15107
  });
15086
15108
  };
@@ -18025,16 +18047,16 @@
18025
18047
  }
18026
18048
  const defaultSchemas = {
18027
18049
  "http:": {
18028
- validate: function(text2, pos, self2) {
18050
+ validate: function(text2, pos, self) {
18029
18051
  const tail = text2.slice(pos);
18030
- if (!self2.re.http) {
18031
- self2.re.http = new RegExp(
18032
- "^\\/\\/" + self2.re.src_auth + self2.re.src_host_port_strict + self2.re.src_path,
18052
+ if (!self.re.http) {
18053
+ self.re.http = new RegExp(
18054
+ "^\\/\\/" + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path,
18033
18055
  "i"
18034
18056
  );
18035
18057
  }
18036
- if (self2.re.http.test(tail)) {
18037
- return tail.match(self2.re.http)[0].length;
18058
+ if (self.re.http.test(tail)) {
18059
+ return tail.match(self.re.http)[0].length;
18038
18060
  }
18039
18061
  return 0;
18040
18062
  }
@@ -18042,39 +18064,39 @@
18042
18064
  "https:": "http:",
18043
18065
  "ftp:": "http:",
18044
18066
  "//": {
18045
- validate: function(text2, pos, self2) {
18067
+ validate: function(text2, pos, self) {
18046
18068
  const tail = text2.slice(pos);
18047
- if (!self2.re.no_http) {
18048
- self2.re.no_http = new RegExp(
18049
- "^" + self2.re.src_auth + // Don't allow single-level domains, because of false positives like '//test'
18069
+ if (!self.re.no_http) {
18070
+ self.re.no_http = new RegExp(
18071
+ "^" + self.re.src_auth + // Don't allow single-level domains, because of false positives like '//test'
18050
18072
  // with code comments
18051
- "(?:localhost|(?:(?:" + self2.re.src_domain + ")\\.)+" + self2.re.src_domain_root + ")" + self2.re.src_port + self2.re.src_host_terminator + self2.re.src_path,
18073
+ "(?:localhost|(?:(?:" + self.re.src_domain + ")\\.)+" + self.re.src_domain_root + ")" + self.re.src_port + self.re.src_host_terminator + self.re.src_path,
18052
18074
  "i"
18053
18075
  );
18054
18076
  }
18055
- if (self2.re.no_http.test(tail)) {
18077
+ if (self.re.no_http.test(tail)) {
18056
18078
  if (pos >= 3 && text2[pos - 3] === ":") {
18057
18079
  return 0;
18058
18080
  }
18059
18081
  if (pos >= 3 && text2[pos - 3] === "/") {
18060
18082
  return 0;
18061
18083
  }
18062
- return tail.match(self2.re.no_http)[0].length;
18084
+ return tail.match(self.re.no_http)[0].length;
18063
18085
  }
18064
18086
  return 0;
18065
18087
  }
18066
18088
  },
18067
18089
  "mailto:": {
18068
- validate: function(text2, pos, self2) {
18090
+ validate: function(text2, pos, self) {
18069
18091
  const tail = text2.slice(pos);
18070
- if (!self2.re.mailto) {
18071
- self2.re.mailto = new RegExp(
18072
- "^" + self2.re.src_email_name + "@" + self2.re.src_host_strict,
18092
+ if (!self.re.mailto) {
18093
+ self.re.mailto = new RegExp(
18094
+ "^" + self.re.src_email_name + "@" + self.re.src_host_strict,
18073
18095
  "i"
18074
18096
  );
18075
18097
  }
18076
- if (self2.re.mailto.test(tail)) {
18077
- return tail.match(self2.re.mailto)[0].length;
18098
+ if (self.re.mailto.test(tail)) {
18099
+ return tail.match(self.re.mailto)[0].length;
18078
18100
  }
18079
18101
  return 0;
18080
18102
  }
@@ -18082,9 +18104,9 @@
18082
18104
  };
18083
18105
  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
18106
  const tlds_default = "biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");
18085
- function resetScanCache(self2) {
18086
- self2.__index__ = -1;
18087
- self2.__text_cache__ = "";
18107
+ function resetScanCache(self) {
18108
+ self.__index__ = -1;
18109
+ self.__text_cache__ = "";
18088
18110
  }
18089
18111
  function createValidator(re) {
18090
18112
  return function(text2, pos) {
@@ -18096,15 +18118,15 @@
18096
18118
  };
18097
18119
  }
18098
18120
  function createNormalizer() {
18099
- return function(match, self2) {
18100
- self2.normalize(match);
18121
+ return function(match, self) {
18122
+ self.normalize(match);
18101
18123
  };
18102
18124
  }
18103
- function compile(self2) {
18104
- const re = self2.re = reFactory(self2.__opts__);
18105
- const tlds = self2.__tlds__.slice();
18106
- self2.onCompile();
18107
- if (!self2.__tlds_replaced__) {
18125
+ function compile(self) {
18126
+ const re = self.re = reFactory(self.__opts__);
18127
+ const tlds = self.__tlds__.slice();
18128
+ self.onCompile();
18129
+ if (!self.__tlds_replaced__) {
18108
18130
  tlds.push(tlds_2ch_src_re);
18109
18131
  }
18110
18132
  tlds.push(re.src_xn);
@@ -18117,17 +18139,17 @@
18117
18139
  re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), "i");
18118
18140
  re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), "i");
18119
18141
  const aliases2 = [];
18120
- self2.__compiled__ = {};
18142
+ self.__compiled__ = {};
18121
18143
  function schemaError(name2, val2) {
18122
18144
  throw new Error('(LinkifyIt) Invalid schema "' + name2 + '": ' + val2);
18123
18145
  }
18124
- Object.keys(self2.__schemas__).forEach(function(name2) {
18125
- const val2 = self2.__schemas__[name2];
18146
+ Object.keys(self.__schemas__).forEach(function(name2) {
18147
+ const val2 = self.__schemas__[name2];
18126
18148
  if (val2 === null) {
18127
18149
  return;
18128
18150
  }
18129
18151
  const compiled = { validate: null, link: null };
18130
- self2.__compiled__[name2] = compiled;
18152
+ self.__compiled__[name2] = compiled;
18131
18153
  if (isObject(val2)) {
18132
18154
  if (isRegExp(val2.validate)) {
18133
18155
  compiled.validate = createValidator(val2.validate);
@@ -18152,39 +18174,39 @@
18152
18174
  schemaError(name2, val2);
18153
18175
  });
18154
18176
  aliases2.forEach(function(alias) {
18155
- if (!self2.__compiled__[self2.__schemas__[alias]]) {
18177
+ if (!self.__compiled__[self.__schemas__[alias]]) {
18156
18178
  return;
18157
18179
  }
18158
- self2.__compiled__[alias].validate = self2.__compiled__[self2.__schemas__[alias]].validate;
18159
- self2.__compiled__[alias].normalize = self2.__compiled__[self2.__schemas__[alias]].normalize;
18180
+ self.__compiled__[alias].validate = self.__compiled__[self.__schemas__[alias]].validate;
18181
+ self.__compiled__[alias].normalize = self.__compiled__[self.__schemas__[alias]].normalize;
18160
18182
  });
18161
- self2.__compiled__[""] = { validate: null, normalize: createNormalizer() };
18162
- const slist = Object.keys(self2.__compiled__).filter(function(name2) {
18163
- return name2.length > 0 && self2.__compiled__[name2];
18183
+ self.__compiled__[""] = { validate: null, normalize: createNormalizer() };
18184
+ const slist = Object.keys(self.__compiled__).filter(function(name2) {
18185
+ return name2.length > 0 && self.__compiled__[name2];
18164
18186
  }).map(escapeRE).join("|");
18165
- self2.re.schema_test = RegExp("(^|(?!_)(?:[><|]|" + re.src_ZPCc + "))(" + slist + ")", "i");
18166
- self2.re.schema_search = RegExp("(^|(?!_)(?:[><|]|" + re.src_ZPCc + "))(" + slist + ")", "ig");
18167
- self2.re.schema_at_start = RegExp("^" + self2.re.schema_search.source, "i");
18168
- self2.re.pretest = RegExp(
18169
- "(" + self2.re.schema_test.source + ")|(" + self2.re.host_fuzzy_test.source + ")|@",
18187
+ self.re.schema_test = RegExp("(^|(?!_)(?:[><|]|" + re.src_ZPCc + "))(" + slist + ")", "i");
18188
+ self.re.schema_search = RegExp("(^|(?!_)(?:[><|]|" + re.src_ZPCc + "))(" + slist + ")", "ig");
18189
+ self.re.schema_at_start = RegExp("^" + self.re.schema_search.source, "i");
18190
+ self.re.pretest = RegExp(
18191
+ "(" + self.re.schema_test.source + ")|(" + self.re.host_fuzzy_test.source + ")|@",
18170
18192
  "i"
18171
18193
  );
18172
- resetScanCache(self2);
18194
+ resetScanCache(self);
18173
18195
  }
18174
- function Match(self2, shift) {
18175
- const start = self2.__index__;
18176
- const end2 = self2.__last_index__;
18177
- const text2 = self2.__text_cache__.slice(start, end2);
18178
- this.schema = self2.__schema__.toLowerCase();
18196
+ function Match(self, shift) {
18197
+ const start = self.__index__;
18198
+ const end2 = self.__last_index__;
18199
+ const text2 = self.__text_cache__.slice(start, end2);
18200
+ this.schema = self.__schema__.toLowerCase();
18179
18201
  this.index = start + shift;
18180
18202
  this.lastIndex = end2 + shift;
18181
18203
  this.raw = text2;
18182
18204
  this.text = text2;
18183
18205
  this.url = text2;
18184
18206
  }
18185
- function createMatch(self2, shift) {
18186
- const match = new Match(self2, shift);
18187
- self2.__compiled__[match.schema].normalize(match, self2);
18207
+ function createMatch(self, shift) {
18208
+ const match = new Match(self, shift);
18209
+ self.__compiled__[match.schema].normalize(match, self);
18188
18210
  return match;
18189
18211
  }
18190
18212
  function LinkifyIt(schemas2, options) {
@@ -18799,7 +18821,7 @@
18799
18821
  return this;
18800
18822
  };
18801
18823
  MarkdownIt.prototype.configure = function(presets) {
18802
- const self2 = this;
18824
+ const self = this;
18803
18825
  if (isString$1(presets)) {
18804
18826
  const presetName = presets;
18805
18827
  presets = config$2[presetName];
@@ -18811,15 +18833,15 @@
18811
18833
  throw new Error("Wrong `markdown-it` preset, can't be empty");
18812
18834
  }
18813
18835
  if (presets.options) {
18814
- self2.set(presets.options);
18836
+ self.set(presets.options);
18815
18837
  }
18816
18838
  if (presets.components) {
18817
18839
  Object.keys(presets.components).forEach(function(name2) {
18818
18840
  if (presets.components[name2].rules) {
18819
- self2[name2].ruler.enableOnly(presets.components[name2].rules);
18841
+ self[name2].ruler.enableOnly(presets.components[name2].rules);
18820
18842
  }
18821
18843
  if (presets.components[name2].rules2) {
18822
- self2[name2].ruler2.enableOnly(presets.components[name2].rules2);
18844
+ self[name2].ruler2.enableOnly(presets.components[name2].rules2);
18823
18845
  }
18824
18846
  });
18825
18847
  }
@@ -20294,21 +20316,29 @@ ${indent}`) + "'";
20294
20316
  start = start.replace(/\n+/g, `$&${indent}`);
20295
20317
  }
20296
20318
  const indentSize = indent ? "2" : "1";
20297
- let header = (literal ? "|" : ">") + (startWithSpace ? indentSize : "") + chomp;
20319
+ let header = (startWithSpace ? indentSize : "") + chomp;
20298
20320
  if (comment2) {
20299
20321
  header += " " + commentString(comment2.replace(/ ?[\r\n]+/g, " "));
20300
20322
  if (onComment)
20301
20323
  onComment();
20302
20324
  }
20303
- if (literal) {
20304
- value = value.replace(/\n+/g, `$&${indent}`);
20305
- return `${header}
20306
- ${indent}${start}${value}${end2}`;
20307
- }
20308
- value = value.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${indent}`);
20309
- const body = foldFlowLines(`${start}${value}${end2}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true));
20310
- return `${header}
20325
+ if (!literal) {
20326
+ const foldedValue = value.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${indent}`);
20327
+ let literalFallback = false;
20328
+ const foldOptions = getFoldOptions(ctx, true);
20329
+ if (blockQuote !== "folded" && type !== Scalar.BLOCK_FOLDED) {
20330
+ foldOptions.onOverflow = () => {
20331
+ literalFallback = true;
20332
+ };
20333
+ }
20334
+ const body = foldFlowLines(`${start}${foldedValue}${end2}`, indent, FOLD_BLOCK, foldOptions);
20335
+ if (!literalFallback)
20336
+ return `>${header}
20311
20337
  ${indent}${body}`;
20338
+ }
20339
+ value = value.replace(/\n+/g, `$&${indent}`);
20340
+ return `|${header}
20341
+ ${indent}${start}${value}${end2}`;
20312
20342
  }
20313
20343
  function plainString(item, ctx, onComment, onChompKeep) {
20314
20344
  const { type, value } = item;
@@ -20428,10 +20458,15 @@ ${indent}`);
20428
20458
  let obj;
20429
20459
  if (isScalar(item)) {
20430
20460
  obj = item.value;
20431
- const match = tags.filter((t) => {
20461
+ let match = tags.filter((t) => {
20432
20462
  var _a3;
20433
20463
  return (_a3 = t.identify) == null ? void 0 : _a3.call(t, obj);
20434
20464
  });
20465
+ if (match.length > 1) {
20466
+ const testMatch = match.filter((t) => t.test);
20467
+ if (testMatch.length > 0)
20468
+ match = testMatch;
20469
+ }
20435
20470
  tagObj = match.find((t) => t.format === item.format) ?? match.find((t) => !t.format);
20436
20471
  } else {
20437
20472
  obj = item;
@@ -20617,41 +20652,29 @@ ${ctx.indent}`;
20617
20652
  }
20618
20653
  }
20619
20654
  const MERGE_KEY = "<<";
20620
- function addPairToJSMap(ctx, map2, { key, value }) {
20621
- if ((ctx == null ? void 0 : ctx.doc.schema.merge) && isMergeKey(key)) {
20622
- value = isAlias(value) ? value.resolve(ctx.doc) : value;
20623
- if (isSeq(value))
20624
- for (const it of value.items)
20625
- mergeToJSMap(ctx, map2, it);
20626
- else if (Array.isArray(value))
20627
- for (const it of value)
20628
- mergeToJSMap(ctx, map2, it);
20629
- else
20630
- mergeToJSMap(ctx, map2, value);
20631
- } else {
20632
- const jsKey = toJS(key, "", ctx);
20633
- if (map2 instanceof Map) {
20634
- map2.set(jsKey, toJS(value, jsKey, ctx));
20635
- } else if (map2 instanceof Set) {
20636
- map2.add(jsKey);
20637
- } else {
20638
- const stringKey = stringifyKey(key, jsKey, ctx);
20639
- const jsValue = toJS(value, stringKey, ctx);
20640
- if (stringKey in map2)
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;
20655
+ const merge = {
20656
+ identify: (value) => value === MERGE_KEY || typeof value === "symbol" && value.description === MERGE_KEY,
20657
+ default: "key",
20658
+ tag: "tag:yaml.org,2002:merge",
20659
+ test: /^<<$/,
20660
+ resolve: () => Object.assign(new Scalar(Symbol(MERGE_KEY)), {
20661
+ addToJSMap: addMergeToJSMap
20662
+ }),
20663
+ stringify: () => MERGE_KEY
20664
+ };
20665
+ 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));
20666
+ function addMergeToJSMap(ctx, map2, value) {
20667
+ value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
20668
+ if (isSeq(value))
20669
+ for (const it of value.items)
20670
+ mergeValue(ctx, map2, it);
20671
+ else if (Array.isArray(value))
20672
+ for (const it of value)
20673
+ mergeValue(ctx, map2, it);
20674
+ else
20675
+ mergeValue(ctx, map2, value);
20652
20676
  }
20653
- const isMergeKey = (key) => key === MERGE_KEY || isScalar(key) && key.value === MERGE_KEY && (!key.type || key.type === Scalar.PLAIN);
20654
- function mergeToJSMap(ctx, map2, value) {
20677
+ function mergeValue(ctx, map2, value) {
20655
20678
  const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
20656
20679
  if (!isMap(source))
20657
20680
  throw new Error("Merge sources must be maps or map aliases");
@@ -20673,6 +20696,33 @@ ${ctx.indent}`;
20673
20696
  }
20674
20697
  return map2;
20675
20698
  }
20699
+ function addPairToJSMap(ctx, map2, { key, value }) {
20700
+ if (isNode(key) && key.addToJSMap)
20701
+ key.addToJSMap(ctx, map2, value);
20702
+ else if (isMergeKey(ctx, key))
20703
+ addMergeToJSMap(ctx, map2, value);
20704
+ else {
20705
+ const jsKey = toJS(key, "", ctx);
20706
+ if (map2 instanceof Map) {
20707
+ map2.set(jsKey, toJS(value, jsKey, ctx));
20708
+ } else if (map2 instanceof Set) {
20709
+ map2.add(jsKey);
20710
+ } else {
20711
+ const stringKey = stringifyKey(key, jsKey, ctx);
20712
+ const jsValue = toJS(value, stringKey, ctx);
20713
+ if (stringKey in map2)
20714
+ Object.defineProperty(map2, stringKey, {
20715
+ value: jsValue,
20716
+ writable: true,
20717
+ enumerable: true,
20718
+ configurable: true
20719
+ });
20720
+ else
20721
+ map2[stringKey] = jsValue;
20722
+ }
20723
+ }
20724
+ return map2;
20725
+ }
20676
20726
  function stringifyKey(key, jsKey, ctx) {
20677
20727
  if (jsKey === null)
20678
20728
  return "";
@@ -21272,7 +21322,7 @@ ${indent}${end2}`;
21272
21322
  identify: (value) => typeof value === "boolean",
21273
21323
  default: true,
21274
21324
  tag: "tag:yaml.org,2002:bool",
21275
- test: /^true|false$/,
21325
+ test: /^true$|^false$/,
21276
21326
  resolve: (str) => str === "true",
21277
21327
  stringify: stringifyJSON
21278
21328
  },
@@ -21763,7 +21813,7 @@ ${cn.comment}` : item.comment;
21763
21813
  }
21764
21814
  return new Date(date);
21765
21815
  },
21766
- stringify: ({ value }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, "")
21816
+ stringify: ({ value }) => value.toISOString().replace(/(T00:00:00)?\.000Z$/, "")
21767
21817
  };
21768
21818
  const schema = [
21769
21819
  map,
@@ -21780,6 +21830,7 @@ ${cn.comment}` : item.comment;
21780
21830
  floatExp,
21781
21831
  float,
21782
21832
  binary,
21833
+ merge,
21783
21834
  omap,
21784
21835
  pairs,
21785
21836
  set,
@@ -21806,6 +21857,7 @@ ${cn.comment}` : item.comment;
21806
21857
  intOct: intOct$1,
21807
21858
  intTime,
21808
21859
  map,
21860
+ merge,
21809
21861
  null: nullTag,
21810
21862
  omap,
21811
21863
  pairs,
@@ -21815,13 +21867,18 @@ ${cn.comment}` : item.comment;
21815
21867
  };
21816
21868
  const coreKnownTags = {
21817
21869
  "tag:yaml.org,2002:binary": binary,
21870
+ "tag:yaml.org,2002:merge": merge,
21818
21871
  "tag:yaml.org,2002:omap": omap,
21819
21872
  "tag:yaml.org,2002:pairs": pairs,
21820
21873
  "tag:yaml.org,2002:set": set,
21821
21874
  "tag:yaml.org,2002:timestamp": timestamp
21822
21875
  };
21823
- function getTags(customTags, schemaName) {
21824
- let tags = schemas.get(schemaName);
21876
+ function getTags(customTags, schemaName, addMergeTag) {
21877
+ const schemaTags = schemas.get(schemaName);
21878
+ if (schemaTags && !customTags) {
21879
+ return addMergeTag && !schemaTags.includes(merge) ? schemaTags.concat(merge) : schemaTags.slice();
21880
+ }
21881
+ let tags = schemaTags;
21825
21882
  if (!tags) {
21826
21883
  if (Array.isArray(customTags))
21827
21884
  tags = [];
@@ -21836,24 +21893,27 @@ ${cn.comment}` : item.comment;
21836
21893
  } else if (typeof customTags === "function") {
21837
21894
  tags = customTags(tags.slice());
21838
21895
  }
21839
- return tags.map((tag) => {
21840
- if (typeof tag !== "string")
21841
- return tag;
21842
- const tagObj = tagsByName[tag];
21843
- if (tagObj)
21844
- return tagObj;
21845
- const keys = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", ");
21846
- throw new Error(`Unknown custom tag "${tag}"; use one of ${keys}`);
21847
- });
21896
+ if (addMergeTag)
21897
+ tags = tags.concat(merge);
21898
+ return tags.reduce((tags2, tag) => {
21899
+ const tagObj = typeof tag === "string" ? tagsByName[tag] : tag;
21900
+ if (!tagObj) {
21901
+ const tagName = JSON.stringify(tag);
21902
+ const keys = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", ");
21903
+ throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
21904
+ }
21905
+ if (!tags2.includes(tagObj))
21906
+ tags2.push(tagObj);
21907
+ return tags2;
21908
+ }, []);
21848
21909
  }
21849
21910
  const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
21850
21911
  class Schema {
21851
21912
  constructor({ compat, customTags, merge: merge2, resolveKnownTags, schema: schema2, sortMapEntries, toStringDefaults }) {
21852
21913
  this.compat = Array.isArray(compat) ? getTags(compat, "compat") : compat ? getTags(null, compat) : null;
21853
- this.merge = !!merge2;
21854
21914
  this.name = typeof schema2 === "string" && schema2 || "core";
21855
21915
  this.knownTags = resolveKnownTags ? coreKnownTags : {};
21856
- this.tags = getTags(customTags, this.name);
21916
+ this.tags = getTags(customTags, this.name, merge2);
21857
21917
  this.toStringOptions = toStringDefaults ?? null;
21858
21918
  Object.defineProperty(this, MAP, { value: map });
21859
21919
  Object.defineProperty(this, SCALAR$1, { value: string });
@@ -21956,6 +22016,7 @@ ${cn.comment}` : item.comment;
21956
22016
  logLevel: "warn",
21957
22017
  prettyErrors: true,
21958
22018
  strict: true,
22019
+ stringKeys: false,
21959
22020
  uniqueKeys: true,
21960
22021
  version: "1.2"
21961
22022
  }, options);
@@ -22157,7 +22218,7 @@ ${cn.comment}` : item.comment;
22157
22218
  this.directives.yaml.version = "1.1";
22158
22219
  else
22159
22220
  this.directives = new Directives({ version: "1.1" });
22160
- opt = { merge: true, resolveKnownTags: false, schema: "yaml-1.1" };
22221
+ opt = { resolveKnownTags: false, schema: "yaml-1.1" };
22161
22222
  break;
22162
22223
  case "1.2":
22163
22224
  case "next":
@@ -22165,7 +22226,7 @@ ${cn.comment}` : item.comment;
22165
22226
  this.directives.yaml.version = version;
22166
22227
  else
22167
22228
  this.directives = new Directives({ version });
22168
- opt = { merge: false, resolveKnownTags: true, schema: "core" };
22229
+ opt = { resolveKnownTags: true, schema: "core" };
22169
22230
  break;
22170
22231
  case null:
22171
22232
  if (this.directives)
@@ -22380,6 +22441,7 @@ ${pointer}
22380
22441
  hasSpace = false;
22381
22442
  break;
22382
22443
  }
22444
+ // else fallthrough
22383
22445
  default:
22384
22446
  onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.type} token`);
22385
22447
  atNewline = false;
@@ -22453,7 +22515,7 @@ ${pointer}
22453
22515
  const { uniqueKeys } = ctx.options;
22454
22516
  if (uniqueKeys === false)
22455
22517
  return false;
22456
- const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a, b) => a === b || isScalar(a) && isScalar(b) && a.value === b.value && !(a.value === "<<" && ctx.schema.merge);
22518
+ const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a, b) => a === b || isScalar(a) && isScalar(b) && a.value === b.value;
22457
22519
  return items.some((pair) => isEqual(pair.key, search));
22458
22520
  }
22459
22521
  const startColMsg = "All mapping items must start at the same column";
@@ -22499,10 +22561,12 @@ ${pointer}
22499
22561
  } else if (((_a2 = keyProps.found) == null ? void 0 : _a2.indent) !== bm.indent) {
22500
22562
  onError(offset, "BAD_INDENT", startColMsg);
22501
22563
  }
22564
+ ctx.atKey = true;
22502
22565
  const keyStart = keyProps.end;
22503
22566
  const keyNode = key ? composeNode2(ctx, key, keyProps, onError) : composeEmptyNode2(ctx, keyStart, start, null, keyProps, onError);
22504
22567
  if (ctx.schema.compat)
22505
22568
  flowIndentCheck(bm.indent, key, onError);
22569
+ ctx.atKey = false;
22506
22570
  if (mapIncludes(ctx, map2.items, keyNode))
22507
22571
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
22508
22572
  const valueProps = resolveProps(sep ?? [], {
@@ -22554,6 +22618,8 @@ ${pointer}
22554
22618
  const seq2 = new NodeClass(ctx.schema);
22555
22619
  if (ctx.atRoot)
22556
22620
  ctx.atRoot = false;
22621
+ if (ctx.atKey)
22622
+ ctx.atKey = false;
22557
22623
  let offset = bs.offset;
22558
22624
  let commentEnd = null;
22559
22625
  for (const { start, value } of bs.items) {
@@ -22633,6 +22699,8 @@ ${pointer}
22633
22699
  const atRoot = ctx.atRoot;
22634
22700
  if (atRoot)
22635
22701
  ctx.atRoot = false;
22702
+ if (ctx.atKey)
22703
+ ctx.atKey = false;
22636
22704
  let offset = fc.offset + fc.start.source.length;
22637
22705
  for (let i = 0; i < fc.items.length; ++i) {
22638
22706
  const collItem = fc.items[i];
@@ -22708,10 +22776,12 @@ ${pointer}
22708
22776
  if (isBlock(value))
22709
22777
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
22710
22778
  } else {
22779
+ ctx.atKey = true;
22711
22780
  const keyStart = props.end;
22712
22781
  const keyNode = key ? composeNode2(ctx, key, props, onError) : composeEmptyNode2(ctx, keyStart, start, null, props, onError);
22713
22782
  if (isBlock(key))
22714
22783
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
22784
+ ctx.atKey = false;
22715
22785
  const valueProps = resolveProps(sep ?? [], {
22716
22786
  flow: fcName,
22717
22787
  indicator: "map-value-ind",
@@ -22983,6 +23053,7 @@ ${pointer}
22983
23053
  switch (token.type) {
22984
23054
  case "space":
22985
23055
  hasSpace = true;
23056
+ // fallthrough
22986
23057
  case "newline":
22987
23058
  length += token.source.length;
22988
23059
  break;
@@ -22998,6 +23069,7 @@ ${pointer}
22998
23069
  onError(token, "UNEXPECTED_TOKEN", token.message);
22999
23070
  length += token.source.length;
23000
23071
  break;
23072
+ /* istanbul ignore next should not happen */
23001
23073
  default: {
23002
23074
  const message = `Unexpected token in block scalar header: ${token.type}`;
23003
23075
  onError(token, "UNEXPECTED_TOKEN", message);
@@ -23037,6 +23109,7 @@ ${pointer}
23037
23109
  _type = Scalar.QUOTE_DOUBLE;
23038
23110
  value = doubleQuotedValue(source, _onError);
23039
23111
  break;
23112
+ /* istanbul ignore next should not happen */
23040
23113
  default:
23041
23114
  onError(scalar, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`);
23042
23115
  return {
@@ -23058,6 +23131,7 @@ ${pointer}
23058
23131
  function plainValue(source, onError) {
23059
23132
  let badChar = "";
23060
23133
  switch (source[0]) {
23134
+ /* istanbul ignore next should not happen */
23061
23135
  case " ":
23062
23136
  badChar = "a tab character";
23063
23137
  break;
@@ -23229,7 +23303,15 @@ ${pointer}
23229
23303
  function composeScalar(ctx, token, tagToken, onError) {
23230
23304
  const { value, type, comment: comment2, range } = token.type === "block-scalar" ? resolveBlockScalar(ctx, token, onError) : resolveFlowScalar(token, ctx.options.strict, onError);
23231
23305
  const tagName = tagToken ? ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)) : null;
23232
- const tag = tagToken && tagName ? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError) : token.type === "scalar" ? findScalarTagByTest(ctx, value, token, onError) : ctx.schema[SCALAR$1];
23306
+ let tag;
23307
+ if (ctx.options.stringKeys && ctx.atKey) {
23308
+ tag = ctx.schema[SCALAR$1];
23309
+ } else if (tagName)
23310
+ tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
23311
+ else if (token.type === "scalar")
23312
+ tag = findScalarTagByTest(ctx, value, token, onError);
23313
+ else
23314
+ tag = ctx.schema[SCALAR$1];
23233
23315
  let scalar;
23234
23316
  try {
23235
23317
  const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
@@ -23275,10 +23357,10 @@ ${pointer}
23275
23357
  onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, tagName !== "tag:yaml.org,2002:str");
23276
23358
  return schema2[SCALAR$1];
23277
23359
  }
23278
- function findScalarTagByTest({ directives, schema: schema2 }, value, token, onError) {
23360
+ function findScalarTagByTest({ atKey, directives, schema: schema2 }, value, token, onError) {
23279
23361
  const tag = schema2.tags.find((tag2) => {
23280
23362
  var _a2;
23281
- return tag2.default && ((_a2 = tag2.test) == null ? void 0 : _a2.test(value));
23363
+ return (tag2.default === true || atKey && tag2.default === "key") && ((_a2 = tag2.test) == null ? void 0 : _a2.test(value));
23282
23364
  }) || schema2[SCALAR$1];
23283
23365
  if (schema2.compat) {
23284
23366
  const compat = schema2.compat.find((tag2) => {
@@ -23319,6 +23401,7 @@ ${pointer}
23319
23401
  }
23320
23402
  const CN = { composeNode, composeEmptyNode };
23321
23403
  function composeNode(ctx, token, props, onError) {
23404
+ const atKey = ctx.atKey;
23322
23405
  const { spaceBefore, comment: comment2, anchor, tag } = props;
23323
23406
  let node;
23324
23407
  let isSrcToken = true;
@@ -23352,6 +23435,10 @@ ${pointer}
23352
23435
  }
23353
23436
  if (anchor && node.anchor === "")
23354
23437
  onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string");
23438
+ if (atKey && ctx.options.stringKeys && (!isScalar(node) || typeof node.value !== "string" || node.tag && node.tag !== "tag:yaml.org,2002:str")) {
23439
+ const msg = "With stringKeys, all keys must be strings";
23440
+ onError(tag ?? token, "NON_STRING_KEY", msg);
23441
+ }
23355
23442
  if (spaceBefore)
23356
23443
  node.spaceBefore = true;
23357
23444
  if (comment2) {
@@ -23402,6 +23489,7 @@ ${pointer}
23402
23489
  const opts = Object.assign({ _directives: directives }, options);
23403
23490
  const doc = new Document(void 0, opts);
23404
23491
  const ctx = {
23492
+ atKey: false,
23405
23493
  atRoot: true,
23406
23494
  directives: doc.directives,
23407
23495
  options: doc.options,
@@ -23891,6 +23979,7 @@ ${end2.comment}` : end2.comment;
23891
23979
  switch (line[n]) {
23892
23980
  case "#":
23893
23981
  yield* this.pushCount(line.length - n);
23982
+ // fallthrough
23894
23983
  case void 0:
23895
23984
  yield* this.pushNewline();
23896
23985
  return yield* this.parseLineStart();
@@ -23986,6 +24075,7 @@ ${end2.comment}` : end2.comment;
23986
24075
  return "flow";
23987
24076
  }
23988
24077
  }
24078
+ // fallthrough
23989
24079
  default:
23990
24080
  this.flowKey = false;
23991
24081
  return yield* this.parsePlainScalar();
@@ -24063,6 +24153,7 @@ ${end2.comment}` : end2.comment;
24063
24153
  if (next2 === "\n")
24064
24154
  break;
24065
24155
  }
24156
+ // fallthrough
24066
24157
  default:
24067
24158
  break loop;
24068
24159
  }
@@ -24180,7 +24271,9 @@ ${end2.comment}` : end2.comment;
24180
24271
  case "&":
24181
24272
  return (yield* this.pushUntil(isNotAnchorChar)) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators());
24182
24273
  case "-":
24274
+ // this is an error
24183
24275
  case "?":
24276
+ // this is an error outside flow collections
24184
24277
  case ":": {
24185
24278
  const inFlow = this.flowLevel > 0;
24186
24279
  const ch1 = this.charAt(1);
@@ -24310,6 +24403,7 @@ ${end2.comment}` : end2.comment;
24310
24403
  }
24311
24404
  case "block-seq":
24312
24405
  return parent2.items[parent2.items.length - 1].start;
24406
+ /* istanbul ignore next should not happen */
24313
24407
  default:
24314
24408
  return [];
24315
24409
  }
@@ -24542,6 +24636,7 @@ ${end2.comment}` : end2.comment;
24542
24636
  Object.assign(it, { key: token, sep: [] });
24543
24637
  return;
24544
24638
  }
24639
+ /* istanbul ignore next should not happen */
24545
24640
  default:
24546
24641
  yield* this.pop();
24547
24642
  yield* this.pop(token);
@@ -24663,6 +24758,7 @@ ${end2.comment}` : end2.comment;
24663
24758
  }
24664
24759
  yield* this.pop();
24665
24760
  break;
24761
+ /* istanbul ignore next should not happen */
24666
24762
  default:
24667
24763
  yield* this.pop();
24668
24764
  yield* this.step();
@@ -25100,6 +25196,7 @@ ${end2.comment}` : end2.comment;
25100
25196
  break;
25101
25197
  case "newline":
25102
25198
  this.onKeyLine = false;
25199
+ // fallthrough
25103
25200
  case "space":
25104
25201
  case "comment":
25105
25202
  default:
@@ -25281,416 +25378,6 @@ ${end2.comment}` : end2.comment;
25281
25378
  };
25282
25379
  }
25283
25380
  });
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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
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
25381
  function addDefaultVersions(paths, name2, version) {
25695
25382
  return paths.map((path) => {
25696
25383
  if (typeof path === "string" && !path.includes("://")) {
@@ -25709,18 +25396,18 @@ ${end2.comment}` : end2.comment;
25709
25396
  }
25710
25397
  const name$2 = "katex";
25711
25398
  const preloadScripts = [
25712
- `katex@${"0.16.11"}/dist/katex.min.js`
25399
+ `katex@${"0.16.15"}/dist/katex.min.js`
25713
25400
  ].map((path) => buildJSItem(path));
25714
25401
  const webfontloader = buildJSItem(
25715
25402
  `webfontloader@${"1.6.28"}/webfontloader.js`
25716
25403
  );
25717
25404
  webfontloader.data.defer = true;
25718
- const styles = [`katex@${"0.16.11"}/dist/katex.min.css`].map(
25405
+ const styles = [`katex@${"0.16.15"}/dist/katex.min.css`].map(
25719
25406
  (path) => buildCSSItem(path)
25720
25407
  );
25721
25408
  const config = {
25722
25409
  versions: {
25723
- katex: "0.16.11",
25410
+ katex: "0.16.15",
25724
25411
  webfontloader: "1.6.28"
25725
25412
  },
25726
25413
  preloadScripts,
@@ -25760,6 +25447,432 @@ ${end2.comment}` : end2.comment;
25760
25447
  ],
25761
25448
  styles
25762
25449
  };
25450
+ var dist = {};
25451
+ var hasRequiredDist;
25452
+ function requireDist() {
25453
+ if (hasRequiredDist) return dist;
25454
+ hasRequiredDist = 1;
25455
+ var __importDefault = dist && dist.__importDefault || function(mod) {
25456
+ return mod && mod.__esModule ? mod : { "default": mod };
25457
+ };
25458
+ Object.defineProperty(dist, "__esModule", { value: true });
25459
+ const katex_1 = __importDefault(require$$0);
25460
+ function isValidInlineDelim(state, pos) {
25461
+ const prevChar = state.src[pos - 1];
25462
+ const char = state.src[pos];
25463
+ const nextChar = state.src[pos + 1];
25464
+ if (char !== "$") {
25465
+ return { can_open: false, can_close: false };
25466
+ }
25467
+ let canOpen = false;
25468
+ let canClose = false;
25469
+ if (prevChar !== "$" && prevChar !== "\\" && (prevChar === void 0 || isWhitespace2(prevChar) || !isWordCharacterOrNumber(prevChar))) {
25470
+ canOpen = true;
25471
+ }
25472
+ if (nextChar !== "$" && (nextChar == void 0 || isWhitespace2(nextChar) || !isWordCharacterOrNumber(nextChar))) {
25473
+ canClose = true;
25474
+ }
25475
+ return { can_open: canOpen, can_close: canClose };
25476
+ }
25477
+ function isWhitespace2(char) {
25478
+ return /^\s$/u.test(char);
25479
+ }
25480
+ function isWordCharacterOrNumber(char) {
25481
+ return /^[\w\d]$/u.test(char);
25482
+ }
25483
+ function isValidBlockDelim(state, pos) {
25484
+ const prevChar = state.src[pos - 1];
25485
+ const char = state.src[pos];
25486
+ const nextChar = state.src[pos + 1];
25487
+ const nextCharPlus1 = state.src[pos + 2];
25488
+ if (char === "$" && prevChar !== "$" && prevChar !== "\\" && nextChar === "$" && nextCharPlus1 !== "$") {
25489
+ return { can_open: true, can_close: true };
25490
+ }
25491
+ return { can_open: false, can_close: false };
25492
+ }
25493
+ function inlineMath(state, silent) {
25494
+ if (state.src[state.pos] !== "$") {
25495
+ return false;
25496
+ }
25497
+ const lastToken = state.tokens.at(-1);
25498
+ if ((lastToken == null ? void 0 : lastToken.type) === "html_inline") {
25499
+ if (/^<\w+.+[^/]>$/.test(lastToken.content)) {
25500
+ return false;
25501
+ }
25502
+ }
25503
+ let res = isValidInlineDelim(state, state.pos);
25504
+ if (!res.can_open) {
25505
+ if (!silent) {
25506
+ state.pending += "$";
25507
+ }
25508
+ state.pos += 1;
25509
+ return true;
25510
+ }
25511
+ let start = state.pos + 1;
25512
+ let match = start;
25513
+ let pos;
25514
+ while ((match = state.src.indexOf("$", match)) !== -1) {
25515
+ pos = match - 1;
25516
+ while (state.src[pos] === "\\") {
25517
+ pos -= 1;
25518
+ }
25519
+ if ((match - pos) % 2 == 1) {
25520
+ break;
25521
+ }
25522
+ match += 1;
25523
+ }
25524
+ if (match === -1) {
25525
+ if (!silent) {
25526
+ state.pending += "$";
25527
+ }
25528
+ state.pos = start;
25529
+ return true;
25530
+ }
25531
+ if (match - start === 0) {
25532
+ if (!silent) {
25533
+ state.pending += "$$";
25534
+ }
25535
+ state.pos = start + 1;
25536
+ return true;
25537
+ }
25538
+ res = isValidInlineDelim(state, match);
25539
+ if (!res.can_close) {
25540
+ if (!silent) {
25541
+ state.pending += "$";
25542
+ }
25543
+ state.pos = start;
25544
+ return true;
25545
+ }
25546
+ if (!silent) {
25547
+ const token = state.push("math_inline", "math", 0);
25548
+ token.markup = "$";
25549
+ token.content = state.src.slice(start, match);
25550
+ }
25551
+ state.pos = match + 1;
25552
+ return true;
25553
+ }
25554
+ function blockMath(state, start, end2, silent) {
25555
+ var lastLine, next2, lastPos, found = false, token, pos = state.bMarks[start] + state.tShift[start], max = state.eMarks[start];
25556
+ if (pos + 2 > max) {
25557
+ return false;
25558
+ }
25559
+ if (state.src.slice(pos, pos + 2) !== "$$") {
25560
+ return false;
25561
+ }
25562
+ pos += 2;
25563
+ let firstLine = state.src.slice(pos, max);
25564
+ if (silent) {
25565
+ return true;
25566
+ }
25567
+ if (firstLine.trim().slice(-2) === "$$") {
25568
+ firstLine = firstLine.trim().slice(0, -2);
25569
+ found = true;
25570
+ }
25571
+ for (next2 = start; !found; ) {
25572
+ next2++;
25573
+ if (next2 >= end2) {
25574
+ break;
25575
+ }
25576
+ pos = state.bMarks[next2] + state.tShift[next2];
25577
+ max = state.eMarks[next2];
25578
+ if (pos < max && state.tShift[next2] < state.blkIndent) {
25579
+ break;
25580
+ }
25581
+ if (state.src.slice(pos, max).trim().slice(-2) === "$$") {
25582
+ lastPos = state.src.slice(0, max).lastIndexOf("$$");
25583
+ lastLine = state.src.slice(pos, lastPos);
25584
+ found = true;
25585
+ } else if (state.src.slice(pos, max).trim().includes("$$")) {
25586
+ lastPos = state.src.slice(0, max).trim().indexOf("$$");
25587
+ lastLine = state.src.slice(pos, lastPos);
25588
+ found = true;
25589
+ }
25590
+ }
25591
+ state.line = next2 + 1;
25592
+ token = state.push("math_block", "math", 0);
25593
+ token.block = true;
25594
+ token.content = (firstLine && firstLine.trim() ? firstLine + "\n" : "") + state.getLines(start + 1, next2, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
25595
+ token.map = [start, state.line];
25596
+ token.markup = "$$";
25597
+ return true;
25598
+ }
25599
+ function blockBareMath(state, start, end2, silent) {
25600
+ const startPos = state.bMarks[start] + state.tShift[start];
25601
+ const startMax = state.eMarks[start];
25602
+ const firstLine = state.src.slice(startPos, startMax);
25603
+ const beginMatch = firstLine.match(/^\s*\\begin\s*\{([^{}]+)\}/);
25604
+ if (!beginMatch) {
25605
+ return false;
25606
+ }
25607
+ if (start > 0) {
25608
+ const previousStart = state.bMarks[start - 1] + state.tShift[start - 1];
25609
+ const previousEnd = state.eMarks[start - 1];
25610
+ const previousLine = state.src.slice(previousStart, previousEnd);
25611
+ if (!/^\s*$/.test(previousLine)) {
25612
+ return false;
25613
+ }
25614
+ }
25615
+ if (silent) {
25616
+ return true;
25617
+ }
25618
+ const beginEndStack = [];
25619
+ let next2 = start;
25620
+ let lastLine;
25621
+ let found = false;
25622
+ outer: for (; !found; next2++) {
25623
+ if (next2 >= end2) {
25624
+ break;
25625
+ }
25626
+ const pos = state.bMarks[next2] + state.tShift[next2];
25627
+ const max = state.eMarks[next2];
25628
+ if (pos < max && state.tShift[next2] < state.blkIndent) {
25629
+ break;
25630
+ }
25631
+ const line = state.src.slice(pos, max);
25632
+ for (const match of line.matchAll(/(\\begin|\\end)\s*\{([^{}]+)\}/g)) {
25633
+ if (match[1] === "\\begin") {
25634
+ beginEndStack.push(match[2].trim());
25635
+ } else if (match[1] === "\\end") {
25636
+ beginEndStack.pop();
25637
+ if (!beginEndStack.length) {
25638
+ lastLine = state.src.slice(pos, max);
25639
+ found = true;
25640
+ break outer;
25641
+ }
25642
+ }
25643
+ }
25644
+ }
25645
+ state.line = next2 + 1;
25646
+ const token = state.push("math_block", "math", 0);
25647
+ token.block = true;
25648
+ token.content = (state.getLines(start, next2, state.tShift[start], true) + (lastLine ?? "")).trim();
25649
+ token.map = [start, state.line];
25650
+ token.markup = "$$";
25651
+ return true;
25652
+ }
25653
+ function inlineMathBlock(state, silent) {
25654
+ var start, match, token, res, pos;
25655
+ if (state.src.slice(state.pos, state.pos + 2) !== "$$") {
25656
+ return false;
25657
+ }
25658
+ res = isValidBlockDelim(state, state.pos);
25659
+ if (!res.can_open) {
25660
+ if (!silent) {
25661
+ state.pending += "$$";
25662
+ }
25663
+ state.pos += 2;
25664
+ return true;
25665
+ }
25666
+ start = state.pos + 2;
25667
+ match = start;
25668
+ while ((match = state.src.indexOf("$$", match)) !== -1) {
25669
+ pos = match - 1;
25670
+ while (state.src[pos] === "\\") {
25671
+ pos -= 1;
25672
+ }
25673
+ if ((match - pos) % 2 == 1) {
25674
+ break;
25675
+ }
25676
+ match += 2;
25677
+ }
25678
+ if (match === -1) {
25679
+ if (!silent) {
25680
+ state.pending += "$$";
25681
+ }
25682
+ state.pos = start;
25683
+ return true;
25684
+ }
25685
+ if (match - start === 0) {
25686
+ if (!silent) {
25687
+ state.pending += "$$$$";
25688
+ }
25689
+ state.pos = start + 2;
25690
+ return true;
25691
+ }
25692
+ res = isValidBlockDelim(state, match);
25693
+ if (!res.can_close) {
25694
+ if (!silent) {
25695
+ state.pending += "$$";
25696
+ }
25697
+ state.pos = start;
25698
+ return true;
25699
+ }
25700
+ if (!silent) {
25701
+ token = state.push("math_block", "math", 0);
25702
+ token.block = true;
25703
+ token.markup = "$$";
25704
+ token.content = state.src.slice(start, match);
25705
+ }
25706
+ state.pos = match + 2;
25707
+ return true;
25708
+ }
25709
+ function inlineBareBlock(state, silent) {
25710
+ const text2 = state.src.slice(state.pos);
25711
+ if (!/^\n\\begin/.test(text2)) {
25712
+ return false;
25713
+ }
25714
+ state.pos += 1;
25715
+ if (silent) {
25716
+ return true;
25717
+ }
25718
+ const lines = text2.split(/\n/g).slice(1);
25719
+ let foundLine;
25720
+ const beginEndStack = [];
25721
+ outer: for (var i = 0; i < lines.length; ++i) {
25722
+ const line = lines[i];
25723
+ for (const match of line.matchAll(/(\\begin|\\end)\s*\{([^{}]+)\}/g)) {
25724
+ if (match[1] === "\\begin") {
25725
+ beginEndStack.push(match[2].trim());
25726
+ } else if (match[1] === "\\end") {
25727
+ beginEndStack.pop();
25728
+ if (!beginEndStack.length) {
25729
+ foundLine = i;
25730
+ break outer;
25731
+ }
25732
+ }
25733
+ }
25734
+ }
25735
+ if (typeof foundLine === "undefined") {
25736
+ return false;
25737
+ }
25738
+ const endIndex = lines.slice(0, foundLine + 1).reduce((p, c) => p + c.length, 0) + foundLine + 1;
25739
+ const token = state.push("math_inline_bare_block", "math", 0);
25740
+ token.block = true;
25741
+ token.markup = "$$";
25742
+ token.content = text2.slice(1, endIndex);
25743
+ state.pos = state.pos + endIndex;
25744
+ return true;
25745
+ }
25746
+ function handleMathInHtml(state, mathType, mathMarkup, mathRegex) {
25747
+ const tokens = state.tokens;
25748
+ for (let index2 = tokens.length - 1; index2 >= 0; index2--) {
25749
+ const currentToken = tokens[index2];
25750
+ const newTokens = [];
25751
+ if (currentToken.type !== "html_block") {
25752
+ continue;
25753
+ }
25754
+ const content = currentToken.content;
25755
+ for (const match of content.matchAll(mathRegex)) {
25756
+ if (!match.groups) {
25757
+ continue;
25758
+ }
25759
+ const html_before_math = match.groups.html_before_math;
25760
+ const math = match.groups.math;
25761
+ const html_after_math = match.groups.html_after_math;
25762
+ if (html_before_math) {
25763
+ newTokens.push({ ...currentToken, type: "html_block", map: null, content: html_before_math });
25764
+ }
25765
+ if (math) {
25766
+ newTokens.push({
25767
+ ...currentToken,
25768
+ type: mathType,
25769
+ map: null,
25770
+ content: math,
25771
+ markup: mathMarkup,
25772
+ block: true,
25773
+ tag: "math"
25774
+ });
25775
+ }
25776
+ if (html_after_math) {
25777
+ newTokens.push({ ...currentToken, type: "html_block", map: null, content: html_after_math });
25778
+ }
25779
+ }
25780
+ if (newTokens.length > 0) {
25781
+ tokens.splice(index2, 1, ...newTokens);
25782
+ }
25783
+ }
25784
+ return true;
25785
+ }
25786
+ function escapeHtml2(unsafe) {
25787
+ return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
25788
+ }
25789
+ function default_1(md, options) {
25790
+ const katex = (options == null ? void 0 : options.katex) ?? katex_1.default;
25791
+ const enableBareBlocks = options == null ? void 0 : options.enableBareBlocks;
25792
+ const enableMathBlockInHtml = options == null ? void 0 : options.enableMathBlockInHtml;
25793
+ const enableMathInlineInHtml = options == null ? void 0 : options.enableMathInlineInHtml;
25794
+ const enableFencedBlocks = options == null ? void 0 : options.enableFencedBlocks;
25795
+ md.inline.ruler.after("escape", "math_inline", inlineMath);
25796
+ md.inline.ruler.after("escape", "math_inline_block", inlineMathBlock);
25797
+ if (enableBareBlocks) {
25798
+ md.inline.ruler.before("text", "math_inline_bare_block", inlineBareBlock);
25799
+ }
25800
+ md.block.ruler.after("blockquote", "math_block", (state, start, end2, silent) => {
25801
+ if (enableBareBlocks && blockBareMath(state, start, end2, silent)) {
25802
+ return true;
25803
+ }
25804
+ return blockMath(state, start, end2, silent);
25805
+ }, {
25806
+ alt: ["paragraph", "reference", "blockquote", "list"]
25807
+ });
25808
+ const math_block_within_html_regex = /(?<html_before_math>[\s\S]*?)\$\$(?<math>[\s\S]+?)\$\$(?<html_after_math>(?:(?!\$\$[\s\S]+?\$\$)[\s\S])*)/gm;
25809
+ const math_inline_within_html_regex = /(?<html_before_math>[\s\S]*?)\$(?<math>.*?)\$(?<html_after_math>(?:(?!\$.*?\$)[\s\S])*)/gm;
25810
+ if (enableMathBlockInHtml) {
25811
+ md.core.ruler.push("math_block_in_html_block", (state) => {
25812
+ return handleMathInHtml(state, "math_block", "$$", math_block_within_html_regex);
25813
+ });
25814
+ }
25815
+ if (enableMathInlineInHtml) {
25816
+ md.core.ruler.push("math_inline_in_html_block", (state) => {
25817
+ return handleMathInHtml(state, "math_inline", "$", math_inline_within_html_regex);
25818
+ });
25819
+ }
25820
+ const katexInline = (latex) => {
25821
+ const displayMode = /\\begin\{(align|equation|gather|cd|alignat)\}/ig.test(latex);
25822
+ try {
25823
+ return katex.renderToString(latex, { ...options, displayMode });
25824
+ } catch (error2) {
25825
+ if (options == null ? void 0 : options.throwOnError) {
25826
+ console.log(error2);
25827
+ }
25828
+ return `<span class="katex-error" title="${escapeHtml2(latex)}">${escapeHtml2(error2 + "")}</span>`;
25829
+ }
25830
+ };
25831
+ const inlineRenderer = (tokens, idx) => {
25832
+ const content = tokens[idx].content;
25833
+ const hasBacktick = content.length > 2 && content[0] === "`" && content[content.length - 1] === "`";
25834
+ const sanitized = hasBacktick ? content.slice(1, -1) : content;
25835
+ return katexInline(sanitized);
25836
+ };
25837
+ const katexBlockRenderer = (latex) => {
25838
+ try {
25839
+ return `<p class="katex-block">${katex.renderToString(latex, { ...options, displayMode: true })}</p>`;
25840
+ } catch (error2) {
25841
+ if (options == null ? void 0 : options.throwOnError) {
25842
+ console.log(error2);
25843
+ }
25844
+ return `<p class="katex-block katex-error" title="${escapeHtml2(latex)}">${escapeHtml2(error2 + "")}</p>`;
25845
+ }
25846
+ };
25847
+ const blockRenderer = (tokens, idx) => {
25848
+ return katexBlockRenderer(tokens[idx].content) + "\n";
25849
+ };
25850
+ md.renderer.rules.math_inline = inlineRenderer;
25851
+ md.renderer.rules.math_inline_block = blockRenderer;
25852
+ md.renderer.rules.math_inline_bare_block = blockRenderer;
25853
+ md.renderer.rules.math_block = blockRenderer;
25854
+ if (enableFencedBlocks) {
25855
+ const mathLanguageId = "math";
25856
+ const originalFenceRenderer = md.renderer.rules.fence;
25857
+ md.renderer.rules.fence = function(tokens, idx, options2, env, self) {
25858
+ const token = tokens[idx];
25859
+ if (token.info.trim().toLowerCase() === mathLanguageId && enableFencedBlocks) {
25860
+ return katexBlockRenderer(token.content) + "\n";
25861
+ } else {
25862
+ return (originalFenceRenderer == null ? void 0 : originalFenceRenderer.call(this, tokens, idx, options2, env, self)) || "";
25863
+ }
25864
+ };
25865
+ }
25866
+ }
25867
+ dist.default = default_1;
25868
+ return dist;
25869
+ }
25870
+ var distExports = requireDist();
25871
+ const katexPluginModule = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
25872
+ function interop(mod) {
25873
+ return mod.default || mod;
25874
+ }
25875
+ const katexPlugin = interop(katexPluginModule);
25763
25876
  const plugin$1 = definePlugin({
25764
25877
  name: name$2,
25765
25878
  config,
@@ -25788,7 +25901,7 @@ ${end2.comment}` : end2.comment;
25788
25901
  };
25789
25902
  let enableFeature = noop;
25790
25903
  transformHooks.parser.tap((md) => {
25791
- md.use(_default);
25904
+ md.use(katexPlugin);
25792
25905
  ["math_block", "math_inline"].forEach((key) => {
25793
25906
  const fn = (tokens, idx) => {
25794
25907
  enableFeature();
@@ -25954,7 +26067,7 @@ ${end2.comment}` : end2.comment;
25954
26067
  }
25955
26068
  }
25956
26069
  const transformerVersions = {
25957
- "markmap-lib": "0.17.3-beta.3"
26070
+ "markmap-lib": "0.18.0"
25958
26071
  };
25959
26072
  exports.Transformer = Transformer;
25960
26073
  exports.builtInPlugins = builtInPlugins;