securemark 0.257.3 → 0.258.2

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.
Files changed (86) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.js +1235 -615
  3. package/markdown.d.ts +1 -12
  4. package/package.json +9 -9
  5. package/src/combinator/control/manipulation/convert.ts +10 -6
  6. package/src/combinator/control/manipulation/scope.ts +10 -2
  7. package/src/combinator/data/parser/context/delimiter.ts +70 -0
  8. package/src/combinator/data/parser/context/memo.ts +36 -0
  9. package/src/combinator/{control/manipulation → data/parser}/context.test.ts +9 -9
  10. package/src/combinator/data/parser/context.ts +158 -0
  11. package/src/combinator/data/parser/inits.ts +3 -2
  12. package/src/combinator/data/parser/sequence.test.ts +1 -1
  13. package/src/combinator/data/parser/sequence.ts +4 -3
  14. package/src/combinator/data/parser/some.test.ts +1 -1
  15. package/src/combinator/data/parser/some.ts +14 -37
  16. package/src/combinator/data/parser/subsequence.test.ts +1 -1
  17. package/src/combinator/data/parser/subsequence.ts +3 -3
  18. package/src/combinator/data/parser/tails.ts +3 -3
  19. package/src/combinator/data/parser/union.test.ts +1 -1
  20. package/src/combinator/data/parser.ts +6 -47
  21. package/src/combinator.ts +1 -2
  22. package/src/parser/api/bind.ts +5 -5
  23. package/src/parser/api/parse.test.ts +11 -8
  24. package/src/parser/api/parse.ts +3 -1
  25. package/src/parser/block/blockquote.ts +1 -1
  26. package/src/parser/block/dlist.ts +4 -10
  27. package/src/parser/block/extension/figure.ts +4 -3
  28. package/src/parser/block/extension/table.ts +2 -2
  29. package/src/parser/block/heading.ts +5 -13
  30. package/src/parser/block/ilist.ts +3 -2
  31. package/src/parser/block/olist.ts +10 -7
  32. package/src/parser/block/paragraph.ts +1 -1
  33. package/src/parser/block/reply/cite.ts +1 -1
  34. package/src/parser/block/reply/quote.ts +1 -1
  35. package/src/parser/block/reply.ts +1 -1
  36. package/src/parser/block/sidefence.ts +1 -1
  37. package/src/parser/block/table.ts +9 -9
  38. package/src/parser/block/ulist.ts +4 -3
  39. package/src/parser/block.ts +1 -1
  40. package/src/parser/context.ts +32 -0
  41. package/src/parser/header.ts +1 -1
  42. package/src/parser/inline/annotation.test.ts +5 -5
  43. package/src/parser/inline/annotation.ts +9 -17
  44. package/src/parser/inline/autolink/email.ts +1 -1
  45. package/src/parser/inline/autolink/url.ts +1 -1
  46. package/src/parser/inline/autolink.ts +5 -3
  47. package/src/parser/inline/bracket.ts +11 -10
  48. package/src/parser/inline/code.ts +1 -1
  49. package/src/parser/inline/comment.ts +4 -3
  50. package/src/parser/inline/deletion.ts +5 -4
  51. package/src/parser/inline/emphasis.ts +5 -4
  52. package/src/parser/inline/emstrong.ts +5 -4
  53. package/src/parser/inline/extension/index.ts +7 -14
  54. package/src/parser/inline/extension/indexee.ts +8 -10
  55. package/src/parser/inline/extension/indexer.ts +4 -3
  56. package/src/parser/inline/extension/label.ts +3 -2
  57. package/src/parser/inline/extension/placeholder.ts +5 -4
  58. package/src/parser/inline/html.ts +5 -4
  59. package/src/parser/inline/htmlentity.ts +1 -1
  60. package/src/parser/inline/insertion.ts +5 -4
  61. package/src/parser/inline/link.test.ts +2 -1
  62. package/src/parser/inline/link.ts +27 -29
  63. package/src/parser/inline/mark.ts +5 -4
  64. package/src/parser/inline/math.ts +1 -1
  65. package/src/parser/inline/media.test.ts +1 -0
  66. package/src/parser/inline/media.ts +8 -7
  67. package/src/parser/inline/reference.test.ts +5 -5
  68. package/src/parser/inline/reference.ts +10 -16
  69. package/src/parser/inline/ruby.test.ts +1 -0
  70. package/src/parser/inline/ruby.ts +4 -3
  71. package/src/parser/inline/shortmedia.ts +3 -2
  72. package/src/parser/inline/strong.ts +5 -4
  73. package/src/parser/inline/template.test.ts +1 -1
  74. package/src/parser/inline/template.ts +9 -6
  75. package/src/parser/inline.test.ts +2 -1
  76. package/src/parser/locale.ts +6 -7
  77. package/src/parser/processor/footnote.ts +5 -3
  78. package/src/parser/source/text.ts +1 -1
  79. package/src/parser/util.ts +0 -220
  80. package/src/parser/visibility.ts +205 -0
  81. package/src/util/info.ts +4 -2
  82. package/src/util/quote.ts +12 -15
  83. package/src/util/toc.ts +14 -17
  84. package/webpack.config.js +1 -0
  85. package/src/combinator/control/manipulation/context.ts +0 -70
  86. package/src/combinator/control/manipulation/resource.ts +0 -54
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.257.3 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.258.2 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("DOMPurify"), require("Prism"));
@@ -882,6 +882,157 @@ exports.MultiMap = MultiMap;
882
882
 
883
883
  /***/ }),
884
884
 
885
+ /***/ 8099:
886
+ /***/ ((__unused_webpack_module, exports) => {
887
+
888
+ "use strict";
889
+
890
+
891
+ Object.defineProperty(exports, "__esModule", ({
892
+ value: true
893
+ }));
894
+ exports.duffReduce = exports.duffEach = exports.duffbk = exports.duff = void 0;
895
+
896
+ function duff(count, proc) {
897
+ if (count > 0) {
898
+ let i = 0,
899
+ m = count % 8,
900
+ d = (count - m) / 8;
901
+
902
+ while (m--) {
903
+ proc(i++);
904
+ }
905
+
906
+ while (d--) {
907
+ proc(i++);
908
+ proc(i++);
909
+ proc(i++);
910
+ proc(i++);
911
+ proc(i++);
912
+ proc(i++);
913
+ proc(i++);
914
+ proc(i++);
915
+ }
916
+ } else {
917
+ let i = -count,
918
+ m = i % 8,
919
+ d = (i - m) / 8;
920
+
921
+ while (m--) {
922
+ proc(--i);
923
+ }
924
+
925
+ while (d--) {
926
+ proc(--i);
927
+ proc(--i);
928
+ proc(--i);
929
+ proc(--i);
930
+ proc(--i);
931
+ proc(--i);
932
+ proc(--i);
933
+ proc(--i);
934
+ }
935
+ }
936
+ }
937
+
938
+ exports.duff = duff;
939
+
940
+ function duffbk(count, proc) {
941
+ if (count > 0) {
942
+ let i = 0,
943
+ m = count % 8,
944
+ d = (count - m) / 8;
945
+
946
+ while (m--) {
947
+ if (proc(i++) === false) return;
948
+ }
949
+
950
+ while (d--) {
951
+ if (proc(i++) === false) return;
952
+ if (proc(i++) === false) return;
953
+ if (proc(i++) === false) return;
954
+ if (proc(i++) === false) return;
955
+ if (proc(i++) === false) return;
956
+ if (proc(i++) === false) return;
957
+ if (proc(i++) === false) return;
958
+ if (proc(i++) === false) return;
959
+ }
960
+ } else {
961
+ let i = -count,
962
+ m = i % 8,
963
+ d = (i - m) / 8;
964
+
965
+ while (m--) {
966
+ if (proc(--i) === false) return;
967
+ }
968
+
969
+ while (d--) {
970
+ if (proc(--i) === false) return;
971
+ if (proc(--i) === false) return;
972
+ if (proc(--i) === false) return;
973
+ if (proc(--i) === false) return;
974
+ if (proc(--i) === false) return;
975
+ if (proc(--i) === false) return;
976
+ if (proc(--i) === false) return;
977
+ if (proc(--i) === false) return;
978
+ }
979
+ }
980
+ }
981
+
982
+ exports.duffbk = duffbk;
983
+
984
+ function duffEach(array, proc) {
985
+ let count = array.length;
986
+ let i = 0,
987
+ m = count % 8,
988
+ d = (count - m) / 8;
989
+
990
+ while (m--) {
991
+ proc(array[i], i++, array);
992
+ }
993
+
994
+ while (d--) {
995
+ proc(array[i], i++, array);
996
+ proc(array[i], i++, array);
997
+ proc(array[i], i++, array);
998
+ proc(array[i], i++, array);
999
+ proc(array[i], i++, array);
1000
+ proc(array[i], i++, array);
1001
+ proc(array[i], i++, array);
1002
+ proc(array[i], i++, array);
1003
+ }
1004
+ }
1005
+
1006
+ exports.duffEach = duffEach;
1007
+
1008
+ function duffReduce(array, proc, initial) {
1009
+ let count = array.length;
1010
+ let i = 0,
1011
+ m = count % 8,
1012
+ d = (count - m) / 8;
1013
+
1014
+ while (m--) {
1015
+ initial = proc(initial, array[i], i++, array);
1016
+ }
1017
+
1018
+ while (d--) {
1019
+ initial = proc(initial, array[i], i++, array);
1020
+ initial = proc(initial, array[i], i++, array);
1021
+ initial = proc(initial, array[i], i++, array);
1022
+ initial = proc(initial, array[i], i++, array);
1023
+ initial = proc(initial, array[i], i++, array);
1024
+ initial = proc(initial, array[i], i++, array);
1025
+ initial = proc(initial, array[i], i++, array);
1026
+ initial = proc(initial, array[i], i++, array);
1027
+ }
1028
+
1029
+ return initial;
1030
+ }
1031
+
1032
+ exports.duffReduce = duffReduce;
1033
+
1034
+ /***/ }),
1035
+
885
1036
  /***/ 7822:
886
1037
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
887
1038
 
@@ -1920,6 +2071,8 @@ __exportStar(__webpack_require__(7005), exports);
1920
2071
 
1921
2072
  __exportStar(__webpack_require__(5418), exports);
1922
2073
 
2074
+ __exportStar(__webpack_require__(5684), exports);
2075
+
1923
2076
  __exportStar(__webpack_require__(2804), exports);
1924
2077
 
1925
2078
  __exportStar(__webpack_require__(9315), exports);
@@ -1932,10 +2085,6 @@ __exportStar(__webpack_require__(9758), exports);
1932
2085
 
1933
2086
  __exportStar(__webpack_require__(1411), exports);
1934
2087
 
1935
- __exportStar(__webpack_require__(8059), exports);
1936
-
1937
- __exportStar(__webpack_require__(1325), exports);
1938
-
1939
2088
  __exportStar(__webpack_require__(7130), exports);
1940
2089
 
1941
2090
  __exportStar(__webpack_require__(8927), exports);
@@ -2090,87 +2239,8 @@ exports.isEmpty = isEmpty;
2090
2239
 
2091
2240
  /***/ }),
2092
2241
 
2093
- /***/ 8059:
2094
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2095
-
2096
- "use strict";
2097
-
2098
-
2099
- Object.defineProperty(exports, "__esModule", ({
2100
- value: true
2101
- }));
2102
- exports.precedence = exports.context = exports.reset = exports.guard = void 0;
2103
-
2104
- const global_1 = __webpack_require__(4128);
2105
-
2106
- const alias_1 = __webpack_require__(5406);
2107
-
2108
- const assign_1 = __webpack_require__(4401);
2109
-
2110
- const type_1 = __webpack_require__(5177);
2111
-
2112
- const memoize_1 = __webpack_require__(1808);
2113
-
2114
- function guard(f, parser) {
2115
- return (source, context) => f(context) ? parser(source, context) : global_1.undefined;
2116
- }
2117
-
2118
- exports.guard = guard;
2119
-
2120
- function reset(base, parser) {
2121
- return (source, context) => parser(source, inherit((0, alias_1.ObjectCreate)(context), base));
2122
- }
2123
-
2124
- exports.reset = reset;
2125
-
2126
- function context(base, parser) {
2127
- const override = (0, memoize_1.memoize)(context => inherit((0, alias_1.ObjectCreate)(context), base), new global_1.WeakMap());
2128
- return (source, context) => parser(source, override(context));
2129
- }
2130
-
2131
- exports.context = context;
2132
- const inherit = (0, assign_1.template)((prop, target, source) => {
2133
- //assert(Object.freeze(source));
2134
- if (target[prop] === source[prop]) return;
2135
-
2136
- switch (prop) {
2137
- case 'resources':
2138
- if (prop in target && !(0, alias_1.hasOwnProperty)(target, prop)) return;
2139
- return target[prop] = (0, alias_1.ObjectCreate)(source[prop]);
2140
- }
2141
-
2142
- switch ((0, type_1.type)(source[prop])) {
2143
- case 'Object':
2144
- //assert(Object.freeze(source[prop]));
2145
- switch ((0, type_1.type)(target[prop])) {
2146
- case 'Object':
2147
- return target[prop] = inherit((0, alias_1.ObjectCreate)(target[prop]), source[prop]);
2148
-
2149
- default:
2150
- return target[prop] = source[prop];
2151
- }
2152
-
2153
- default:
2154
- return target[prop] = source[prop];
2155
- }
2156
- });
2157
-
2158
- function precedence(precedence, parser) {
2159
- return (source, context) => {
2160
- const p = context.precedence;
2161
- context.precedence = precedence;
2162
- const result = parser(source, context);
2163
- context.precedence = p;
2164
- return result;
2165
- };
2166
- }
2167
-
2168
- exports.precedence = precedence;
2169
-
2170
- /***/ }),
2171
-
2172
2242
  /***/ 7957:
2173
- /***/ ((__unused_webpack_module, exports) => {
2243
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2174
2244
 
2175
2245
  "use strict";
2176
2246
 
@@ -2180,11 +2250,18 @@ Object.defineProperty(exports, "__esModule", ({
2180
2250
  }));
2181
2251
  exports.convert = void 0;
2182
2252
 
2253
+ const parser_1 = __webpack_require__(6728);
2254
+
2183
2255
  function convert(conv, parser) {
2184
- return (source, context) => {
2256
+ return (source, context = {}) => {
2185
2257
  if (source === '') return;
2186
- source = conv(source);
2187
- return source === '' ? [[], ''] : parser(source, context);
2258
+ const src = conv(source);
2259
+ if (src === '') return [[], ''];
2260
+ const memo = context.memo;
2261
+ memo && (memo.offset += source.length - src.length);
2262
+ const result = parser(src, context);
2263
+ memo && (memo.offset -= source.length - src.length);
2264
+ return result;
2188
2265
  };
2189
2266
  }
2190
2267
 
@@ -2423,87 +2500,6 @@ exports.recover = recover;
2423
2500
 
2424
2501
  /***/ }),
2425
2502
 
2426
- /***/ 1325:
2427
- /***/ ((__unused_webpack_module, exports) => {
2428
-
2429
- "use strict";
2430
-
2431
-
2432
- Object.defineProperty(exports, "__esModule", ({
2433
- value: true
2434
- }));
2435
- exports.recursion = exports.uncreator = exports.creator = void 0;
2436
-
2437
- function creator(cost, parser) {
2438
- if (typeof cost === 'function') return creator(1, cost);
2439
- return (source, context) => {
2440
- const {
2441
- resources = {
2442
- budget: 1,
2443
- recursion: 1
2444
- }
2445
- } = context;
2446
- if (resources.budget <= 0) throw new Error('Too many creations');
2447
- if (resources.recursion <= 0) throw new Error('Too much recursion');
2448
- --resources.recursion;
2449
- const result = parser(source, context);
2450
- ++resources.recursion;
2451
-
2452
- if (result) {
2453
- resources.budget -= cost;
2454
- }
2455
-
2456
- return result;
2457
- };
2458
- }
2459
-
2460
- exports.creator = creator;
2461
-
2462
- function uncreator(cost, parser) {
2463
- if (typeof cost === 'function') return uncreator(1, cost);
2464
- return (source, context) => {
2465
- const {
2466
- resources = {
2467
- budget: 1,
2468
- recursion: 1
2469
- }
2470
- } = context;
2471
- if (resources.budget <= 0) throw new Error('Too many creations');
2472
- if (resources.recursion <= 0) throw new Error('Too much recursion');
2473
- ++resources.recursion;
2474
- const result = parser(source, context);
2475
- --resources.recursion;
2476
-
2477
- if (result) {
2478
- resources.budget += cost;
2479
- }
2480
-
2481
- return result;
2482
- };
2483
- }
2484
-
2485
- exports.uncreator = uncreator;
2486
-
2487
- function recursion(cost, parser) {
2488
- if (typeof cost === 'function') return recursion(1, cost);
2489
- return (source, context) => {
2490
- const {
2491
- resources = {
2492
- recursion: 1
2493
- }
2494
- } = context;
2495
- if (resources.recursion <= 0) throw new Error('Too much recursion');
2496
- --resources.recursion;
2497
- const result = parser(source, context);
2498
- ++resources.recursion;
2499
- return result;
2500
- };
2501
- }
2502
-
2503
- exports.recursion = recursion;
2504
-
2505
- /***/ }),
2506
-
2507
2503
  /***/ 1109:
2508
2504
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2509
2505
 
@@ -2542,11 +2538,14 @@ const parser_1 = __webpack_require__(6728);
2542
2538
 
2543
2539
  function focus(scope, parser) {
2544
2540
  const match = typeof scope === 'string' ? source => source.slice(0, scope.length) === scope ? scope : '' : source => source.match(scope)?.[0] ?? '';
2545
- return (source, context) => {
2541
+ return (source, context = {}) => {
2546
2542
  if (source === '') return;
2547
2543
  const src = match(source);
2548
2544
  if (src === '') return;
2545
+ const memo = context.memo;
2546
+ memo && (memo.offset += source.length - src.length);
2549
2547
  const result = parser(src, context);
2548
+ memo && (memo.offset -= source.length - src.length);
2550
2549
  if (!result) return;
2551
2550
  return (0, parser_1.exec)(result).length < src.length ? [(0, parser_1.eval)(result), (0, parser_1.exec)(result) + source.slice(src.length)] : global_1.undefined;
2552
2551
  };
@@ -2555,12 +2554,17 @@ function focus(scope, parser) {
2555
2554
  exports.focus = focus;
2556
2555
 
2557
2556
  function rewrite(scope, parser) {
2558
- return (source, context) => {
2557
+ return (source, context = {}) => {
2559
2558
  if (source === '') return;
2559
+ const memo = context.memo;
2560
+ context.memo = global_1.undefined;
2560
2561
  const res1 = scope(source, context);
2562
+ context.memo = memo;
2561
2563
  if (!res1 || (0, parser_1.exec)(res1).length >= source.length) return;
2562
2564
  const src = source.slice(0, source.length - (0, parser_1.exec)(res1).length);
2565
+ memo && (memo.offset += source.length - src.length);
2563
2566
  const res2 = parser(src, context);
2567
+ memo && (memo.offset -= source.length - src.length);
2564
2568
  if (!res2) return;
2565
2569
  return (0, parser_1.exec)(res2).length < src.length ? [(0, parser_1.eval)(res2), (0, parser_1.exec)(res2) + (0, parser_1.exec)(res1)] : global_1.undefined;
2566
2570
  };
@@ -2748,81 +2752,347 @@ exports.fmap = fmap;
2748
2752
  Object.defineProperty(exports, "__esModule", ({
2749
2753
  value: true
2750
2754
  }));
2751
- exports.check = exports.exec = exports.eval = exports.Delimiters = void 0;
2755
+ exports.check = exports.exec = exports.eval = void 0;
2752
2756
 
2753
- class Delimiters {
2754
- constructor() {
2755
- this.matchers = [];
2756
- this.registry = {};
2757
- this.length = 0;
2758
- }
2757
+ function eval_(result, default_) {
2758
+ return result ? result[0] : default_;
2759
+ }
2759
2760
 
2760
- push(...delimiters) {
2761
- for (let i = 0; i < delimiters.length; ++i) {
2762
- const delimiter = delimiters[i];
2763
- const {
2764
- signature,
2765
- matcher,
2766
- precedence = 1
2767
- } = delimiter;
2761
+ exports.eval = eval_;
2768
2762
 
2769
- if (!this.registry[signature]) {
2770
- this.matchers.unshift([this.length, signature, precedence, matcher]);
2771
- this.registry[signature] = true;
2772
- }
2763
+ function exec(result, default_) {
2764
+ return result ? result[1] : default_;
2765
+ }
2773
2766
 
2774
- ++this.length;
2775
- }
2776
- }
2767
+ exports.exec = exec;
2777
2768
 
2778
- pop(count = 1) {
2779
- for (let i = 0; i < count; ++i) {
2780
- if (--this.length === this.matchers[0][0]) {
2781
- this.registry[this.matchers.shift()[1]] = false;
2782
- }
2783
- }
2784
- }
2769
+ function check(source, result, mustConsume = true) {
2770
+ return true;
2771
+ }
2785
2772
 
2786
- match(source, precedence = 1) {
2787
- const {
2788
- matchers
2789
- } = this;
2773
+ exports.check = check;
2790
2774
 
2791
- for (let i = 0; i < matchers.length; ++i) {
2792
- switch (matchers[i][3](source)) {
2793
- case true:
2794
- if (precedence < matchers[i][2]) return true;
2795
- continue;
2775
+ /***/ }),
2796
2776
 
2797
- case false:
2798
- return false;
2799
- }
2800
- }
2777
+ /***/ 5684:
2778
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2801
2779
 
2802
- return false;
2780
+ "use strict";
2781
+
2782
+
2783
+ Object.defineProperty(exports, "__esModule", ({
2784
+ value: true
2785
+ }));
2786
+ exports.state = exports.guard = exports.precedence = exports.creator = exports.syntax = exports.context = exports.reset = void 0;
2787
+
2788
+ const global_1 = __webpack_require__(4128);
2789
+
2790
+ const alias_1 = __webpack_require__(5406);
2791
+
2792
+ const parser_1 = __webpack_require__(6728);
2793
+
2794
+ const memo_1 = __webpack_require__(1090);
2795
+
2796
+ function reset(base, parser) {
2797
+ const changes = global_1.Object.entries(base);
2798
+ const values = (0, global_1.Array)(changes.length);
2799
+ return (source, context) => apply(parser, source, (0, alias_1.ObjectCreate)(context), changes, values);
2800
+ }
2801
+
2802
+ exports.reset = reset;
2803
+
2804
+ function context(base, parser) {
2805
+ const changes = global_1.Object.entries(base);
2806
+ const values = (0, global_1.Array)(changes.length);
2807
+ return (source, context) => apply(parser, source, context, changes, values);
2808
+ }
2809
+
2810
+ exports.context = context;
2811
+
2812
+ function apply(parser, source, context, changes, values) {
2813
+ if (context) for (let i = 0; i < changes.length; ++i) {
2814
+ const change = changes[i];
2815
+ const prop = change[0];
2816
+
2817
+ switch (prop) {
2818
+ case 'resources':
2819
+ if (prop in context && !(0, alias_1.hasOwnProperty)(context, prop)) break; // @ts-expect-error
2820
+
2821
+ context[prop] = (0, alias_1.ObjectCreate)(change[1]);
2822
+ break;
2823
+
2824
+ default:
2825
+ values[i] = context[prop];
2826
+ context[prop] = change[1];
2827
+ }
2803
2828
  }
2829
+ const result = parser(source, context);
2830
+ if (context) for (let i = 0; i < changes.length; ++i) {
2831
+ const change = changes[i];
2832
+ const prop = change[0];
2804
2833
 
2834
+ switch (prop) {
2835
+ case 'resources':
2836
+ break;
2837
+
2838
+ default:
2839
+ context[prop] = values[i];
2840
+ values[i] = global_1.undefined;
2841
+ }
2842
+ }
2843
+ return result;
2805
2844
  }
2806
2845
 
2807
- exports.Delimiters = Delimiters;
2846
+ function syntax(syntax, precedence, cost, parser) {
2847
+ if (typeof cost === 'function') {
2848
+ parser = cost;
2849
+ cost = 1;
2850
+ }
2808
2851
 
2809
- function eval_(result, default_) {
2810
- return result ? result[0] : default_;
2852
+ return (source, context) => {
2853
+ if (source === '') return;
2854
+ context.backtrackable ??= ~0;
2855
+ const state = context.state ??= 0;
2856
+ const p = context.precedence;
2857
+ context.precedence = precedence;
2858
+ const {
2859
+ resources = {
2860
+ budget: 1,
2861
+ recursion: 1
2862
+ }
2863
+ } = context;
2864
+ if (resources.budget <= 0) throw new Error('Too many creations');
2865
+ if (resources.recursion <= 0) throw new Error('Too much recursion');
2866
+ --resources.recursion;
2867
+ const pos = source.length;
2868
+ const cache = syntax && context.memo?.get(pos, syntax, state);
2869
+ const result = cache ? cache.length === 0 ? global_1.undefined : [cache[0], source.slice(cache[1])] : parser(source, context);
2870
+ ++resources.recursion;
2871
+
2872
+ if (result && !cache) {
2873
+ resources.budget -= cost;
2874
+ }
2875
+
2876
+ if (syntax) {
2877
+ if (state & context.backtrackable) {
2878
+ context.memo ??= new memo_1.Memo();
2879
+ cache ?? context.memo.set(pos, syntax, state, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result, '').length);
2880
+ } else if (result && context.memo?.length >= pos) {
2881
+ context.memo.clear(pos);
2882
+ }
2883
+ }
2884
+
2885
+ context.precedence = p;
2886
+ return result;
2887
+ };
2811
2888
  }
2812
2889
 
2813
- exports.eval = eval_;
2890
+ exports.syntax = syntax;
2814
2891
 
2815
- function exec(result, default_) {
2816
- return result ? result[1] : default_;
2892
+ function creator(cost, parser) {
2893
+ if (typeof cost === 'function') return creator(1, cost);
2894
+ return (source, context) => {
2895
+ const {
2896
+ resources = {
2897
+ budget: 1,
2898
+ recursion: 1
2899
+ }
2900
+ } = context;
2901
+ if (resources.budget <= 0) throw new Error('Too many creations');
2902
+ if (resources.recursion <= 0) throw new Error('Too much recursion');
2903
+ --resources.recursion;
2904
+ const result = parser(source, context);
2905
+ ++resources.recursion;
2906
+
2907
+ if (result) {
2908
+ resources.budget -= cost;
2909
+ }
2910
+
2911
+ return result;
2912
+ };
2817
2913
  }
2818
2914
 
2819
- exports.exec = exec;
2915
+ exports.creator = creator;
2820
2916
 
2821
- function check(source, result, mustConsume = true) {
2822
- return true;
2917
+ function precedence(precedence, parser) {
2918
+ return (source, context) => {
2919
+ const p = context.precedence;
2920
+ context.precedence = precedence;
2921
+ const result = parser(source, context);
2922
+ context.precedence = p;
2923
+ return result;
2924
+ };
2823
2925
  }
2824
2926
 
2825
- exports.check = check;
2927
+ exports.precedence = precedence;
2928
+
2929
+ function guard(f, parser) {
2930
+ return (source, context) => f(context) ? parser(source, context) : global_1.undefined;
2931
+ }
2932
+
2933
+ exports.guard = guard;
2934
+
2935
+ function state(state, positive, parser) {
2936
+ if (typeof positive === 'function') {
2937
+ parser = positive;
2938
+ positive = true;
2939
+ }
2940
+
2941
+ return (source, context) => {
2942
+ const s = context.state ?? 0;
2943
+ context.state = positive ? s | state : s & ~state;
2944
+ const result = parser(source, context);
2945
+ context.state = s;
2946
+ return result;
2947
+ };
2948
+ }
2949
+
2950
+ exports.state = state;
2951
+
2952
+ /***/ }),
2953
+
2954
+ /***/ 1435:
2955
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2956
+
2957
+ "use strict";
2958
+
2959
+
2960
+ var _a;
2961
+
2962
+ Object.defineProperty(exports, "__esModule", ({
2963
+ value: true
2964
+ }));
2965
+ exports.Delimiters = void 0;
2966
+
2967
+ const memoize_1 = __webpack_require__(1808);
2968
+
2969
+ class Delimiters {
2970
+ constructor() {
2971
+ this.matchers = [];
2972
+ this.registry = {};
2973
+ this.length = 0;
2974
+ }
2975
+
2976
+ static signature(pattern) {
2977
+ switch (typeof pattern) {
2978
+ case 'undefined':
2979
+ return `undefined`;
2980
+
2981
+ case 'string':
2982
+ return `s:${pattern}`;
2983
+
2984
+ case 'object':
2985
+ return `r/${pattern.source}/${pattern.flags}`;
2986
+ }
2987
+ }
2988
+
2989
+ push(...delimiters) {
2990
+ for (let i = 0; i < delimiters.length; ++i) {
2991
+ const delimiter = delimiters[i];
2992
+ const {
2993
+ signature,
2994
+ matcher,
2995
+ precedence = 1
2996
+ } = delimiter;
2997
+
2998
+ if (!this.registry[signature]) {
2999
+ this.matchers.unshift([this.length, signature, precedence, matcher]);
3000
+ this.registry[signature] = true;
3001
+ }
3002
+
3003
+ ++this.length;
3004
+ }
3005
+ }
3006
+
3007
+ pop(count = 1) {
3008
+ for (let i = 0; i < count; ++i) {
3009
+ if (--this.length === this.matchers[0][0]) {
3010
+ this.registry[this.matchers.shift()[1]] = false;
3011
+ }
3012
+ }
3013
+ }
3014
+
3015
+ match(source, precedence = 1) {
3016
+ const {
3017
+ matchers
3018
+ } = this;
3019
+
3020
+ for (let i = 0; i < matchers.length; ++i) {
3021
+ switch (matchers[i][3](source)) {
3022
+ case true:
3023
+ if (precedence < matchers[i][2]) return true;
3024
+ continue;
3025
+
3026
+ case false:
3027
+ return false;
3028
+ }
3029
+ }
3030
+
3031
+ return false;
3032
+ }
3033
+
3034
+ }
3035
+
3036
+ exports.Delimiters = Delimiters;
3037
+ _a = Delimiters;
3038
+ Delimiters.matcher = (0, memoize_1.memoize)(pattern => {
3039
+ switch (typeof pattern) {
3040
+ case 'undefined':
3041
+ return () => undefined;
3042
+
3043
+ case 'string':
3044
+ return source => source.slice(0, pattern.length) === pattern || undefined;
3045
+
3046
+ case 'object':
3047
+ return (0, memoize_1.reduce)(source => pattern.test(source) || undefined);
3048
+ }
3049
+ }, _a.signature);
3050
+
3051
+ /***/ }),
3052
+
3053
+ /***/ 1090:
3054
+ /***/ ((__unused_webpack_module, exports) => {
3055
+
3056
+ "use strict";
3057
+
3058
+
3059
+ Object.defineProperty(exports, "__esModule", ({
3060
+ value: true
3061
+ }));
3062
+ exports.Memo = void 0;
3063
+
3064
+ class Memo {
3065
+ constructor() {
3066
+ this.memory = [];
3067
+ this.offset = 0;
3068
+ }
3069
+
3070
+ get length() {
3071
+ return this.memory.length;
3072
+ }
3073
+
3074
+ get(position, syntax, state) {
3075
+ //console.log('get', position + this.offset, syntax, state, this.memory[position + this.offset - 1]?.[`${syntax}:${state}`]);;
3076
+ return this.memory[position + this.offset - 1]?.[`${syntax}:${state}`];
3077
+ }
3078
+
3079
+ set(position, syntax, state, nodes, offset) {
3080
+ const record = this.memory[position + this.offset - 1] ??= {};
3081
+ record[`${syntax}:${state}`] = nodes ? [nodes.slice(), offset] : []; //console.log('set', position + this.offset, syntax, state);
3082
+ }
3083
+
3084
+ clear(position) {
3085
+ const memory = this.memory;
3086
+
3087
+ for (let i = position + this.offset, len = memory.length; i < len; ++i) {
3088
+ memory.pop();
3089
+ } //console.log('clear', position);
3090
+
3091
+ }
3092
+
3093
+ }
3094
+
3095
+ exports.Memo = Memo;
2826
3096
 
2827
3097
  /***/ }),
2828
3098
 
@@ -2843,7 +3113,7 @@ const parser_1 = __webpack_require__(6728);
2843
3113
 
2844
3114
  const array_1 = __webpack_require__(8112);
2845
3115
 
2846
- function inits(parsers) {
3116
+ function inits(parsers, resume) {
2847
3117
  if (parsers.length === 1) return parsers[0];
2848
3118
  return (source, context) => {
2849
3119
  let rest = source;
@@ -2856,6 +3126,7 @@ function inits(parsers) {
2856
3126
  if (!result) break;
2857
3127
  nodes = nodes ? (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
2858
3128
  rest = (0, parser_1.exec)(result);
3129
+ if (resume?.((0, parser_1.eval)(result), (0, parser_1.exec)(result)) === false) break;
2859
3130
  }
2860
3131
 
2861
3132
  return nodes && rest.length < source.length ? [nodes, rest] : global_1.undefined;
@@ -2883,7 +3154,7 @@ const parser_1 = __webpack_require__(6728);
2883
3154
 
2884
3155
  const array_1 = __webpack_require__(8112);
2885
3156
 
2886
- function sequence(parsers) {
3157
+ function sequence(parsers, resume) {
2887
3158
  if (parsers.length === 1) return parsers[0];
2888
3159
  return (source, context) => {
2889
3160
  let rest = source;
@@ -2891,11 +3162,12 @@ function sequence(parsers) {
2891
3162
 
2892
3163
  for (let i = 0, len = parsers.length; i < len; ++i) {
2893
3164
  if (rest === '') return;
2894
- if (context.delimiters?.match(rest, context.precedence)) break;
3165
+ if (context.delimiters?.match(rest, context.precedence)) return;
2895
3166
  const result = parsers[i](rest, context);
2896
3167
  if (!result) return;
2897
3168
  nodes = nodes ? (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
2898
3169
  rest = (0, parser_1.exec)(result);
3170
+ if (resume?.((0, parser_1.eval)(result), (0, parser_1.exec)(result)) === false) return;
2899
3171
  }
2900
3172
 
2901
3173
  return nodes && rest.length < source.length ? [nodes, rest] : global_1.undefined;
@@ -2921,42 +3193,16 @@ const global_1 = __webpack_require__(4128);
2921
3193
 
2922
3194
  const parser_1 = __webpack_require__(6728);
2923
3195
 
2924
- const memoize_1 = __webpack_require__(1808);
3196
+ const delimiter_1 = __webpack_require__(1435);
2925
3197
 
2926
3198
  const array_1 = __webpack_require__(8112);
2927
3199
 
2928
- const signature = pattern => {
2929
- switch (typeof pattern) {
2930
- case 'undefined':
2931
- return signature('');
2932
-
2933
- case 'string':
2934
- return `s:${pattern}`;
2935
-
2936
- case 'object':
2937
- return `r/${pattern.source}/${pattern.flags}`;
2938
- }
2939
- };
2940
-
2941
- const matcher = (0, memoize_1.memoize)(pattern => {
2942
- switch (typeof pattern) {
2943
- case 'undefined':
2944
- return () => global_1.undefined;
2945
-
2946
- case 'string':
2947
- return source => source.slice(0, pattern.length) === pattern || global_1.undefined;
2948
-
2949
- case 'object':
2950
- return (0, memoize_1.reduce)(source => pattern.test(source) || global_1.undefined);
2951
- }
2952
- }, signature);
2953
-
2954
- function some(parser, until, deeps = [], limit = -1) {
2955
- if (typeof until === 'number') return some(parser, global_1.undefined, deeps, until);
2956
- const match = matcher(until);
2957
- const delimiters = deeps.map(([delimiter, precedence]) => ({
2958
- signature: signature(delimiter),
2959
- matcher: matcher(delimiter),
3200
+ function some(parser, end, delimiters = [], limit = -1) {
3201
+ if (typeof end === 'number') return some(parser, global_1.undefined, delimiters, end);
3202
+ const match = delimiter_1.Delimiters.matcher(end);
3203
+ const delims = delimiters.map(([delimiter, precedence]) => ({
3204
+ signature: delimiter_1.Delimiters.signature(delimiter),
3205
+ matcher: delimiter_1.Delimiters.matcher(delimiter),
2960
3206
  precedence
2961
3207
  }));
2962
3208
  return (source, context) => {
@@ -2964,9 +3210,9 @@ function some(parser, until, deeps = [], limit = -1) {
2964
3210
  let rest = source;
2965
3211
  let nodes;
2966
3212
 
2967
- if (delimiters.length > 0) {
2968
- context.delimiters ??= new parser_1.Delimiters();
2969
- context.delimiters.push(...delimiters);
3213
+ if (delims.length > 0) {
3214
+ context.delimiters ??= new delimiter_1.Delimiters();
3215
+ context.delimiters.push(...delims);
2970
3216
  }
2971
3217
 
2972
3218
  while (true) {
@@ -2980,8 +3226,8 @@ function some(parser, until, deeps = [], limit = -1) {
2980
3226
  if (limit >= 0 && source.length - rest.length > limit) break;
2981
3227
  }
2982
3228
 
2983
- if (delimiters.length > 0) {
2984
- context.delimiters.pop(delimiters.length);
3229
+ if (delims.length > 0) {
3230
+ context.delimiters.pop(delims.length);
2985
3231
  }
2986
3232
 
2987
3233
  return nodes && rest.length < source.length ? [nodes, rest] : global_1.undefined;
@@ -3007,8 +3253,8 @@ const union_1 = __webpack_require__(6366);
3007
3253
 
3008
3254
  const inits_1 = __webpack_require__(2491);
3009
3255
 
3010
- function subsequence(parsers) {
3011
- return (0, union_1.union)(parsers.map((_, i) => i + 1 < parsers.length ? (0, inits_1.inits)([parsers[i], subsequence(parsers.slice(i + 1))]) : parsers[i]));
3256
+ function subsequence(parsers, resume) {
3257
+ return (0, union_1.union)(parsers.map((_, i) => i + 1 < parsers.length ? (0, inits_1.inits)([parsers[i], subsequence(parsers.slice(i + 1), resume)], resume) : parsers[i]));
3012
3258
  }
3013
3259
 
3014
3260
  exports.subsequence = subsequence;
@@ -3030,8 +3276,8 @@ const union_1 = __webpack_require__(6366);
3030
3276
 
3031
3277
  const sequence_1 = __webpack_require__(2287);
3032
3278
 
3033
- function tails(parsers) {
3034
- return (0, union_1.union)(parsers.map((_, i) => (0, sequence_1.sequence)(parsers.slice(i))));
3279
+ function tails(parsers, resume) {
3280
+ return (0, union_1.union)(parsers.map((_, i) => (0, sequence_1.sequence)(parsers.slice(i), resume)));
3035
3281
  }
3036
3282
 
3037
3283
  exports.tails = tails;
@@ -3193,11 +3439,13 @@ const global_1 = __webpack_require__(4128);
3193
3439
 
3194
3440
  const parser_1 = __webpack_require__(6728);
3195
3441
 
3442
+ const segment_1 = __webpack_require__(9002);
3443
+
3196
3444
  const header_1 = __webpack_require__(5702);
3197
3445
 
3198
3446
  const block_1 = __webpack_require__(4032);
3199
3447
 
3200
- const segment_1 = __webpack_require__(9002);
3448
+ const context_1 = __webpack_require__(6484);
3201
3449
 
3202
3450
  const normalize_1 = __webpack_require__(185);
3203
3451
 
@@ -3213,7 +3461,8 @@ const array_1 = __webpack_require__(8112);
3213
3461
 
3214
3462
  function bind(target, settings) {
3215
3463
  let context = { ...settings,
3216
- host: settings.host ?? new url_1.ReadonlyURL(global_1.location.pathname, global_1.location.origin)
3464
+ host: settings.host ?? new url_1.ReadonlyURL(global_1.location.pathname, global_1.location.origin),
3465
+ backtrackable: context_1.backtrackable
3217
3466
  };
3218
3467
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
3219
3468
  const blocks = [];
@@ -3355,9 +3604,8 @@ function bind(target, settings) {
3355
3604
 
3356
3605
  function nearest(index) {
3357
3606
  let el;
3358
- let len = 0;
3359
3607
 
3360
- for (let i = 0; i < blocks.length; ++i) {
3608
+ for (let i = 0, len = 0; i < blocks.length; ++i) {
3361
3609
  const block = blocks[i];
3362
3610
  len += block[0].length;
3363
3611
  el = block[1][0] ?? el;
@@ -3368,9 +3616,7 @@ function bind(target, settings) {
3368
3616
  }
3369
3617
 
3370
3618
  function index(source) {
3371
- let len = 0;
3372
-
3373
- for (let i = 0; i < blocks.length; ++i) {
3619
+ for (let i = 0, len = 0; i < blocks.length; ++i) {
3374
3620
  const block = blocks[i];
3375
3621
  if (block[1].includes(source)) return len;
3376
3622
  len += block[0].length;
@@ -3544,11 +3790,13 @@ const global_1 = __webpack_require__(4128);
3544
3790
 
3545
3791
  const parser_1 = __webpack_require__(6728);
3546
3792
 
3793
+ const segment_1 = __webpack_require__(9002);
3794
+
3547
3795
  const header_1 = __webpack_require__(5702);
3548
3796
 
3549
3797
  const block_1 = __webpack_require__(4032);
3550
3798
 
3551
- const segment_1 = __webpack_require__(9002);
3799
+ const context_1 = __webpack_require__(6484);
3552
3800
 
3553
3801
  const normalize_1 = __webpack_require__(185);
3554
3802
 
@@ -3573,7 +3821,8 @@ function parse(source, opts = {}, context) {
3573
3821
  caches: context?.caches,
3574
3822
  ...(context?.resources && {
3575
3823
  resources: context.resources
3576
- })
3824
+ }),
3825
+ backtrackable: context_1.backtrackable
3577
3826
  };
3578
3827
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
3579
3828
  const node = (0, dom_1.frag)();
@@ -3671,7 +3920,7 @@ const random_1 = __webpack_require__(7325);
3671
3920
  exports.block = (0, combinator_1.creator)(error((0, combinator_1.reset)({
3672
3921
  resources: {
3673
3922
  budget: 50 * 1000,
3674
- recursion: 20 + 1
3923
+ recursion: 20
3675
3924
  }
3676
3925
  }, (0, combinator_1.union)([source_1.emptyline, horizontalrule_1.horizontalrule, heading_1.heading, ulist_1.ulist, olist_1.olist, ilist_1.ilist, dlist_1.dlist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, extension_1.extension, sidefence_1.sidefence, blockquote_1.blockquote, reply_1.reply, paragraph_1.paragraph]))));
3677
3926
 
@@ -3826,26 +4075,27 @@ const source_1 = __webpack_require__(6743);
3826
4075
 
3827
4076
  const locale_1 = __webpack_require__(5485);
3828
4077
 
3829
- const util_1 = __webpack_require__(9437);
4078
+ const visibility_1 = __webpack_require__(7618);
3830
4079
 
3831
4080
  const dom_1 = __webpack_require__(3252);
3832
4081
 
3833
4082
  const array_1 = __webpack_require__(8112);
3834
4083
 
3835
- exports.dlist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, locale_1.localize)((0, combinator_1.fmap)((0, combinator_1.validate)(/^~[^\S\n]+(?=\S)/, (0, combinator_1.some)((0, combinator_1.inits)([(0, combinator_1.context)({
3836
- syntax: {
3837
- inline: {
3838
- annotation: false,
3839
- reference: false,
3840
- index: false,
3841
- label: false,
3842
- link: false,
3843
- media: false
3844
- }
3845
- }
3846
- }, (0, combinator_1.some)(term)), (0, combinator_1.some)(desc)]))), es => [(0, dom_1.html)('dl', fillTrailingDescription(es))]))));
3847
- const term = (0, combinator_1.creator)((0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.open)(/^~[^\S\n]+(?=\S)/, (0, util_1.visualize)((0, util_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), ns => [(0, dom_1.html)('dt', (0, dom_1.defrag)(ns))]))));
3848
- const desc = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, util_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('dd', (0, dom_1.defrag)(ns))]), false));
4084
+ exports.dlist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, locale_1.localize)((0, combinator_1.fmap)((0, combinator_1.validate)(/^~[^\S\n]+(?=\S)/, (0, combinator_1.some)((0, combinator_1.inits)([(0, combinator_1.state)(64
4085
+ /* State.annotation */
4086
+ | 32
4087
+ /* State.reference */
4088
+ | 16
4089
+ /* State.index */
4090
+ | 8
4091
+ /* State.label */
4092
+ | 4
4093
+ /* State.link */
4094
+ | 2
4095
+ /* State.media */
4096
+ , (0, combinator_1.some)(term)), (0, combinator_1.some)(desc)]))), es => [(0, dom_1.html)('dl', fillTrailingDescription(es))]))));
4097
+ const term = (0, combinator_1.creator)((0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.open)(/^~[^\S\n]+(?=\S)/, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), ns => [(0, dom_1.html)('dt', (0, dom_1.defrag)(ns))]))));
4098
+ const desc = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('dd', (0, dom_1.defrag)(ns))]), false));
3849
4099
 
3850
4100
  function fillTrailingDescription(es) {
3851
4101
  return es.length > 0 && es[es.length - 1].tagName === 'DT' ? (0, array_1.push)(es, [(0, dom_1.html)('dd')]) : es;
@@ -4122,7 +4372,7 @@ const inline_1 = __webpack_require__(1160);
4122
4372
 
4123
4373
  const locale_1 = __webpack_require__(5485);
4124
4374
 
4125
- const util_1 = __webpack_require__(9437);
4375
+ const visibility_1 = __webpack_require__(7618);
4126
4376
 
4127
4377
  const dom_1 = __webpack_require__(3252);
4128
4378
 
@@ -4130,13 +4380,9 @@ const memoize_1 = __webpack_require__(1808);
4130
4380
 
4131
4381
  exports.segment = (0, combinator_1.block)((0, combinator_1.match)(/^(~{3,})(?:figure[^\S\n])?(?=\[?\$)/, (0, memoize_1.memoize)(([, fence], closer = new RegExp(String.raw`^${fence}[^\S\n]*(?:$|\n)`)) => (0, combinator_1.close)((0, combinator_1.sequence)([source_1.contentline, (0, combinator_1.inits)([// All parsers which can include closing terms.
4132
4382
  (0, combinator_1.union)([codeblock_1.segment_, mathblock_1.segment_, table_2.segment_, blockquote_1.segment, placeholder_1.segment_, (0, combinator_1.some)(source_1.contentline, closer)]), source_1.emptyline, (0, combinator_1.union)([source_1.emptyline, (0, combinator_1.some)(source_1.contentline, closer)])])]), closer), ([, fence]) => fence.length, [])));
4133
- exports.figure = (0, combinator_1.block)((0, combinator_1.fallback)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.fmap)((0, combinator_1.convert)(source => source.slice(source.match(/^~+(?:\w+\s+)?/)[0].length, source.trimEnd().lastIndexOf('\n')), (0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.sequence)([label_1.label, (0, source_1.str)(/^(?=\s).*\n/)])), (0, combinator_1.inits)([(0, combinator_1.block)((0, combinator_1.union)([ulist_1.ulist, olist_1.olist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, example_1.example, table_2.table, blockquote_1.blockquote, placeholder_1.placeholder, (0, combinator_1.line)(inline_1.media), (0, combinator_1.line)(inline_1.shortmedia)])), source_1.emptyline, (0, combinator_1.block)((0, locale_1.localize)((0, combinator_1.context)({
4134
- syntax: {
4135
- inline: {
4136
- media: false
4137
- }
4138
- }
4139
- }, (0, util_1.visualize)((0, util_1.trimBlank)((0, combinator_1.trimEnd)((0, combinator_1.some)(inline_1.inline)))))))])])), ([label, param, content, ...caption]) => [(0, dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [(0, dom_1.html)('figcaption', [(0, dom_1.html)('span', {
4383
+ exports.figure = (0, combinator_1.block)((0, combinator_1.fallback)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.fmap)((0, combinator_1.convert)(source => source.slice(source.match(/^~+(?:\w+\s+)?/)[0].length, source.trimEnd().lastIndexOf('\n')), (0, combinator_1.sequence)([(0, combinator_1.line)((0, combinator_1.sequence)([label_1.label, (0, source_1.str)(/^(?=\s).*\n/)])), (0, combinator_1.inits)([(0, combinator_1.block)((0, combinator_1.union)([ulist_1.ulist, olist_1.olist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, example_1.example, table_2.table, blockquote_1.blockquote, placeholder_1.placeholder, (0, combinator_1.line)(inline_1.media), (0, combinator_1.line)(inline_1.shortmedia)])), source_1.emptyline, (0, combinator_1.block)((0, locale_1.localize)((0, combinator_1.state)(2
4384
+ /* State.media */
4385
+ , (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.trimEnd)((0, combinator_1.some)(inline_1.inline)))))))])])), ([label, param, content, ...caption]) => [(0, dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [(0, dom_1.html)('figcaption', [(0, dom_1.html)('span', {
4140
4386
  class: 'figindex'
4141
4387
  }), (0, dom_1.html)('span', {
4142
4388
  class: 'figtext'
@@ -4382,7 +4628,7 @@ const source_1 = __webpack_require__(6743);
4382
4628
 
4383
4629
  const locale_1 = __webpack_require__(5485);
4384
4630
 
4385
- const util_1 = __webpack_require__(9437);
4631
+ const visibility_1 = __webpack_require__(7618);
4386
4632
 
4387
4633
  const dom_1 = __webpack_require__(3252);
4388
4634
 
@@ -4423,8 +4669,8 @@ const row = (0, combinator_1.lazy)(() => (0, combinator_1.dup)((0, combinator_1.
4423
4669
  const alignment = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)/;
4424
4670
  const align = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.union)([(0, source_1.str)(alignment)]), ([s]) => s.split('/').map(s => s.split(''))));
4425
4671
  const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/;
4426
- const head = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
4427
- const data = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
4672
+ const head = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
4673
+ const data = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.anyline, (0, combinator_1.some)(source_1.contentline, delimiter)]), (0, combinator_1.trim)((0, visibility_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false));
4428
4674
  const dataline = (0, combinator_1.creator)((0, combinator_1.line)((0, combinator_1.rewrite)(source_1.contentline, (0, combinator_1.union)([(0, combinator_1.validate)(/^!+\s/, (0, combinator_1.convert)(source => `:${source}`, data)), (0, combinator_1.convert)(source => `: ${source}`, data)]))));
4429
4675
 
4430
4676
  function attributes(source) {
@@ -4655,29 +4901,26 @@ const inline_1 = __webpack_require__(1160);
4655
4901
 
4656
4902
  const source_1 = __webpack_require__(6743);
4657
4903
 
4658
- const util_1 = __webpack_require__(9437);
4904
+ const visibility_1 = __webpack_require__(7618);
4659
4905
 
4660
4906
  const dom_1 = __webpack_require__(3252);
4661
4907
 
4662
4908
  exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('#', (0, combinator_1.focus)(/^#+[^\S\n]+\S[^\n]*(?:\n#+(?!\S)[^\n]*)*(?:$|\n)/, (0, combinator_1.some)((0, combinator_1.line)(source => [[source], ''])))));
4663
- exports.heading = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.context)({
4664
- syntax: {
4665
- inline: {
4666
- annotation: false,
4667
- reference: false,
4668
- index: false,
4669
- label: false,
4670
- link: false,
4671
- media: false
4672
- }
4673
- }
4674
- }, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.open)((0, source_1.str)(/^##+/), (0, util_1.visualize)((0, util_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), (0, combinator_1.open)((0, source_1.str)('#'), (0, combinator_1.context)({
4675
- syntax: {
4676
- inline: {
4677
- autolink: false
4678
- }
4679
- }
4680
- }, (0, util_1.visualize)((0, util_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))), true)]), ([h, ...ns]) => [h.length <= 6 ? (0, dom_1.html)(`h${h.length}`, (0, dom_1.defrag)(ns)) : (0, dom_1.html)(`h6`, {
4909
+ exports.heading = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.state)(64
4910
+ /* State.annotation */
4911
+ | 32
4912
+ /* State.reference */
4913
+ | 16
4914
+ /* State.index */
4915
+ | 8
4916
+ /* State.label */
4917
+ | 4
4918
+ /* State.link */
4919
+ | 2
4920
+ /* State.media */
4921
+ , (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.open)((0, source_1.str)(/^##+/), (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))), true), (0, combinator_1.open)((0, source_1.str)('#'), (0, combinator_1.state)(1
4922
+ /* State.autolink */
4923
+ , (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))), true)]), ([h, ...ns]) => [h.length <= 6 ? (0, dom_1.html)(`h${h.length}`, (0, dom_1.defrag)(ns)) : (0, dom_1.html)(`h6`, {
4681
4924
  class: 'invalid',
4682
4925
  'data-invalid-syntax': 'heading',
4683
4926
  'data-invalid-type': 'syntax',
@@ -4726,13 +4969,9 @@ const inline_1 = __webpack_require__(1160);
4726
4969
 
4727
4970
  const dom_1 = __webpack_require__(3252);
4728
4971
 
4729
- exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.context)({
4730
- syntax: {
4731
- inline: {
4732
- media: false
4733
- }
4734
- }
4735
- }, exports.ilist_))));
4972
+ exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.state)(2
4973
+ /* State.media */
4974
+ , exports.ilist_))));
4736
4975
  exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^[-+*](?:$|\s)/, (0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.some)(inline_1.inline), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
4737
4976
  class: 'invalid',
4738
4977
  'data-invalid-syntax': 'list',
@@ -4803,12 +5042,14 @@ const inline_1 = __webpack_require__(1160);
4803
5042
 
4804
5043
  const source_1 = __webpack_require__(6743);
4805
5044
 
4806
- const util_1 = __webpack_require__(9437);
5045
+ const visibility_1 = __webpack_require__(7618);
4807
5046
 
4808
5047
  const dom_1 = __webpack_require__(3252);
4809
5048
 
4810
5049
  const memoize_1 = __webpack_require__(1808);
4811
5050
 
5051
+ const duff_1 = __webpack_require__(8099);
5052
+
4812
5053
  const array_1 = __webpack_require__(8112);
4813
5054
 
4814
5055
  const tuple_1 = __webpack_require__(5341);
@@ -4817,16 +5058,12 @@ const openers = {
4817
5058
  '.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?:$|\s)/,
4818
5059
  '(': /^\(([0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?:$|\s)/
4819
5060
  };
4820
- exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(new RegExp([/^([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*\.(?=[^\S\n]|\n[^\S\n]*\S)/.source, /^\(([0-9]+|[a-z]+)\)(?:-[0-9]+)*(?=[^\S\n]|\n[^\S\n]*\S)/.source].join('|')), (0, combinator_1.context)({
4821
- syntax: {
4822
- inline: {
4823
- media: false
4824
- }
4825
- }
4826
- }, exports.olist_))));
5061
+ exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(new RegExp([/^([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*\.(?=[^\S\n]|\n[^\S\n]*\S)/.source, /^\(([0-9]+|[a-z]+)\)(?:-[0-9]+)*(?=[^\S\n]|\n[^\S\n]*\S)/.source].join('|')), (0, combinator_1.state)(2
5062
+ /* State.media */
5063
+ , exports.olist_))));
4827
5064
  exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.match)(openers['.'], (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => type(ms[1]).charCodeAt(0) || 0, [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => type(ms[1]).charCodeAt(0) || 0, []))])));
4828
5065
 
4829
- const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, util_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
5066
+ const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
4830
5067
  'data-marker': ns[0] || global_1.undefined
4831
5068
  }, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)((0, array_1.shift)(ns)[1])))]), true)]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
4832
5069
 
@@ -4909,20 +5146,19 @@ function format(el, type, form) {
4909
5146
  'data-type': style(type) || global_1.undefined
4910
5147
  });
4911
5148
  const marker = el.firstElementChild?.getAttribute('data-marker').match(initial(type))?.[0] ?? '';
4912
-
4913
- for (let es = el.children, len = es.length, i = 0; i < len; ++i) {
5149
+ const es = el.children;
5150
+ (0, duff_1.duffbk)(es.length, i => {
4914
5151
  const el = es[i];
4915
5152
 
4916
5153
  switch (el.getAttribute('data-marker')) {
4917
5154
  case '':
4918
5155
  case marker:
4919
5156
  el.removeAttribute('data-marker');
4920
- continue;
5157
+ return;
4921
5158
  }
4922
5159
 
4923
- break;
4924
- }
4925
-
5160
+ return false;
5161
+ });
4926
5162
  return el;
4927
5163
  }
4928
5164
 
@@ -4945,11 +5181,11 @@ const inline_1 = __webpack_require__(1160);
4945
5181
 
4946
5182
  const locale_1 = __webpack_require__(5485);
4947
5183
 
4948
- const util_1 = __webpack_require__(9437);
5184
+ const visibility_1 = __webpack_require__(7618);
4949
5185
 
4950
5186
  const dom_1 = __webpack_require__(3252);
4951
5187
 
4952
- exports.paragraph = (0, combinator_1.block)((0, locale_1.localize)((0, combinator_1.fmap)((0, util_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline])))), ns => [(0, dom_1.html)('p', (0, dom_1.defrag)(ns))])));
5188
+ exports.paragraph = (0, combinator_1.block)((0, locale_1.localize)((0, combinator_1.fmap)((0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline])))), ns => [(0, dom_1.html)('p', (0, dom_1.defrag)(ns))])));
4953
5189
 
4954
5190
  /***/ }),
4955
5191
 
@@ -4976,7 +5212,7 @@ const source_1 = __webpack_require__(6743);
4976
5212
 
4977
5213
  const locale_1 = __webpack_require__(5485);
4978
5214
 
4979
- const util_1 = __webpack_require__(9437);
5215
+ const visibility_1 = __webpack_require__(7618);
4980
5216
 
4981
5217
  const dom_1 = __webpack_require__(3252);
4982
5218
 
@@ -4989,7 +5225,7 @@ const array_1 = __webpack_require__(8112);
4989
5225
  */
4990
5226
 
4991
5227
 
4992
- exports.reply = (0, combinator_1.block)((0, combinator_1.validate)('>', (0, locale_1.localize)((0, combinator_1.fmap)((0, combinator_1.inits)([(0, combinator_1.some)((0, combinator_1.inits)([cite_1.cite, quote_1.quote])), (0, combinator_1.some)((0, combinator_1.subsequence)([(0, combinator_1.some)(quote_1.quote), (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, quote_1.syntax), (0, util_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)(inline_1.inline)))), ns => (0, array_1.push)(ns, [(0, dom_1.html)('br')]))]))]), ns => [(0, dom_1.html)('p', (0, dom_1.defrag)((0, array_1.pop)(ns)[0]))]))));
5228
+ exports.reply = (0, combinator_1.block)((0, combinator_1.validate)('>', (0, locale_1.localize)((0, combinator_1.fmap)((0, combinator_1.inits)([(0, combinator_1.some)((0, combinator_1.inits)([cite_1.cite, quote_1.quote])), (0, combinator_1.some)((0, combinator_1.subsequence)([(0, combinator_1.some)(quote_1.quote), (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, quote_1.syntax), (0, visibility_1.visualize)((0, combinator_1.trimEnd)((0, combinator_1.some)(inline_1.inline)))), ns => (0, array_1.push)(ns, [(0, dom_1.html)('br')]))]))]), ns => [(0, dom_1.html)('p', (0, dom_1.defrag)((0, array_1.pop)(ns)[0]))]))));
4993
5229
 
4994
5230
  /***/ }),
4995
5231
 
@@ -5148,10 +5384,12 @@ const inline_1 = __webpack_require__(1160);
5148
5384
 
5149
5385
  const source_1 = __webpack_require__(6743);
5150
5386
 
5151
- const util_1 = __webpack_require__(9437);
5387
+ const visibility_1 = __webpack_require__(7618);
5152
5388
 
5153
5389
  const dom_1 = __webpack_require__(3252);
5154
5390
 
5391
+ const duff_1 = __webpack_require__(8099);
5392
+
5155
5393
  const array_1 = __webpack_require__(8112);
5156
5394
 
5157
5395
  exports.table = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^\|[^\n]*(?:\n\|[^\n]*){2}/, (0, combinator_1.sequence)([row((0, combinator_1.some)(head), true), row((0, combinator_1.some)(align), false), (0, combinator_1.some)(row((0, combinator_1.some)(data), true))])), rows => [(0, dom_1.html)('table', [(0, dom_1.html)('thead', [rows.shift()]), (0, dom_1.html)('tbody', format(rows))])])));
@@ -5165,23 +5403,21 @@ const row = (parser, optional) => (0, combinator_1.creator)((0, combinator_1.fal
5165
5403
 
5166
5404
  const align = (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.open)('|', (0, combinator_1.union)([(0, combinator_1.focus)(/^:-+:/, () => [['center'], '']), (0, combinator_1.focus)(/^:-+/, () => [['start'], '']), (0, combinator_1.focus)(/^-+:/, () => [['end'], '']), (0, combinator_1.focus)(/^-+/, () => [[''], ''])])), ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]));
5167
5405
  const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /^\|/, [[/^[|\\]?\s*$/, 9]]), /^[^|]*/, true);
5168
- const head = (0, combinator_1.creator)((0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, util_1.trimNode)((0, dom_1.defrag)(ns)))]));
5169
- const data = (0, combinator_1.creator)((0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, util_1.trimNode)((0, dom_1.defrag)(ns)))]));
5406
+ const head = (0, combinator_1.creator)((0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
5407
+ const data = (0, combinator_1.creator)((0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))]));
5170
5408
 
5171
5409
  function format(rows) {
5172
- const aligns = rows[0].classList.contains('invalid') ? [] : (0, array_1.push)([], rows.shift().children).map(el => el.textContent);
5173
-
5174
- for (let i = 0, len = rows.length; i < len; ++i) {
5175
- const cols = rows[i].children;
5410
+ const aligns = rows[0].classList.contains('invalid') ? [] : (0, duff_1.duffReduce)(rows.shift().children, (acc, el) => (0, array_1.push)(acc, [el.textContent]), []);
5176
5411
 
5177
- for (let i = 0, len = cols.length; i < len; ++i) {
5412
+ for (let i = 0; i < rows.length; ++i) {
5413
+ (0, duff_1.duffEach)(rows[i].children, (col, i) => {
5178
5414
  if (i > 0 && !aligns[i]) {
5179
5415
  aligns[i] = aligns[i - 1];
5180
5416
  }
5181
5417
 
5182
- if (!aligns[i]) continue;
5183
- cols[i].setAttribute('align', aligns[i]);
5184
- }
5418
+ if (!aligns[i]) return;
5419
+ col.setAttribute('align', aligns[i]);
5420
+ });
5185
5421
  }
5186
5422
 
5187
5423
  return rows;
@@ -5208,20 +5444,16 @@ const ilist_1 = __webpack_require__(238);
5208
5444
 
5209
5445
  const inline_1 = __webpack_require__(1160);
5210
5446
 
5211
- const util_1 = __webpack_require__(9437);
5447
+ const visibility_1 = __webpack_require__(7618);
5212
5448
 
5213
5449
  const dom_1 = __webpack_require__(3252);
5214
5450
 
5215
5451
  const array_1 = __webpack_require__(8112);
5216
5452
 
5217
- exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.context)({
5218
- syntax: {
5219
- inline: {
5220
- media: false
5221
- }
5222
- }
5223
- }, exports.ulist_))));
5224
- exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, util_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
5453
+ exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.state)(2
5454
+ /* State.media */
5455
+ , exports.ulist_))));
5456
+ exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
5225
5457
  exports.checkbox = (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, source => [[(0, dom_1.html)('span', {
5226
5458
  class: 'checkbox'
5227
5459
  }, source[1].trimStart() ? '☑' : '☐')], '']);
@@ -5242,6 +5474,30 @@ function format(el) {
5242
5474
 
5243
5475
  /***/ }),
5244
5476
 
5477
+ /***/ 6484:
5478
+ /***/ ((__unused_webpack_module, exports) => {
5479
+
5480
+ "use strict";
5481
+
5482
+
5483
+ Object.defineProperty(exports, "__esModule", ({
5484
+ value: true
5485
+ }));
5486
+ exports.backtrackable = void 0;
5487
+ exports.backtrackable = 0 | 64
5488
+ /* State.annotation */
5489
+ | 32
5490
+ /* State.reference */
5491
+ | 16
5492
+ /* State.index */
5493
+ | 4
5494
+ /* State.link */
5495
+ | 2
5496
+ /* State.media */
5497
+ ;
5498
+
5499
+ /***/ }),
5500
+
5245
5501
  /***/ 5702:
5246
5502
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5247
5503
 
@@ -5408,28 +5664,23 @@ const inline_1 = __webpack_require__(1160);
5408
5664
 
5409
5665
  const link_1 = __webpack_require__(9628);
5410
5666
 
5411
- const util_1 = __webpack_require__(9437);
5667
+ const visibility_1 = __webpack_require__(7618);
5412
5668
 
5413
5669
  const dom_1 = __webpack_require__(3252);
5414
5670
 
5415
- exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.recursion)((0, combinator_1.precedence)(6, (0, combinator_1.validate)('((', (0, combinator_1.surround)('((', (0, combinator_1.guard)(context => context.syntax?.inline?.annotation ?? true, (0, util_1.startLoose)((0, combinator_1.context)({
5416
- syntax: {
5417
- inline: {
5418
- annotation: false,
5419
- // Redundant
5420
- //reference: true,
5421
- media: false // Redundant
5422
- //index: true,
5423
- //label: true,
5424
- //link: true,
5425
- //autolink: true,
5426
-
5427
- }
5428
- },
5671
+ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('((', (0, combinator_1.syntax)(32
5672
+ /* Rule.annotation */
5673
+ , 6, (0, combinator_1.surround)('((', (0, combinator_1.guard)(context => ~context.state & 64
5674
+ /* State.annotation */
5675
+ , (0, combinator_1.state)(64
5676
+ /* State.annotation */
5677
+ | 2
5678
+ /* State.media */
5679
+ , (0, visibility_1.startLoose)((0, combinator_1.context)({
5429
5680
  delimiters: global_1.undefined
5430
- }, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])), ')')), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
5681
+ }, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])), ')'))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
5431
5682
  class: 'annotation'
5432
- }, [(0, dom_1.html)('span', (0, util_1.trimNode)((0, dom_1.defrag)(ns)))])], rest], ([, ns, rest], next) => next[0] === ')' ? global_1.undefined : (0, link_1.optimize)('((', ns, rest)))))));
5683
+ }, [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest], ([, ns, rest], next) => next[0] === ')' ? global_1.undefined : (0, link_1.optimize)('((', ns, rest, next)))));
5433
5684
 
5434
5685
  /***/ }),
5435
5686
 
@@ -5464,11 +5715,15 @@ const source_1 = __webpack_require__(6743);
5464
5715
 
5465
5716
  const util_1 = __webpack_require__(9437);
5466
5717
 
5467
- exports.autolink = (0, combinator_1.fmap)((0, combinator_1.validate)(/^(?:[@#>0-9A-Za-z]|\S#)/, (0, combinator_1.guard)(context => context.syntax?.inline?.autolink ?? true, (0, combinator_1.some)((0, combinator_1.union)([url_1.url, email_1.email, // Escape unmatched email-like strings.
5718
+ exports.autolink = (0, combinator_1.fmap)((0, combinator_1.validate)(/^(?:[@#>0-9A-Za-z]|\S#)/, (0, combinator_1.guard)(context => ~context.state & 1
5719
+ /* State.autolink */
5720
+ , (0, combinator_1.syntax)(2
5721
+ /* Rule.autolink */
5722
+ , 1, (0, combinator_1.some)((0, combinator_1.union)([url_1.url, email_1.email, // Escape unmatched email-like strings.
5468
5723
  (0, source_1.str)(/^[0-9A-Za-z]+(?:[.+_-][0-9A-Za-z]+)*(?:@(?:[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?)+/), channel_1.channel, account_1.account, // Escape unmatched account-like strings.
5469
5724
  (0, source_1.str)(/^@+[0-9A-Za-z]*(?:-[0-9A-Za-z]+)*/), // Escape invalid leading characters.
5470
5725
  (0, source_1.str)(new RegExp(/^(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])(?=#)/u.source.replace('emoji', hashtag_1.emoji), 'u')), hashtag_1.hashtag, hashnum_1.hashnum, // Escape unmatched hashtag-like strings.
5471
- (0, source_1.str)(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])*/u.source.replace('emoji', hashtag_1.emoji), 'u')), anchor_1.anchor])))), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)]);
5726
+ (0, source_1.str)(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])*/u.source.replace('emoji', hashtag_1.emoji), 'u')), anchor_1.anchor]))))), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)]);
5472
5727
 
5473
5728
  /***/ }),
5474
5729
 
@@ -5690,12 +5945,26 @@ const dom_1 = __webpack_require__(3252);
5690
5945
  const array_1 = __webpack_require__(8112);
5691
5946
 
5692
5947
  const index = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*/;
5693
- exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creator)(0, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(2, (0, source_1.str)(index)), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, ')', [[')', 2]])), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
5948
+ exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.syntax)(0
5949
+ /* Rule.none */
5950
+ , 2, (0, source_1.str)(index)), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.syntax)(128
5951
+ /* Rule.bracket */
5952
+ , 2, (0, combinator_1.some)(inline_1.inline, ')', [[')', 2]])), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
5694
5953
  class: 'paren'
5695
- }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)([''], (0, array_1.unshift)(as, bs)), rest]), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(2, (0, source_1.str)(new RegExp(index.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0))))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, ')', [[')', 2]])), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
5954
+ }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)([''], (0, array_1.unshift)(as, bs)), rest]), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.syntax)(0
5955
+ /* Rule.none */
5956
+ , 2, (0, source_1.str)(new RegExp(index.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0))))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.syntax)(128
5957
+ /* Rule.bracket */
5958
+ , 2, (0, combinator_1.some)(inline_1.inline, ')', [[')', 2]])), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
5696
5959
  class: 'paren'
5697
- }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, ']', [[']', 2]])), (0, source_1.str)(']'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)([''], (0, array_1.unshift)(as, bs)), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '}', [['}', 2]])), (0, source_1.str)('}'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), // Control media blinking in editing rather than control confusion of pairs of quote marks.
5698
- (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(8, (0, combinator_1.some)(inline_1.inline, '"', [['"', 8]])), (0, source_1.str)('"'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])])));
5960
+ }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.syntax)(128
5961
+ /* Rule.bracket */
5962
+ , 2, (0, combinator_1.some)(inline_1.inline, ']', [[']', 2]])), (0, source_1.str)(']'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)([''], (0, array_1.unshift)(as, bs)), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.syntax)(128
5963
+ /* Rule.bracket */
5964
+ , 2, (0, combinator_1.some)(inline_1.inline, '}', [['}', 2]])), (0, source_1.str)('}'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), // Control media blinking in editing rather than control confusion of pairs of quote marks.
5965
+ (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.syntax)(1
5966
+ /* Rule.quote */
5967
+ , 8, (0, combinator_1.some)(inline_1.inline, '"', [['"', 8]])), (0, source_1.str)('"'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])]));
5699
5968
 
5700
5969
  /***/ }),
5701
5970
 
@@ -5747,11 +6016,13 @@ const memoize_1 = __webpack_require__(1808);
5747
6016
 
5748
6017
  const array_1 = __webpack_require__(8112);
5749
6018
 
5750
- exports.comment = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[%', (0, combinator_1.creator)((0, combinator_1.precedence)(4, (0, combinator_1.match)(/^\[(%+)\s/, (0, memoize_1.memoize)(([, fence]) => (0, combinator_1.surround)((0, combinator_1.open)((0, source_1.str)(`[${fence}`), (0, combinator_1.some)(source_1.text, new RegExp(String.raw`^\s+${fence}\]|^\S`)), true), (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), new RegExp(String.raw`^\s+${fence}\]`), [[new RegExp(String.raw`^\s+${fence}\]`), 4]]), (0, combinator_1.close)((0, combinator_1.some)(source_1.text, /^\S/), (0, source_1.str)(`${fence}]`)), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
6019
+ exports.comment = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[%', (0, combinator_1.syntax)(0
6020
+ /* Rule.none */
6021
+ , 4, (0, combinator_1.match)(/^\[(%+)\s/, (0, memoize_1.memoize)(([, fence]) => (0, combinator_1.surround)((0, combinator_1.open)((0, source_1.str)(`[${fence}`), (0, combinator_1.some)(source_1.text, new RegExp(String.raw`^\s+${fence}\]|^\S`)), true), (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), new RegExp(String.raw`^\s+${fence}\]`), [[new RegExp(String.raw`^\s+${fence}\]`), 4]]), (0, combinator_1.close)((0, combinator_1.some)(source_1.text, /^\S/), (0, source_1.str)(`${fence}]`)), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
5751
6022
  class: 'comment'
5752
6023
  }, [(0, dom_1.html)('input', {
5753
6024
  type: 'checkbox'
5754
- }), (0, dom_1.html)('span', (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))])], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), ([, fence]) => fence.length, []))))));
6025
+ }), (0, dom_1.html)('span', (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))])], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), ([, fence]) => fence.length, [])))));
5755
6026
 
5756
6027
  /***/ }),
5757
6028
 
@@ -5772,13 +6043,15 @@ const inline_1 = __webpack_require__(1160);
5772
6043
 
5773
6044
  const source_1 = __webpack_require__(6743);
5774
6045
 
5775
- const util_1 = __webpack_require__(9437);
6046
+ const visibility_1 = __webpack_require__(7618);
5776
6047
 
5777
6048
  const dom_1 = __webpack_require__(3252);
5778
6049
 
5779
6050
  const array_1 = __webpack_require__(8112);
5780
6051
 
5781
- exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.precedence)(1, (0, combinator_1.surround)((0, source_1.str)('~~'), (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('\n', '~~')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '~'), true)])), (0, source_1.str)('~~'), false, ([, bs], rest) => [[(0, dom_1.html)('del', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]))));
6052
+ exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
6053
+ /* Rule.none */
6054
+ , 1, (0, combinator_1.surround)((0, source_1.str)('~~'), (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '~~')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '~'), true)])), (0, source_1.str)('~~'), false, ([, bs], rest) => [[(0, dom_1.html)('del', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
5782
6055
 
5783
6056
  /***/ }),
5784
6057
 
@@ -5803,13 +6076,15 @@ const strong_1 = __webpack_require__(8072);
5803
6076
 
5804
6077
  const source_1 = __webpack_require__(6743);
5805
6078
 
5806
- const util_1 = __webpack_require__(9437);
6079
+ const visibility_1 = __webpack_require__(7618);
5807
6080
 
5808
6081
  const dom_1 = __webpack_require__(3252);
5809
6082
 
5810
6083
  const array_1 = __webpack_require__(8112);
5811
6084
 
5812
- exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.precedence)(1, (0, combinator_1.surround)((0, source_1.str)('*'), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([strong_1.strong, (0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, strong_1.strong, exports.emphasis]))])), '*'), (0, source_1.str)('*'), false, ([, bs], rest) => [[(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]))));
6085
+ exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
6086
+ /* Rule.none */
6087
+ , 1, (0, combinator_1.surround)((0, source_1.str)('*'), (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([strong_1.strong, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, strong_1.strong, exports.emphasis]))])), '*'), (0, source_1.str)('*'), false, ([, bs], rest) => [[(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
5813
6088
 
5814
6089
  /***/ }),
5815
6090
 
@@ -5834,15 +6109,17 @@ const emphasis_1 = __webpack_require__(3867);
5834
6109
 
5835
6110
  const source_1 = __webpack_require__(6743);
5836
6111
 
5837
- const util_1 = __webpack_require__(9437);
6112
+ const visibility_1 = __webpack_require__(7618);
5838
6113
 
5839
6114
  const dom_1 = __webpack_require__(3252);
5840
6115
 
5841
6116
  const array_1 = __webpack_require__(8112);
5842
6117
 
5843
- const substrong = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('**')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([exports.emstrong, strong_1.strong]))])));
5844
- const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([strong_1.strong, (0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([exports.emstrong, strong_1.strong, emphasis_1.emphasis]))])));
5845
- exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.precedence)(1, (0, combinator_1.surround)((0, source_1.str)('***'), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)]))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], rest, context) => {
6118
+ const substrong = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('**')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([exports.emstrong, strong_1.strong]))])));
6119
+ const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([strong_1.strong, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([exports.emstrong, strong_1.strong, emphasis_1.emphasis]))])));
6120
+ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
6121
+ /* Rule.none */
6122
+ , 1, (0, combinator_1.surround)((0, source_1.str)('***'), (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)]))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], rest, context) => {
5846
6123
  switch (cs[0]) {
5847
6124
  case '***':
5848
6125
  return [[(0, dom_1.html)('em', [(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))])], rest];
@@ -5853,7 +6130,7 @@ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, co
5853
6130
  case '*':
5854
6131
  return (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' ? [[(0, dom_1.html)('strong', (0, array_1.unshift)([(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds)))], rest.slice(2)] : [(0, array_1.unshift)(['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], ds), rest])(rest, context) ?? [['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest];
5855
6132
  }
5856
- }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]))));
6133
+ }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
5857
6134
 
5858
6135
  /***/ }),
5859
6136
 
@@ -5939,28 +6216,34 @@ const indexee_1 = __webpack_require__(1269);
5939
6216
 
5940
6217
  const source_1 = __webpack_require__(6743);
5941
6218
 
5942
- const util_1 = __webpack_require__(9437);
6219
+ const visibility_1 = __webpack_require__(7618);
5943
6220
 
5944
6221
  const dom_1 = __webpack_require__(3252);
5945
6222
 
5946
- exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.creator)((0, combinator_1.precedence)(2, (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.guard)(context => context.syntax?.inline?.index ?? true, (0, util_1.startTight)((0, combinator_1.context)({
5947
- syntax: {
5948
- inline: {
5949
- annotation: false,
5950
- reference: false,
5951
- index: false,
5952
- label: false,
5953
- link: false,
5954
- media: false,
5955
- autolink: false
5956
- }
5957
- }
5958
- }, (0, combinator_1.open)((0, source_1.stropt)(/^\|?/), (0, util_1.trimBlankEnd)((0, combinator_1.some)((0, combinator_1.union)([signature, inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]])), true)))), ']', false, ([, ns], rest) => [[(0, dom_1.html)('a', (0, dom_1.defrag)(ns))], rest])), ([el]) => [(0, dom_1.define)(el, {
6223
+ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.syntax)(1024
6224
+ /* Rule.index */
6225
+ , 2, (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.guard)(context => ~context.state & 16
6226
+ /* State.index */
6227
+ , (0, combinator_1.state)(64
6228
+ /* State.annotation */
6229
+ | 32
6230
+ /* State.reference */
6231
+ | 16
6232
+ /* State.index */
6233
+ | 8
6234
+ /* State.label */
6235
+ | 4
6236
+ /* State.link */
6237
+ | 2
6238
+ /* State.media */
6239
+ | 1
6240
+ /* State.autolink */
6241
+ , (0, visibility_1.startTight)((0, combinator_1.open)((0, source_1.stropt)(/^\|?/), (0, visibility_1.trimBlankEnd)((0, combinator_1.some)((0, combinator_1.union)([signature, inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]])), true)))), ']', false, ([, ns], rest) => [[(0, dom_1.html)('a', (0, dom_1.defrag)(ns))], rest])), ([el]) => [(0, dom_1.define)(el, {
5959
6242
  id: el.id ? null : global_1.undefined,
5960
6243
  class: 'index',
5961
6244
  href: el.id ? `#${el.id}` : global_1.undefined
5962
- }, el.childNodes)])))));
5963
- const signature = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.open)('|#', (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ']'))), ns => [(0, dom_1.html)('span', {
6245
+ }, el.childNodes)]))));
6246
+ const signature = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.open)('|#', (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ']'))), ns => [(0, dom_1.html)('span', {
5964
6247
  class: 'indexer',
5965
6248
  'data-index': (0, indexee_1.identity)(ns.join('')).slice(6)
5966
6249
  })])));
@@ -5985,6 +6268,8 @@ const combinator_1 = __webpack_require__(2087);
5985
6268
 
5986
6269
  const dom_1 = __webpack_require__(3252);
5987
6270
 
6271
+ const duff_1 = __webpack_require__(8099);
6272
+
5988
6273
  function indexee(parser, optional) {
5989
6274
  return (0, combinator_1.fmap)(parser, ([el], _, {
5990
6275
  id
@@ -6008,41 +6293,37 @@ function text(source, optional = false) {
6008
6293
  const index = indexer?.getAttribute('data-index');
6009
6294
  if (index) return index;
6010
6295
  const target = source.cloneNode(true);
6011
-
6012
- for (let es = target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference, .checkbox, ul, ol'), i = 0, len = es.length; i < len; ++i) {
6013
- const el = es[i];
6014
-
6296
+ (0, duff_1.duffEach)(target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference, .checkbox, ul, ol'), el => {
6015
6297
  switch (el.tagName) {
6016
6298
  case 'CODE':
6017
6299
  (0, dom_1.define)(el, el.getAttribute('data-src'));
6018
- continue;
6300
+ return;
6019
6301
 
6020
6302
  case 'RT':
6021
6303
  case 'RP':
6022
6304
  case 'UL':
6023
6305
  case 'OL':
6024
6306
  el.remove();
6025
- continue;
6307
+ return;
6026
6308
  }
6027
6309
 
6028
6310
  switch (el.className) {
6029
6311
  case 'math':
6030
6312
  (0, dom_1.define)(el, el.getAttribute('data-src'));
6031
- continue;
6313
+ return;
6032
6314
 
6033
6315
  case 'comment':
6034
6316
  case 'checkbox':
6035
6317
  el.remove();
6036
- continue;
6318
+ return;
6037
6319
 
6038
6320
  case 'reference':
6039
6321
  el.firstChild.remove();
6040
- continue;
6322
+ return;
6041
6323
  }
6042
- } // Better:
6324
+ }); // Better:
6043
6325
  //return target.innerText;
6044
6326
 
6045
-
6046
6327
  return target.textContent;
6047
6328
  }
6048
6329
 
@@ -6065,11 +6346,11 @@ const combinator_1 = __webpack_require__(2087);
6065
6346
 
6066
6347
  const index_1 = __webpack_require__(4479);
6067
6348
 
6068
- const util_1 = __webpack_require__(9437);
6069
-
6070
6349
  const dom_1 = __webpack_require__(3252);
6071
6350
 
6072
- exports.indexer = (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.surround)(/^\s+(?=\[#\S)/, (0, util_1.clean)((0, combinator_1.union)([(0, combinator_1.focus)('[#]', () => [[(0, dom_1.html)('a', {
6351
+ exports.indexer = (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.surround)(/^\s+(?=\[#\S)/, (0, combinator_1.state)(16
6352
+ /* State.index */
6353
+ , false, (0, combinator_1.union)([(0, combinator_1.focus)('[#]', () => [[(0, dom_1.html)('a', {
6073
6354
  href: '#'
6074
6355
  })], '']), index_1.index])), /^\s*$/), // Indexer is invisible but invalids must be visible.
6075
6356
  ([el]) => el.getElementsByClassName('invalid').length === 0), ([el]) => [(0, dom_1.html)('span', {
@@ -6100,7 +6381,9 @@ const dom_1 = __webpack_require__(3252);
6100
6381
 
6101
6382
  const body = (0, source_1.str)(/^\$[A-Za-z]*(?:(?:-[A-Za-z][0-9A-Za-z]*)+|-(?:(?:0|[1-9][0-9]*)\.)*(?:0|[1-9][0-9]*)(?![0-9A-Za-z]))/);
6102
6383
  exports.segment = (0, combinator_1.clear)((0, combinator_1.validate)(['[$', '$'], (0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']'), body])));
6103
- exports.label = (0, combinator_1.validate)(['[$', '$'], (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.guard)(context => context.syntax?.inline?.label ?? true, (0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']'), body])), ([text]) => [(0, dom_1.html)('a', {
6384
+ exports.label = (0, combinator_1.validate)(['[$', '$'], (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.guard)(context => ~context.state & 8
6385
+ /* State.label */
6386
+ , (0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']'), body])), ([text]) => [(0, dom_1.html)('a', {
6104
6387
  class: 'label',
6105
6388
  'data-label': text.slice(text[1] === '-' ? 0 : 1).toLowerCase()
6106
6389
  }, text)])));
@@ -6148,7 +6431,7 @@ const inline_1 = __webpack_require__(1160);
6148
6431
 
6149
6432
  const source_1 = __webpack_require__(6743);
6150
6433
 
6151
- const util_1 = __webpack_require__(9437);
6434
+ const visibility_1 = __webpack_require__(7618);
6152
6435
 
6153
6436
  const dom_1 = __webpack_require__(3252);
6154
6437
 
@@ -6156,12 +6439,14 @@ const array_1 = __webpack_require__(8112); // Don't use the symbols already used
6156
6439
  // All syntax surrounded by square brackets shouldn't contain line breaks.
6157
6440
 
6158
6441
 
6159
- exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[:', '[^'], (0, combinator_1.creator)((0, combinator_1.precedence)(2, (0, combinator_1.surround)((0, source_1.str)(/^\[[:^]/), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]])), (0, source_1.str)(']'), false, ([as, bs], rest) => [[(0, dom_1.html)('span', {
6442
+ exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[:', '[^'], (0, combinator_1.syntax)(0
6443
+ /* Rule.none */
6444
+ , 2, (0, combinator_1.surround)((0, source_1.str)(/^\[[:^]/), (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]])), (0, source_1.str)(']'), false, ([as, bs], rest) => [[(0, dom_1.html)('span', {
6160
6445
  class: 'invalid',
6161
6446
  'data-invalid-syntax': 'extension',
6162
6447
  'data-invalid-type': 'syntax',
6163
6448
  'data-invalid-message': `Reserved start symbol "${as[0][1]}" cannot be used in "[]"`
6164
- }, (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])))));
6449
+ }, (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]))));
6165
6450
 
6166
6451
  /***/ }),
6167
6452
 
@@ -6184,7 +6469,7 @@ const inline_1 = __webpack_require__(1160);
6184
6469
 
6185
6470
  const source_1 = __webpack_require__(6743);
6186
6471
 
6187
- const util_1 = __webpack_require__(9437);
6472
+ const visibility_1 = __webpack_require__(7618);
6188
6473
 
6189
6474
  const dom_1 = __webpack_require__(3252);
6190
6475
 
@@ -6202,8 +6487,10 @@ const attrspecs = {
6202
6487
  };
6203
6488
  global_1.Object.setPrototypeOf(attrspecs, null);
6204
6489
  global_1.Object.values(attrspecs).forEach(o => global_1.Object.setPrototypeOf(o, null));
6205
- exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('<', (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/, (0, combinator_1.creator)((0, combinator_1.precedence)(5, (0, combinator_1.union)([(0, combinator_1.focus)('<wbr>', () => [[(0, dom_1.html)('wbr')], '']), (0, combinator_1.focus)( // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
6206
- /^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/, source => [[source], '']), (0, combinator_1.match)(new RegExp(String.raw`^<(${TAGS.join('|')})(?=[^\S\n]|>)`), (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true), (0, combinator_1.subsequence)([(0, combinator_1.focus)(/^[^\S\n]*\n/, (0, combinator_1.some)(inline_1.inline)), (0, combinator_1.some)((0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('\n', `</${tag}>`), [[(0, util_1.blankWith)('\n', `</${tag}>`), 5]]), true))]), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], rest) => [[elem(tag, as, bs, cs)], rest], ([as, bs = []], rest) => [[elem(tag, as, bs, [])], rest]), ([, tag]) => TAGS.indexOf(tag), [])), (0, combinator_1.match)(/^<([a-z]+)(?=[^\S\n]|>)/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true), (0, combinator_1.subsequence)([(0, combinator_1.focus)(/^[^\S\n]*\n/, (0, combinator_1.some)(inline_1.inline)), (0, combinator_1.some)(inline_1.inline, `</${tag}>`, [[`</${tag}>`, 5]])]), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], rest) => [[elem(tag, as, bs, cs)], rest], ([as, bs = []], rest) => [[elem(tag, as, bs, [])], rest]), ([, tag]) => tag, new cache_1.Cache(10000)))]))))));
6490
+ exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('<', (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/, (0, combinator_1.syntax)(0
6491
+ /* Rule.none */
6492
+ , 5, (0, combinator_1.union)([(0, combinator_1.focus)('<wbr>', () => [[(0, dom_1.html)('wbr')], '']), (0, combinator_1.focus)( // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
6493
+ /^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/, source => [[source], '']), (0, combinator_1.match)(new RegExp(String.raw`^<(${TAGS.join('|')})(?=[^\S\n]|>)`), (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true), (0, combinator_1.subsequence)([(0, combinator_1.focus)(/^[^\S\n]*\n/, (0, combinator_1.some)(inline_1.inline)), (0, combinator_1.some)((0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', `</${tag}>`), [[(0, visibility_1.blankWith)('\n', `</${tag}>`), 5]]), true))]), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], rest) => [[elem(tag, as, bs, cs)], rest], ([as, bs = []], rest) => [[elem(tag, as, bs, [])], rest]), ([, tag]) => TAGS.indexOf(tag), [])), (0, combinator_1.match)(/^<([a-z]+)(?=[^\S\n]|>)/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true), (0, combinator_1.subsequence)([(0, combinator_1.focus)(/^[^\S\n]*\n/, (0, combinator_1.some)(inline_1.inline)), (0, combinator_1.some)(inline_1.inline, `</${tag}>`, [[`</${tag}>`, 5]])]), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], rest) => [[elem(tag, as, bs, cs)], rest], ([as, bs = []], rest) => [[elem(tag, as, bs, [])], rest]), ([, tag]) => tag, new cache_1.Cache(10000)))])))));
6207
6494
  exports.attribute = (0, combinator_1.union)([(0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/)]); // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
6208
6495
  // [...document.querySelectorAll('tbody > tr > td:first-child')].map(el => el.textContent.slice(1, -1))
6209
6496
 
@@ -6213,7 +6500,7 @@ function elem(tag, as, bs, cs) {
6213
6500
  if (!tags.includes(tag)) return invalid('tag', `Invalid HTML tag name "${tag}"`, as, bs, cs);
6214
6501
  if (cs.length === 0) return invalid('tag', `Missing the closing HTML tag "</${tag}>"`, as, bs, cs);
6215
6502
  if (bs.length === 0) return invalid('content', `Missing the content`, as, bs, cs);
6216
- if (!(0, util_1.isStartLooseNodes)(bs)) return invalid('content', `Missing the visible content in the same line`, as, bs, cs);
6503
+ if (!(0, visibility_1.isStartLooseNodes)(bs)) return invalid('content', `Missing the visible content in the same line`, as, bs, cs);
6217
6504
  const attrs = attributes('html', [], attrspecs[tag], as.slice(1, -1));
6218
6505
  return 'data-invalid-syntax' in attrs ? invalid('attribute', 'Invalid HTML attribute', as, bs, cs) : (0, dom_1.html)(tag, attrs, (0, dom_1.defrag)(bs));
6219
6506
  }
@@ -6311,13 +6598,15 @@ const inline_1 = __webpack_require__(1160);
6311
6598
 
6312
6599
  const source_1 = __webpack_require__(6743);
6313
6600
 
6314
- const util_1 = __webpack_require__(9437);
6601
+ const visibility_1 = __webpack_require__(7618);
6315
6602
 
6316
6603
  const dom_1 = __webpack_require__(3252);
6317
6604
 
6318
6605
  const array_1 = __webpack_require__(8112);
6319
6606
 
6320
- exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.precedence)(1, (0, combinator_1.surround)((0, source_1.str)('++'), (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('\n', '++')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '+'), true)])), (0, source_1.str)('++'), false, ([, bs], rest) => [[(0, dom_1.html)('ins', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]))));
6607
+ exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
6608
+ /* Rule.none */
6609
+ , 1, (0, combinator_1.surround)((0, source_1.str)('++'), (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '++')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '+'), true)])), (0, source_1.str)('++'), false, ([, bs], rest) => [[(0, dom_1.html)('ins', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
6321
6610
 
6322
6611
  /***/ }),
6323
6612
 
@@ -6346,6 +6635,8 @@ const autolink_1 = __webpack_require__(6578);
6346
6635
 
6347
6636
  const source_1 = __webpack_require__(6743);
6348
6637
 
6638
+ const visibility_1 = __webpack_require__(7618);
6639
+
6349
6640
  const util_1 = __webpack_require__(9437);
6350
6641
 
6351
6642
  const dom_1 = __webpack_require__(3252);
@@ -6356,43 +6647,49 @@ const optspec = {
6356
6647
  rel: ['nofollow']
6357
6648
  };
6358
6649
  Object.setPrototypeOf(optspec, null);
6359
- exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.creator)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.guard)(context => context.syntax?.inline?.link ?? true, (0, combinator_1.fmap)((0, combinator_1.subsequence)([(0, combinator_1.context)({
6360
- syntax: {
6361
- inline: {
6362
- link: false
6363
- }
6364
- }
6365
- }, (0, combinator_1.dup)((0, combinator_1.union)([(0, combinator_1.surround)('[', inline_1.media, ']'), (0, combinator_1.surround)('[', inline_1.shortmedia, ']'), (0, combinator_1.surround)('[', (0, combinator_1.context)({
6366
- syntax: {
6367
- inline: {
6368
- annotation: false,
6369
- reference: false,
6370
- index: false,
6371
- label: false,
6372
- // Redundant
6373
- //link: false,
6374
- media: false,
6375
- autolink: false
6376
- }
6377
- }
6378
- }, (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2]])), ']', true, global_1.undefined, ([, ns = [], rest], next) => next[0] === ']' ? global_1.undefined : optimize('[', ns, rest))]))), // 全体の失敗が確定した時も解析し予算を浪費している
6379
- (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))]), ([as, bs = []]) => bs[0] === '\r' && bs.shift() ? [as, bs] : as[0] === '\r' && as.shift() ? [[], as] : [as, []])), ([content, params], rest, context) => {
6380
- if (params.length === 0) return;
6650
+ exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.syntax)(256
6651
+ /* Rule.link */
6652
+ , 2, 10, (0, combinator_1.bind)((0, combinator_1.guard)(context => ~context.state & 4
6653
+ /* State.link */
6654
+ , (0, combinator_1.fmap)((0, combinator_1.subsequence)([(0, combinator_1.state)(4
6655
+ /* State.link */
6656
+ , (0, combinator_1.dup)((0, combinator_1.union)([(0, combinator_1.surround)('[', inline_1.media, ']'), (0, combinator_1.surround)('[', inline_1.shortmedia, ']'), (0, combinator_1.surround)('[', (0, combinator_1.state)(64
6657
+ /* State.annotation */
6658
+ | 32
6659
+ /* State.reference */
6660
+ | 16
6661
+ /* State.index */
6662
+ | 8
6663
+ /* State.label */
6664
+ | 2
6665
+ /* State.media */
6666
+ | 1
6667
+ /* State.autolink */
6668
+ , (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2]])), ']', true, global_1.undefined, ([, ns = [], rest], next) => next[0] === ']' ? global_1.undefined : optimize('[', ns, rest, next))]))), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))], nodes => nodes[0][0] !== ''), ([as, bs = []]) => bs[0] === '\r' && bs.shift() ? [as, bs] : as[0] === '\r' && as.shift() ? [[], as] : [as, []])), ([content, params], rest, context) => {
6381
6669
  if (content[0] === '') return [content, rest];
6382
- if (content.length !== 0 && (0, util_1.trimNode)(content).length === 0) return;
6383
- if ((0, parser_1.eval)((0, combinator_1.some)(autolink_1.autolink)((0, util_1.stringify)(content), context))?.some(node => typeof node === 'object')) return;
6670
+ if (params.length === 0) return;
6671
+ if (content.length !== 0 && (0, visibility_1.trimNode)(content).length === 0) return;
6672
+
6673
+ for (let source = (0, util_1.stringify)(content); source;) {
6674
+ const result = (0, autolink_1.autolink)(source, context);
6675
+ if (typeof (0, parser_1.eval)(result)[0] === 'object') return;
6676
+ source = (0, parser_1.exec)(result);
6677
+ }
6678
+
6384
6679
  const INSECURE_URI = params.shift();
6385
6680
  const el = elem(INSECURE_URI, (0, dom_1.defrag)(content), new url_1.ReadonlyURL(resolve(INSECURE_URI, context.host ?? global_1.location, context.url ?? context.host ?? global_1.location), context.host?.href || global_1.location.href), context.host?.origin || global_1.location.origin);
6386
6681
  if (el.classList.contains('invalid')) return [[el], rest];
6387
6682
  return [[(0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))], rest];
6388
- })))));
6389
- exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.creator)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => {
6683
+ }))));
6684
+ exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.syntax)(256
6685
+ /* Rule.link */
6686
+ , 2, 10, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => {
6390
6687
  params.shift();
6391
- (0, util_1.trimNode)(content);
6688
+ (0, visibility_1.trimNode)(content);
6392
6689
  const INSECURE_URI = params.shift();
6393
6690
  const el = elem(INSECURE_URI, (0, dom_1.defrag)(content), new url_1.ReadonlyURL(resolve(INSECURE_URI, context.host ?? global_1.location, context.url ?? context.host ?? global_1.location), context.host?.href || global_1.location.href), context.host?.origin || global_1.location.origin);
6394
6691
  return [[(0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))], rest];
6395
- })))));
6692
+ }))));
6396
6693
  exports.uri = (0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)), (0, source_1.str)(/^[^\s{}]+/)]), ([uri]) => ['\r', uri]);
6397
6694
  exports.option = (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+nofollow(?=[^\S\n]|})/), () => [` rel="nofollow"`]), (0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|})/), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[^\s{}]+/), opt => [` \\${opt.slice(1)}`])]);
6398
6695
 
@@ -6470,12 +6767,15 @@ function decode(uri) {
6470
6767
  }
6471
6768
  }
6472
6769
 
6473
- function optimize(opener, ns, rest) {
6770
+ function optimize(opener, ns, rest, next) {
6771
+ if (next[+(next[0] === '\\')] === '\n') return;
6474
6772
  let count = 0;
6475
6773
 
6476
6774
  for (let i = 0; i < ns.length - 1; i += 2) {
6477
- if (ns[i] !== '' || ns[i + 1] !== opener[0]) break;
6478
- ++count;
6775
+ const fst = ns[i];
6776
+ const snd = ns[i + 1];
6777
+ if (fst !== '' || snd[0] !== opener[0]) break;
6778
+ count += snd.length;
6479
6779
  }
6480
6780
 
6481
6781
  return [['', opener[0].repeat(opener.length + count)], rest.slice(count)];
@@ -6502,13 +6802,15 @@ const inline_1 = __webpack_require__(1160);
6502
6802
 
6503
6803
  const source_1 = __webpack_require__(6743);
6504
6804
 
6505
- const util_1 = __webpack_require__(9437);
6805
+ const visibility_1 = __webpack_require__(7618);
6506
6806
 
6507
6807
  const dom_1 = __webpack_require__(3252);
6508
6808
 
6509
6809
  const array_1 = __webpack_require__(8112);
6510
6810
 
6511
- exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.precedence)(1, (0, combinator_1.surround)((0, source_1.str)('=='), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('==')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '='), exports.mark)]))), (0, source_1.str)('=='), false, ([, bs], rest) => [[(0, dom_1.html)('mark', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]))));
6811
+ exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
6812
+ /* Rule.none */
6813
+ , 1, (0, combinator_1.surround)((0, source_1.str)('=='), (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('==')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '='), exports.mark)]))), (0, source_1.str)('=='), false, ([, bs], rest) => [[(0, dom_1.html)('mark', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
6512
6814
 
6513
6815
  /***/ }),
6514
6816
 
@@ -6585,7 +6887,11 @@ const optspec = {
6585
6887
  rel: global_1.undefined
6586
6888
  };
6587
6889
  Object.setPrototypeOf(optspec, null);
6588
- exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creator)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.open)('!', (0, combinator_1.guard)(context => context.syntax?.inline?.media ?? true, (0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']', [[/^\\?\n/, 9]]), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/))]))), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], (0, array_1.shift)(bs)[1]] : [[''], (0, array_1.shift)(as)[1]]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
6890
+ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.syntax)(64
6891
+ /* Rule.media */
6892
+ , 2, 10, (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.open)('!', (0, combinator_1.guard)(context => ~context.state & 2
6893
+ /* State.media */
6894
+ , (0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']', [[/^\\?\n/, 9]]), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/))]))), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], (0, array_1.shift)(bs)[1]] : [[''], (0, array_1.shift)(as)[1]]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
6589
6895
  const INSECURE_URI = params.shift();
6590
6896
  const url = new url_1.ReadonlyURL((0, link_1.resolve)(INSECURE_URI, context.host ?? global_1.location, context.url ?? context.host ?? global_1.location), context.host?.href || global_1.location.href);
6591
6897
  let cache;
@@ -6603,12 +6909,14 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '
6603
6909
  el.style.aspectRatio = el.getAttribute('aspect-ratio');
6604
6910
  }
6605
6911
 
6606
- if (context.syntax?.inline?.link === false || cache && cache.tagName !== 'IMG') return [[el], rest];
6912
+ if (context.state & 4
6913
+ /* State.link */
6914
+ || cache && cache.tagName !== 'IMG') return [[el], rest];
6607
6915
  return (0, combinator_1.fmap)(link_1.textlink, ([link]) => [(0, dom_1.define)(link, {
6608
6916
  target: '_blank'
6609
6917
  }, [el])])(`{ ${INSECURE_URI}${params.join('')} }${rest}`, context);
6610
- })))));
6611
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(8, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true)]));
6918
+ }))));
6919
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(8, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true)])));
6612
6920
  const option = (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*x[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` width="${opt.slice(1).split('x')[0]}"`, ` height="${opt.slice(1).split('x')[1]}"`]), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*:[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` aspect-ratio="${opt.slice(1).split(':').join('/')}"`]), link_1.option]);
6613
6921
 
6614
6922
  function sanitize(target, uri, alt) {
@@ -6674,26 +6982,26 @@ const link_1 = __webpack_require__(9628);
6674
6982
 
6675
6983
  const source_1 = __webpack_require__(6743);
6676
6984
 
6985
+ const visibility_1 = __webpack_require__(7618);
6986
+
6677
6987
  const util_1 = __webpack_require__(9437);
6678
6988
 
6679
6989
  const dom_1 = __webpack_require__(3252);
6680
6990
 
6681
- exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[[', (0, combinator_1.creator)((0, combinator_1.recursion)((0, combinator_1.precedence)(6, (0, combinator_1.surround)('[[', (0, combinator_1.guard)(context => context.syntax?.inline?.reference ?? true, (0, util_1.startLoose)((0, combinator_1.context)({
6682
- syntax: {
6683
- inline: {
6684
- annotation: false,
6685
- reference: false,
6686
- media: false // Redundant
6687
- //index: true,
6688
- //label: true,
6689
- //link: true,
6690
- //autolink: true,
6691
-
6692
- }
6693
- },
6991
+ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[[', (0, combinator_1.syntax)(4096
6992
+ /* Rule.reference */
6993
+ , 6, (0, combinator_1.surround)('[[', (0, combinator_1.guard)(context => ~context.state & 32
6994
+ /* State.reference */
6995
+ , (0, combinator_1.state)(64
6996
+ /* State.annotation */
6997
+ | 32
6998
+ /* State.reference */
6999
+ | 2
7000
+ /* State.media */
7001
+ , (0, visibility_1.startLoose)((0, combinator_1.context)({
6694
7002
  delimiters: global_1.undefined
6695
- }, (0, combinator_1.subsequence)([abbr, (0, combinator_1.open)((0, source_1.stropt)(/^(?=\^)/), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])])), ']')), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, util_1.trimNode)((0, dom_1.defrag)(ns)))])], rest], ([, ns, rest], next) => next[0] === ']' ? global_1.undefined : (0, link_1.optimize)('[[', ns, rest)))))));
6696
- const abbr = (0, combinator_1.creator)((0, combinator_1.bind)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?![0-9]+\s?[|\]])[0-9A-Za-z]+(?:(?:-|(?=\W)(?!'\d)'?(?!\.\d)\.?(?!,\S),? ?)[0-9A-Za-z]+)*(?:-|'?\.?,? ?)?/)]), /^\|?(?=]])|^\|[^\S\n]*/), ([source], rest) => [[(0, dom_1.html)('abbr', source)], rest.replace(util_1.regBlankStart, '')]));
7003
+ }, (0, combinator_1.subsequence)([abbr, (0, combinator_1.open)((0, source_1.stropt)(/^(?=\^)/), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])])), ']'))), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest], ([, ns, rest], next) => next[0] === ']' ? global_1.undefined : (0, link_1.optimize)('[[', ns, rest, next)))));
7004
+ const abbr = (0, combinator_1.creator)((0, combinator_1.bind)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?![0-9]+\s?[|\]])[0-9A-Za-z]+(?:(?:-|(?=\W)(?!'\d)'?(?!\.\d)\.?(?!,\S),? ?)[0-9A-Za-z]+)*(?:-|'?\.?,? ?)?/)]), /^\|?(?=]])|^\|[^\S\n]*/), ([source], rest) => [[(0, dom_1.html)('abbr', source)], rest.replace(visibility_1.regBlankStart, '')]));
6697
7005
 
6698
7006
  function attributes(ns) {
6699
7007
  return typeof ns[0] === 'object' && ns[0].tagName === 'ABBR' ? {
@@ -6732,13 +7040,15 @@ const htmlentity_1 = __webpack_require__(1562);
6732
7040
 
6733
7041
  const source_1 = __webpack_require__(6743);
6734
7042
 
6735
- const util_1 = __webpack_require__(9437);
7043
+ const visibility_1 = __webpack_require__(7618);
6736
7044
 
6737
7045
  const dom_1 = __webpack_require__(3252);
6738
7046
 
6739
7047
  const array_1 = __webpack_require__(8112);
6740
7048
 
6741
- exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.sequence)([(0, combinator_1.surround)('[', (0, combinator_1.focus)(/^(?:\\[^\n]|[^\\[\](){}"\n])+(?=]\()/, text), ']'), (0, combinator_1.surround)('(', (0, combinator_1.focus)(/^(?:\\[^\n]|[^\\[\](){}"\n])+(?=\))/, text), ')')]), ([texts]) => (0, util_1.isStartTightNodes)(texts)), ([texts, rubies]) => {
7049
+ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.syntax)(0
7050
+ /* Rule.none */
7051
+ , 2, (0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.sequence)([(0, combinator_1.surround)('[', (0, combinator_1.focus)(/^(?:\\[^\n]|[^\\[\](){}"\n])+(?=]\()/, text), ']'), (0, combinator_1.surround)('(', (0, combinator_1.focus)(/^(?:\\[^\n]|[^\\[\](){}"\n])+(?=\))/, text), ')')]), ([texts]) => (0, visibility_1.isStartTightNodes)(texts)), ([texts, rubies]) => {
6742
7052
  texts[texts.length - 1] === '' && texts.pop();
6743
7053
 
6744
7054
  switch (true) {
@@ -6827,7 +7137,9 @@ const url_1 = __webpack_require__(4318);
6827
7137
 
6828
7138
  const media_1 = __webpack_require__(1303);
6829
7139
 
6830
- exports.shortmedia = (0, combinator_1.rewrite)((0, combinator_1.guard)(context => context.syntax?.inline?.media ?? true, (0, combinator_1.open)('!', url_1.url)), (0, combinator_1.convert)(source => `!{ ${source.slice(1)} }`, (0, combinator_1.union)([media_1.media])));
7140
+ exports.shortmedia = (0, combinator_1.rewrite)((0, combinator_1.guard)(context => ~context.state & 2
7141
+ /* State.media */
7142
+ , (0, combinator_1.open)('!', url_1.url)), (0, combinator_1.convert)(source => `!{ ${source.slice(1)} }`, (0, combinator_1.union)([media_1.media])));
6831
7143
 
6832
7144
  /***/ }),
6833
7145
 
@@ -6850,13 +7162,15 @@ const emstrong_1 = __webpack_require__(6132);
6850
7162
 
6851
7163
  const source_1 = __webpack_require__(6743);
6852
7164
 
6853
- const util_1 = __webpack_require__(9437);
7165
+ const visibility_1 = __webpack_require__(7618);
6854
7166
 
6855
7167
  const dom_1 = __webpack_require__(3252);
6856
7168
 
6857
7169
  const array_1 = __webpack_require__(8112);
6858
7170
 
6859
- exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.precedence)(1, (0, combinator_1.surround)((0, source_1.str)('**'), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('**')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, exports.strong]))])), '*'), (0, source_1.str)('**'), false, ([, bs], rest) => [[(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]))));
7171
+ exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
7172
+ /* Rule.none */
7173
+ , 1, (0, combinator_1.surround)((0, source_1.str)('**'), (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('**')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, exports.strong]))])), '*'), (0, source_1.str)('**'), false, ([, bs], rest) => [[(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
6860
7174
 
6861
7175
  /***/ }),
6862
7176
 
@@ -6875,16 +7189,20 @@ const global_1 = __webpack_require__(4128);
6875
7189
 
6876
7190
  const combinator_1 = __webpack_require__(2087);
6877
7191
 
7192
+ const link_1 = __webpack_require__(9628);
7193
+
6878
7194
  const source_1 = __webpack_require__(6743);
6879
7195
 
6880
7196
  const dom_1 = __webpack_require__(3252);
6881
7197
 
6882
7198
  const array_1 = __webpack_require__(8112);
6883
7199
 
6884
- exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.precedence)(2, (0, combinator_1.rewrite)((0, combinator_1.surround)('{{', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}'), '}}', true), source => [[(0, dom_1.html)('span', {
7200
+ exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
7201
+ /* Rule.none */
7202
+ , 2, (0, combinator_1.surround)('{{', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}'), '}}', true, ([, ns = []], rest) => [[(0, dom_1.html)('span', {
6885
7203
  class: 'template'
6886
- }, source.replace(/\x1B/g, ''))], '']))));
6887
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')'), (0, source_1.str)(')'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']'), (0, source_1.str)(']'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}'), (0, source_1.str)('}'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(8, (0, combinator_1.some)(source_1.escsource, /^"|^\\?\n/)), (0, source_1.str)('"'), true)]));
7204
+ }, `{{${ns.join('').replace(/\x1B/g, '')}}}`)], rest], ([, ns = [], rest], next) => next[0] === '}' ? global_1.undefined : (0, link_1.optimize)('{{', ns, rest, next))));
7205
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')'), (0, source_1.str)(')'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']'), (0, source_1.str)(']'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}'), (0, source_1.str)('}'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(8, (0, combinator_1.some)(source_1.escsource, /^"|^\\?\n/)), (0, source_1.str)('"'), true)])));
6888
7206
 
6889
7207
  /***/ }),
6890
7208
 
@@ -6905,18 +7223,16 @@ const ja_1 = __webpack_require__(1499);
6905
7223
 
6906
7224
  const dom_1 = __webpack_require__(3252);
6907
7225
 
7226
+ const duff_1 = __webpack_require__(8099);
7227
+
6908
7228
  function localize(parser) {
6909
7229
  return (0, combinator_1.fmap)(parser, ns => {
6910
7230
  if (ns.length === 0) return ns;
6911
7231
  const el = ns.length === 1 && typeof ns[0] === 'object' ? ns[0] : (0, dom_1.html)('div', ns);
6912
- const es = el.querySelectorAll('.linebreak:not(:empty)');
6913
-
6914
- for (let i = 0, len = es.length; i < len; ++i) {
6915
- const sb = es[i];
6916
- if (!check(sb)) continue;
6917
- sb.firstChild.remove();
6918
- }
6919
-
7232
+ (0, duff_1.duffEach)(el.querySelectorAll('.linebreak:not(:empty)'), el => {
7233
+ if (!check(el)) return;
7234
+ el.firstChild.remove();
7235
+ });
6920
7236
  return ns;
6921
7237
  });
6922
7238
  }
@@ -7210,12 +7526,14 @@ const dom_1 = __webpack_require__(3252);
7210
7526
 
7211
7527
  const multimap_1 = __webpack_require__(940);
7212
7528
 
7529
+ const duff_1 = __webpack_require__(8099);
7530
+
7213
7531
  const array_1 = __webpack_require__(8112);
7214
7532
 
7215
7533
  function* footnote(target, footnotes, opts = {}, bottom = null) {
7216
7534
  // Bug: Firefox
7217
7535
  //target.querySelectorAll(`:scope > .annotations`).forEach(el => el.remove());
7218
- target.querySelectorAll(`.annotations`).forEach(el => el.parentNode === target && el.remove());
7536
+ (0, duff_1.duffEach)(target.querySelectorAll(`.annotations`), el => el.parentNode === target && el.remove());
7219
7537
  yield* (0, exports.reference)(target, footnotes?.references, opts, bottom);
7220
7538
  yield* (0, exports.annotation)(target, footnotes?.annotations, opts, bottom);
7221
7539
  return;
@@ -7234,7 +7552,7 @@ function build(syntax, marker, splitter) {
7234
7552
  const titles = new global_1.Map(); // Bug: Firefox
7235
7553
  //const splitters = push([], target.querySelectorAll(`:scope > :is(${splitter ?? '_'})`));
7236
7554
 
7237
- const splitters = (0, array_1.push)([], target.querySelectorAll(splitter ?? '_')).filter(el => el.parentNode === target);
7555
+ const splitters = (0, duff_1.duffReduce)(target.querySelectorAll(splitter ?? '_'), (acc, el) => el.parentNode === target ? (0, array_1.push)(acc, [el]) : acc, []);
7238
7556
  let count = 0;
7239
7557
  let total = 0;
7240
7558
  let style;
@@ -7775,6 +8093,38 @@ exports.unescsource = (0, combinator_1.creator)(source => {
7775
8093
  /***/ }),
7776
8094
 
7777
8095
  /***/ 9437:
8096
+ /***/ ((__unused_webpack_module, exports) => {
8097
+
8098
+ "use strict";
8099
+
8100
+
8101
+ Object.defineProperty(exports, "__esModule", ({
8102
+ value: true
8103
+ }));
8104
+ exports.stringify = void 0;
8105
+
8106
+ function stringify(nodes) {
8107
+ let acc = '';
8108
+
8109
+ for (let i = 0; i < nodes.length; ++i) {
8110
+ const node = nodes[i];
8111
+
8112
+ if (typeof node === 'string') {
8113
+ acc += node;
8114
+ } else {
8115
+ // NOTE: Doesn't reflect line breaks.
8116
+ acc += node.innerText;
8117
+ }
8118
+ }
8119
+
8120
+ return acc;
8121
+ }
8122
+
8123
+ exports.stringify = stringify;
8124
+
8125
+ /***/ }),
8126
+
8127
+ /***/ 7618:
7778
8128
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7779
8129
 
7780
8130
  "use strict";
@@ -7783,7 +8133,7 @@ exports.unescsource = (0, combinator_1.creator)(source => {
7783
8133
  Object.defineProperty(exports, "__esModule", ({
7784
8134
  value: true
7785
8135
  }));
7786
- exports.stringify = exports.trimNode = exports.trimBlankEnd = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.startLoose = exports.visualize = exports.blankWith = exports.regBlankStart = exports.clean = void 0;
8136
+ exports.trimNode = exports.trimBlankEnd = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.startLoose = exports.blankWith = exports.regBlankStart = exports.visualize = void 0;
7787
8137
 
7788
8138
  const global_1 = __webpack_require__(4128);
7789
8139
 
@@ -7801,30 +8151,6 @@ const memoize_1 = __webpack_require__(1808);
7801
8151
 
7802
8152
  const array_1 = __webpack_require__(8112);
7803
8153
 
7804
- function clean(parser) {
7805
- const clean = (0, memoize_1.memoize)(context => ({
7806
- resources: context.resources,
7807
- precedence: context.precedence,
7808
- delimiters: context.delimiters,
7809
- host: context.host,
7810
- url: context.url,
7811
- id: context.id,
7812
- header: context.header,
7813
- cache: context.caches
7814
- }), new WeakMap());
7815
- return (source, context) => parser(source, context.syntax ? clean(context) : context);
7816
- }
7817
-
7818
- exports.clean = clean;
7819
- exports.regBlankStart = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
7820
-
7821
- function blankWith(starting, delimiter) {
7822
- if (delimiter === global_1.undefined) return blankWith('', starting);
7823
- return new RegExp(String.raw`^(?:(?=${starting})(?:\\?\s|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr>)${starting && '+'})?${typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source}`);
7824
- }
7825
-
7826
- exports.blankWith = blankWith;
7827
-
7828
8154
  function visualize(parser) {
7829
8155
  const blankline = new RegExp(/^(?:\\$|\\?[^\S\n]|&IHN;|<wbr>)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
7830
8156
  return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
@@ -7833,11 +8159,7 @@ function visualize(parser) {
7833
8159
  exports.visualize = visualize;
7834
8160
 
7835
8161
  function hasVisible(nodes, {
7836
- syntax: {
7837
- inline: {
7838
- media = true
7839
- } = {}
7840
- } = {}
8162
+ state = 0
7841
8163
  } = {}) {
7842
8164
  for (let i = 0; i < nodes.length; ++i) {
7843
8165
  const node = nodes[i];
@@ -7846,13 +8168,26 @@ function hasVisible(nodes, {
7846
8168
  if (node && node.trimStart()) return true;
7847
8169
  } else {
7848
8170
  if (node.innerText.trimStart()) return true;
7849
- if (media && (node.classList.contains('media') || node.getElementsByClassName('media')[0])) return true;
8171
+ if (state & 2
8172
+ /* State.media */
8173
+ ^ 2
8174
+ /* State.media */
8175
+ && (node.classList.contains('media') || node.getElementsByClassName('media')[0])) return true;
7850
8176
  }
7851
8177
  }
7852
8178
 
7853
8179
  return false;
7854
8180
  }
7855
8181
 
8182
+ exports.regBlankStart = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
8183
+
8184
+ function blankWith(starting, delimiter) {
8185
+ if (delimiter === global_1.undefined) return blankWith('', starting);
8186
+ return new RegExp(String.raw`^(?:(?=${starting})(?:\\?\s|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr>)${starting && '+'})?${typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source}`);
8187
+ }
8188
+
8189
+ exports.blankWith = blankWith;
8190
+
7856
8191
  function startLoose(parser, except) {
7857
8192
  return (source, context) => isStartLoose(source, context, except) ? parser(source, context) : global_1.undefined;
7858
8193
  }
@@ -8010,39 +8345,20 @@ function trimNodeEnd(nodes) {
8010
8345
 
8011
8346
  for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
8012
8347
  if (typeof node === 'string') {
8013
- const pos = node.trimEnd().length;
8014
-
8015
- if (pos > 0) {
8016
- nodes[nodes.length - 1] = node.slice(0, pos);
8017
- break;
8018
- }
8019
- }
8020
-
8021
- nodes.pop();
8022
- }
8023
-
8024
- return (0, array_1.push)(nodes, skip);
8025
- }
8026
-
8027
- function stringify(nodes) {
8028
- let acc = '';
8029
-
8030
- for (let i = 0; i < nodes.length; ++i) {
8031
- const node = nodes[i];
8032
-
8033
- if (typeof node === 'string') {
8034
- acc += node;
8035
- } else {
8036
- // NOTE: Doesn't reflect line breaks.
8037
- acc += node.innerText;
8348
+ const pos = node.trimEnd().length;
8349
+
8350
+ if (pos > 0) {
8351
+ nodes[nodes.length - 1] = node.slice(0, pos);
8352
+ break;
8353
+ }
8038
8354
  }
8355
+
8356
+ nodes.pop();
8039
8357
  }
8040
8358
 
8041
- return acc;
8359
+ return (0, array_1.push)(nodes, skip);
8042
8360
  }
8043
8361
 
8044
- exports.stringify = stringify;
8045
-
8046
8362
  /***/ }),
8047
8363
 
8048
8364
  /***/ 256:
@@ -8553,6 +8869,8 @@ exports.info = void 0;
8553
8869
 
8554
8870
  const scope_1 = __webpack_require__(5202);
8555
8871
 
8872
+ const duff_1 = __webpack_require__(8099);
8873
+
8556
8874
  const array_1 = __webpack_require__(8112);
8557
8875
 
8558
8876
  function info(source) {
@@ -8571,7 +8889,7 @@ function info(source) {
8571
8889
  };
8572
8890
 
8573
8891
  function find(selector) {
8574
- return (0, array_1.push)([], source.querySelectorAll(selector)).filter(match);
8892
+ return (0, duff_1.duffReduce)(source.querySelectorAll(selector), (acc, el) => match(el) ? (0, array_1.push)(acc, [el]) : acc, []);
8575
8893
  }
8576
8894
  }
8577
8895
 
@@ -8598,30 +8916,29 @@ const cite_1 = __webpack_require__(6315);
8598
8916
 
8599
8917
  const dom_1 = __webpack_require__(3252);
8600
8918
 
8919
+ const duff_1 = __webpack_require__(8099);
8920
+
8601
8921
  function quote(anchor, range) {
8602
8922
  if ((0, parser_1.exec)((0, cite_1.cite)(`>>${anchor}`, {})) !== '') throw new Error(`Invalid anchor: ${anchor}`);
8603
8923
  fit(range);
8604
8924
  const node = trim(range.cloneContents());
8605
8925
  if (!node.firstChild) return '';
8606
-
8607
- for (let es = node.querySelectorAll('code[data-src], .math[data-src], .media[data-src], rt, rp'), i = 0, len = es.length; i < len; ++i) {
8608
- const el = es[i];
8609
-
8926
+ (0, duff_1.duffEach)(node.querySelectorAll('code[data-src], .math[data-src], .media[data-src], rt, rp'), el => {
8610
8927
  switch (true) {
8611
8928
  case el.matches('code'):
8612
8929
  case el.matches('.math'):
8613
8930
  (0, dom_1.define)(el, el.getAttribute('data-src'));
8614
- continue;
8931
+ return;
8615
8932
 
8616
8933
  case el.matches('.media'):
8617
8934
  el.replaceWith(/[\s{}]/.test(el.getAttribute('data-src')) ? `!{ ${el.getAttribute('data-src')} }` : `!{${el.getAttribute('data-src')}}`);
8618
- continue;
8935
+ return;
8619
8936
 
8620
8937
  case el.matches('rt, rp'):
8621
8938
  el.remove();
8622
- continue;
8939
+ return;
8623
8940
  }
8624
- }
8941
+ });
8625
8942
 
8626
8943
  if (range.startOffset === 0 && range.startContainer.parentElement?.matches('.cite, .quote') && (!range.startContainer.previousSibling || range.startContainer.previousSibling.nodeName === 'BR')) {
8627
8944
  node.prepend(`>${range.startContainer.parentElement.matches('.quote.invalid') ? ' ' : ''}`);
@@ -8630,29 +8947,26 @@ function quote(anchor, range) {
8630
8947
  anchor = '';
8631
8948
  }
8632
8949
 
8633
- for (let es = node.querySelectorAll('br'), i = 0, len = es.length; i < len; ++i) {
8634
- const el = es[i];
8635
-
8950
+ (0, duff_1.duffEach)(node.querySelectorAll('br'), el => {
8636
8951
  if (anchor && el.nextSibling instanceof global_1.Element && el.nextSibling.matches('.cite, .quote')) {
8637
8952
  el.replaceWith(`\n>${el.nextSibling.matches('.quote.invalid') ? ' ' : ''}`);
8638
- continue;
8953
+ return;
8639
8954
  }
8640
8955
 
8641
8956
  if (anchor && el.parentElement?.closest('.cite, .quote')) {
8642
8957
  el.replaceWith(`\n>${el.parentElement.closest('.quote.invalid') ? ' ' : ''}`);
8643
- continue;
8958
+ return;
8644
8959
  }
8645
8960
 
8646
8961
  if (anchor) {
8647
8962
  el.replaceWith(`\n>>${anchor}\n> `);
8648
8963
  anchor = '';
8649
- continue;
8964
+ return;
8650
8965
  } else {
8651
8966
  el.replaceWith(`\n> `);
8652
- continue;
8967
+ return;
8653
8968
  }
8654
- }
8655
-
8969
+ });
8656
8970
  anchor && node.append(`\n>>${anchor}`);
8657
8971
  return node.textContent;
8658
8972
  }
@@ -8740,6 +9054,8 @@ const global_1 = __webpack_require__(4128);
8740
9054
 
8741
9055
  const dom_1 = __webpack_require__(3252);
8742
9056
 
9057
+ const duff_1 = __webpack_require__(8099);
9058
+
8743
9059
  const array_1 = __webpack_require__(8112); // Bug: Firefox
8744
9060
  //const selector = 'h1 h2 h3 h4 h5 h6 aside.aside'.split(' ').map(s => `:scope > ${s}[id]`).join();
8745
9061
 
@@ -8747,18 +9063,18 @@ const array_1 = __webpack_require__(8112); // Bug: Firefox
8747
9063
  const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]';
8748
9064
 
8749
9065
  function toc(source) {
8750
- const hs = (0, array_1.push)([], source.querySelectorAll(selector)).map(el => {
9066
+ const hs = (0, duff_1.duffReduce)(source.querySelectorAll(selector), (acc, el) => {
8751
9067
  switch (el.tagName) {
8752
9068
  case 'ASIDE':
8753
- return (0, dom_1.html)(el.firstElementChild.tagName.toLowerCase(), {
9069
+ return (0, array_1.push)(acc, [(0, dom_1.html)(el.firstElementChild.tagName.toLowerCase(), {
8754
9070
  id: el.id,
8755
9071
  class: 'aside'
8756
- }, el.firstElementChild.cloneNode(true).childNodes);
9072
+ }, el.firstElementChild.cloneNode(true).childNodes)]);
8757
9073
 
8758
9074
  default:
8759
- return el;
9075
+ return (0, array_1.push)(acc, [el]);
8760
9076
  }
8761
- });
9077
+ }, []);
8762
9078
  return parse(cons(hs));
8763
9079
  }
8764
9080
 
@@ -8772,7 +9088,7 @@ function parse(node, index = '') {
8772
9088
  return (0, dom_1.html)('li', (0, array_1.push)([(0, dom_1.html)('a', {
8773
9089
  href: `#${el.id}`,
8774
9090
  'data-index': isHeading ? idx : global_1.undefined
8775
- }, fix(el))], cs.length > 0 ? [parse(cs, idx)] : []));
9091
+ }, unlink(el.cloneNode(true)))], cs.length > 0 ? [parse(cs, idx)] : []));
8776
9092
  }));
8777
9093
  }
8778
9094
 
@@ -8787,14 +9103,8 @@ function level(h) {
8787
9103
  return +h.tagName[1];
8788
9104
  }
8789
9105
 
8790
- function fix(h) {
8791
- h = h.cloneNode(true);
8792
-
8793
- for (let es = h.getElementsByTagName('a'), i = 0, len = es.length; i < len; ++i) {
8794
- const el = es[i];
8795
- el.replaceWith(...el.childNodes);
8796
- }
8797
-
9106
+ function unlink(h) {
9107
+ (0, duff_1.duffEach)(h.getElementsByTagName('a'), el => void el.replaceWith(...el.childNodes));
8798
9108
  return h.childNodes;
8799
9109
  }
8800
9110
 
@@ -8803,7 +9113,7 @@ function fix(h) {
8803
9113
  /***/ 3252:
8804
9114
  /***/ (function(module) {
8805
9115
 
8806
- /*! typed-dom v0.0.299 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9116
+ /*! typed-dom v0.0.301 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8807
9117
  (function webpackUniversalModuleDefinition(root, factory) {
8808
9118
  if(true)
8809
9119
  module.exports = factory();
@@ -9237,7 +9547,7 @@ exports.defrag = defrag;
9237
9547
  /***/ 6120:
9238
9548
  /***/ (function(module) {
9239
9549
 
9240
- /*! typed-dom v0.0.299 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9550
+ /*! typed-dom v0.0.301 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9241
9551
  (function webpackUniversalModuleDefinition(root, factory) {
9242
9552
  if(true)
9243
9553
  module.exports = factory();
@@ -9245,8 +9555,320 @@ exports.defrag = defrag;
9245
9555
  })(this, () => {
9246
9556
  return /******/ (() => { // webpackBootstrap
9247
9557
  /******/ "use strict";
9558
+ /******/ var __webpack_modules__ = ({
9559
+
9560
+ /***/ 112:
9561
+ /***/ ((__unused_webpack_module, exports, __nested_webpack_require_645__) => {
9562
+
9563
+
9564
+
9565
+ Object.defineProperty(exports, "__esModule", ({
9566
+ value: true
9567
+ }));
9568
+ exports.splice = exports.pop = exports.push = exports.shift = exports.unshift = exports.indexOf = void 0;
9569
+
9570
+ const global_1 = __nested_webpack_require_645__(128);
9571
+
9572
+ function indexOf(as, a) {
9573
+ if (as.length === 0) return -1;
9574
+ return a === a ? as.indexOf(a) : as.findIndex(a => a !== a);
9575
+ }
9576
+
9577
+ exports.indexOf = indexOf;
9578
+
9579
+ function unshift(as, bs) {
9580
+ if ('length' in as) {
9581
+ for (let i = as.length - 1; i >= 0; --i) {
9582
+ bs.unshift(as[i]);
9583
+ }
9584
+ } else {
9585
+ bs.unshift(...as);
9586
+ }
9587
+
9588
+ return bs;
9589
+ }
9590
+
9591
+ exports.unshift = unshift;
9592
+
9593
+ function shift(as, count) {
9594
+ if (count < 0) throw new Error('Unexpected negative number');
9595
+ return count === void 0 ? [as.shift(), as] : [splice(as, 0, count), as];
9596
+ }
9597
+
9598
+ exports.shift = shift;
9599
+
9600
+ function push(as, bs) {
9601
+ if ('length' in bs) {
9602
+ for (let i = 0, len = bs.length; i < len; ++i) {
9603
+ as.push(bs[i]);
9604
+ }
9605
+ } else {
9606
+ for (const b of bs) {
9607
+ as.push(b);
9608
+ }
9609
+ }
9610
+
9611
+ return as;
9612
+ }
9613
+
9614
+ exports.push = push;
9615
+
9616
+ function pop(as, count) {
9617
+ if (count < 0) throw new Error('Unexpected negative number');
9618
+ return count === void 0 ? [as, as.pop()] : [as, splice(as, as.length - count, count)];
9619
+ }
9620
+
9621
+ exports.pop = pop;
9622
+
9623
+ function splice(as, index, count, ...inserts) {
9624
+ if (count === 0 && inserts.length === 0) return [];
9625
+ count = count > as.length ? as.length : count;
9626
+
9627
+ switch (index) {
9628
+ case 0:
9629
+ switch (count) {
9630
+ case 0:
9631
+ return [[], unshift(inserts, as)][0];
9632
+
9633
+ case 1:
9634
+ return as.length === 0 ? [[], unshift(inserts, as)][0] : [[as.shift()], unshift(inserts, as)][0];
9635
+
9636
+ case void 0:
9637
+ if (as.length > 1 || arguments.length > 2) break;
9638
+ return as.length === 0 ? [] : splice(as, index, 1);
9639
+ }
9640
+
9641
+ break;
9642
+
9643
+ case -1:
9644
+ case as.length - 1:
9645
+ switch (count) {
9646
+ case 1:
9647
+ return as.length === 0 ? [[], push(as, inserts)][0] : [[as.pop()], push(as, inserts)][0];
9648
+
9649
+ case void 0:
9650
+ if (as.length > 1 || arguments.length > 2) break;
9651
+ return as.length === 0 ? [] : splice(as, index, 1);
9652
+ }
9653
+
9654
+ break;
9655
+
9656
+ case as.length:
9657
+ case global_1.Infinity:
9658
+ return [[], push(as, inserts)][0];
9659
+ }
9660
+
9661
+ return arguments.length > 2 ? as.splice(index, count, ...inserts) : as.splice(index);
9662
+ }
9663
+
9664
+ exports.splice = splice;
9665
+
9666
+ /***/ }),
9667
+
9668
+ /***/ 99:
9669
+ /***/ ((__unused_webpack_module, exports) => {
9670
+
9671
+
9672
+
9673
+ Object.defineProperty(exports, "__esModule", ({
9674
+ value: true
9675
+ }));
9676
+ exports.duffReduce = exports.duffEach = exports.duffbk = exports.duff = void 0;
9677
+
9678
+ function duff(count, proc) {
9679
+ if (count > 0) {
9680
+ let i = 0,
9681
+ m = count % 8,
9682
+ d = (count - m) / 8;
9683
+
9684
+ while (m--) {
9685
+ proc(i++);
9686
+ }
9687
+
9688
+ while (d--) {
9689
+ proc(i++);
9690
+ proc(i++);
9691
+ proc(i++);
9692
+ proc(i++);
9693
+ proc(i++);
9694
+ proc(i++);
9695
+ proc(i++);
9696
+ proc(i++);
9697
+ }
9698
+ } else {
9699
+ let i = -count,
9700
+ m = i % 8,
9701
+ d = (i - m) / 8;
9702
+
9703
+ while (m--) {
9704
+ proc(--i);
9705
+ }
9706
+
9707
+ while (d--) {
9708
+ proc(--i);
9709
+ proc(--i);
9710
+ proc(--i);
9711
+ proc(--i);
9712
+ proc(--i);
9713
+ proc(--i);
9714
+ proc(--i);
9715
+ proc(--i);
9716
+ }
9717
+ }
9718
+ }
9719
+
9720
+ exports.duff = duff;
9721
+
9722
+ function duffbk(count, proc) {
9723
+ if (count > 0) {
9724
+ let i = 0,
9725
+ m = count % 8,
9726
+ d = (count - m) / 8;
9727
+
9728
+ while (m--) {
9729
+ if (proc(i++) === false) return;
9730
+ }
9731
+
9732
+ while (d--) {
9733
+ if (proc(i++) === false) return;
9734
+ if (proc(i++) === false) return;
9735
+ if (proc(i++) === false) return;
9736
+ if (proc(i++) === false) return;
9737
+ if (proc(i++) === false) return;
9738
+ if (proc(i++) === false) return;
9739
+ if (proc(i++) === false) return;
9740
+ if (proc(i++) === false) return;
9741
+ }
9742
+ } else {
9743
+ let i = -count,
9744
+ m = i % 8,
9745
+ d = (i - m) / 8;
9746
+
9747
+ while (m--) {
9748
+ if (proc(--i) === false) return;
9749
+ }
9750
+
9751
+ while (d--) {
9752
+ if (proc(--i) === false) return;
9753
+ if (proc(--i) === false) return;
9754
+ if (proc(--i) === false) return;
9755
+ if (proc(--i) === false) return;
9756
+ if (proc(--i) === false) return;
9757
+ if (proc(--i) === false) return;
9758
+ if (proc(--i) === false) return;
9759
+ if (proc(--i) === false) return;
9760
+ }
9761
+ }
9762
+ }
9763
+
9764
+ exports.duffbk = duffbk;
9765
+
9766
+ function duffEach(array, proc) {
9767
+ let count = array.length;
9768
+ let i = 0,
9769
+ m = count % 8,
9770
+ d = (count - m) / 8;
9771
+
9772
+ while (m--) {
9773
+ proc(array[i], i++, array);
9774
+ }
9775
+
9776
+ while (d--) {
9777
+ proc(array[i], i++, array);
9778
+ proc(array[i], i++, array);
9779
+ proc(array[i], i++, array);
9780
+ proc(array[i], i++, array);
9781
+ proc(array[i], i++, array);
9782
+ proc(array[i], i++, array);
9783
+ proc(array[i], i++, array);
9784
+ proc(array[i], i++, array);
9785
+ }
9786
+ }
9787
+
9788
+ exports.duffEach = duffEach;
9789
+
9790
+ function duffReduce(array, proc, initial) {
9791
+ let count = array.length;
9792
+ let i = 0,
9793
+ m = count % 8,
9794
+ d = (count - m) / 8;
9795
+
9796
+ while (m--) {
9797
+ initial = proc(initial, array[i], i++, array);
9798
+ }
9799
+
9800
+ while (d--) {
9801
+ initial = proc(initial, array[i], i++, array);
9802
+ initial = proc(initial, array[i], i++, array);
9803
+ initial = proc(initial, array[i], i++, array);
9804
+ initial = proc(initial, array[i], i++, array);
9805
+ initial = proc(initial, array[i], i++, array);
9806
+ initial = proc(initial, array[i], i++, array);
9807
+ initial = proc(initial, array[i], i++, array);
9808
+ initial = proc(initial, array[i], i++, array);
9809
+ }
9810
+
9811
+ return initial;
9812
+ }
9813
+
9814
+ exports.duffReduce = duffReduce;
9815
+
9816
+ /***/ }),
9817
+
9818
+ /***/ 128:
9819
+ /***/ ((module, __unused_webpack_exports, __nested_webpack_require_6113__) => {
9820
+
9821
+
9822
+
9823
+ __nested_webpack_require_6113__(921);
9824
+
9825
+ const global = void 0 || typeof globalThis !== 'undefined' && globalThis // @ts-ignore
9826
+ || typeof self !== 'undefined' && self || Function('return this')();
9827
+ global.global = global;
9828
+ module.exports = global;
9829
+
9830
+ /***/ }),
9831
+
9832
+ /***/ 921:
9833
+ /***/ (() => {
9834
+
9835
+ // @ts-ignore
9836
+
9837
+ var globalThis; // @ts-ignore
9838
+
9839
+ var global = (/* unused pure expression or super */ null && (0));
9840
+
9841
+ /***/ })
9842
+
9843
+ /******/ });
9844
+ /************************************************************************/
9845
+ /******/ // The module cache
9846
+ /******/ var __webpack_module_cache__ = {};
9847
+ /******/
9848
+ /******/ // The require function
9849
+ /******/ function __nested_webpack_require_6765__(moduleId) {
9850
+ /******/ // Check if module is in cache
9851
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
9852
+ /******/ if (cachedModule !== undefined) {
9853
+ /******/ return cachedModule.exports;
9854
+ /******/ }
9855
+ /******/ // Create a new module (and put it into the cache)
9856
+ /******/ var module = __webpack_module_cache__[moduleId] = {
9857
+ /******/ // no module.id needed
9858
+ /******/ // no module.loaded needed
9859
+ /******/ exports: {}
9860
+ /******/ };
9861
+ /******/
9862
+ /******/ // Execute the module function
9863
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_6765__);
9864
+ /******/
9865
+ /******/ // Return the exports of the module
9866
+ /******/ return module.exports;
9867
+ /******/ }
9868
+ /******/
9869
+ /************************************************************************/
9248
9870
  var __webpack_exports__ = {};
9249
- // This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
9871
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
9250
9872
  (() => {
9251
9873
  var exports = __webpack_exports__;
9252
9874
 
@@ -9256,6 +9878,10 @@ Object.defineProperty(exports, "__esModule", ({
9256
9878
  }));
9257
9879
  exports.querySelectorAll = exports.querySelector = void 0;
9258
9880
 
9881
+ const duff_1 = __nested_webpack_require_6765__(99);
9882
+
9883
+ const array_1 = __nested_webpack_require_6765__(112);
9884
+
9259
9885
  function querySelector(node, selector) {
9260
9886
  return 'matches' in node && node.matches(selector) ? node : node.querySelector(selector);
9261
9887
  }
@@ -9269,13 +9895,7 @@ function querySelectorAll(node, selector) {
9269
9895
  acc.push(node);
9270
9896
  }
9271
9897
 
9272
- const nodes = node.querySelectorAll(selector);
9273
-
9274
- for (let i = 0, len = nodes.length; i < len; ++i) {
9275
- acc.push(nodes[i]);
9276
- }
9277
-
9278
- return acc;
9898
+ return (0, duff_1.duffReduce)(node.querySelectorAll(selector), (acc, node) => (0, array_1.push)(acc, [node]), acc);
9279
9899
  }
9280
9900
 
9281
9901
  exports.querySelectorAll = querySelectorAll;