securemark 0.257.2 → 0.258.1

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 (87) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.js +1238 -618
  3. package/markdown.d.ts +1 -12
  4. package/package.json +9 -9
  5. package/src/combinator/control/manipulation/convert.ts +8 -4
  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 +34 -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 +4 -3
  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.test.ts +5 -0
  38. package/src/parser/block/table.ts +14 -13
  39. package/src/parser/block/ulist.ts +4 -3
  40. package/src/parser/block.ts +1 -1
  41. package/src/parser/context.ts +32 -0
  42. package/src/parser/header.ts +1 -1
  43. package/src/parser/inline/annotation.test.ts +5 -5
  44. package/src/parser/inline/annotation.ts +9 -17
  45. package/src/parser/inline/autolink/email.ts +1 -1
  46. package/src/parser/inline/autolink/url.ts +1 -1
  47. package/src/parser/inline/autolink.ts +5 -3
  48. package/src/parser/inline/bracket.ts +16 -15
  49. package/src/parser/inline/code.ts +1 -1
  50. package/src/parser/inline/comment.ts +4 -3
  51. package/src/parser/inline/deletion.ts +5 -4
  52. package/src/parser/inline/emphasis.ts +5 -4
  53. package/src/parser/inline/emstrong.ts +5 -4
  54. package/src/parser/inline/extension/index.ts +7 -14
  55. package/src/parser/inline/extension/indexee.ts +8 -10
  56. package/src/parser/inline/extension/indexer.ts +4 -3
  57. package/src/parser/inline/extension/label.ts +3 -2
  58. package/src/parser/inline/extension/placeholder.ts +5 -4
  59. package/src/parser/inline/html.ts +5 -4
  60. package/src/parser/inline/htmlentity.ts +1 -1
  61. package/src/parser/inline/insertion.ts +5 -4
  62. package/src/parser/inline/link.test.ts +2 -1
  63. package/src/parser/inline/link.ts +21 -27
  64. package/src/parser/inline/mark.ts +5 -4
  65. package/src/parser/inline/math.ts +1 -1
  66. package/src/parser/inline/media.test.ts +1 -0
  67. package/src/parser/inline/media.ts +8 -7
  68. package/src/parser/inline/reference.test.ts +5 -5
  69. package/src/parser/inline/reference.ts +10 -16
  70. package/src/parser/inline/ruby.test.ts +1 -0
  71. package/src/parser/inline/ruby.ts +4 -3
  72. package/src/parser/inline/shortmedia.ts +3 -2
  73. package/src/parser/inline/strong.ts +5 -4
  74. package/src/parser/inline/template.test.ts +1 -1
  75. package/src/parser/inline/template.ts +9 -6
  76. package/src/parser/inline.test.ts +2 -1
  77. package/src/parser/locale.ts +6 -7
  78. package/src/parser/processor/footnote.ts +5 -3
  79. package/src/parser/source/text.ts +1 -1
  80. package/src/parser/util.ts +0 -220
  81. package/src/parser/visibility.ts +205 -0
  82. package/src/util/info.ts +4 -2
  83. package/src/util/quote.ts +12 -15
  84. package/src/util/toc.ts +14 -17
  85. package/webpack.config.js +1 -0
  86. package/src/combinator/control/manipulation/context.ts +0 -70
  87. package/src/combinator/control/manipulation/resource.ts +0 -54
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.257.2 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.258.1 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,7 +2239,7 @@ exports.isEmpty = isEmpty;
2090
2239
 
2091
2240
  /***/ }),
2092
2241
 
2093
- /***/ 8059:
2242
+ /***/ 7957:
2094
2243
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2095
2244
 
2096
2245
  "use strict";
@@ -2099,92 +2248,20 @@ exports.isEmpty = isEmpty;
2099
2248
  Object.defineProperty(exports, "__esModule", ({
2100
2249
  value: true
2101
2250
  }));
2102
- exports.precedence = exports.context = exports.reset = exports.guard = void 0;
2251
+ exports.convert = void 0;
2103
2252
 
2104
2253
  const global_1 = __webpack_require__(4128);
2105
2254
 
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
- /***/ 7957:
2173
- /***/ ((__unused_webpack_module, exports) => {
2174
-
2175
- "use strict";
2176
-
2177
-
2178
- Object.defineProperty(exports, "__esModule", ({
2179
- value: true
2180
- }));
2181
- exports.convert = void 0;
2182
-
2183
2255
  function convert(conv, parser) {
2184
- return (source, context) => {
2256
+ return (source, context = {}) => {
2185
2257
  if (source === '') return;
2186
2258
  source = conv(source);
2187
- return source === '' ? [[], ''] : parser(source, context);
2259
+ if (source === '') return [[], ''];
2260
+ const memo = context.memo;
2261
+ context.memo = global_1.undefined;
2262
+ const result = parser(source, context);
2263
+ context.memo = memo;
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,63 +2752,7 @@ 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;
2752
-
2753
- class Delimiters {
2754
- constructor() {
2755
- this.matchers = [];
2756
- this.registry = {};
2757
- this.length = 0;
2758
- }
2759
-
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;
2768
-
2769
- if (!this.registry[signature]) {
2770
- this.matchers.unshift([this.length, signature, precedence, matcher]);
2771
- this.registry[signature] = true;
2772
- }
2773
-
2774
- ++this.length;
2775
- }
2776
- }
2777
-
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
- }
2785
-
2786
- match(source, precedence = 1) {
2787
- const {
2788
- matchers
2789
- } = this;
2790
-
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;
2796
-
2797
- case false:
2798
- return false;
2799
- }
2800
- }
2801
-
2802
- return false;
2803
- }
2804
-
2805
- }
2806
-
2807
- exports.Delimiters = Delimiters;
2755
+ exports.check = exports.exec = exports.eval = void 0;
2808
2756
 
2809
2757
  function eval_(result, default_) {
2810
2758
  return result ? result[0] : default_;
@@ -2826,7 +2774,331 @@ exports.check = check;
2826
2774
 
2827
2775
  /***/ }),
2828
2776
 
2829
- /***/ 2491:
2777
+ /***/ 5684:
2778
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2779
+
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
+ }
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];
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;
2844
+ }
2845
+
2846
+ function syntax(syntax, precedence, cost, parser) {
2847
+ if (typeof cost === 'function') {
2848
+ parser = cost;
2849
+ cost = 1;
2850
+ }
2851
+
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[0], source.slice(cache[1])] : parser(source, context);
2870
+ ++resources.recursion;
2871
+
2872
+ if (result) {
2873
+ if (!cache) {
2874
+ resources.budget -= cost;
2875
+ }
2876
+
2877
+ if (syntax) {
2878
+ if (state & context.backtrackable) {
2879
+ context.memo ??= new memo_1.Memo();
2880
+ cache ?? context.memo.set(pos, syntax, state, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result).length);
2881
+ } else if (context.memo?.length >= pos) {
2882
+ context.memo.clear(pos);
2883
+ }
2884
+ }
2885
+ }
2886
+
2887
+ context.precedence = p;
2888
+ return result;
2889
+ };
2890
+ }
2891
+
2892
+ exports.syntax = syntax;
2893
+
2894
+ function creator(cost, parser) {
2895
+ if (typeof cost === 'function') return creator(1, cost);
2896
+ return (source, context) => {
2897
+ const {
2898
+ resources = {
2899
+ budget: 1,
2900
+ recursion: 1
2901
+ }
2902
+ } = context;
2903
+ if (resources.budget <= 0) throw new Error('Too many creations');
2904
+ if (resources.recursion <= 0) throw new Error('Too much recursion');
2905
+ --resources.recursion;
2906
+ const result = parser(source, context);
2907
+ ++resources.recursion;
2908
+
2909
+ if (result) {
2910
+ resources.budget -= cost;
2911
+ }
2912
+
2913
+ return result;
2914
+ };
2915
+ }
2916
+
2917
+ exports.creator = creator;
2918
+
2919
+ function precedence(precedence, parser) {
2920
+ return (source, context) => {
2921
+ const p = context.precedence;
2922
+ context.precedence = precedence;
2923
+ const result = parser(source, context);
2924
+ context.precedence = p;
2925
+ return result;
2926
+ };
2927
+ }
2928
+
2929
+ exports.precedence = precedence;
2930
+
2931
+ function guard(f, parser) {
2932
+ return (source, context) => f(context) ? parser(source, context) : global_1.undefined;
2933
+ }
2934
+
2935
+ exports.guard = guard;
2936
+
2937
+ function state(state, positive, parser) {
2938
+ if (typeof positive === 'function') {
2939
+ parser = positive;
2940
+ positive = true;
2941
+ }
2942
+
2943
+ return (source, context) => {
2944
+ const s = context.state ?? 0;
2945
+ context.state = positive ? s | state : s & ~state;
2946
+ const result = parser(source, context);
2947
+ context.state = s;
2948
+ return result;
2949
+ };
2950
+ }
2951
+
2952
+ exports.state = state;
2953
+
2954
+ /***/ }),
2955
+
2956
+ /***/ 1435:
2957
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2958
+
2959
+ "use strict";
2960
+
2961
+
2962
+ var _a;
2963
+
2964
+ Object.defineProperty(exports, "__esModule", ({
2965
+ value: true
2966
+ }));
2967
+ exports.Delimiters = void 0;
2968
+
2969
+ const memoize_1 = __webpack_require__(1808);
2970
+
2971
+ class Delimiters {
2972
+ constructor() {
2973
+ this.matchers = [];
2974
+ this.registry = {};
2975
+ this.length = 0;
2976
+ }
2977
+
2978
+ static signature(pattern) {
2979
+ switch (typeof pattern) {
2980
+ case 'undefined':
2981
+ return `undefined`;
2982
+
2983
+ case 'string':
2984
+ return `s:${pattern}`;
2985
+
2986
+ case 'object':
2987
+ return `r/${pattern.source}/${pattern.flags}`;
2988
+ }
2989
+ }
2990
+
2991
+ push(...delimiters) {
2992
+ for (let i = 0; i < delimiters.length; ++i) {
2993
+ const delimiter = delimiters[i];
2994
+ const {
2995
+ signature,
2996
+ matcher,
2997
+ precedence = 1
2998
+ } = delimiter;
2999
+
3000
+ if (!this.registry[signature]) {
3001
+ this.matchers.unshift([this.length, signature, precedence, matcher]);
3002
+ this.registry[signature] = true;
3003
+ }
3004
+
3005
+ ++this.length;
3006
+ }
3007
+ }
3008
+
3009
+ pop(count = 1) {
3010
+ for (let i = 0; i < count; ++i) {
3011
+ if (--this.length === this.matchers[0][0]) {
3012
+ this.registry[this.matchers.shift()[1]] = false;
3013
+ }
3014
+ }
3015
+ }
3016
+
3017
+ match(source, precedence = 1) {
3018
+ const {
3019
+ matchers
3020
+ } = this;
3021
+
3022
+ for (let i = 0; i < matchers.length; ++i) {
3023
+ switch (matchers[i][3](source)) {
3024
+ case true:
3025
+ if (precedence < matchers[i][2]) return true;
3026
+ continue;
3027
+
3028
+ case false:
3029
+ return false;
3030
+ }
3031
+ }
3032
+
3033
+ return false;
3034
+ }
3035
+
3036
+ }
3037
+
3038
+ exports.Delimiters = Delimiters;
3039
+ _a = Delimiters;
3040
+ Delimiters.matcher = (0, memoize_1.memoize)(pattern => {
3041
+ switch (typeof pattern) {
3042
+ case 'undefined':
3043
+ return () => undefined;
3044
+
3045
+ case 'string':
3046
+ return source => source.slice(0, pattern.length) === pattern || undefined;
3047
+
3048
+ case 'object':
3049
+ return (0, memoize_1.reduce)(source => pattern.test(source) || undefined);
3050
+ }
3051
+ }, _a.signature);
3052
+
3053
+ /***/ }),
3054
+
3055
+ /***/ 1090:
3056
+ /***/ ((__unused_webpack_module, exports) => {
3057
+
3058
+ "use strict";
3059
+
3060
+
3061
+ Object.defineProperty(exports, "__esModule", ({
3062
+ value: true
3063
+ }));
3064
+ exports.Memo = void 0;
3065
+
3066
+ class Memo {
3067
+ constructor() {
3068
+ this.memory = [];
3069
+ this.offset = 0;
3070
+ }
3071
+
3072
+ get length() {
3073
+ return this.memory.length;
3074
+ }
3075
+
3076
+ get(position, syntax, state) {
3077
+ //console.log('get', position + this.offset, syntax, state, this.memory[position + this.offset - 1]?.[`${syntax}:${state}`]);;
3078
+ return this.memory[position + this.offset - 1]?.[`${syntax}:${state}`];
3079
+ }
3080
+
3081
+ set(position, syntax, state, nodes, offset) {
3082
+ const record = this.memory[position + this.offset - 1] ??= {};
3083
+ record[`${syntax}:${state}`] = [nodes.slice(), offset]; //console.log('set', position + this.offset, syntax, state);
3084
+ }
3085
+
3086
+ clear(position) {
3087
+ const memory = this.memory;
3088
+
3089
+ for (let i = position + this.offset, len = memory.length; i < len; ++i) {
3090
+ memory.pop();
3091
+ } //console.log(position);
3092
+
3093
+ }
3094
+
3095
+ }
3096
+
3097
+ exports.Memo = Memo;
3098
+
3099
+ /***/ }),
3100
+
3101
+ /***/ 2491:
2830
3102
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2831
3103
 
2832
3104
  "use strict";
@@ -2843,7 +3115,7 @@ const parser_1 = __webpack_require__(6728);
2843
3115
 
2844
3116
  const array_1 = __webpack_require__(8112);
2845
3117
 
2846
- function inits(parsers) {
3118
+ function inits(parsers, resume) {
2847
3119
  if (parsers.length === 1) return parsers[0];
2848
3120
  return (source, context) => {
2849
3121
  let rest = source;
@@ -2851,10 +3123,12 @@ function inits(parsers) {
2851
3123
 
2852
3124
  for (let i = 0, len = parsers.length; i < len; ++i) {
2853
3125
  if (rest === '') break;
3126
+ if (context.delimiters?.match(rest, context.precedence)) break;
2854
3127
  const result = parsers[i](rest, context);
2855
3128
  if (!result) break;
2856
3129
  nodes = nodes ? (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
2857
3130
  rest = (0, parser_1.exec)(result);
3131
+ if (resume?.((0, parser_1.eval)(result), (0, parser_1.exec)(result)) === false) break;
2858
3132
  }
2859
3133
 
2860
3134
  return nodes && rest.length < source.length ? [nodes, rest] : global_1.undefined;
@@ -2882,7 +3156,7 @@ const parser_1 = __webpack_require__(6728);
2882
3156
 
2883
3157
  const array_1 = __webpack_require__(8112);
2884
3158
 
2885
- function sequence(parsers) {
3159
+ function sequence(parsers, resume) {
2886
3160
  if (parsers.length === 1) return parsers[0];
2887
3161
  return (source, context) => {
2888
3162
  let rest = source;
@@ -2890,10 +3164,12 @@ function sequence(parsers) {
2890
3164
 
2891
3165
  for (let i = 0, len = parsers.length; i < len; ++i) {
2892
3166
  if (rest === '') return;
3167
+ if (context.delimiters?.match(rest, context.precedence)) return;
2893
3168
  const result = parsers[i](rest, context);
2894
3169
  if (!result) return;
2895
3170
  nodes = nodes ? (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
2896
3171
  rest = (0, parser_1.exec)(result);
3172
+ if (resume?.((0, parser_1.eval)(result), (0, parser_1.exec)(result)) === false) return;
2897
3173
  }
2898
3174
 
2899
3175
  return nodes && rest.length < source.length ? [nodes, rest] : global_1.undefined;
@@ -2919,42 +3195,16 @@ const global_1 = __webpack_require__(4128);
2919
3195
 
2920
3196
  const parser_1 = __webpack_require__(6728);
2921
3197
 
2922
- const memoize_1 = __webpack_require__(1808);
3198
+ const delimiter_1 = __webpack_require__(1435);
2923
3199
 
2924
3200
  const array_1 = __webpack_require__(8112);
2925
3201
 
2926
- const signature = pattern => {
2927
- switch (typeof pattern) {
2928
- case 'undefined':
2929
- return signature('');
2930
-
2931
- case 'string':
2932
- return `s:${pattern}`;
2933
-
2934
- case 'object':
2935
- return `r/${pattern.source}/${pattern.flags}`;
2936
- }
2937
- };
2938
-
2939
- const matcher = (0, memoize_1.memoize)(pattern => {
2940
- switch (typeof pattern) {
2941
- case 'undefined':
2942
- return () => global_1.undefined;
2943
-
2944
- case 'string':
2945
- return source => source.slice(0, pattern.length) === pattern || global_1.undefined;
2946
-
2947
- case 'object':
2948
- return (0, memoize_1.reduce)(source => pattern.test(source) || global_1.undefined);
2949
- }
2950
- }, signature);
2951
-
2952
- function some(parser, until, deeps = [], limit = -1) {
2953
- if (typeof until === 'number') return some(parser, global_1.undefined, deeps, until);
2954
- const match = matcher(until);
2955
- const delimiters = deeps.map(([delimiter, precedence]) => ({
2956
- signature: signature(delimiter),
2957
- matcher: matcher(delimiter),
3202
+ function some(parser, end, delimiters = [], limit = -1) {
3203
+ if (typeof end === 'number') return some(parser, global_1.undefined, delimiters, end);
3204
+ const match = delimiter_1.Delimiters.matcher(end);
3205
+ const delims = delimiters.map(([delimiter, precedence]) => ({
3206
+ signature: delimiter_1.Delimiters.signature(delimiter),
3207
+ matcher: delimiter_1.Delimiters.matcher(delimiter),
2958
3208
  precedence
2959
3209
  }));
2960
3210
  return (source, context) => {
@@ -2962,9 +3212,9 @@ function some(parser, until, deeps = [], limit = -1) {
2962
3212
  let rest = source;
2963
3213
  let nodes;
2964
3214
 
2965
- if (delimiters.length > 0) {
2966
- context.delimiters ??= new parser_1.Delimiters();
2967
- context.delimiters.push(...delimiters);
3215
+ if (delims.length > 0) {
3216
+ context.delimiters ??= new delimiter_1.Delimiters();
3217
+ context.delimiters.push(...delims);
2968
3218
  }
2969
3219
 
2970
3220
  while (true) {
@@ -2978,8 +3228,8 @@ function some(parser, until, deeps = [], limit = -1) {
2978
3228
  if (limit >= 0 && source.length - rest.length > limit) break;
2979
3229
  }
2980
3230
 
2981
- if (delimiters.length > 0) {
2982
- context.delimiters.pop(delimiters.length);
3231
+ if (delims.length > 0) {
3232
+ context.delimiters.pop(delims.length);
2983
3233
  }
2984
3234
 
2985
3235
  return nodes && rest.length < source.length ? [nodes, rest] : global_1.undefined;
@@ -3005,8 +3255,8 @@ const union_1 = __webpack_require__(6366);
3005
3255
 
3006
3256
  const inits_1 = __webpack_require__(2491);
3007
3257
 
3008
- function subsequence(parsers) {
3009
- 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]));
3258
+ function subsequence(parsers, resume) {
3259
+ 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]));
3010
3260
  }
3011
3261
 
3012
3262
  exports.subsequence = subsequence;
@@ -3028,8 +3278,8 @@ const union_1 = __webpack_require__(6366);
3028
3278
 
3029
3279
  const sequence_1 = __webpack_require__(2287);
3030
3280
 
3031
- function tails(parsers) {
3032
- return (0, union_1.union)(parsers.map((_, i) => (0, sequence_1.sequence)(parsers.slice(i))));
3281
+ function tails(parsers, resume) {
3282
+ return (0, union_1.union)(parsers.map((_, i) => (0, sequence_1.sequence)(parsers.slice(i), resume)));
3033
3283
  }
3034
3284
 
3035
3285
  exports.tails = tails;
@@ -3191,11 +3441,13 @@ const global_1 = __webpack_require__(4128);
3191
3441
 
3192
3442
  const parser_1 = __webpack_require__(6728);
3193
3443
 
3444
+ const segment_1 = __webpack_require__(9002);
3445
+
3194
3446
  const header_1 = __webpack_require__(5702);
3195
3447
 
3196
3448
  const block_1 = __webpack_require__(4032);
3197
3449
 
3198
- const segment_1 = __webpack_require__(9002);
3450
+ const context_1 = __webpack_require__(6484);
3199
3451
 
3200
3452
  const normalize_1 = __webpack_require__(185);
3201
3453
 
@@ -3211,7 +3463,8 @@ const array_1 = __webpack_require__(8112);
3211
3463
 
3212
3464
  function bind(target, settings) {
3213
3465
  let context = { ...settings,
3214
- host: settings.host ?? new url_1.ReadonlyURL(global_1.location.pathname, global_1.location.origin)
3466
+ host: settings.host ?? new url_1.ReadonlyURL(global_1.location.pathname, global_1.location.origin),
3467
+ backtrackable: context_1.backtrackable
3215
3468
  };
3216
3469
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
3217
3470
  const blocks = [];
@@ -3353,9 +3606,8 @@ function bind(target, settings) {
3353
3606
 
3354
3607
  function nearest(index) {
3355
3608
  let el;
3356
- let len = 0;
3357
3609
 
3358
- for (let i = 0; i < blocks.length; ++i) {
3610
+ for (let i = 0, len = 0; i < blocks.length; ++i) {
3359
3611
  const block = blocks[i];
3360
3612
  len += block[0].length;
3361
3613
  el = block[1][0] ?? el;
@@ -3366,9 +3618,7 @@ function bind(target, settings) {
3366
3618
  }
3367
3619
 
3368
3620
  function index(source) {
3369
- let len = 0;
3370
-
3371
- for (let i = 0; i < blocks.length; ++i) {
3621
+ for (let i = 0, len = 0; i < blocks.length; ++i) {
3372
3622
  const block = blocks[i];
3373
3623
  if (block[1].includes(source)) return len;
3374
3624
  len += block[0].length;
@@ -3542,11 +3792,13 @@ const global_1 = __webpack_require__(4128);
3542
3792
 
3543
3793
  const parser_1 = __webpack_require__(6728);
3544
3794
 
3795
+ const segment_1 = __webpack_require__(9002);
3796
+
3545
3797
  const header_1 = __webpack_require__(5702);
3546
3798
 
3547
3799
  const block_1 = __webpack_require__(4032);
3548
3800
 
3549
- const segment_1 = __webpack_require__(9002);
3801
+ const context_1 = __webpack_require__(6484);
3550
3802
 
3551
3803
  const normalize_1 = __webpack_require__(185);
3552
3804
 
@@ -3571,7 +3823,8 @@ function parse(source, opts = {}, context) {
3571
3823
  caches: context?.caches,
3572
3824
  ...(context?.resources && {
3573
3825
  resources: context.resources
3574
- })
3826
+ }),
3827
+ backtrackable: context_1.backtrackable
3575
3828
  };
3576
3829
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
3577
3830
  const node = (0, dom_1.frag)();
@@ -3669,7 +3922,7 @@ const random_1 = __webpack_require__(7325);
3669
3922
  exports.block = (0, combinator_1.creator)(error((0, combinator_1.reset)({
3670
3923
  resources: {
3671
3924
  budget: 50 * 1000,
3672
- recursion: 20 + 1
3925
+ recursion: 20
3673
3926
  }
3674
3927
  }, (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]))));
3675
3928
 
@@ -3824,26 +4077,27 @@ const source_1 = __webpack_require__(6743);
3824
4077
 
3825
4078
  const locale_1 = __webpack_require__(5485);
3826
4079
 
3827
- const util_1 = __webpack_require__(9437);
4080
+ const visibility_1 = __webpack_require__(7618);
3828
4081
 
3829
4082
  const dom_1 = __webpack_require__(3252);
3830
4083
 
3831
4084
  const array_1 = __webpack_require__(8112);
3832
4085
 
3833
- 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)({
3834
- syntax: {
3835
- inline: {
3836
- annotation: false,
3837
- reference: false,
3838
- index: false,
3839
- label: false,
3840
- link: false,
3841
- media: false
3842
- }
3843
- }
3844
- }, (0, combinator_1.some)(term)), (0, combinator_1.some)(desc)]))), es => [(0, dom_1.html)('dl', fillTrailingDescription(es))]))));
3845
- 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))]))));
3846
- 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));
4086
+ 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
4087
+ /* State.annotation */
4088
+ | 32
4089
+ /* State.reference */
4090
+ | 16
4091
+ /* State.index */
4092
+ | 8
4093
+ /* State.label */
4094
+ | 4
4095
+ /* State.link */
4096
+ | 2
4097
+ /* State.media */
4098
+ , (0, combinator_1.some)(term)), (0, combinator_1.some)(desc)]))), es => [(0, dom_1.html)('dl', fillTrailingDescription(es))]))));
4099
+ 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))]))));
4100
+ 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));
3847
4101
 
3848
4102
  function fillTrailingDescription(es) {
3849
4103
  return es.length > 0 && es[es.length - 1].tagName === 'DT' ? (0, array_1.push)(es, [(0, dom_1.html)('dd')]) : es;
@@ -4120,7 +4374,7 @@ const inline_1 = __webpack_require__(1160);
4120
4374
 
4121
4375
  const locale_1 = __webpack_require__(5485);
4122
4376
 
4123
- const util_1 = __webpack_require__(9437);
4377
+ const visibility_1 = __webpack_require__(7618);
4124
4378
 
4125
4379
  const dom_1 = __webpack_require__(3252);
4126
4380
 
@@ -4128,13 +4382,9 @@ const memoize_1 = __webpack_require__(1808);
4128
4382
 
4129
4383
  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.
4130
4384
  (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, [])));
4131
- 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)({
4132
- syntax: {
4133
- inline: {
4134
- media: false
4135
- }
4136
- }
4137
- }, (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', {
4385
+ 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
4386
+ /* State.media */
4387
+ , (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', {
4138
4388
  class: 'figindex'
4139
4389
  }), (0, dom_1.html)('span', {
4140
4390
  class: 'figtext'
@@ -4380,7 +4630,7 @@ const source_1 = __webpack_require__(6743);
4380
4630
 
4381
4631
  const locale_1 = __webpack_require__(5485);
4382
4632
 
4383
- const util_1 = __webpack_require__(9437);
4633
+ const visibility_1 = __webpack_require__(7618);
4384
4634
 
4385
4635
  const dom_1 = __webpack_require__(3252);
4386
4636
 
@@ -4421,8 +4671,8 @@ const row = (0, combinator_1.lazy)(() => (0, combinator_1.dup)((0, combinator_1.
4421
4671
  const alignment = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)/;
4422
4672
  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(''))));
4423
4673
  const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/;
4424
- 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));
4425
- 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));
4674
+ 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));
4675
+ 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));
4426
4676
  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)]))));
4427
4677
 
4428
4678
  function attributes(source) {
@@ -4653,29 +4903,26 @@ const inline_1 = __webpack_require__(1160);
4653
4903
 
4654
4904
  const source_1 = __webpack_require__(6743);
4655
4905
 
4656
- const util_1 = __webpack_require__(9437);
4906
+ const visibility_1 = __webpack_require__(7618);
4657
4907
 
4658
4908
  const dom_1 = __webpack_require__(3252);
4659
4909
 
4660
4910
  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], ''])))));
4661
- exports.heading = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.context)({
4662
- syntax: {
4663
- inline: {
4664
- annotation: false,
4665
- reference: false,
4666
- index: false,
4667
- label: false,
4668
- link: false,
4669
- media: false
4670
- }
4671
- }
4672
- }, (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)({
4673
- syntax: {
4674
- inline: {
4675
- autolink: false
4676
- }
4677
- }
4678
- }, (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`, {
4911
+ exports.heading = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.state)(64
4912
+ /* State.annotation */
4913
+ | 32
4914
+ /* State.reference */
4915
+ | 16
4916
+ /* State.index */
4917
+ | 8
4918
+ /* State.label */
4919
+ | 4
4920
+ /* State.link */
4921
+ | 2
4922
+ /* State.media */
4923
+ , (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
4924
+ /* State.autolink */
4925
+ , (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`, {
4679
4926
  class: 'invalid',
4680
4927
  'data-invalid-syntax': 'heading',
4681
4928
  'data-invalid-type': 'syntax',
@@ -4724,13 +4971,9 @@ const inline_1 = __webpack_require__(1160);
4724
4971
 
4725
4972
  const dom_1 = __webpack_require__(3252);
4726
4973
 
4727
- exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.context)({
4728
- syntax: {
4729
- inline: {
4730
- media: false
4731
- }
4732
- }
4733
- }, exports.ilist_))));
4974
+ 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
4975
+ /* State.media */
4976
+ , exports.ilist_))));
4734
4977
  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', {
4735
4978
  class: 'invalid',
4736
4979
  'data-invalid-syntax': 'list',
@@ -4801,12 +5044,14 @@ const inline_1 = __webpack_require__(1160);
4801
5044
 
4802
5045
  const source_1 = __webpack_require__(6743);
4803
5046
 
4804
- const util_1 = __webpack_require__(9437);
5047
+ const visibility_1 = __webpack_require__(7618);
4805
5048
 
4806
5049
  const dom_1 = __webpack_require__(3252);
4807
5050
 
4808
5051
  const memoize_1 = __webpack_require__(1808);
4809
5052
 
5053
+ const duff_1 = __webpack_require__(8099);
5054
+
4810
5055
  const array_1 = __webpack_require__(8112);
4811
5056
 
4812
5057
  const tuple_1 = __webpack_require__(5341);
@@ -4815,16 +5060,12 @@ const openers = {
4815
5060
  '.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?:$|\s)/,
4816
5061
  '(': /^\(([0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?:$|\s)/
4817
5062
  };
4818
- 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)({
4819
- syntax: {
4820
- inline: {
4821
- media: false
4822
- }
4823
- }
4824
- }, exports.olist_))));
5063
+ 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
5064
+ /* State.media */
5065
+ , exports.olist_))));
4825
5066
  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, []))])));
4826
5067
 
4827
- 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', {
5068
+ 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', {
4828
5069
  'data-marker': ns[0] || global_1.undefined
4829
5070
  }, (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)]);
4830
5071
 
@@ -4907,20 +5148,19 @@ function format(el, type, form) {
4907
5148
  'data-type': style(type) || global_1.undefined
4908
5149
  });
4909
5150
  const marker = el.firstElementChild?.getAttribute('data-marker').match(initial(type))?.[0] ?? '';
4910
-
4911
- for (let es = el.children, len = es.length, i = 0; i < len; ++i) {
5151
+ const es = el.children;
5152
+ (0, duff_1.duffbk)(es.length, i => {
4912
5153
  const el = es[i];
4913
5154
 
4914
5155
  switch (el.getAttribute('data-marker')) {
4915
5156
  case '':
4916
5157
  case marker:
4917
5158
  el.removeAttribute('data-marker');
4918
- continue;
5159
+ return;
4919
5160
  }
4920
5161
 
4921
- break;
4922
- }
4923
-
5162
+ return false;
5163
+ });
4924
5164
  return el;
4925
5165
  }
4926
5166
 
@@ -4943,11 +5183,11 @@ const inline_1 = __webpack_require__(1160);
4943
5183
 
4944
5184
  const locale_1 = __webpack_require__(5485);
4945
5185
 
4946
- const util_1 = __webpack_require__(9437);
5186
+ const visibility_1 = __webpack_require__(7618);
4947
5187
 
4948
5188
  const dom_1 = __webpack_require__(3252);
4949
5189
 
4950
- 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))])));
5190
+ 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))])));
4951
5191
 
4952
5192
  /***/ }),
4953
5193
 
@@ -4974,7 +5214,7 @@ const source_1 = __webpack_require__(6743);
4974
5214
 
4975
5215
  const locale_1 = __webpack_require__(5485);
4976
5216
 
4977
- const util_1 = __webpack_require__(9437);
5217
+ const visibility_1 = __webpack_require__(7618);
4978
5218
 
4979
5219
  const dom_1 = __webpack_require__(3252);
4980
5220
 
@@ -4987,7 +5227,7 @@ const array_1 = __webpack_require__(8112);
4987
5227
  */
4988
5228
 
4989
5229
 
4990
- 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]))]))));
5230
+ 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]))]))));
4991
5231
 
4992
5232
  /***/ }),
4993
5233
 
@@ -5146,13 +5386,17 @@ const inline_1 = __webpack_require__(1160);
5146
5386
 
5147
5387
  const source_1 = __webpack_require__(6743);
5148
5388
 
5389
+ const visibility_1 = __webpack_require__(7618);
5390
+
5149
5391
  const dom_1 = __webpack_require__(3252);
5150
5392
 
5393
+ const duff_1 = __webpack_require__(8099);
5394
+
5151
5395
  const array_1 = __webpack_require__(8112);
5152
5396
 
5153
5397
  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))])])));
5154
5398
 
5155
- const row = (parser, optional) => (0, combinator_1.creator)((0, combinator_1.fallback)((0, combinator_1.fmap)((0, combinator_1.line)((0, combinator_1.surround)(/^(?=\|)/, (0, combinator_1.some)((0, combinator_1.union)([parser])), /^\|?\s*$/, optional)), es => [(0, dom_1.html)('tr', es)]), (0, combinator_1.rewrite)(source_1.contentline, source => [[(0, dom_1.html)('tr', {
5399
+ const row = (parser, optional) => (0, combinator_1.creator)((0, combinator_1.fallback)((0, combinator_1.fmap)((0, combinator_1.line)((0, combinator_1.surround)(/^(?=\|)/, (0, combinator_1.some)((0, combinator_1.union)([parser])), /^[|\\]?\s*$/, optional)), es => [(0, dom_1.html)('tr', es)]), (0, combinator_1.rewrite)(source_1.contentline, source => [[(0, dom_1.html)('tr', {
5156
5400
  class: 'invalid',
5157
5401
  'data-invalid-syntax': 'table-row',
5158
5402
  'data-invalid-type': 'syntax',
@@ -5160,24 +5404,22 @@ const row = (parser, optional) => (0, combinator_1.creator)((0, combinator_1.fal
5160
5404
  }, [(0, dom_1.html)('td', source.replace('\n', ''))])], ''])));
5161
5405
 
5162
5406
  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))]));
5163
- const cell = (0, combinator_1.surround)(/^\|(?:\\?\s)*(?=\S)/, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /^(?:\\?\s)*(?=\||\\?$)/), /^[^|]*/, true);
5164
- const head = (0, combinator_1.creator)((0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, dom_1.defrag)(ns))]));
5165
- const data = (0, combinator_1.creator)((0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]));
5407
+ const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /^\|/, [[/^[|\\]?\s*$/, 9]]), /^[^|]*/, true);
5408
+ 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)))]));
5409
+ 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)))]));
5166
5410
 
5167
5411
  function format(rows) {
5168
- const aligns = rows[0].classList.contains('invalid') ? [] : (0, array_1.push)([], rows.shift().children).map(el => el.textContent);
5169
-
5170
- for (let i = 0, len = rows.length; i < len; ++i) {
5171
- const cols = rows[i].children;
5412
+ const aligns = rows[0].classList.contains('invalid') ? [] : (0, duff_1.duffReduce)(rows.shift().children, (acc, el) => (0, array_1.push)(acc, [el.textContent]), []);
5172
5413
 
5173
- for (let i = 0, len = cols.length; i < len; ++i) {
5414
+ for (let i = 0; i < rows.length; ++i) {
5415
+ (0, duff_1.duffEach)(rows[i].children, (col, i) => {
5174
5416
  if (i > 0 && !aligns[i]) {
5175
5417
  aligns[i] = aligns[i - 1];
5176
5418
  }
5177
5419
 
5178
- if (!aligns[i]) continue;
5179
- cols[i].setAttribute('align', aligns[i]);
5180
- }
5420
+ if (!aligns[i]) return;
5421
+ col.setAttribute('align', aligns[i]);
5422
+ });
5181
5423
  }
5182
5424
 
5183
5425
  return rows;
@@ -5204,20 +5446,16 @@ const ilist_1 = __webpack_require__(238);
5204
5446
 
5205
5447
  const inline_1 = __webpack_require__(1160);
5206
5448
 
5207
- const util_1 = __webpack_require__(9437);
5449
+ const visibility_1 = __webpack_require__(7618);
5208
5450
 
5209
5451
  const dom_1 = __webpack_require__(3252);
5210
5452
 
5211
5453
  const array_1 = __webpack_require__(8112);
5212
5454
 
5213
- exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.context)({
5214
- syntax: {
5215
- inline: {
5216
- media: false
5217
- }
5218
- }
5219
- }, exports.ulist_))));
5220
- 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))])));
5455
+ 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
5456
+ /* State.media */
5457
+ , exports.ulist_))));
5458
+ 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))])));
5221
5459
  exports.checkbox = (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, source => [[(0, dom_1.html)('span', {
5222
5460
  class: 'checkbox'
5223
5461
  }, source[1].trimStart() ? '☑' : '☐')], '']);
@@ -5238,6 +5476,30 @@ function format(el) {
5238
5476
 
5239
5477
  /***/ }),
5240
5478
 
5479
+ /***/ 6484:
5480
+ /***/ ((__unused_webpack_module, exports) => {
5481
+
5482
+ "use strict";
5483
+
5484
+
5485
+ Object.defineProperty(exports, "__esModule", ({
5486
+ value: true
5487
+ }));
5488
+ exports.backtrackable = void 0;
5489
+ exports.backtrackable = 0 | 64
5490
+ /* State.annotation */
5491
+ | 32
5492
+ /* State.reference */
5493
+ | 16
5494
+ /* State.index */
5495
+ | 4
5496
+ /* State.link */
5497
+ | 2
5498
+ /* State.media */
5499
+ ;
5500
+
5501
+ /***/ }),
5502
+
5241
5503
  /***/ 5702:
5242
5504
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5243
5505
 
@@ -5404,28 +5666,23 @@ const inline_1 = __webpack_require__(1160);
5404
5666
 
5405
5667
  const link_1 = __webpack_require__(9628);
5406
5668
 
5407
- const util_1 = __webpack_require__(9437);
5669
+ const visibility_1 = __webpack_require__(7618);
5408
5670
 
5409
5671
  const dom_1 = __webpack_require__(3252);
5410
5672
 
5411
- 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)({
5412
- syntax: {
5413
- inline: {
5414
- annotation: false,
5415
- // Redundant
5416
- //reference: true,
5417
- media: false // Redundant
5418
- //index: true,
5419
- //label: true,
5420
- //link: true,
5421
- //autolink: true,
5422
-
5423
- }
5424
- },
5673
+ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('((', (0, combinator_1.syntax)(32
5674
+ /* Rule.annotation */
5675
+ , 6, (0, combinator_1.surround)('((', (0, combinator_1.guard)(context => ~context.state & 64
5676
+ /* State.annotation */
5677
+ , (0, combinator_1.state)(64
5678
+ /* State.annotation */
5679
+ | 2
5680
+ /* State.media */
5681
+ , (0, visibility_1.startLoose)((0, combinator_1.context)({
5425
5682
  delimiters: global_1.undefined
5426
- }, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])), ')')), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
5683
+ }, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])), ')'))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
5427
5684
  class: 'annotation'
5428
- }, [(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)))))));
5685
+ }, [(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)))));
5429
5686
 
5430
5687
  /***/ }),
5431
5688
 
@@ -5460,11 +5717,15 @@ const source_1 = __webpack_require__(6743);
5460
5717
 
5461
5718
  const util_1 = __webpack_require__(9437);
5462
5719
 
5463
- 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.
5720
+ exports.autolink = (0, combinator_1.fmap)((0, combinator_1.validate)(/^(?:[@#>0-9A-Za-z]|\S#)/, (0, combinator_1.guard)(context => ~context.state & 1
5721
+ /* State.autolink */
5722
+ , (0, combinator_1.syntax)(2
5723
+ /* Rule.autolink */
5724
+ , 1, (0, combinator_1.some)((0, combinator_1.union)([url_1.url, email_1.email, // Escape unmatched email-like strings.
5464
5725
  (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.
5465
5726
  (0, source_1.str)(/^@+[0-9A-Za-z]*(?:-[0-9A-Za-z]+)*/), // Escape invalid leading characters.
5466
5727
  (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.
5467
- (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)]);
5728
+ (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)]);
5468
5729
 
5469
5730
  /***/ }),
5470
5731
 
@@ -5686,12 +5947,26 @@ const dom_1 = __webpack_require__(3252);
5686
5947
  const array_1 = __webpack_require__(8112);
5687
5948
 
5688
5949
  const index = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*/;
5689
- 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', {
5950
+ exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.syntax)(0
5951
+ /* Rule.none */
5952
+ , 2, (0, combinator_1.surround)((0, source_1.str)('('), (0, source_1.str)(index), (0, source_1.str)(')'))), (0, combinator_1.syntax)(128
5953
+ /* Rule.bracket */
5954
+ , 2, (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)(inline_1.inline, ')', [[')', 2]]), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
5690
5955
  class: 'paren'
5691
- }, (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', {
5956
+ }, (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.syntax)(0
5957
+ /* Rule.none */
5958
+ , 2, (0, combinator_1.surround)((0, source_1.str)('('), (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.syntax)(128
5959
+ /* Rule.bracket */
5960
+ , 2, (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)(inline_1.inline, ')', [[')', 2]]), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
5692
5961
  class: 'paren'
5693
- }, (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.
5694
- (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])])));
5962
+ }, (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.syntax)(128
5963
+ /* Rule.bracket */
5964
+ , 2, (0, combinator_1.surround)((0, source_1.str)('['), (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.syntax)(128
5965
+ /* Rule.bracket */
5966
+ , 2, (0, combinator_1.surround)((0, source_1.str)('{'), (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.
5967
+ (0, combinator_1.syntax)(1
5968
+ /* Rule.quote */
5969
+ , 8, (0, combinator_1.surround)((0, source_1.str)('"'), (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]))]));
5695
5970
 
5696
5971
  /***/ }),
5697
5972
 
@@ -5743,11 +6018,13 @@ const memoize_1 = __webpack_require__(1808);
5743
6018
 
5744
6019
  const array_1 = __webpack_require__(8112);
5745
6020
 
5746
- 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', {
6021
+ exports.comment = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[%', (0, combinator_1.syntax)(0
6022
+ /* Rule.none */
6023
+ , 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', {
5747
6024
  class: 'comment'
5748
6025
  }, [(0, dom_1.html)('input', {
5749
6026
  type: 'checkbox'
5750
- }), (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, []))))));
6027
+ }), (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, [])))));
5751
6028
 
5752
6029
  /***/ }),
5753
6030
 
@@ -5768,13 +6045,15 @@ const inline_1 = __webpack_require__(1160);
5768
6045
 
5769
6046
  const source_1 = __webpack_require__(6743);
5770
6047
 
5771
- const util_1 = __webpack_require__(9437);
6048
+ const visibility_1 = __webpack_require__(7618);
5772
6049
 
5773
6050
  const dom_1 = __webpack_require__(3252);
5774
6051
 
5775
6052
  const array_1 = __webpack_require__(8112);
5776
6053
 
5777
- 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]))));
6054
+ exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
6055
+ /* Rule.none */
6056
+ , 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])));
5778
6057
 
5779
6058
  /***/ }),
5780
6059
 
@@ -5799,13 +6078,15 @@ const strong_1 = __webpack_require__(8072);
5799
6078
 
5800
6079
  const source_1 = __webpack_require__(6743);
5801
6080
 
5802
- const util_1 = __webpack_require__(9437);
6081
+ const visibility_1 = __webpack_require__(7618);
5803
6082
 
5804
6083
  const dom_1 = __webpack_require__(3252);
5805
6084
 
5806
6085
  const array_1 = __webpack_require__(8112);
5807
6086
 
5808
- 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]))));
6087
+ exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
6088
+ /* Rule.none */
6089
+ , 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])));
5809
6090
 
5810
6091
  /***/ }),
5811
6092
 
@@ -5830,15 +6111,17 @@ const emphasis_1 = __webpack_require__(3867);
5830
6111
 
5831
6112
  const source_1 = __webpack_require__(6743);
5832
6113
 
5833
- const util_1 = __webpack_require__(9437);
6114
+ const visibility_1 = __webpack_require__(7618);
5834
6115
 
5835
6116
  const dom_1 = __webpack_require__(3252);
5836
6117
 
5837
6118
  const array_1 = __webpack_require__(8112);
5838
6119
 
5839
- 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]))])));
5840
- 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]))])));
5841
- 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) => {
6120
+ 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]))])));
6121
+ 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]))])));
6122
+ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
6123
+ /* Rule.none */
6124
+ , 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) => {
5842
6125
  switch (cs[0]) {
5843
6126
  case '***':
5844
6127
  return [[(0, dom_1.html)('em', [(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))])], rest];
@@ -5849,7 +6132,7 @@ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, co
5849
6132
  case '*':
5850
6133
  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];
5851
6134
  }
5852
- }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]))));
6135
+ }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
5853
6136
 
5854
6137
  /***/ }),
5855
6138
 
@@ -5935,28 +6218,34 @@ const indexee_1 = __webpack_require__(1269);
5935
6218
 
5936
6219
  const source_1 = __webpack_require__(6743);
5937
6220
 
5938
- const util_1 = __webpack_require__(9437);
6221
+ const visibility_1 = __webpack_require__(7618);
5939
6222
 
5940
6223
  const dom_1 = __webpack_require__(3252);
5941
6224
 
5942
- 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)({
5943
- syntax: {
5944
- inline: {
5945
- annotation: false,
5946
- reference: false,
5947
- index: false,
5948
- label: false,
5949
- link: false,
5950
- media: false,
5951
- autolink: false
5952
- }
5953
- }
5954
- }, (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, {
6225
+ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.syntax)(1024
6226
+ /* Rule.index */
6227
+ , 2, (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.guard)(context => ~context.state & 16
6228
+ /* State.index */
6229
+ , (0, combinator_1.state)(64
6230
+ /* State.annotation */
6231
+ | 32
6232
+ /* State.reference */
6233
+ | 16
6234
+ /* State.index */
6235
+ | 8
6236
+ /* State.label */
6237
+ | 4
6238
+ /* State.link */
6239
+ | 2
6240
+ /* State.media */
6241
+ | 1
6242
+ /* State.autolink */
6243
+ , (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, {
5955
6244
  id: el.id ? null : global_1.undefined,
5956
6245
  class: 'index',
5957
6246
  href: el.id ? `#${el.id}` : global_1.undefined
5958
- }, el.childNodes)])))));
5959
- 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', {
6247
+ }, el.childNodes)]))));
6248
+ 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', {
5960
6249
  class: 'indexer',
5961
6250
  'data-index': (0, indexee_1.identity)(ns.join('')).slice(6)
5962
6251
  })])));
@@ -5981,6 +6270,8 @@ const combinator_1 = __webpack_require__(2087);
5981
6270
 
5982
6271
  const dom_1 = __webpack_require__(3252);
5983
6272
 
6273
+ const duff_1 = __webpack_require__(8099);
6274
+
5984
6275
  function indexee(parser, optional) {
5985
6276
  return (0, combinator_1.fmap)(parser, ([el], _, {
5986
6277
  id
@@ -6004,41 +6295,37 @@ function text(source, optional = false) {
6004
6295
  const index = indexer?.getAttribute('data-index');
6005
6296
  if (index) return index;
6006
6297
  const target = source.cloneNode(true);
6007
-
6008
- 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) {
6009
- const el = es[i];
6010
-
6298
+ (0, duff_1.duffEach)(target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference, .checkbox, ul, ol'), el => {
6011
6299
  switch (el.tagName) {
6012
6300
  case 'CODE':
6013
6301
  (0, dom_1.define)(el, el.getAttribute('data-src'));
6014
- continue;
6302
+ return;
6015
6303
 
6016
6304
  case 'RT':
6017
6305
  case 'RP':
6018
6306
  case 'UL':
6019
6307
  case 'OL':
6020
6308
  el.remove();
6021
- continue;
6309
+ return;
6022
6310
  }
6023
6311
 
6024
6312
  switch (el.className) {
6025
6313
  case 'math':
6026
6314
  (0, dom_1.define)(el, el.getAttribute('data-src'));
6027
- continue;
6315
+ return;
6028
6316
 
6029
6317
  case 'comment':
6030
6318
  case 'checkbox':
6031
6319
  el.remove();
6032
- continue;
6320
+ return;
6033
6321
 
6034
6322
  case 'reference':
6035
6323
  el.firstChild.remove();
6036
- continue;
6324
+ return;
6037
6325
  }
6038
- } // Better:
6326
+ }); // Better:
6039
6327
  //return target.innerText;
6040
6328
 
6041
-
6042
6329
  return target.textContent;
6043
6330
  }
6044
6331
 
@@ -6061,11 +6348,11 @@ const combinator_1 = __webpack_require__(2087);
6061
6348
 
6062
6349
  const index_1 = __webpack_require__(4479);
6063
6350
 
6064
- const util_1 = __webpack_require__(9437);
6065
-
6066
6351
  const dom_1 = __webpack_require__(3252);
6067
6352
 
6068
- 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', {
6353
+ 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
6354
+ /* State.index */
6355
+ , false, (0, combinator_1.union)([(0, combinator_1.focus)('[#]', () => [[(0, dom_1.html)('a', {
6069
6356
  href: '#'
6070
6357
  })], '']), index_1.index])), /^\s*$/), // Indexer is invisible but invalids must be visible.
6071
6358
  ([el]) => el.getElementsByClassName('invalid').length === 0), ([el]) => [(0, dom_1.html)('span', {
@@ -6096,7 +6383,9 @@ const dom_1 = __webpack_require__(3252);
6096
6383
 
6097
6384
  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]))/);
6098
6385
  exports.segment = (0, combinator_1.clear)((0, combinator_1.validate)(['[$', '$'], (0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']'), body])));
6099
- 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', {
6386
+ exports.label = (0, combinator_1.validate)(['[$', '$'], (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.guard)(context => ~context.state & 8
6387
+ /* State.label */
6388
+ , (0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']'), body])), ([text]) => [(0, dom_1.html)('a', {
6100
6389
  class: 'label',
6101
6390
  'data-label': text.slice(text[1] === '-' ? 0 : 1).toLowerCase()
6102
6391
  }, text)])));
@@ -6144,7 +6433,7 @@ const inline_1 = __webpack_require__(1160);
6144
6433
 
6145
6434
  const source_1 = __webpack_require__(6743);
6146
6435
 
6147
- const util_1 = __webpack_require__(9437);
6436
+ const visibility_1 = __webpack_require__(7618);
6148
6437
 
6149
6438
  const dom_1 = __webpack_require__(3252);
6150
6439
 
@@ -6152,12 +6441,14 @@ const array_1 = __webpack_require__(8112); // Don't use the symbols already used
6152
6441
  // All syntax surrounded by square brackets shouldn't contain line breaks.
6153
6442
 
6154
6443
 
6155
- 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', {
6444
+ exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[:', '[^'], (0, combinator_1.syntax)(0
6445
+ /* Rule.none */
6446
+ , 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', {
6156
6447
  class: 'invalid',
6157
6448
  'data-invalid-syntax': 'extension',
6158
6449
  'data-invalid-type': 'syntax',
6159
6450
  'data-invalid-message': `Reserved start symbol "${as[0][1]}" cannot be used in "[]"`
6160
- }, (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])))));
6451
+ }, (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]))));
6161
6452
 
6162
6453
  /***/ }),
6163
6454
 
@@ -6180,7 +6471,7 @@ const inline_1 = __webpack_require__(1160);
6180
6471
 
6181
6472
  const source_1 = __webpack_require__(6743);
6182
6473
 
6183
- const util_1 = __webpack_require__(9437);
6474
+ const visibility_1 = __webpack_require__(7618);
6184
6475
 
6185
6476
  const dom_1 = __webpack_require__(3252);
6186
6477
 
@@ -6198,8 +6489,10 @@ const attrspecs = {
6198
6489
  };
6199
6490
  global_1.Object.setPrototypeOf(attrspecs, null);
6200
6491
  global_1.Object.values(attrspecs).forEach(o => global_1.Object.setPrototypeOf(o, null));
6201
- 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
6202
- /^<(?: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)))]))))));
6492
+ exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('<', (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/, (0, combinator_1.syntax)(0
6493
+ /* Rule.none */
6494
+ , 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
6495
+ /^<(?: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)))])))));
6203
6496
  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
6204
6497
  // [...document.querySelectorAll('tbody > tr > td:first-child')].map(el => el.textContent.slice(1, -1))
6205
6498
 
@@ -6209,7 +6502,7 @@ function elem(tag, as, bs, cs) {
6209
6502
  if (!tags.includes(tag)) return invalid('tag', `Invalid HTML tag name "${tag}"`, as, bs, cs);
6210
6503
  if (cs.length === 0) return invalid('tag', `Missing the closing HTML tag "</${tag}>"`, as, bs, cs);
6211
6504
  if (bs.length === 0) return invalid('content', `Missing the content`, as, bs, cs);
6212
- if (!(0, util_1.isStartLooseNodes)(bs)) return invalid('content', `Missing the visible content in the same line`, as, bs, cs);
6505
+ if (!(0, visibility_1.isStartLooseNodes)(bs)) return invalid('content', `Missing the visible content in the same line`, as, bs, cs);
6213
6506
  const attrs = attributes('html', [], attrspecs[tag], as.slice(1, -1));
6214
6507
  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));
6215
6508
  }
@@ -6307,13 +6600,15 @@ const inline_1 = __webpack_require__(1160);
6307
6600
 
6308
6601
  const source_1 = __webpack_require__(6743);
6309
6602
 
6310
- const util_1 = __webpack_require__(9437);
6603
+ const visibility_1 = __webpack_require__(7618);
6311
6604
 
6312
6605
  const dom_1 = __webpack_require__(3252);
6313
6606
 
6314
6607
  const array_1 = __webpack_require__(8112);
6315
6608
 
6316
- 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]))));
6609
+ exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
6610
+ /* Rule.none */
6611
+ , 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])));
6317
6612
 
6318
6613
  /***/ }),
6319
6614
 
@@ -6342,6 +6637,8 @@ const autolink_1 = __webpack_require__(6578);
6342
6637
 
6343
6638
  const source_1 = __webpack_require__(6743);
6344
6639
 
6640
+ const visibility_1 = __webpack_require__(7618);
6641
+
6345
6642
  const util_1 = __webpack_require__(9437);
6346
6643
 
6347
6644
  const dom_1 = __webpack_require__(3252);
@@ -6352,43 +6649,43 @@ const optspec = {
6352
6649
  rel: ['nofollow']
6353
6650
  };
6354
6651
  Object.setPrototypeOf(optspec, null);
6355
- 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)({
6356
- syntax: {
6357
- inline: {
6358
- link: false
6359
- }
6360
- }
6361
- }, (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)({
6362
- syntax: {
6363
- inline: {
6364
- annotation: false,
6365
- reference: false,
6366
- index: false,
6367
- label: false,
6368
- // Redundant
6369
- //link: false,
6370
- media: false,
6371
- autolink: false
6372
- }
6373
- }
6374
- }, (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))]))), // 全体の失敗が確定した時も解析し予算を浪費している
6375
- (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) => {
6376
- if (params.length === 0) return;
6652
+ exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.syntax)(256
6653
+ /* Rule.link */
6654
+ , 2, 10, (0, combinator_1.bind)((0, combinator_1.guard)(context => ~context.state & 4
6655
+ /* State.link */
6656
+ , (0, combinator_1.fmap)((0, combinator_1.subsequence)([(0, combinator_1.state)(4
6657
+ /* State.link */
6658
+ , (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
6659
+ /* State.annotation */
6660
+ | 32
6661
+ /* State.reference */
6662
+ | 16
6663
+ /* State.index */
6664
+ | 8
6665
+ /* State.label */
6666
+ | 2
6667
+ /* State.media */
6668
+ | 1
6669
+ /* State.autolink */
6670
+ , (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) => {
6377
6671
  if (content[0] === '') return [content, rest];
6378
- if (content.length !== 0 && (0, util_1.trimNode)(content).length === 0) return;
6672
+ if (params.length === 0) return;
6673
+ if (content.length !== 0 && (0, visibility_1.trimNode)(content).length === 0) return;
6379
6674
  if ((0, parser_1.eval)((0, combinator_1.some)(autolink_1.autolink)((0, util_1.stringify)(content), context))?.some(node => typeof node === 'object')) return;
6380
6675
  const INSECURE_URI = params.shift();
6381
6676
  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);
6382
6677
  if (el.classList.contains('invalid')) return [[el], rest];
6383
6678
  return [[(0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))], rest];
6384
- })))));
6385
- 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) => {
6679
+ }))));
6680
+ exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.syntax)(256
6681
+ /* Rule.link */
6682
+ , 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) => {
6386
6683
  params.shift();
6387
- (0, util_1.trimNode)(content);
6684
+ (0, visibility_1.trimNode)(content);
6388
6685
  const INSECURE_URI = params.shift();
6389
6686
  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);
6390
6687
  return [[(0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))], rest];
6391
- })))));
6688
+ }))));
6392
6689
  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]);
6393
6690
  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)}`])]);
6394
6691
 
@@ -6466,12 +6763,15 @@ function decode(uri) {
6466
6763
  }
6467
6764
  }
6468
6765
 
6469
- function optimize(opener, ns, rest) {
6766
+ function optimize(opener, ns, rest, next) {
6767
+ if (next[+(next[0] === '\\')] === '\n') return;
6470
6768
  let count = 0;
6471
6769
 
6472
6770
  for (let i = 0; i < ns.length - 1; i += 2) {
6473
- if (ns[i] !== '' || ns[i + 1] !== opener[0]) break;
6474
- ++count;
6771
+ const fst = ns[i];
6772
+ const snd = ns[i + 1];
6773
+ if (fst !== '' || snd[0] !== opener[0]) break;
6774
+ count += snd.length;
6475
6775
  }
6476
6776
 
6477
6777
  return [['', opener[0].repeat(opener.length + count)], rest.slice(count)];
@@ -6498,13 +6798,15 @@ const inline_1 = __webpack_require__(1160);
6498
6798
 
6499
6799
  const source_1 = __webpack_require__(6743);
6500
6800
 
6501
- const util_1 = __webpack_require__(9437);
6801
+ const visibility_1 = __webpack_require__(7618);
6502
6802
 
6503
6803
  const dom_1 = __webpack_require__(3252);
6504
6804
 
6505
6805
  const array_1 = __webpack_require__(8112);
6506
6806
 
6507
- 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]))));
6807
+ exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
6808
+ /* Rule.none */
6809
+ , 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])));
6508
6810
 
6509
6811
  /***/ }),
6510
6812
 
@@ -6581,7 +6883,11 @@ const optspec = {
6581
6883
  rel: global_1.undefined
6582
6884
  };
6583
6885
  Object.setPrototypeOf(optspec, null);
6584
- 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) => {
6886
+ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.syntax)(64
6887
+ /* Rule.media */
6888
+ , 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
6889
+ /* State.media */
6890
+ , (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) => {
6585
6891
  const INSECURE_URI = params.shift();
6586
6892
  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);
6587
6893
  let cache;
@@ -6599,12 +6905,14 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '
6599
6905
  el.style.aspectRatio = el.getAttribute('aspect-ratio');
6600
6906
  }
6601
6907
 
6602
- if (context.syntax?.inline?.link === false || cache && cache.tagName !== 'IMG') return [[el], rest];
6908
+ if (context.state & 4
6909
+ /* State.link */
6910
+ || cache && cache.tagName !== 'IMG') return [[el], rest];
6603
6911
  return (0, combinator_1.fmap)(link_1.textlink, ([link]) => [(0, dom_1.define)(link, {
6604
6912
  target: '_blank'
6605
6913
  }, [el])])(`{ ${INSECURE_URI}${params.join('')} }${rest}`, context);
6606
- })))));
6607
- 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)]));
6914
+ }))));
6915
+ 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)])));
6608
6916
  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]);
6609
6917
 
6610
6918
  function sanitize(target, uri, alt) {
@@ -6670,26 +6978,26 @@ const link_1 = __webpack_require__(9628);
6670
6978
 
6671
6979
  const source_1 = __webpack_require__(6743);
6672
6980
 
6981
+ const visibility_1 = __webpack_require__(7618);
6982
+
6673
6983
  const util_1 = __webpack_require__(9437);
6674
6984
 
6675
6985
  const dom_1 = __webpack_require__(3252);
6676
6986
 
6677
- 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)({
6678
- syntax: {
6679
- inline: {
6680
- annotation: false,
6681
- reference: false,
6682
- media: false // Redundant
6683
- //index: true,
6684
- //label: true,
6685
- //link: true,
6686
- //autolink: true,
6687
-
6688
- }
6689
- },
6987
+ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[[', (0, combinator_1.syntax)(4096
6988
+ /* Rule.reference */
6989
+ , 6, (0, combinator_1.surround)('[[', (0, combinator_1.guard)(context => ~context.state & 32
6990
+ /* State.reference */
6991
+ , (0, combinator_1.state)(64
6992
+ /* State.annotation */
6993
+ | 32
6994
+ /* State.reference */
6995
+ | 2
6996
+ /* State.media */
6997
+ , (0, visibility_1.startLoose)((0, combinator_1.context)({
6690
6998
  delimiters: global_1.undefined
6691
- }, (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)))))));
6692
- 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, '')]));
6999
+ }, (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)))));
7000
+ 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, '')]));
6693
7001
 
6694
7002
  function attributes(ns) {
6695
7003
  return typeof ns[0] === 'object' && ns[0].tagName === 'ABBR' ? {
@@ -6728,13 +7036,15 @@ const htmlentity_1 = __webpack_require__(1562);
6728
7036
 
6729
7037
  const source_1 = __webpack_require__(6743);
6730
7038
 
6731
- const util_1 = __webpack_require__(9437);
7039
+ const visibility_1 = __webpack_require__(7618);
6732
7040
 
6733
7041
  const dom_1 = __webpack_require__(3252);
6734
7042
 
6735
7043
  const array_1 = __webpack_require__(8112);
6736
7044
 
6737
- 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]) => {
7045
+ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.syntax)(0
7046
+ /* Rule.none */
7047
+ , 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]) => {
6738
7048
  texts[texts.length - 1] === '' && texts.pop();
6739
7049
 
6740
7050
  switch (true) {
@@ -6823,7 +7133,9 @@ const url_1 = __webpack_require__(4318);
6823
7133
 
6824
7134
  const media_1 = __webpack_require__(1303);
6825
7135
 
6826
- 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])));
7136
+ exports.shortmedia = (0, combinator_1.rewrite)((0, combinator_1.guard)(context => ~context.state & 2
7137
+ /* State.media */
7138
+ , (0, combinator_1.open)('!', url_1.url)), (0, combinator_1.convert)(source => `!{ ${source.slice(1)} }`, (0, combinator_1.union)([media_1.media])));
6827
7139
 
6828
7140
  /***/ }),
6829
7141
 
@@ -6846,13 +7158,15 @@ const emstrong_1 = __webpack_require__(6132);
6846
7158
 
6847
7159
  const source_1 = __webpack_require__(6743);
6848
7160
 
6849
- const util_1 = __webpack_require__(9437);
7161
+ const visibility_1 = __webpack_require__(7618);
6850
7162
 
6851
7163
  const dom_1 = __webpack_require__(3252);
6852
7164
 
6853
7165
  const array_1 = __webpack_require__(8112);
6854
7166
 
6855
- 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]))));
7167
+ exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
7168
+ /* Rule.none */
7169
+ , 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])));
6856
7170
 
6857
7171
  /***/ }),
6858
7172
 
@@ -6871,16 +7185,20 @@ const global_1 = __webpack_require__(4128);
6871
7185
 
6872
7186
  const combinator_1 = __webpack_require__(2087);
6873
7187
 
7188
+ const link_1 = __webpack_require__(9628);
7189
+
6874
7190
  const source_1 = __webpack_require__(6743);
6875
7191
 
6876
7192
  const dom_1 = __webpack_require__(3252);
6877
7193
 
6878
7194
  const array_1 = __webpack_require__(8112);
6879
7195
 
6880
- 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', {
7196
+ exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.syntax)(0
7197
+ /* Rule.none */
7198
+ , 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', {
6881
7199
  class: 'template'
6882
- }, source.replace(/\x1B/g, ''))], '']))));
6883
- 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)]));
7200
+ }, `{{${ns.join('').replace(/\x1B/g, '')}}}`)], rest], ([, ns = [], rest], next) => next[0] === '}' ? global_1.undefined : (0, link_1.optimize)('{{', ns, rest, next))));
7201
+ 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)])));
6884
7202
 
6885
7203
  /***/ }),
6886
7204
 
@@ -6901,18 +7219,16 @@ const ja_1 = __webpack_require__(1499);
6901
7219
 
6902
7220
  const dom_1 = __webpack_require__(3252);
6903
7221
 
7222
+ const duff_1 = __webpack_require__(8099);
7223
+
6904
7224
  function localize(parser) {
6905
7225
  return (0, combinator_1.fmap)(parser, ns => {
6906
7226
  if (ns.length === 0) return ns;
6907
7227
  const el = ns.length === 1 && typeof ns[0] === 'object' ? ns[0] : (0, dom_1.html)('div', ns);
6908
- const es = el.querySelectorAll('.linebreak:not(:empty)');
6909
-
6910
- for (let i = 0, len = es.length; i < len; ++i) {
6911
- const sb = es[i];
6912
- if (!check(sb)) continue;
6913
- sb.firstChild.remove();
6914
- }
6915
-
7228
+ (0, duff_1.duffEach)(el.querySelectorAll('.linebreak:not(:empty)'), el => {
7229
+ if (!check(el)) return;
7230
+ el.firstChild.remove();
7231
+ });
6916
7232
  return ns;
6917
7233
  });
6918
7234
  }
@@ -7206,12 +7522,14 @@ const dom_1 = __webpack_require__(3252);
7206
7522
 
7207
7523
  const multimap_1 = __webpack_require__(940);
7208
7524
 
7525
+ const duff_1 = __webpack_require__(8099);
7526
+
7209
7527
  const array_1 = __webpack_require__(8112);
7210
7528
 
7211
7529
  function* footnote(target, footnotes, opts = {}, bottom = null) {
7212
7530
  // Bug: Firefox
7213
7531
  //target.querySelectorAll(`:scope > .annotations`).forEach(el => el.remove());
7214
- target.querySelectorAll(`.annotations`).forEach(el => el.parentNode === target && el.remove());
7532
+ (0, duff_1.duffEach)(target.querySelectorAll(`.annotations`), el => el.parentNode === target && el.remove());
7215
7533
  yield* (0, exports.reference)(target, footnotes?.references, opts, bottom);
7216
7534
  yield* (0, exports.annotation)(target, footnotes?.annotations, opts, bottom);
7217
7535
  return;
@@ -7230,7 +7548,7 @@ function build(syntax, marker, splitter) {
7230
7548
  const titles = new global_1.Map(); // Bug: Firefox
7231
7549
  //const splitters = push([], target.querySelectorAll(`:scope > :is(${splitter ?? '_'})`));
7232
7550
 
7233
- const splitters = (0, array_1.push)([], target.querySelectorAll(splitter ?? '_')).filter(el => el.parentNode === target);
7551
+ const splitters = (0, duff_1.duffReduce)(target.querySelectorAll(splitter ?? '_'), (acc, el) => el.parentNode === target ? (0, array_1.push)(acc, [el]) : acc, []);
7234
7552
  let count = 0;
7235
7553
  let total = 0;
7236
7554
  let style;
@@ -7771,6 +8089,38 @@ exports.unescsource = (0, combinator_1.creator)(source => {
7771
8089
  /***/ }),
7772
8090
 
7773
8091
  /***/ 9437:
8092
+ /***/ ((__unused_webpack_module, exports) => {
8093
+
8094
+ "use strict";
8095
+
8096
+
8097
+ Object.defineProperty(exports, "__esModule", ({
8098
+ value: true
8099
+ }));
8100
+ exports.stringify = void 0;
8101
+
8102
+ function stringify(nodes) {
8103
+ let acc = '';
8104
+
8105
+ for (let i = 0; i < nodes.length; ++i) {
8106
+ const node = nodes[i];
8107
+
8108
+ if (typeof node === 'string') {
8109
+ acc += node;
8110
+ } else {
8111
+ // NOTE: Doesn't reflect line breaks.
8112
+ acc += node.innerText;
8113
+ }
8114
+ }
8115
+
8116
+ return acc;
8117
+ }
8118
+
8119
+ exports.stringify = stringify;
8120
+
8121
+ /***/ }),
8122
+
8123
+ /***/ 7618:
7774
8124
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7775
8125
 
7776
8126
  "use strict";
@@ -7779,7 +8129,7 @@ exports.unescsource = (0, combinator_1.creator)(source => {
7779
8129
  Object.defineProperty(exports, "__esModule", ({
7780
8130
  value: true
7781
8131
  }));
7782
- 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;
8132
+ exports.trimNode = exports.trimBlankEnd = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.startLoose = exports.blankWith = exports.regBlankStart = exports.visualize = void 0;
7783
8133
 
7784
8134
  const global_1 = __webpack_require__(4128);
7785
8135
 
@@ -7797,30 +8147,6 @@ const memoize_1 = __webpack_require__(1808);
7797
8147
 
7798
8148
  const array_1 = __webpack_require__(8112);
7799
8149
 
7800
- function clean(parser) {
7801
- const clean = (0, memoize_1.memoize)(context => ({
7802
- resources: context.resources,
7803
- precedence: context.precedence,
7804
- delimiters: context.delimiters,
7805
- host: context.host,
7806
- url: context.url,
7807
- id: context.id,
7808
- header: context.header,
7809
- cache: context.caches
7810
- }), new WeakMap());
7811
- return (source, context) => parser(source, context.syntax ? clean(context) : context);
7812
- }
7813
-
7814
- exports.clean = clean;
7815
- exports.regBlankStart = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
7816
-
7817
- function blankWith(starting, delimiter) {
7818
- if (delimiter === global_1.undefined) return blankWith('', starting);
7819
- return new RegExp(String.raw`^(?:(?=${starting})(?:\\?\s|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr>)${starting && '+'})?${typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source}`);
7820
- }
7821
-
7822
- exports.blankWith = blankWith;
7823
-
7824
8150
  function visualize(parser) {
7825
8151
  const blankline = new RegExp(/^(?:\\$|\\?[^\S\n]|&IHN;|<wbr>)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
7826
8152
  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]))]);
@@ -7829,11 +8155,7 @@ function visualize(parser) {
7829
8155
  exports.visualize = visualize;
7830
8156
 
7831
8157
  function hasVisible(nodes, {
7832
- syntax: {
7833
- inline: {
7834
- media = true
7835
- } = {}
7836
- } = {}
8158
+ state = 0
7837
8159
  } = {}) {
7838
8160
  for (let i = 0; i < nodes.length; ++i) {
7839
8161
  const node = nodes[i];
@@ -7842,13 +8164,26 @@ function hasVisible(nodes, {
7842
8164
  if (node && node.trimStart()) return true;
7843
8165
  } else {
7844
8166
  if (node.innerText.trimStart()) return true;
7845
- if (media && (node.classList.contains('media') || node.getElementsByClassName('media')[0])) return true;
8167
+ if (state & 2
8168
+ /* State.media */
8169
+ ^ 2
8170
+ /* State.media */
8171
+ && (node.classList.contains('media') || node.getElementsByClassName('media')[0])) return true;
7846
8172
  }
7847
8173
  }
7848
8174
 
7849
8175
  return false;
7850
8176
  }
7851
8177
 
8178
+ exports.regBlankStart = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
8179
+
8180
+ function blankWith(starting, delimiter) {
8181
+ if (delimiter === global_1.undefined) return blankWith('', starting);
8182
+ return new RegExp(String.raw`^(?:(?=${starting})(?:\\?\s|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr>)${starting && '+'})?${typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source}`);
8183
+ }
8184
+
8185
+ exports.blankWith = blankWith;
8186
+
7852
8187
  function startLoose(parser, except) {
7853
8188
  return (source, context) => isStartLoose(source, context, except) ? parser(source, context) : global_1.undefined;
7854
8189
  }
@@ -7990,7 +8325,7 @@ function trimNodeStart(nodes) {
7990
8325
  const pos = node.trimStart().length;
7991
8326
 
7992
8327
  if (pos > 0) {
7993
- nodes[0] = node.slice(pos);
8328
+ nodes[0] = node.slice(-pos);
7994
8329
  break;
7995
8330
  }
7996
8331
  }
@@ -8006,39 +8341,20 @@ function trimNodeEnd(nodes) {
8006
8341
 
8007
8342
  for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
8008
8343
  if (typeof node === 'string') {
8009
- const pos = node.trimEnd().length;
8010
-
8011
- if (pos > 0) {
8012
- nodes[nodes.length - 1] = node.slice(0, pos);
8013
- break;
8014
- }
8015
- }
8016
-
8017
- nodes.pop();
8018
- }
8019
-
8020
- return (0, array_1.push)(nodes, skip);
8021
- }
8022
-
8023
- function stringify(nodes) {
8024
- let acc = '';
8025
-
8026
- for (let i = 0; i < nodes.length; ++i) {
8027
- const node = nodes[i];
8028
-
8029
- if (typeof node === 'string') {
8030
- acc += node;
8031
- } else {
8032
- // NOTE: Doesn't reflect line breaks.
8033
- acc += node.innerText;
8344
+ const pos = node.trimEnd().length;
8345
+
8346
+ if (pos > 0) {
8347
+ nodes[nodes.length - 1] = node.slice(0, pos);
8348
+ break;
8349
+ }
8034
8350
  }
8351
+
8352
+ nodes.pop();
8035
8353
  }
8036
8354
 
8037
- return acc;
8355
+ return (0, array_1.push)(nodes, skip);
8038
8356
  }
8039
8357
 
8040
- exports.stringify = stringify;
8041
-
8042
8358
  /***/ }),
8043
8359
 
8044
8360
  /***/ 256:
@@ -8549,6 +8865,8 @@ exports.info = void 0;
8549
8865
 
8550
8866
  const scope_1 = __webpack_require__(5202);
8551
8867
 
8868
+ const duff_1 = __webpack_require__(8099);
8869
+
8552
8870
  const array_1 = __webpack_require__(8112);
8553
8871
 
8554
8872
  function info(source) {
@@ -8567,7 +8885,7 @@ function info(source) {
8567
8885
  };
8568
8886
 
8569
8887
  function find(selector) {
8570
- return (0, array_1.push)([], source.querySelectorAll(selector)).filter(match);
8888
+ return (0, duff_1.duffReduce)(source.querySelectorAll(selector), (acc, el) => match(el) ? (0, array_1.push)(acc, [el]) : acc, []);
8571
8889
  }
8572
8890
  }
8573
8891
 
@@ -8594,30 +8912,29 @@ const cite_1 = __webpack_require__(6315);
8594
8912
 
8595
8913
  const dom_1 = __webpack_require__(3252);
8596
8914
 
8915
+ const duff_1 = __webpack_require__(8099);
8916
+
8597
8917
  function quote(anchor, range) {
8598
8918
  if ((0, parser_1.exec)((0, cite_1.cite)(`>>${anchor}`, {})) !== '') throw new Error(`Invalid anchor: ${anchor}`);
8599
8919
  fit(range);
8600
8920
  const node = trim(range.cloneContents());
8601
8921
  if (!node.firstChild) return '';
8602
-
8603
- for (let es = node.querySelectorAll('code[data-src], .math[data-src], .media[data-src], rt, rp'), i = 0, len = es.length; i < len; ++i) {
8604
- const el = es[i];
8605
-
8922
+ (0, duff_1.duffEach)(node.querySelectorAll('code[data-src], .math[data-src], .media[data-src], rt, rp'), el => {
8606
8923
  switch (true) {
8607
8924
  case el.matches('code'):
8608
8925
  case el.matches('.math'):
8609
8926
  (0, dom_1.define)(el, el.getAttribute('data-src'));
8610
- continue;
8927
+ return;
8611
8928
 
8612
8929
  case el.matches('.media'):
8613
8930
  el.replaceWith(/[\s{}]/.test(el.getAttribute('data-src')) ? `!{ ${el.getAttribute('data-src')} }` : `!{${el.getAttribute('data-src')}}`);
8614
- continue;
8931
+ return;
8615
8932
 
8616
8933
  case el.matches('rt, rp'):
8617
8934
  el.remove();
8618
- continue;
8935
+ return;
8619
8936
  }
8620
- }
8937
+ });
8621
8938
 
8622
8939
  if (range.startOffset === 0 && range.startContainer.parentElement?.matches('.cite, .quote') && (!range.startContainer.previousSibling || range.startContainer.previousSibling.nodeName === 'BR')) {
8623
8940
  node.prepend(`>${range.startContainer.parentElement.matches('.quote.invalid') ? ' ' : ''}`);
@@ -8626,29 +8943,26 @@ function quote(anchor, range) {
8626
8943
  anchor = '';
8627
8944
  }
8628
8945
 
8629
- for (let es = node.querySelectorAll('br'), i = 0, len = es.length; i < len; ++i) {
8630
- const el = es[i];
8631
-
8946
+ (0, duff_1.duffEach)(node.querySelectorAll('br'), el => {
8632
8947
  if (anchor && el.nextSibling instanceof global_1.Element && el.nextSibling.matches('.cite, .quote')) {
8633
8948
  el.replaceWith(`\n>${el.nextSibling.matches('.quote.invalid') ? ' ' : ''}`);
8634
- continue;
8949
+ return;
8635
8950
  }
8636
8951
 
8637
8952
  if (anchor && el.parentElement?.closest('.cite, .quote')) {
8638
8953
  el.replaceWith(`\n>${el.parentElement.closest('.quote.invalid') ? ' ' : ''}`);
8639
- continue;
8954
+ return;
8640
8955
  }
8641
8956
 
8642
8957
  if (anchor) {
8643
8958
  el.replaceWith(`\n>>${anchor}\n> `);
8644
8959
  anchor = '';
8645
- continue;
8960
+ return;
8646
8961
  } else {
8647
8962
  el.replaceWith(`\n> `);
8648
- continue;
8963
+ return;
8649
8964
  }
8650
- }
8651
-
8965
+ });
8652
8966
  anchor && node.append(`\n>>${anchor}`);
8653
8967
  return node.textContent;
8654
8968
  }
@@ -8736,6 +9050,8 @@ const global_1 = __webpack_require__(4128);
8736
9050
 
8737
9051
  const dom_1 = __webpack_require__(3252);
8738
9052
 
9053
+ const duff_1 = __webpack_require__(8099);
9054
+
8739
9055
  const array_1 = __webpack_require__(8112); // Bug: Firefox
8740
9056
  //const selector = 'h1 h2 h3 h4 h5 h6 aside.aside'.split(' ').map(s => `:scope > ${s}[id]`).join();
8741
9057
 
@@ -8743,18 +9059,18 @@ const array_1 = __webpack_require__(8112); // Bug: Firefox
8743
9059
  const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]';
8744
9060
 
8745
9061
  function toc(source) {
8746
- const hs = (0, array_1.push)([], source.querySelectorAll(selector)).map(el => {
9062
+ const hs = (0, duff_1.duffReduce)(source.querySelectorAll(selector), (acc, el) => {
8747
9063
  switch (el.tagName) {
8748
9064
  case 'ASIDE':
8749
- return (0, dom_1.html)(el.firstElementChild.tagName.toLowerCase(), {
9065
+ return (0, array_1.push)(acc, [(0, dom_1.html)(el.firstElementChild.tagName.toLowerCase(), {
8750
9066
  id: el.id,
8751
9067
  class: 'aside'
8752
- }, el.firstElementChild.cloneNode(true).childNodes);
9068
+ }, el.firstElementChild.cloneNode(true).childNodes)]);
8753
9069
 
8754
9070
  default:
8755
- return el;
9071
+ return (0, array_1.push)(acc, [el]);
8756
9072
  }
8757
- });
9073
+ }, []);
8758
9074
  return parse(cons(hs));
8759
9075
  }
8760
9076
 
@@ -8768,7 +9084,7 @@ function parse(node, index = '') {
8768
9084
  return (0, dom_1.html)('li', (0, array_1.push)([(0, dom_1.html)('a', {
8769
9085
  href: `#${el.id}`,
8770
9086
  'data-index': isHeading ? idx : global_1.undefined
8771
- }, fix(el))], cs.length > 0 ? [parse(cs, idx)] : []));
9087
+ }, unlink(el.cloneNode(true)))], cs.length > 0 ? [parse(cs, idx)] : []));
8772
9088
  }));
8773
9089
  }
8774
9090
 
@@ -8783,14 +9099,8 @@ function level(h) {
8783
9099
  return +h.tagName[1];
8784
9100
  }
8785
9101
 
8786
- function fix(h) {
8787
- h = h.cloneNode(true);
8788
-
8789
- for (let es = h.getElementsByTagName('a'), i = 0, len = es.length; i < len; ++i) {
8790
- const el = es[i];
8791
- el.replaceWith(...el.childNodes);
8792
- }
8793
-
9102
+ function unlink(h) {
9103
+ (0, duff_1.duffEach)(h.getElementsByTagName('a'), el => void el.replaceWith(...el.childNodes));
8794
9104
  return h.childNodes;
8795
9105
  }
8796
9106
 
@@ -8799,7 +9109,7 @@ function fix(h) {
8799
9109
  /***/ 3252:
8800
9110
  /***/ (function(module) {
8801
9111
 
8802
- /*! typed-dom v0.0.299 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9112
+ /*! typed-dom v0.0.301 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8803
9113
  (function webpackUniversalModuleDefinition(root, factory) {
8804
9114
  if(true)
8805
9115
  module.exports = factory();
@@ -9233,7 +9543,7 @@ exports.defrag = defrag;
9233
9543
  /***/ 6120:
9234
9544
  /***/ (function(module) {
9235
9545
 
9236
- /*! typed-dom v0.0.299 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9546
+ /*! typed-dom v0.0.301 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9237
9547
  (function webpackUniversalModuleDefinition(root, factory) {
9238
9548
  if(true)
9239
9549
  module.exports = factory();
@@ -9241,8 +9551,320 @@ exports.defrag = defrag;
9241
9551
  })(this, () => {
9242
9552
  return /******/ (() => { // webpackBootstrap
9243
9553
  /******/ "use strict";
9554
+ /******/ var __webpack_modules__ = ({
9555
+
9556
+ /***/ 112:
9557
+ /***/ ((__unused_webpack_module, exports, __nested_webpack_require_645__) => {
9558
+
9559
+
9560
+
9561
+ Object.defineProperty(exports, "__esModule", ({
9562
+ value: true
9563
+ }));
9564
+ exports.splice = exports.pop = exports.push = exports.shift = exports.unshift = exports.indexOf = void 0;
9565
+
9566
+ const global_1 = __nested_webpack_require_645__(128);
9567
+
9568
+ function indexOf(as, a) {
9569
+ if (as.length === 0) return -1;
9570
+ return a === a ? as.indexOf(a) : as.findIndex(a => a !== a);
9571
+ }
9572
+
9573
+ exports.indexOf = indexOf;
9574
+
9575
+ function unshift(as, bs) {
9576
+ if ('length' in as) {
9577
+ for (let i = as.length - 1; i >= 0; --i) {
9578
+ bs.unshift(as[i]);
9579
+ }
9580
+ } else {
9581
+ bs.unshift(...as);
9582
+ }
9583
+
9584
+ return bs;
9585
+ }
9586
+
9587
+ exports.unshift = unshift;
9588
+
9589
+ function shift(as, count) {
9590
+ if (count < 0) throw new Error('Unexpected negative number');
9591
+ return count === void 0 ? [as.shift(), as] : [splice(as, 0, count), as];
9592
+ }
9593
+
9594
+ exports.shift = shift;
9595
+
9596
+ function push(as, bs) {
9597
+ if ('length' in bs) {
9598
+ for (let i = 0, len = bs.length; i < len; ++i) {
9599
+ as.push(bs[i]);
9600
+ }
9601
+ } else {
9602
+ for (const b of bs) {
9603
+ as.push(b);
9604
+ }
9605
+ }
9606
+
9607
+ return as;
9608
+ }
9609
+
9610
+ exports.push = push;
9611
+
9612
+ function pop(as, count) {
9613
+ if (count < 0) throw new Error('Unexpected negative number');
9614
+ return count === void 0 ? [as, as.pop()] : [as, splice(as, as.length - count, count)];
9615
+ }
9616
+
9617
+ exports.pop = pop;
9618
+
9619
+ function splice(as, index, count, ...inserts) {
9620
+ if (count === 0 && inserts.length === 0) return [];
9621
+ count = count > as.length ? as.length : count;
9622
+
9623
+ switch (index) {
9624
+ case 0:
9625
+ switch (count) {
9626
+ case 0:
9627
+ return [[], unshift(inserts, as)][0];
9628
+
9629
+ case 1:
9630
+ return as.length === 0 ? [[], unshift(inserts, as)][0] : [[as.shift()], unshift(inserts, as)][0];
9631
+
9632
+ case void 0:
9633
+ if (as.length > 1 || arguments.length > 2) break;
9634
+ return as.length === 0 ? [] : splice(as, index, 1);
9635
+ }
9636
+
9637
+ break;
9638
+
9639
+ case -1:
9640
+ case as.length - 1:
9641
+ switch (count) {
9642
+ case 1:
9643
+ return as.length === 0 ? [[], push(as, inserts)][0] : [[as.pop()], push(as, inserts)][0];
9644
+
9645
+ case void 0:
9646
+ if (as.length > 1 || arguments.length > 2) break;
9647
+ return as.length === 0 ? [] : splice(as, index, 1);
9648
+ }
9649
+
9650
+ break;
9651
+
9652
+ case as.length:
9653
+ case global_1.Infinity:
9654
+ return [[], push(as, inserts)][0];
9655
+ }
9656
+
9657
+ return arguments.length > 2 ? as.splice(index, count, ...inserts) : as.splice(index);
9658
+ }
9659
+
9660
+ exports.splice = splice;
9661
+
9662
+ /***/ }),
9663
+
9664
+ /***/ 99:
9665
+ /***/ ((__unused_webpack_module, exports) => {
9666
+
9667
+
9668
+
9669
+ Object.defineProperty(exports, "__esModule", ({
9670
+ value: true
9671
+ }));
9672
+ exports.duffReduce = exports.duffEach = exports.duffbk = exports.duff = void 0;
9673
+
9674
+ function duff(count, proc) {
9675
+ if (count > 0) {
9676
+ let i = 0,
9677
+ m = count % 8,
9678
+ d = (count - m) / 8;
9679
+
9680
+ while (m--) {
9681
+ proc(i++);
9682
+ }
9683
+
9684
+ while (d--) {
9685
+ proc(i++);
9686
+ proc(i++);
9687
+ proc(i++);
9688
+ proc(i++);
9689
+ proc(i++);
9690
+ proc(i++);
9691
+ proc(i++);
9692
+ proc(i++);
9693
+ }
9694
+ } else {
9695
+ let i = -count,
9696
+ m = i % 8,
9697
+ d = (i - m) / 8;
9698
+
9699
+ while (m--) {
9700
+ proc(--i);
9701
+ }
9702
+
9703
+ while (d--) {
9704
+ proc(--i);
9705
+ proc(--i);
9706
+ proc(--i);
9707
+ proc(--i);
9708
+ proc(--i);
9709
+ proc(--i);
9710
+ proc(--i);
9711
+ proc(--i);
9712
+ }
9713
+ }
9714
+ }
9715
+
9716
+ exports.duff = duff;
9717
+
9718
+ function duffbk(count, proc) {
9719
+ if (count > 0) {
9720
+ let i = 0,
9721
+ m = count % 8,
9722
+ d = (count - m) / 8;
9723
+
9724
+ while (m--) {
9725
+ if (proc(i++) === false) return;
9726
+ }
9727
+
9728
+ while (d--) {
9729
+ if (proc(i++) === false) return;
9730
+ if (proc(i++) === false) return;
9731
+ if (proc(i++) === false) return;
9732
+ if (proc(i++) === false) return;
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
+ }
9738
+ } else {
9739
+ let i = -count,
9740
+ m = i % 8,
9741
+ d = (i - m) / 8;
9742
+
9743
+ while (m--) {
9744
+ if (proc(--i) === false) return;
9745
+ }
9746
+
9747
+ while (d--) {
9748
+ if (proc(--i) === false) return;
9749
+ if (proc(--i) === false) return;
9750
+ if (proc(--i) === false) return;
9751
+ if (proc(--i) === false) return;
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
+ }
9757
+ }
9758
+ }
9759
+
9760
+ exports.duffbk = duffbk;
9761
+
9762
+ function duffEach(array, proc) {
9763
+ let count = array.length;
9764
+ let i = 0,
9765
+ m = count % 8,
9766
+ d = (count - m) / 8;
9767
+
9768
+ while (m--) {
9769
+ proc(array[i], i++, array);
9770
+ }
9771
+
9772
+ while (d--) {
9773
+ proc(array[i], i++, array);
9774
+ proc(array[i], i++, array);
9775
+ proc(array[i], i++, array);
9776
+ proc(array[i], i++, array);
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
+ }
9782
+ }
9783
+
9784
+ exports.duffEach = duffEach;
9785
+
9786
+ function duffReduce(array, proc, initial) {
9787
+ let count = array.length;
9788
+ let i = 0,
9789
+ m = count % 8,
9790
+ d = (count - m) / 8;
9791
+
9792
+ while (m--) {
9793
+ initial = proc(initial, array[i], i++, array);
9794
+ }
9795
+
9796
+ while (d--) {
9797
+ initial = proc(initial, array[i], i++, array);
9798
+ initial = proc(initial, array[i], i++, array);
9799
+ initial = proc(initial, array[i], i++, array);
9800
+ initial = proc(initial, array[i], i++, array);
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
+ }
9806
+
9807
+ return initial;
9808
+ }
9809
+
9810
+ exports.duffReduce = duffReduce;
9811
+
9812
+ /***/ }),
9813
+
9814
+ /***/ 128:
9815
+ /***/ ((module, __unused_webpack_exports, __nested_webpack_require_6113__) => {
9816
+
9817
+
9818
+
9819
+ __nested_webpack_require_6113__(921);
9820
+
9821
+ const global = void 0 || typeof globalThis !== 'undefined' && globalThis // @ts-ignore
9822
+ || typeof self !== 'undefined' && self || Function('return this')();
9823
+ global.global = global;
9824
+ module.exports = global;
9825
+
9826
+ /***/ }),
9827
+
9828
+ /***/ 921:
9829
+ /***/ (() => {
9830
+
9831
+ // @ts-ignore
9832
+
9833
+ var globalThis; // @ts-ignore
9834
+
9835
+ var global = (/* unused pure expression or super */ null && (0));
9836
+
9837
+ /***/ })
9838
+
9839
+ /******/ });
9840
+ /************************************************************************/
9841
+ /******/ // The module cache
9842
+ /******/ var __webpack_module_cache__ = {};
9843
+ /******/
9844
+ /******/ // The require function
9845
+ /******/ function __nested_webpack_require_6765__(moduleId) {
9846
+ /******/ // Check if module is in cache
9847
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
9848
+ /******/ if (cachedModule !== undefined) {
9849
+ /******/ return cachedModule.exports;
9850
+ /******/ }
9851
+ /******/ // Create a new module (and put it into the cache)
9852
+ /******/ var module = __webpack_module_cache__[moduleId] = {
9853
+ /******/ // no module.id needed
9854
+ /******/ // no module.loaded needed
9855
+ /******/ exports: {}
9856
+ /******/ };
9857
+ /******/
9858
+ /******/ // Execute the module function
9859
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_6765__);
9860
+ /******/
9861
+ /******/ // Return the exports of the module
9862
+ /******/ return module.exports;
9863
+ /******/ }
9864
+ /******/
9865
+ /************************************************************************/
9244
9866
  var __webpack_exports__ = {};
9245
- // This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
9867
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
9246
9868
  (() => {
9247
9869
  var exports = __webpack_exports__;
9248
9870
 
@@ -9252,6 +9874,10 @@ Object.defineProperty(exports, "__esModule", ({
9252
9874
  }));
9253
9875
  exports.querySelectorAll = exports.querySelector = void 0;
9254
9876
 
9877
+ const duff_1 = __nested_webpack_require_6765__(99);
9878
+
9879
+ const array_1 = __nested_webpack_require_6765__(112);
9880
+
9255
9881
  function querySelector(node, selector) {
9256
9882
  return 'matches' in node && node.matches(selector) ? node : node.querySelector(selector);
9257
9883
  }
@@ -9265,13 +9891,7 @@ function querySelectorAll(node, selector) {
9265
9891
  acc.push(node);
9266
9892
  }
9267
9893
 
9268
- const nodes = node.querySelectorAll(selector);
9269
-
9270
- for (let i = 0, len = nodes.length; i < len; ++i) {
9271
- acc.push(nodes[i]);
9272
- }
9273
-
9274
- return acc;
9894
+ return (0, duff_1.duffReduce)(node.querySelectorAll(selector), (acc, node) => (0, array_1.push)(acc, [node]), acc);
9275
9895
  }
9276
9896
 
9277
9897
  exports.querySelectorAll = querySelectorAll;