securemark 0.291.1 → 0.292.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/design.md +13 -2
  3. package/dist/index.js +1093 -756
  4. package/markdown.d.ts +17 -17
  5. package/package.json +1 -1
  6. package/src/combinator/control/constraint/block.test.ts +8 -5
  7. package/src/combinator/control/constraint/block.ts +9 -9
  8. package/src/combinator/control/constraint/contract.ts +20 -28
  9. package/src/combinator/control/constraint/line.test.ts +9 -6
  10. package/src/combinator/control/constraint/line.ts +21 -22
  11. package/src/combinator/control/manipulation/convert.ts +29 -13
  12. package/src/combinator/control/manipulation/fence.ts +18 -15
  13. package/src/combinator/control/manipulation/indent.test.ts +17 -14
  14. package/src/combinator/control/manipulation/indent.ts +15 -8
  15. package/src/combinator/control/manipulation/match.ts +11 -10
  16. package/src/combinator/control/manipulation/recovery.ts +6 -2
  17. package/src/combinator/control/manipulation/scope.ts +37 -38
  18. package/src/combinator/control/manipulation/surround.ts +78 -60
  19. package/src/combinator/control/manipulation/trim.test.ts +12 -9
  20. package/src/combinator/control/monad/bind.ts +16 -16
  21. package/src/combinator/control/monad/fmap.ts +6 -6
  22. package/src/combinator/data/parser/context/delimiter.ts +8 -7
  23. package/src/combinator/data/parser/context.test.ts +19 -14
  24. package/src/combinator/data/parser/context.ts +20 -16
  25. package/src/combinator/data/parser/inits.ts +13 -14
  26. package/src/combinator/data/parser/sequence.test.ts +16 -15
  27. package/src/combinator/data/parser/sequence.ts +13 -14
  28. package/src/combinator/data/parser/some.test.ts +19 -18
  29. package/src/combinator/data/parser/some.ts +13 -15
  30. package/src/combinator/data/parser/subsequence.test.ts +22 -21
  31. package/src/combinator/data/parser/subsequence.ts +3 -3
  32. package/src/combinator/data/parser/tails.ts +3 -3
  33. package/src/combinator/data/parser/union.test.ts +16 -15
  34. package/src/combinator/data/parser/union.ts +2 -2
  35. package/src/combinator/data/parser.ts +66 -28
  36. package/src/debug.test.ts +3 -3
  37. package/src/parser/api/bind.ts +3 -3
  38. package/src/parser/api/header.ts +7 -6
  39. package/src/parser/api/normalize.ts +2 -2
  40. package/src/parser/api/parse.test.ts +14 -15
  41. package/src/parser/api/parse.ts +3 -3
  42. package/src/parser/autolink.test.ts +19 -17
  43. package/src/parser/block/blockquote.test.ts +86 -84
  44. package/src/parser/block/blockquote.ts +4 -2
  45. package/src/parser/block/codeblock.test.ts +58 -56
  46. package/src/parser/block/codeblock.ts +3 -3
  47. package/src/parser/block/dlist.test.ts +58 -56
  48. package/src/parser/block/extension/aside.test.ts +10 -8
  49. package/src/parser/block/extension/aside.ts +1 -1
  50. package/src/parser/block/extension/example.test.ts +20 -18
  51. package/src/parser/block/extension/example.ts +3 -3
  52. package/src/parser/block/extension/fig.test.ts +38 -36
  53. package/src/parser/block/extension/fig.ts +1 -1
  54. package/src/parser/block/extension/figbase.test.ts +17 -15
  55. package/src/parser/block/extension/figure.test.ts +64 -62
  56. package/src/parser/block/extension/figure.ts +3 -2
  57. package/src/parser/block/extension/message.test.ts +15 -13
  58. package/src/parser/block/extension/message.ts +3 -3
  59. package/src/parser/block/extension/placeholder.test.ts +3 -1
  60. package/src/parser/block/extension/table.test.ts +73 -71
  61. package/src/parser/block/extension/table.ts +5 -5
  62. package/src/parser/block/extension.test.ts +3 -1
  63. package/src/parser/block/heading.test.ts +65 -64
  64. package/src/parser/block/heading.ts +3 -3
  65. package/src/parser/block/ilist.test.ts +3 -1
  66. package/src/parser/block/ilist.ts +3 -3
  67. package/src/parser/block/mathblock.test.ts +33 -31
  68. package/src/parser/block/mathblock.ts +1 -1
  69. package/src/parser/block/mediablock.ts +2 -2
  70. package/src/parser/block/olist.test.ts +99 -97
  71. package/src/parser/block/olist.ts +2 -2
  72. package/src/parser/block/pagebreak.test.ts +17 -15
  73. package/src/parser/block/pagebreak.ts +1 -1
  74. package/src/parser/block/paragraph.test.ts +60 -57
  75. package/src/parser/block/reply/cite.test.ts +41 -39
  76. package/src/parser/block/reply/cite.ts +3 -3
  77. package/src/parser/block/reply/quote.test.ts +52 -50
  78. package/src/parser/block/reply.test.ts +21 -19
  79. package/src/parser/block/sidefence.test.ts +51 -49
  80. package/src/parser/block/table.test.ts +51 -50
  81. package/src/parser/block/table.ts +6 -6
  82. package/src/parser/block/ulist.test.ts +52 -50
  83. package/src/parser/block/ulist.ts +2 -2
  84. package/src/parser/block.ts +6 -5
  85. package/src/parser/context.ts +1 -0
  86. package/src/parser/header.test.ts +22 -21
  87. package/src/parser/header.ts +25 -13
  88. package/src/parser/inline/annotation.test.ts +44 -42
  89. package/src/parser/inline/annotation.ts +2 -2
  90. package/src/parser/inline/autolink/account.test.ts +32 -30
  91. package/src/parser/inline/autolink/account.ts +1 -1
  92. package/src/parser/inline/autolink/anchor.test.ts +23 -21
  93. package/src/parser/inline/autolink/anchor.ts +1 -1
  94. package/src/parser/inline/autolink/channel.test.ts +16 -14
  95. package/src/parser/inline/autolink/channel.ts +2 -2
  96. package/src/parser/inline/autolink/email.test.ts +38 -36
  97. package/src/parser/inline/autolink/email.ts +2 -2
  98. package/src/parser/inline/autolink/hashnum.test.ts +39 -37
  99. package/src/parser/inline/autolink/hashnum.ts +1 -1
  100. package/src/parser/inline/autolink/hashtag.test.ts +58 -56
  101. package/src/parser/inline/autolink/hashtag.ts +1 -1
  102. package/src/parser/inline/autolink/url.test.ts +76 -74
  103. package/src/parser/inline/autolink/url.ts +6 -6
  104. package/src/parser/inline/bracket.test.ts +69 -67
  105. package/src/parser/inline/bracket.ts +32 -32
  106. package/src/parser/inline/code.test.ts +32 -29
  107. package/src/parser/inline/code.ts +20 -13
  108. package/src/parser/inline/deletion.test.ts +29 -27
  109. package/src/parser/inline/deletion.ts +2 -2
  110. package/src/parser/inline/emphasis.test.ts +40 -36
  111. package/src/parser/inline/emphasis.ts +2 -2
  112. package/src/parser/inline/emstrong.test.ts +102 -96
  113. package/src/parser/inline/emstrong.ts +96 -36
  114. package/src/parser/inline/extension/index.test.ts +91 -89
  115. package/src/parser/inline/extension/index.ts +18 -30
  116. package/src/parser/inline/extension/indexee.ts +1 -1
  117. package/src/parser/inline/extension/indexer.test.ts +26 -24
  118. package/src/parser/inline/extension/indexer.ts +1 -1
  119. package/src/parser/inline/extension/label.test.ts +34 -32
  120. package/src/parser/inline/extension/placeholder.test.ts +44 -42
  121. package/src/parser/inline/extension/placeholder.ts +11 -8
  122. package/src/parser/inline/html.test.ts +108 -106
  123. package/src/parser/inline/html.ts +24 -23
  124. package/src/parser/inline/htmlentity.test.ts +39 -37
  125. package/src/parser/inline/htmlentity.ts +9 -3
  126. package/src/parser/inline/insertion.test.ts +29 -27
  127. package/src/parser/inline/insertion.ts +2 -2
  128. package/src/parser/inline/italic.test.ts +55 -53
  129. package/src/parser/inline/italic.ts +2 -2
  130. package/src/parser/inline/link.test.ts +187 -185
  131. package/src/parser/inline/link.ts +30 -12
  132. package/src/parser/inline/mark.test.ts +31 -29
  133. package/src/parser/inline/mark.ts +3 -3
  134. package/src/parser/inline/math.test.ts +133 -131
  135. package/src/parser/inline/math.ts +2 -2
  136. package/src/parser/inline/media.test.ts +93 -91
  137. package/src/parser/inline/media.ts +41 -17
  138. package/src/parser/inline/reference.test.ts +110 -108
  139. package/src/parser/inline/reference.ts +48 -39
  140. package/src/parser/inline/remark.test.ts +53 -51
  141. package/src/parser/inline/remark.ts +3 -3
  142. package/src/parser/inline/ruby.test.ts +46 -44
  143. package/src/parser/inline/ruby.ts +24 -27
  144. package/src/parser/inline/shortmedia.test.ts +11 -9
  145. package/src/parser/inline/strong.test.ts +37 -33
  146. package/src/parser/inline/strong.ts +6 -3
  147. package/src/parser/inline/template.test.ts +24 -22
  148. package/src/parser/inline/template.ts +20 -11
  149. package/src/parser/inline.test.ts +221 -220
  150. package/src/parser/inline.ts +13 -8
  151. package/src/parser/segment.ts +13 -8
  152. package/src/parser/source/escapable.test.ts +24 -22
  153. package/src/parser/source/escapable.ts +26 -41
  154. package/src/parser/source/line.test.ts +19 -17
  155. package/src/parser/source/line.ts +3 -3
  156. package/src/parser/source/str.ts +28 -11
  157. package/src/parser/source/text.test.ts +85 -83
  158. package/src/parser/source/text.ts +26 -54
  159. package/src/parser/source/unescapable.test.ts +24 -22
  160. package/src/parser/source/unescapable.ts +18 -33
  161. package/src/parser/source.ts +1 -1
  162. package/src/parser/util.ts +36 -33
  163. package/src/parser/visibility.ts +19 -15
  164. package/src/util/quote.ts +4 -2
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.291.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.292.0 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("Prism"), require("DOMPurify"));
@@ -2464,17 +2464,20 @@ exports.block = void 0;
2464
2464
  const parser_1 = __webpack_require__(605);
2465
2465
  const line_1 = __webpack_require__(8287);
2466
2466
  function block(parser, separation = true) {
2467
- return input => {
2467
+ return (0, parser_1.failsafe)(input => {
2468
2468
  const {
2469
- source
2469
+ context
2470
2470
  } = input;
2471
- if (source === '') return;
2471
+ const {
2472
+ source,
2473
+ position
2474
+ } = context;
2475
+ if (position === source.length) return;
2472
2476
  const result = parser(input);
2473
2477
  if (result === undefined) return;
2474
- const rest = (0, parser_1.exec)(result);
2475
- if (separation && !(0, line_1.isBlank)((0, line_1.firstline)(rest))) return;
2476
- return rest === '' || source[source.length - rest.length - 1] === '\n' ? result : undefined;
2477
- };
2478
+ if (separation && !(0, line_1.isBlank)((0, line_1.firstline)(source, context.position))) return;
2479
+ return context.position === source.length || source[context.position - 1] === '\n' ? result : undefined;
2480
+ });
2478
2481
  }
2479
2482
  exports.block = block;
2480
2483
 
@@ -2495,16 +2498,18 @@ const parser_1 = __webpack_require__(605);
2495
2498
  function validate(patterns, parser) {
2496
2499
  if (typeof patterns === 'function') return guard(patterns, parser);
2497
2500
  if (!(0, alias_1.isArray)(patterns)) return validate([patterns], parser);
2498
- const match = __webpack_require__.g.eval(['source =>', patterns.map(pattern => typeof pattern === 'string' ? `|| source.slice(0, ${pattern.length}) === '${pattern}'` : `|| /${pattern.source}/${pattern.flags}.test(source)`).join('').slice(2)].join(''));
2501
+ const match = __webpack_require__.g.eval(['({ source, position }) =>', patterns.map(pattern => typeof pattern === 'string' ? `|| source.startsWith('${pattern}', position)` : `|| /${pattern.source}/${pattern.flags}.test(source.slice(position))`).join('').slice(2)].join(''));
2499
2502
  return input => {
2500
2503
  const {
2501
- source
2504
+ context
2502
2505
  } = input;
2503
- if (source === '') return;
2504
- if (!match(source)) return;
2505
- const result = parser(input);
2506
- if (result === undefined) return;
2507
- return (0, parser_1.exec)(result).length < source.length ? result : undefined;
2506
+ const {
2507
+ source,
2508
+ position
2509
+ } = context;
2510
+ if (position === source.length) return;
2511
+ if (!match(context)) return;
2512
+ return parser(input);
2508
2513
  };
2509
2514
  }
2510
2515
  exports.validate = validate;
@@ -2512,17 +2517,19 @@ function guard(f, parser) {
2512
2517
  return input => f(input) ? parser(input) : undefined;
2513
2518
  }
2514
2519
  function verify(parser, cond) {
2515
- return input => {
2520
+ return (0, parser_1.failsafe)(input => {
2516
2521
  const {
2517
- source,
2518
2522
  context
2519
2523
  } = input;
2520
- if (source === '') return;
2524
+ const {
2525
+ source,
2526
+ position
2527
+ } = context;
2528
+ if (position === source.length) return;
2521
2529
  const result = parser(input);
2522
- if (result === undefined) return;
2523
- if (!cond((0, parser_1.eval)(result), (0, parser_1.exec)(result), context)) return;
2524
- return (0, parser_1.exec)(result).length < source.length ? result : undefined;
2525
- };
2530
+ if (result && !cond((0, parser_1.eval)(result), context)) return;
2531
+ return result;
2532
+ });
2526
2533
  }
2527
2534
  exports.verify = verify;
2528
2535
 
@@ -2540,34 +2547,32 @@ Object.defineProperty(exports, "__esModule", ({
2540
2547
  exports.isBlank = exports.firstline = exports.line = void 0;
2541
2548
  const parser_1 = __webpack_require__(605);
2542
2549
  function line(parser) {
2543
- return ({
2544
- source,
2550
+ return (0, parser_1.failsafe)(({
2545
2551
  context
2546
2552
  }) => {
2547
- if (source === '') return;
2548
- const line = firstline(source);
2553
+ const {
2554
+ source,
2555
+ position
2556
+ } = context;
2557
+ if (position === source.length) return;
2558
+ const line = firstline(source, position);
2549
2559
  context.offset ??= 0;
2550
- context.offset += source.length - line.length;
2551
- const result = parser({
2552
- source: line,
2553
- context
2554
- });
2555
- context.offset -= source.length - line.length;
2560
+ context.offset += position;
2561
+ const result = parser((0, parser_1.input)(line, context));
2562
+ context.position += position;
2563
+ context.position += result && context.position === position ? line.length : 0;
2564
+ context.source = source;
2565
+ context.offset -= position;
2556
2566
  if (result === undefined) return;
2557
- return isBlank((0, parser_1.exec)(result)) ? [(0, parser_1.eval)(result), source.slice(line.length)] : undefined;
2558
- };
2567
+ if (!isBlank(source.slice(context.position, position + line.length))) return;
2568
+ context.position = position + line.length;
2569
+ return [(0, parser_1.eval)(result)];
2570
+ });
2559
2571
  }
2560
2572
  exports.line = line;
2561
- function firstline(source) {
2562
- const i = source.indexOf('\n');
2563
- switch (i) {
2564
- case -1:
2565
- return source;
2566
- case 0:
2567
- return '\n';
2568
- default:
2569
- return source.slice(0, i + 1);
2570
- }
2573
+ function firstline(source, position) {
2574
+ const i = source.indexOf('\n', position);
2575
+ return i === -1 ? source.slice(position) : source.slice(position, i + 1);
2571
2576
  }
2572
2577
  exports.firstline = firstline;
2573
2578
  function isBlank(line) {
@@ -2607,24 +2612,36 @@ Object.defineProperty(exports, "__esModule", ({
2607
2612
  exports.convert = void 0;
2608
2613
  const parser_1 = __webpack_require__(605);
2609
2614
  function convert(conv, parser, continuous, empty = false) {
2610
- return ({
2611
- source,
2612
- context
2613
- }) => {
2614
- if (source === '') return;
2615
- const src = conv(source, context);
2616
- if (src === '') return empty ? [[], ''] : undefined;
2615
+ return (0, parser_1.failsafe)(input => {
2617
2616
  const {
2618
- backtracks
2619
- } = context;
2620
- context.backtracks = continuous ? backtracks : {};
2621
- const result = parser({
2622
- source: src,
2623
2617
  context
2624
- });
2625
- context.backtracks = backtracks;
2626
- return result;
2627
- };
2618
+ } = input;
2619
+ const {
2620
+ source,
2621
+ position
2622
+ } = context;
2623
+ if (position === source.length) return;
2624
+ const src = conv(source.slice(position), context);
2625
+ if (src === '') {
2626
+ if (!empty) return;
2627
+ context.position = source.length;
2628
+ return [[]];
2629
+ }
2630
+ if (continuous) {
2631
+ context.position += source.length - position - src.length;
2632
+ const result = parser(input);
2633
+ context.source = source;
2634
+ return result;
2635
+ } else {
2636
+ const {
2637
+ offset,
2638
+ backtracks
2639
+ } = context;
2640
+ const result = parser((0, parser_1.subinput)(src, context));
2641
+ context.position = context.source.length;
2642
+ return result;
2643
+ }
2644
+ });
2628
2645
  }
2629
2646
  exports.convert = convert;
2630
2647
 
@@ -2676,38 +2693,45 @@ Object.defineProperty(exports, "__esModule", ({
2676
2693
  value: true
2677
2694
  }));
2678
2695
  exports.fence = void 0;
2696
+ const parser_1 = __webpack_require__(605);
2679
2697
  const line_1 = __webpack_require__(8287);
2680
2698
  const array_1 = __webpack_require__(6876);
2681
2699
  function fence(opener, limit, separation = true) {
2682
- return ({
2683
- source
2684
- }) => {
2685
- if (source === '') return;
2686
- const matches = source.match(opener);
2700
+ return (0, parser_1.failsafe)(input => {
2701
+ const {
2702
+ context
2703
+ } = input;
2704
+ const {
2705
+ source,
2706
+ position
2707
+ } = context;
2708
+ if (position === source.length) return;
2709
+ const matches = source.slice(position).match(opener);
2687
2710
  if (!matches) return;
2688
2711
  const delim = matches[1];
2689
2712
  if (matches[0].includes(delim, delim.length)) return;
2690
- let rest = source.slice(matches[0].length);
2713
+ context.position += matches[0].length;
2691
2714
  // Prevent annoying parsing in editing.
2692
- if ((0, line_1.isBlank)((0, line_1.firstline)(rest)) && (0, line_1.firstline)(rest.slice((0, line_1.firstline)(rest).length)).trimEnd() !== delim) return;
2715
+ const secondline = (0, line_1.firstline)(source, context.position);
2716
+ if ((0, line_1.isBlank)(secondline) && (0, line_1.firstline)(source, context.position + secondline.length).trimEnd() !== delim) return;
2693
2717
  let block = '';
2694
2718
  let closer = '';
2695
2719
  let overflow = '';
2696
2720
  for (let count = 1;; ++count) {
2697
- if (rest === '') break;
2698
- const line = (0, line_1.firstline)(rest);
2721
+ if (context.position === source.length) break;
2722
+ const line = (0, line_1.firstline)(source, context.position);
2699
2723
  if ((closer || count > limit + 1) && (0, line_1.isBlank)(line)) break;
2700
2724
  if (closer) {
2701
2725
  overflow += line;
2702
2726
  }
2703
2727
  if (!closer && count <= limit + 1 && line.slice(0, delim.length) === delim && line.trimEnd() === delim) {
2704
2728
  closer = line;
2705
- if ((0, line_1.isBlank)((0, line_1.firstline)(rest.slice(line.length)))) {
2706
- rest = rest.slice(line.length);
2729
+ if ((0, line_1.isBlank)((0, line_1.firstline)(source, context.position + line.length))) {
2730
+ context.position += line.length;
2707
2731
  break;
2708
2732
  }
2709
2733
  if (!separation) {
2710
- rest = rest.slice(line.length);
2734
+ context.position += line.length;
2711
2735
  break;
2712
2736
  }
2713
2737
  overflow = line;
@@ -2715,10 +2739,10 @@ function fence(opener, limit, separation = true) {
2715
2739
  if (!overflow) {
2716
2740
  block += line;
2717
2741
  }
2718
- rest = rest.slice(line.length);
2742
+ context.position += line.length;
2719
2743
  }
2720
- return [(0, array_1.push)([block, overflow, closer], matches), rest];
2721
- };
2744
+ return [(0, array_1.push)([block, overflow, closer], matches)];
2745
+ });
2722
2746
  }
2723
2747
  exports.fence = fence;
2724
2748
 
@@ -2748,20 +2772,30 @@ function indent(opener, parser = false, separation = false) {
2748
2772
  parser = opener;
2749
2773
  opener = /^([ \t])\1*/;
2750
2774
  }
2751
- return (0, bind_1.bind)((0, block_1.block)((0, match_1.match)(opener, (0, memoize_1.memoize)(([indent]) => (0, some_1.some)((0, line_1.line)((0, surround_1.open)(indent, ({
2752
- source
2753
- }) => [[source], '']))), ([indent]) => indent.length * 2 + +(indent[0] === ' '), {})), separation), (lines, rest, context) => {
2775
+ return (0, parser_1.failsafe)((0, bind_1.bind)((0, block_1.block)((0, match_1.match)(opener, (0, memoize_1.memoize)(([indent]) => (0, some_1.some)((0, line_1.line)((0, surround_1.open)(indent, ({
2776
+ context
2777
+ }) => {
2778
+ const {
2779
+ source,
2780
+ position
2781
+ } = context;
2782
+ context.position = source.length;
2783
+ return [[source.slice(position)]];
2784
+ }))), ([indent]) => indent.length * 2 + +(indent[0] === ' '), {})), separation), (lines, context) => {
2785
+ const {
2786
+ source,
2787
+ position
2788
+ } = context;
2754
2789
  // 影響する使用はないはず
2755
2790
  //const { backtracks } = context;
2756
2791
  //context.backtracks = {};
2757
- const result = parser({
2758
- source: trimBlockEnd(lines.join('')),
2759
- context
2760
- });
2792
+ const result = parser((0, parser_1.input)(trimBlockEnd(lines.join('')), context));
2761
2793
  //context.backtracks = backtracks;
2762
2794
 
2763
- return result && (0, parser_1.exec)(result) === '' ? [(0, parser_1.eval)(result), rest] : undefined;
2764
- });
2795
+ context.position = position - (context.source.length - context.position);
2796
+ context.source = source;
2797
+ return result && context.position === position ? [(0, parser_1.eval)(result)] : undefined;
2798
+ }));
2765
2799
  }
2766
2800
  exports.indent = indent;
2767
2801
  function trimBlockEnd(block) {
@@ -2801,19 +2835,22 @@ exports.match = void 0;
2801
2835
  const parser_1 = __webpack_require__(605);
2802
2836
  const combinator_1 = __webpack_require__(3484);
2803
2837
  function match(pattern, f, cost = false) {
2804
- return input => {
2838
+ return (0, parser_1.failsafe)(input => {
2805
2839
  const {
2806
- source,
2807
2840
  context
2808
2841
  } = input;
2809
- if (source === '') return;
2810
- const param = source.match(pattern);
2842
+ const {
2843
+ source,
2844
+ position
2845
+ } = context;
2846
+ if (position === source.length) return;
2847
+ const param = source.slice(position).match(pattern);
2811
2848
  if (!param) return;
2812
2849
  cost && (0, combinator_1.consume)(param[0].length, context);
2813
2850
  const result = f(param)(input);
2814
- if (result === undefined) return;
2815
- return (0, parser_1.exec)(result).length < source.length && (0, parser_1.exec)(result).length <= source.length ? result : undefined;
2816
- };
2851
+ context.position += result && context.position === position ? param[0].length : 0;
2852
+ return context.position > position ? result : undefined;
2853
+ });
2817
2854
  }
2818
2855
  exports.match = match;
2819
2856
 
@@ -2831,9 +2868,18 @@ Object.defineProperty(exports, "__esModule", ({
2831
2868
  exports.recover = void 0;
2832
2869
  function recover(parser, fallback) {
2833
2870
  return input => {
2871
+ const {
2872
+ context
2873
+ } = input;
2874
+ const {
2875
+ source,
2876
+ position
2877
+ } = context;
2834
2878
  try {
2835
2879
  return parser(input);
2836
2880
  } catch (reason) {
2881
+ context.source = source;
2882
+ context.position = position;
2837
2883
  return fallback(input, reason);
2838
2884
  }
2839
2885
  };
@@ -2873,53 +2919,59 @@ exports.rewrite = exports.focus = void 0;
2873
2919
  const parser_1 = __webpack_require__(605);
2874
2920
  const combinator_1 = __webpack_require__(3484);
2875
2921
  function focus(scope, parser, cost = true) {
2876
- const match = typeof scope === 'string' ? source => source.slice(0, scope.length) === scope ? scope : '' : source => source.match(scope)?.[0] ?? '';
2877
- return ({
2878
- source,
2922
+ const match = typeof scope === 'string' ? (source, position) => source.startsWith(scope, position) ? scope : '' : (source, position) => source.slice(position).match(scope)?.[0] ?? '';
2923
+ return (0, parser_1.failsafe)(({
2879
2924
  context
2880
2925
  }) => {
2881
- if (source === '') return;
2882
- const src = match(source);
2926
+ const {
2927
+ source,
2928
+ position
2929
+ } = context;
2930
+ if (position === source.length) return;
2931
+ const src = match(source, position);
2883
2932
  if (src === '') return;
2884
2933
  cost && (0, combinator_1.consume)(src.length, context);
2885
- const offset = source.length - src.length;
2934
+ context.range = src.length;
2886
2935
  context.offset ??= 0;
2887
- context.offset += offset;
2888
- const result = parser({
2889
- source: src,
2890
- context
2891
- });
2892
- context.offset -= offset;
2936
+ context.offset += position;
2937
+ const result = parser((0, parser_1.input)(src, context));
2938
+ context.position += position;
2939
+ context.position += result && context.position === position ? src.length : 0;
2940
+ context.source = source;
2941
+ context.offset -= position;
2893
2942
  if (result === undefined) return;
2894
- return (0, parser_1.exec)(result).length < src.length ? [(0, parser_1.eval)(result), (0, parser_1.exec)(result) + source.slice(src.length)] : undefined;
2895
- };
2943
+ return [(0, parser_1.eval)(result)];
2944
+ });
2896
2945
  }
2897
2946
  exports.focus = focus;
2898
2947
  function rewrite(scope, parser) {
2899
- return input => {
2948
+ return (0, parser_1.failsafe)(({
2949
+ context
2950
+ }) => {
2900
2951
  const {
2901
2952
  source,
2902
- context
2903
- } = input;
2904
- if (source === '') return;
2953
+ position
2954
+ } = context;
2955
+ if (position === source.length) return;
2905
2956
  // 影響する使用はないはず
2906
2957
  //const { backtracks } = context;
2907
2958
  //context.backtracks = {};
2908
- const res1 = scope(input);
2909
- //context.backtracks = backtracks;
2910
- if (res1 === undefined || (0, parser_1.exec)(res1).length >= source.length) return;
2911
- const src = source.slice(0, source.length - (0, parser_1.exec)(res1).length);
2912
- const offset = source.length - src.length;
2913
- context.offset ??= 0;
2914
- context.offset += offset;
2915
- const res2 = parser({
2916
- source: src,
2959
+ const res1 = scope({
2917
2960
  context
2918
2961
  });
2919
- context.offset -= offset;
2962
+ //context.backtracks = backtracks;
2963
+ if (res1 === undefined || context.position < position) return;
2964
+ const src = source.slice(position, context.position);
2965
+ context.offset ??= 0;
2966
+ context.offset += position;
2967
+ const res2 = parser((0, parser_1.input)(src, context));
2968
+ context.position += position;
2969
+ context.position += res2 && context.position === position ? src.length : 0;
2970
+ context.source = source;
2971
+ context.offset -= position;
2920
2972
  if (res2 === undefined) return;
2921
- return (0, parser_1.exec)(res2).length < src.length ? [(0, parser_1.eval)(res2), (0, parser_1.exec)(res2) + (0, parser_1.exec)(res1)] : undefined;
2922
- };
2973
+ return [(0, parser_1.eval)(res2)];
2974
+ });
2923
2975
  }
2924
2976
  exports.rewrite = rewrite;
2925
2977
 
@@ -2949,48 +3001,57 @@ function surround(opener, parser, closer, optional = false, f, g, backtracks = [
2949
3001
  case 'object':
2950
3002
  closer = match(closer);
2951
3003
  }
2952
- return ({
2953
- source,
2954
- context
2955
- }) => {
2956
- const sme_ = source;
2957
- if (sme_ === '') return;
3004
+ return (0, parser_1.failsafe)(input => {
3005
+ const {
3006
+ context
3007
+ } = input;
3008
+ const {
3009
+ source,
3010
+ position
3011
+ } = context;
3012
+ if (position === source.length) return;
2958
3013
  const {
2959
3014
  linebreak
2960
3015
  } = context;
2961
3016
  context.linebreak = 0;
2962
- const resultS = opener({
2963
- source: sme_,
2964
- context
2965
- });
2966
- if (resultS === undefined) return void revert(context, linebreak);
2967
- const nodesS = (0, parser_1.eval)(resultS);
2968
- const me_ = (0, parser_1.exec)(resultS);
2969
- if (isBacktrack(context, backtracks, sme_, sme_.length - me_.length)) return void revert(context, linebreak);
2970
- const resultM = me_ !== '' ? parser({
2971
- source: me_,
2972
- context
2973
- }) : undefined;
3017
+ const resultO = opener(input);
3018
+ const nodesO = (0, parser_1.eval)(resultO);
3019
+ if (!nodesO) {
3020
+ return void revert(context, linebreak);
3021
+ }
3022
+ if (isBacktrack(context, backtracks, position, context.position - position || 1)) {
3023
+ return void revert(context, linebreak);
3024
+ }
3025
+ const resultM = context.position < source.length ? parser(input) : undefined;
3026
+ context.range = context.position - position;
2974
3027
  const nodesM = (0, parser_1.eval)(resultM);
2975
- const e_ = (0, parser_1.exec)(resultM) ?? me_;
2976
- const resultE = nodesM || optional ? closer({
2977
- source: e_,
2978
- context
2979
- }) : undefined;
2980
- const nodesE = (0, parser_1.eval)(resultE);
2981
- const rest = (0, parser_1.exec)(resultE) ?? e_;
2982
- nodesE || setBacktrack(context, backtracks, sme_.length);
2983
- if (!nodesM && !optional) return void revert(context, linebreak);
2984
- if (rest.length === sme_.length) return void revert(context, linebreak);
2985
- context.recent = [sme_.slice(0, sme_.length - me_.length), me_.slice(0, me_.length - e_.length), e_.slice(0, e_.length - rest.length)];
2986
- const result = nodesE ? f ? f([nodesS, nodesM, nodesE], rest, context) : [(0, array_1.push)((0, array_1.unshift)(nodesS, nodesM ?? []), nodesE), rest] : g ? g([nodesS, nodesM], rest, context) : undefined;
3028
+ if (!resultM && !optional) {
3029
+ setBacktrack(context, backtracks, position);
3030
+ const result = g?.([nodesO, nodesM], context);
3031
+ revert(context, linebreak);
3032
+ return result;
3033
+ }
3034
+ const resultC = resultM || optional ? closer(input) : undefined;
3035
+ context.range = context.position - position;
3036
+ const nodesC = (0, parser_1.eval)(resultC);
3037
+ if (!nodesC) {
3038
+ setBacktrack(context, backtracks, position);
3039
+ const result = g?.([nodesO, nodesM], context);
3040
+ revert(context, linebreak);
3041
+ return result;
3042
+ }
3043
+ if (context.position === position) {
3044
+ return void revert(context, linebreak);
3045
+ }
3046
+ context.range = context.position - position;
3047
+ const result = f ? f([nodesO, nodesM, nodesC], context) : [(0, array_1.push)(nodesM ? (0, array_1.unshift)(nodesO, nodesM) : nodesO, nodesC)];
2987
3048
  if (result) {
2988
3049
  context.linebreak ||= linebreak;
2989
3050
  } else {
2990
3051
  revert(context, linebreak);
2991
3052
  }
2992
3053
  return result;
2993
- };
3054
+ });
2994
3055
  }
2995
3056
  exports.surround = surround;
2996
3057
  function open(opener, parser, optional, backtracks) {
@@ -3002,8 +3063,12 @@ function close(parser, closer, optional, backtracks) {
3002
3063
  }
3003
3064
  exports.close = close;
3004
3065
  const statesize = 2;
3005
- function isBacktrack(context, backtracks, source, length = 1) {
3006
- if (length === 0 || source.length === 0) return false;
3066
+ function isBacktrack(context, backtracks, position = context.position, length = 1) {
3067
+ const {
3068
+ source
3069
+ } = context;
3070
+ if (position === source.length) return false;
3071
+ if (length === 0) return false;
3007
3072
  for (const backtrack of backtracks) {
3008
3073
  if (backtrack & 1) {
3009
3074
  const {
@@ -3011,8 +3076,9 @@ function isBacktrack(context, backtracks, source, length = 1) {
3011
3076
  offset = 0
3012
3077
  } = context;
3013
3078
  for (let i = 0; i < length; ++i) {
3014
- if (source[i] !== source[0]) break;
3015
- const pos = source.length - i + offset - 1;
3079
+ if (position + i === source.length) break;
3080
+ if (source[position + i] !== source[position + 0]) break;
3081
+ const pos = position + i + offset;
3016
3082
  if (!(pos in backtracks)) continue;
3017
3083
  if (backtracks[pos] & 1 << size(backtrack >>> statesize)) return true;
3018
3084
  }
@@ -3022,15 +3088,20 @@ function isBacktrack(context, backtracks, source, length = 1) {
3022
3088
  }
3023
3089
  exports.isBacktrack = isBacktrack;
3024
3090
  function setBacktrack(context, backtracks, position, length = 1) {
3025
- if (length === 0 || position === 0) return;
3091
+ const {
3092
+ source
3093
+ } = context;
3094
+ if (position === source.length) return;
3095
+ if (length === 0) return;
3026
3096
  for (const backtrack of backtracks) {
3027
- if (backtrack & 2 && position !== 0) {
3097
+ if (backtrack & 2) {
3028
3098
  const {
3029
3099
  backtracks = {},
3030
3100
  offset = 0
3031
3101
  } = context;
3032
3102
  for (let i = 0; i < length; ++i) {
3033
- const pos = position - i + offset - 1;
3103
+ if (position + i === source.length) break;
3104
+ const pos = position + i + offset;
3034
3105
  backtracks[pos] |= 1 << size(backtrack >>> statesize);
3035
3106
  }
3036
3107
  }
@@ -3041,17 +3112,29 @@ function match(pattern) {
3041
3112
  switch (typeof pattern) {
3042
3113
  case 'string':
3043
3114
  return ({
3044
- source
3045
- }) => source.slice(0, pattern.length) === pattern ? [[], source.slice(pattern.length)] : undefined;
3115
+ context
3116
+ }) => {
3117
+ const {
3118
+ source,
3119
+ position
3120
+ } = context;
3121
+ if (!source.startsWith(pattern, position)) return;
3122
+ context.position += pattern.length;
3123
+ return [[]];
3124
+ };
3046
3125
  case 'object':
3047
3126
  return ({
3048
- source,
3049
3127
  context
3050
3128
  }) => {
3051
- const m = source.match(pattern);
3129
+ const {
3130
+ source,
3131
+ position
3132
+ } = context;
3133
+ const m = source.slice(position).match(pattern);
3052
3134
  if (m === null) return;
3053
3135
  (0, combinator_1.consume)(m[0].length, context);
3054
- return [[], source.slice(m[0].length)];
3136
+ context.position += m[0].length;
3137
+ return [[]];
3055
3138
  };
3056
3139
  }
3057
3140
  }
@@ -3109,19 +3192,22 @@ Object.defineProperty(exports, "__esModule", ({
3109
3192
  exports.bind = void 0;
3110
3193
  const parser_1 = __webpack_require__(605);
3111
3194
  function bind(parser, f) {
3112
- return input => {
3195
+ return (0, parser_1.failsafe)(input => {
3113
3196
  const {
3114
- source,
3115
3197
  context
3116
3198
  } = input;
3117
- if (source === '') return;
3199
+ const {
3200
+ source,
3201
+ position
3202
+ } = context;
3203
+ if (position === source.length) return;
3118
3204
  const res1 = parser(input);
3119
3205
  if (res1 === undefined) return;
3120
- context.recent = [source.slice(0, source.length - (0, parser_1.exec)(res1).length)];
3121
- const res2 = f((0, parser_1.eval)(res1), (0, parser_1.exec)(res1), context);
3206
+ context.range = context.position - position;
3207
+ const res2 = f((0, parser_1.eval)(res1), context);
3122
3208
  if (res2 === undefined) return;
3123
- return (0, parser_1.exec)(res2).length <= (0, parser_1.exec)(res1).length ? res2 : undefined;
3124
- };
3209
+ return context.position > position ? res2 : undefined;
3210
+ });
3125
3211
  }
3126
3212
  exports.bind = bind;
3127
3213
 
@@ -3139,7 +3225,7 @@ Object.defineProperty(exports, "__esModule", ({
3139
3225
  exports.fmap = void 0;
3140
3226
  const bind_1 = __webpack_require__(994);
3141
3227
  function fmap(parser, f) {
3142
- return (0, bind_1.bind)(parser, (nodes, rest, context) => [f(nodes, rest, context), rest]);
3228
+ return (0, bind_1.bind)(parser, (nodes, context) => [f(nodes, context)]);
3143
3229
  }
3144
3230
  exports.fmap = fmap;
3145
3231
 
@@ -3154,19 +3240,66 @@ exports.fmap = fmap;
3154
3240
  Object.defineProperty(exports, "__esModule", ({
3155
3241
  value: true
3156
3242
  }));
3157
- exports.check = exports.exec = exports.eval = void 0;
3243
+ exports.failsafe = exports.eval = exports.clean = exports.subinput = exports.input = void 0;
3244
+ function input(source, context) {
3245
+ // @ts-expect-error
3246
+ context.source = source;
3247
+ // @ts-expect-error
3248
+ context.position = 0;
3249
+ return {
3250
+ source,
3251
+ // @ts-expect-error
3252
+ context
3253
+ };
3254
+ }
3255
+ exports.input = input;
3256
+ function subinput(source, context) {
3257
+ return {
3258
+ context: {
3259
+ ...context,
3260
+ source,
3261
+ position: 0,
3262
+ offset: undefined,
3263
+ backtracks: {}
3264
+ }
3265
+ };
3266
+ }
3267
+ exports.subinput = subinput;
3268
+ function clean(context) {
3269
+ const {
3270
+ source,
3271
+ position
3272
+ } = context;
3273
+ for (const p of Object.keys(context)) {
3274
+ context[p] = undefined;
3275
+ }
3276
+ context.source = source;
3277
+ context.position = position;
3278
+ return context;
3279
+ }
3280
+ exports.clean = clean;
3158
3281
  function eval_(result, default_) {
3159
3282
  return result ? result[0] : default_;
3160
3283
  }
3161
3284
  exports.eval = eval_;
3162
- function exec(result, default_) {
3163
- return result ? result[1] : default_;
3164
- }
3165
- exports.exec = exec;
3166
- function check(source, result, mustConsume = true) {
3167
- return true;
3285
+ function failsafe(parser) {
3286
+ return input => {
3287
+ const {
3288
+ context
3289
+ } = input;
3290
+ const {
3291
+ source,
3292
+ position
3293
+ } = context;
3294
+ const result = parser(input);
3295
+ if (result === undefined) {
3296
+ context.source = source;
3297
+ context.position = position;
3298
+ }
3299
+ return result;
3300
+ };
3168
3301
  }
3169
- exports.check = check;
3302
+ exports.failsafe = failsafe;
3170
3303
 
3171
3304
  /***/ },
3172
3305
 
@@ -3186,46 +3319,47 @@ function reset(base, parser) {
3186
3319
  const changes = Object.entries(base);
3187
3320
  const values = Array(changes.length);
3188
3321
  return ({
3189
- source,
3190
3322
  context
3191
- }) => apply(parser, source, (0, alias_1.ObjectCreate)(context), changes, values, true);
3323
+ }) => apply(parser, context, changes, values, true);
3192
3324
  }
3193
3325
  exports.reset = reset;
3194
3326
  function context(base, parser) {
3195
3327
  const changes = Object.entries(base);
3196
3328
  const values = Array(changes.length);
3197
3329
  return ({
3198
- source,
3199
3330
  context
3200
- }) => apply(parser, source, context, changes, values);
3331
+ }) => apply(parser, context, changes, values);
3201
3332
  }
3202
3333
  exports.context = context;
3203
- function apply(parser, source, context, changes, values, reset = false) {
3204
- if (reset) {
3205
- context.backtracks = {};
3206
- }
3334
+ function apply(parser, context, changes, values, reset = false) {
3207
3335
  for (let i = 0; i < changes.length; ++i) {
3208
3336
  const change = changes[i];
3209
3337
  const prop = change[0];
3210
3338
  switch (prop) {
3339
+ case 'source':
3340
+ case 'position':
3341
+ continue;
3211
3342
  case 'resources':
3343
+ values[i] = context[prop];
3212
3344
  context[prop] ??= (0, assign_1.clone)({}, change[1]);
3213
3345
  continue;
3346
+ case 'backtracks':
3347
+ change[1] = {};
3214
3348
  }
3215
3349
  values[i] = context[prop];
3216
3350
  context[prop] = change[1];
3217
3351
  }
3218
3352
  const result = parser({
3219
- source,
3220
3353
  context
3221
3354
  });
3222
3355
  for (let i = 0; i < changes.length; ++i) {
3223
3356
  const change = changes[i];
3224
3357
  const prop = change[0];
3225
3358
  switch (prop) {
3226
- case 'resources':
3227
- // プロトタイプに戻ることで戻す
3359
+ case 'source':
3360
+ case 'position':
3228
3361
  continue;
3362
+ case 'resources':
3229
3363
  }
3230
3364
  context[prop] = values[i];
3231
3365
  values[i] = undefined;
@@ -3375,9 +3509,15 @@ class Delimiters {
3375
3509
  case 'undefined':
3376
3510
  return () => undefined;
3377
3511
  case 'string':
3378
- return source => source.slice(0, pattern.length) === pattern || undefined;
3512
+ return ({
3513
+ source,
3514
+ position
3515
+ }) => source.startsWith(pattern, position) || undefined;
3379
3516
  case 'object':
3380
- return source => pattern.test(source) || undefined;
3517
+ return ({
3518
+ source,
3519
+ position
3520
+ }) => pattern.test(source.slice(position)) || undefined;
3381
3521
  }
3382
3522
  }
3383
3523
  registry(signature) {
@@ -3468,17 +3608,18 @@ class Delimiters {
3468
3608
  delimiters[indexes[i]].state = true;
3469
3609
  }
3470
3610
  }
3471
- match(source, {
3472
- precedence = 0,
3473
- linebreak = 0
3474
- }) {
3611
+ match(context) {
3612
+ const {
3613
+ precedence = 0,
3614
+ linebreak = 0
3615
+ } = context;
3475
3616
  const {
3476
3617
  delimiters
3477
3618
  } = this;
3478
3619
  for (let i = delimiters.length; i--;) {
3479
3620
  const delimiter = delimiters[i];
3480
3621
  if (delimiter.precedence <= precedence || !delimiter.state) continue;
3481
- switch (delimiter.matcher(source)) {
3622
+ switch (delimiter.matcher(context)) {
3482
3623
  case true:
3483
3624
  if (!delimiter.linebreakable && linebreak > 0) return false;
3484
3625
  return true;
@@ -3509,25 +3650,24 @@ const parser_1 = __webpack_require__(605);
3509
3650
  const array_1 = __webpack_require__(6876);
3510
3651
  function inits(parsers, resume) {
3511
3652
  if (parsers.length === 1) return parsers[0];
3512
- return ({
3513
- source,
3514
- context
3515
- }) => {
3516
- let rest = source;
3653
+ return input => {
3654
+ const {
3655
+ context
3656
+ } = input;
3657
+ const {
3658
+ source,
3659
+ position
3660
+ } = context;
3517
3661
  let nodes;
3518
3662
  for (let len = parsers.length, i = 0; i < len; ++i) {
3519
- if (rest === '') break;
3520
- if (context.delimiters?.match(rest, context)) break;
3521
- const result = parsers[i]({
3522
- source: rest,
3523
- context
3524
- });
3663
+ if (context.position === source.length) break;
3664
+ if (context.delimiters?.match(context)) break;
3665
+ const result = parsers[i](input);
3525
3666
  if (result === undefined) break;
3526
3667
  nodes = nodes ? (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
3527
- rest = (0, parser_1.exec)(result);
3528
- if (resume?.((0, parser_1.eval)(result), (0, parser_1.exec)(result)) === false) break;
3668
+ if (resume?.((0, parser_1.eval)(result)) === false) break;
3529
3669
  }
3530
- return nodes && rest.length < source.length ? [nodes, rest] : undefined;
3670
+ return nodes && context.position > position ? [nodes] : undefined;
3531
3671
  };
3532
3672
  }
3533
3673
  exports.inits = inits;
@@ -3548,25 +3688,24 @@ const parser_1 = __webpack_require__(605);
3548
3688
  const array_1 = __webpack_require__(6876);
3549
3689
  function sequence(parsers, resume) {
3550
3690
  if (parsers.length === 1) return parsers[0];
3551
- return ({
3552
- source,
3553
- context
3554
- }) => {
3555
- let rest = source;
3691
+ return input => {
3692
+ const {
3693
+ context
3694
+ } = input;
3695
+ const {
3696
+ source,
3697
+ position
3698
+ } = context;
3556
3699
  let nodes;
3557
3700
  for (let len = parsers.length, i = 0; i < len; ++i) {
3558
- if (rest === '') return;
3559
- if (context.delimiters?.match(rest, context)) return;
3560
- const result = parsers[i]({
3561
- source: rest,
3562
- context
3563
- });
3701
+ if (context.position === source.length) return;
3702
+ if (context.delimiters?.match(context)) return;
3703
+ const result = parsers[i](input);
3564
3704
  if (result === undefined) return;
3565
3705
  nodes = nodes ? (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
3566
- rest = (0, parser_1.exec)(result);
3567
- if (resume?.((0, parser_1.eval)(result), (0, parser_1.exec)(result)) === false) return;
3706
+ if (resume?.((0, parser_1.eval)(result)) === false) return;
3568
3707
  }
3569
- return nodes && rest.length < source.length ? [nodes, rest] : undefined;
3708
+ return nodes && context.position > position ? [nodes] : undefined;
3570
3709
  };
3571
3710
  }
3572
3711
  exports.sequence = sequence;
@@ -3595,34 +3734,33 @@ function some(parser, end, delimiters = [], limit = 0) {
3595
3734
  precedence,
3596
3735
  linebreakable
3597
3736
  }));
3598
- return ({
3599
- source,
3600
- context
3601
- }) => {
3602
- if (source === '') return;
3603
- let rest = source;
3737
+ return input => {
3738
+ const {
3739
+ context
3740
+ } = input;
3741
+ const {
3742
+ source,
3743
+ position
3744
+ } = context;
3745
+ //assert(context.backtracks ??= {});
3604
3746
  let nodes;
3605
3747
  if (delims.length > 0) {
3606
3748
  context.delimiters ??= new delimiter_1.Delimiters();
3607
3749
  context.delimiters.push(delims);
3608
3750
  }
3609
3751
  while (true) {
3610
- if (rest === '') break;
3611
- if (match(rest)) break;
3612
- if (context.delimiters?.match(rest, context)) break;
3613
- const result = parser({
3614
- source: rest,
3615
- context
3616
- });
3752
+ if (context.position === source.length) break;
3753
+ if (match(context)) break;
3754
+ if (context.delimiters?.match(context)) break;
3755
+ const result = parser(input);
3617
3756
  if (result === undefined) break;
3618
3757
  nodes = nodes ? nodes.length < (0, parser_1.eval)(result).length / 8 ? (0, array_1.unshift)(nodes, (0, parser_1.eval)(result)) : (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
3619
- rest = (0, parser_1.exec)(result);
3620
- if (limit > 0 && source.length - rest.length > limit) break;
3758
+ if (limit > 0 && context.position - position > limit) break;
3621
3759
  }
3622
3760
  if (delims.length > 0) {
3623
3761
  context.delimiters.pop(delims.length);
3624
3762
  }
3625
- return nodes && rest.length < source.length ? [nodes, rest] : undefined;
3763
+ return nodes && context.position > position ? [nodes] : undefined;
3626
3764
  };
3627
3765
  }
3628
3766
  exports.some = some;
@@ -3855,15 +3993,9 @@ function bind(target, settings) {
3855
3993
  let index = head;
3856
3994
  for (; index < sourceSegments.length - last; ++index) {
3857
3995
  const seg = sourceSegments[index];
3858
- const es = (0, parser_1.eval)((0, header_1.header)({
3859
- source: seg,
3860
- context: {
3861
- header: index === 0
3862
- }
3863
- }) || (0, block_1.block)({
3864
- source: seg,
3865
- context
3866
- }), []);
3996
+ const es = (0, parser_1.eval)((0, header_1.header)((0, parser_1.input)(seg, {
3997
+ header: index === 0
3998
+ })) || (0, block_1.block)((0, parser_1.input)(seg, context)), []);
3867
3999
  blocks.splice(index, 0, [seg, es, url]);
3868
4000
  if (es.length === 0) continue;
3869
4001
  // All deletion processes always run after all addition processes have done.
@@ -4032,8 +4164,8 @@ exports.headers = exports.header = void 0;
4032
4164
  const parser_1 = __webpack_require__(605);
4033
4165
  const header_1 = __webpack_require__(3009);
4034
4166
  function header(source) {
4035
- const [, rest = source] = parse(source);
4036
- return source.slice(0, source.length - rest.length);
4167
+ const [, pos = 0] = parse(source);
4168
+ return source.slice(0, pos);
4037
4169
  }
4038
4170
  exports.header = header;
4039
4171
  function headers(source) {
@@ -4042,12 +4174,10 @@ function headers(source) {
4042
4174
  }
4043
4175
  exports.headers = headers;
4044
4176
  function parse(source) {
4045
- const result = (0, header_1.header)({
4046
- source,
4047
- context: {}
4048
- });
4177
+ const i = (0, parser_1.input)(source, {});
4178
+ const result = (0, header_1.header)(i);
4049
4179
  const [el] = (0, parser_1.eval)(result, []);
4050
- return el?.tagName === 'ASIDE' ? [el, (0, parser_1.exec)(result)] : [];
4180
+ return el?.tagName === 'ASIDE' ? [el, i.context.position] : [];
4051
4181
  }
4052
4182
 
4053
4183
  /***/ },
@@ -4079,10 +4209,7 @@ function sanitize(source) {
4079
4209
  // https://en.wikipedia.org/wiki/Whitespace_character
4080
4210
  exports.invisibleHTMLEntityNames = ['Tab', 'NewLine', 'NonBreakingSpace', 'nbsp', 'shy', 'ensp', 'emsp', 'emsp13', 'emsp14', 'numsp', 'puncsp', 'ThinSpace', 'thinsp', 'VeryThinSpace', 'hairsp', 'ZeroWidthSpace', 'NegativeVeryThinSpace', 'NegativeThinSpace', 'NegativeMediumSpace', 'NegativeThickSpace', 'zwj', 'zwnj', 'lrm', 'rlm', 'MediumSpace', 'NoBreak', 'ApplyFunction', 'af', 'InvisibleTimes', 'it', 'InvisibleComma', 'ic'];
4081
4211
  const unreadableHTMLEntityNames = exports.invisibleHTMLEntityNames.slice(2);
4082
- const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)({
4083
- source: `&${name};`,
4084
- context: {}
4085
- }))[0]);
4212
+ const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)((0, parser_1.input)(`&${name};`, {})))[0]);
4086
4213
  const unreadableEscapableCharacter = new RegExp(`[${[...new Set(unreadableEscapableCharacters)].join('')}]`, 'g');
4087
4214
  // https://www.pandanoir.info/entry/2018/03/11/193000
4088
4215
  // http://anti.rosx.net/etc/memo/002_space.html
@@ -4160,15 +4287,9 @@ function parse(source, opts = {}, context) {
4160
4287
  const node = (0, dom_1.frag)();
4161
4288
  let index = 0;
4162
4289
  for (const seg of (0, segment_1.segment)(source)) {
4163
- node.append(...(0, parser_1.eval)((0, header_1.header)({
4164
- source: seg,
4165
- context: {
4166
- header: index++ === 0
4167
- }
4168
- }) || (0, block_1.block)({
4169
- source: seg,
4170
- context
4171
- }), []));
4290
+ node.append(...(0, parser_1.eval)((0, header_1.header)((0, parser_1.input)(seg, {
4291
+ header: index++ === 0
4292
+ })) || (0, block_1.block)((0, parser_1.input)(seg, context)), []));
4172
4293
  }
4173
4294
  if (opts.test) return node;
4174
4295
  for (const _ of (0, figure_1.figure)(node, opts.notes, context));
@@ -4229,19 +4350,24 @@ const dom_1 = __webpack_require__(394);
4229
4350
  exports.block = (0, combinator_1.reset)({
4230
4351
  resources: {
4231
4352
  // バックトラックのせいで文字数制限を受けないようにする。
4232
- clock: segment_1.MAX_SEGMENT_SIZE * 11 + 1,
4353
+ clock: segment_1.MAX_SEGMENT_SIZE * 1,
4233
4354
  recursions: [10 || 0 /* Recursion.block */, 20 || 0 /* Recursion.blockquote */, 40 || 0 /* Recursion.listitem */, 20 || 0 /* Recursion.inline */, 20 || 0 /* Recursion.bracket */, 20 || 0 /* Recursion.terminal */]
4234
- }
4355
+ },
4356
+ backtracks: {}
4235
4357
  }, error((0, combinator_1.union)([source_1.emptyline, pagebreak_1.pagebreak, 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, mediablock_1.mediablock, reply_1.reply, paragraph_1.paragraph])));
4236
4358
  function error(parser) {
4237
4359
  const reg = new RegExp(String.raw`^${"\u0007" /* Command.Error */}.*\n`);
4238
4360
  return (0, combinator_1.recover)((0, combinator_1.fallback)((0, combinator_1.open)("\u0007" /* Command.Error */, ({
4239
- source
4361
+ context: {
4362
+ source,
4363
+ position
4364
+ }
4240
4365
  }) => {
4241
- throw new Error(source.split('\n', 1)[0]);
4366
+ throw new Error(source.slice(position).split('\n', 1)[0]);
4242
4367
  }), parser), ({
4243
- source,
4244
4368
  context: {
4369
+ source,
4370
+ position,
4245
4371
  id
4246
4372
  }
4247
4373
  }, reason) => [[(0, dom_1.html)('h1', {
@@ -4250,7 +4376,7 @@ function error(parser) {
4250
4376
  }, reason instanceof Error ? `${reason.name}: ${reason.message}` : `UnknownError: ${reason}`), (0, dom_1.html)('pre', {
4251
4377
  class: 'error',
4252
4378
  translate: 'no'
4253
- }, source.replace(reg, '').slice(0, 1001).replace(/^(.{997}).{4}$/s, '$1...') || undefined)], '']);
4379
+ }, source.slice(position).replace(reg, '').slice(0, 1001).replace(/^(.{997}).{4}$/s, '$1...') || undefined)]]);
4254
4380
  }
4255
4381
 
4256
4382
  /***/ },
@@ -4277,9 +4403,11 @@ const indent = (0, combinator_1.block)((0, combinator_1.open)(opener, (0, combin
4277
4403
  const unindent = source => source.replace(/(?<=^|\n)>(?:[^\S\n]|(?=>*(?:$|\s)))|\n$/g, '');
4278
4404
  const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.recursion)(2 /* Recursion.blockquote */, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source, false, true)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))]), false, true))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
4279
4405
  const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.recursion)(2 /* Recursion.blockquote */, (0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown, false, true)), (0, combinator_1.creation)(10, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
4280
- source,
4281
4406
  context
4282
4407
  }) => {
4408
+ const {
4409
+ source
4410
+ } = context;
4283
4411
  const references = (0, dom_1.html)('ol', {
4284
4412
  class: 'references'
4285
4413
  });
@@ -4289,7 +4417,8 @@ const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combina
4289
4417
  references
4290
4418
  }
4291
4419
  }, context);
4292
- return [[(0, dom_1.html)('section', [document, (0, dom_1.html)('h2', 'References'), references])], ''];
4420
+ context.position = source.length;
4421
+ return [[(0, dom_1.html)('section', [document, (0, dom_1.html)('h2', 'References'), references])]];
4293
4422
  }, false, true)))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
4294
4423
 
4295
4424
  /***/ },
@@ -4315,7 +4444,7 @@ exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('```', (0,
4315
4444
  exports.segment_ = (0, combinator_1.block)((0, combinator_1.validate)('```', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 300, false))), false);
4316
4445
  exports.codeblock = (0, combinator_1.block)((0, combinator_1.validate)('```', (0, combinator_1.fmap)((0, combinator_1.fence)(opener, 300),
4317
4446
  // Bug: Type mismatch between outer and inner.
4318
- ([body, overflow, closer, opener, delim, param], _, context) => {
4447
+ ([body, overflow, closer, opener, delim, param], context) => {
4319
4448
  const params = param.match(/(?:\\.?|\S)+/g)?.reduce((params, value, i) => {
4320
4449
  let name;
4321
4450
  switch (true) {
@@ -4347,10 +4476,9 @@ exports.codeblock = (0, combinator_1.block)((0, combinator_1.validate)('```', (0
4347
4476
  'data-lang': params.lang || undefined,
4348
4477
  'data-line': params.line || undefined,
4349
4478
  'data-path': params.path || undefined
4350
- }, params.lang ? context.caches?.code?.get(`${params.lang ?? ''}\n${body.slice(0, -1)}`)?.cloneNode(true).childNodes || body.slice(0, -1) || undefined : (0, dom_1.defrag)((0, parser_1.eval)((0, autolink_1.autolink)({
4351
- source: body.slice(0, -1),
4352
- context
4353
- }), [])));
4479
+ }, params.lang ? context.caches?.code?.get(`${params.lang ?? ''}\n${body.slice(0, -1)}`)?.cloneNode(true).childNodes || body.slice(0, -1) || undefined : (0, dom_1.defrag)((0, parser_1.eval)((0, autolink_1.autolink)((0, parser_1.input)(body.slice(0, -1), {
4480
+ ...context
4481
+ })), [])));
4354
4482
  return [el];
4355
4483
  })));
4356
4484
 
@@ -4425,7 +4553,7 @@ const parse_1 = __webpack_require__(3662);
4425
4553
  const dom_1 = __webpack_require__(394);
4426
4554
  exports.aside = (0, combinator_1.recursion)(1 /* Recursion.block */, (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.fmap)((0, combinator_1.fence)(/^(~{3,})aside(?!\S)([^\n]*)(?:$|\n)/, 300),
4427
4555
  // Bug: Type mismatch between outer and inner.
4428
- ([body, overflow, closer, opener, delim, param], _, context) => {
4556
+ ([body, overflow, closer, opener, delim, param], context) => {
4429
4557
  if (!closer || overflow || param.trimStart()) return [(0, dom_1.html)('pre', {
4430
4558
  class: 'invalid',
4431
4559
  translate: 'no',
@@ -4473,7 +4601,7 @@ const dom_1 = __webpack_require__(394);
4473
4601
  const opener = /^(~{3,})(?:example\/(\S+))?(?!\S)([^\n]*)(?:$|\n)/;
4474
4602
  exports.example = (0, combinator_1.recursion)(1 /* Recursion.block */, (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.fmap)((0, combinator_1.fence)(opener, 300),
4475
4603
  // Bug: Type mismatch between outer and inner.
4476
- ([body, overflow, closer, opener, delim, type = 'markdown', param], _, context) => {
4604
+ ([body, overflow, closer, opener, delim, type = 'markdown', param], context) => {
4477
4605
  if (!closer || overflow || param.trimStart()) return [(0, dom_1.html)('pre', {
4478
4606
  class: 'invalid',
4479
4607
  translate: 'no',
@@ -4504,10 +4632,9 @@ exports.example = (0, combinator_1.recursion)(1 /* Recursion.block */, (0, combi
4504
4632
  'data-type': 'math'
4505
4633
  }, [(0, dom_1.html)('pre', {
4506
4634
  translate: 'no'
4507
- }, body.slice(0, -1)), (0, dom_1.html)('hr'), (0, parser_1.eval)((0, mathblock_1.mathblock)({
4508
- source: `$$\n${body}$$`,
4509
- context
4510
- }), [])[0]])];
4635
+ }, body.slice(0, -1)), (0, dom_1.html)('hr'), (0, parser_1.eval)((0, mathblock_1.mathblock)((0, parser_1.input)(`$$\n${body}$$`, {
4636
+ ...context
4637
+ })), [])[0]])];
4511
4638
  default:
4512
4639
  return [(0, dom_1.html)('pre', {
4513
4640
  class: 'invalid',
@@ -4544,7 +4671,6 @@ exports.fig = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment,
4544
4671
  // Bug: TypeScript
4545
4672
  const fence = (/^[^\n]*\n!?>+\s/.test(source) && source.match(/^~{3,}(?=[^\S\n]*$)/mg) || []).reduce((max, fence) => fence > max ? fence : max, '~~') + '~';
4546
4673
  return parser({
4547
- source,
4548
4674
  context
4549
4675
  }) ? `${fence}figure ${source.replace(/^(.+\n.+\n)([\S\s]+?)\n?$/, '$1\n$2')}\n${fence}` : `${fence}figure ${source}\n\n${fence}`;
4550
4676
  }, (0, combinator_1.union)([figure_1.figure]), false), ([el]) => el.tagName === 'FIGURE')));
@@ -4587,6 +4713,7 @@ Object.defineProperty(exports, "__esModule", ({
4587
4713
  value: true
4588
4714
  }));
4589
4715
  exports.figure = exports.segment = void 0;
4716
+ const parser_1 = __webpack_require__(605);
4590
4717
  const combinator_1 = __webpack_require__(3484);
4591
4718
  const source_1 = __webpack_require__(8745);
4592
4719
  const label_1 = __webpack_require__(2178);
@@ -4611,11 +4738,10 @@ exports.figure = (0, combinator_1.block)((0, combinator_1.fallback)((0, combinat
4611
4738
  class: 'figindex'
4612
4739
  }), (0, dom_1.html)('span', {
4613
4740
  class: 'figtext'
4614
- }, (0, dom_1.defrag)(caption))]), (0, dom_1.html)('div', [content])])])), (0, combinator_1.fmap)((0, combinator_1.fence)(/^(~{3,})(?:figure|\[?\$\S*)(?!\S)[^\n]*(?:$|\n)/, 300), ([body, overflow, closer, opener, delim], _, context) => {
4615
- const violation = !closer && ['fence', `Missing the closing delimiter "${delim}"`] || overflow && ['fence', `Invalid trailing line after the closing delimiter "${delim}"`] || !(0, label_1.segment)({
4616
- source: opener.match(/^~+(?:figure[^\S\n]+)?(\[?\$\S+)/)?.[1] ?? '',
4617
- context
4618
- }) && ['label', 'Invalid label'] || /^~+(?:figure[^\S\n]+)?(\[?\$\S+)[^\S\n]+\S/.test(opener) && ['argument', 'Invalid argument'] || ['content', 'Invalid content'];
4741
+ }, (0, dom_1.defrag)(caption))]), (0, dom_1.html)('div', [content])])])), (0, combinator_1.fmap)((0, combinator_1.fence)(/^(~{3,})(?:figure|\[?\$\S*)(?!\S)[^\n]*(?:$|\n)/, 300), ([body, overflow, closer, opener, delim], context) => {
4742
+ const violation = !closer && ['fence', `Missing the closing delimiter "${delim}"`] || overflow && ['fence', `Invalid trailing line after the closing delimiter "${delim}"`] || !(0, label_1.segment)((0, parser_1.input)(opener.match(/^~+(?:figure[^\S\n]+)?(\[?\$\S+)/)?.[1] ?? '', {
4743
+ ...context
4744
+ })) && ['label', 'Invalid label'] || /^~+(?:figure[^\S\n]+)?(\[?\$\S+)[^\S\n]+\S/.test(opener) && ['argument', 'Invalid argument'] || ['content', 'Invalid content'];
4619
4745
  return [(0, dom_1.html)('pre', {
4620
4746
  class: 'invalid',
4621
4747
  translate: 'no',
@@ -4691,7 +4817,7 @@ const array_1 = __webpack_require__(6876);
4691
4817
  const dom_1 = __webpack_require__(394);
4692
4818
  exports.message = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.fmap)((0, combinator_1.fence)(/^(~{3,})message\/(\S+)([^\n]*)(?:$|\n)/, 300),
4693
4819
  // Bug: Type mismatch between outer and inner.
4694
- ([body, overflow, closer, opener, delim, type, param], _, context) => {
4820
+ ([body, overflow, closer, opener, delim, type, param], context) => {
4695
4821
  if (!closer || overflow || param.trimStart()) return [(0, dom_1.html)('pre', {
4696
4822
  class: 'invalid',
4697
4823
  translate: 'no',
@@ -4712,10 +4838,9 @@ exports.message = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0,
4712
4838
  return [(0, dom_1.html)('section', {
4713
4839
  class: `message`,
4714
4840
  'data-type': type
4715
- }, (0, array_1.unshift)([(0, dom_1.html)('h1', title(type))], [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, parser_1.eval)(content({
4716
- source: seg,
4717
- context
4718
- }), [])), [])))];
4841
+ }, (0, array_1.unshift)([(0, dom_1.html)('h1', title(type))], [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, parser_1.eval)(content((0, parser_1.input)(seg, {
4842
+ ...context
4843
+ })), [])), [])))];
4719
4844
  })));
4720
4845
  function title(type) {
4721
4846
  switch (type) {
@@ -4780,7 +4905,7 @@ exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0,
4780
4905
  exports.segment_ = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 10000, false))), false);
4781
4906
  exports.table = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.fmap)((0, combinator_1.fence)(opener, 10000),
4782
4907
  // Bug: Type mismatch between outer and inner.
4783
- ([body, overflow, closer, opener, delim, type, param], _, context) => {
4908
+ ([body, overflow, closer, opener, delim, type, param], context) => {
4784
4909
  if (!closer || overflow || param.trimStart()) return [(0, dom_1.html)('pre', {
4785
4910
  class: 'invalid',
4786
4911
  translate: 'no',
@@ -4789,10 +4914,9 @@ exports.table = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, co
4789
4914
  switch (type) {
4790
4915
  case 'grid':
4791
4916
  case undefined:
4792
- return ((0, parser_1.eval)(parser({
4793
- source: body,
4794
- context
4795
- })) ?? [(0, dom_1.html)('table')]).map(el => (0, dom_1.define)(el, {
4917
+ return ((0, parser_1.eval)(parser((0, parser_1.input)(body, {
4918
+ ...context
4919
+ }))) ?? [(0, dom_1.html)('table')]).map(el => (0, dom_1.define)(el, {
4796
4920
  'data-type': type
4797
4921
  }));
4798
4922
  default:
@@ -4810,7 +4934,7 @@ const align = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.uni
4810
4934
  const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?(?:!+[+]?)?(?=\s)/;
4811
4935
  const head = (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.union)([(0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.medialink, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.media, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.shortmedia, /^\s*$/)), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)(inline_1.inline))), true)])), true), ns => [(0, dom_1.html)('th', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false);
4812
4936
  const data = (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.union)([(0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.medialink, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.media, /^\s*$/)), (0, combinator_1.block)((0, combinator_1.surround)(/^[^\n]/, inline_1.shortmedia, /^\s*$/)), (0, combinator_1.open)(/^(?:\s*\n|\s)/, (0, visibility_1.visualize)((0, visibility_1.trimBlankEnd)((0, util_1.lineable)((0, combinator_1.some)(inline_1.inline)))), true)])), true), ns => [(0, dom_1.html)('td', attributes(ns.shift()), (0, dom_1.defrag)(ns))]), false);
4813
- const dataline = (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, true)), (0, combinator_1.convert)(source => `: ${source}`, data, true)])));
4937
+ const dataline = (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, false)), (0, combinator_1.convert)(source => `: ${source}`, data, false)])));
4814
4938
  function attributes(source) {
4815
4939
  let [, rowspan = undefined, colspan = undefined, highlight = undefined, extension = undefined] = source.match(/^[#:](?:(\d+)?:(\d+)?)?(?:(!+)([+]?))?$/) ?? [];
4816
4940
  rowspan === '1' ? rowspan = undefined : undefined;
@@ -5027,16 +5151,18 @@ const visibility_1 = __webpack_require__(6364);
5027
5151
  const util_1 = __webpack_require__(4992);
5028
5152
  const dom_1 = __webpack_require__(394);
5029
5153
  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)(({
5030
- source
5031
- }) => [[source], ''])))));
5154
+ context: {
5155
+ source
5156
+ }
5157
+ }) => [[source]])))));
5032
5158
  exports.heading = (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment,
5033
5159
  // その他の表示制御は各所のCSSで行う。
5034
- (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */ | 32 /* State.index */ | 16 /* State.label */ | 8 /* State.link */, (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)(251 /* State.linkers */, (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}`, {
5160
+ (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */ | 32 /* State.index */ | 16 /* State.label */ | 8 /* State.link */, (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)(251 /* State.linkers */, (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], context) => [h.length <= 6 ? (0, dom_1.html)(`h${h.length}`, {
5035
5161
  'data-index': (0, inline_1.dataindex)(ns)
5036
5162
  }, (0, dom_1.defrag)(ns)) : (0, dom_1.html)(`h6`, {
5037
5163
  class: 'invalid',
5038
5164
  ...(0, util_1.invalid)('heading', 'syntax', 'Heading level must be up to 6')
5039
- }, (0, dom_1.defrag)(ns))]))))));
5165
+ }, context.source.slice(context.position - context.range, context.position))]))))));
5040
5166
 
5041
5167
  /***/ },
5042
5168
 
@@ -5064,13 +5190,17 @@ exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combin
5064
5190
  ...(0, util_1.invalid)('list', 'syntax', 'Use "-" instead of "+" or "*"')
5065
5191
  }, es)])));
5066
5192
  exports.ilistitem = (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.contentline, (0, combinator_1.indent)(({
5067
- source
5068
- }) => [[source], ''])]), ({
5069
- source
5193
+ context: {
5194
+ source
5195
+ }
5196
+ }) => [[source]])]), ({
5197
+ context: {
5198
+ source
5199
+ }
5070
5200
  }) => [['', (0, dom_1.html)('span', {
5071
5201
  class: 'invalid',
5072
5202
  ...(0, util_1.invalid)('list', 'syntax', 'Fix the indent or the head of the list item')
5073
- }, source.replace('\n', ''))], '']);
5203
+ }, source.replace('\n', ''))]]);
5074
5204
 
5075
5205
  /***/ },
5076
5206
 
@@ -5092,7 +5222,7 @@ exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('$$', (0, c
5092
5222
  exports.segment_ = (0, combinator_1.block)((0, combinator_1.validate)('$$', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 300, false))), false);
5093
5223
  exports.mathblock = (0, combinator_1.block)((0, combinator_1.validate)('$$', (0, combinator_1.fmap)((0, combinator_1.fence)(opener, 300),
5094
5224
  // Bug: Type mismatch between outer and inner.
5095
- ([body, overflow, closer, opener, delim, param], _, {
5225
+ ([body, overflow, closer, opener, delim, param], {
5096
5226
  caches: {
5097
5227
  math: cache = undefined
5098
5228
  } = {}
@@ -5122,11 +5252,13 @@ const inline_1 = __webpack_require__(7973);
5122
5252
  const util_1 = __webpack_require__(4992);
5123
5253
  const dom_1 = __webpack_require__(394);
5124
5254
  exports.mediablock = (0, combinator_1.block)((0, combinator_1.validate)(['[!', '!'], (0, combinator_1.fmap)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.union)([inline_1.medialink, inline_1.media, inline_1.shortmedia])), (0, combinator_1.some)((0, combinator_1.line)((0, combinator_1.fallback)((0, combinator_1.union)([inline_1.medialink, inline_1.media, inline_1.shortmedia]), ({
5125
- source
5255
+ context: {
5256
+ source
5257
+ }
5126
5258
  }) => [[(0, dom_1.html)('span', {
5127
5259
  class: 'invalid',
5128
5260
  ...(0, util_1.invalid)('mediablock', 'syntax', 'Not media syntax')
5129
- }, source.replace('\n', ''))], ''])))]), ns => [(0, dom_1.html)('div', ns)])));
5261
+ }, source.replace('\n', ''))]])))]), ns => [(0, dom_1.html)('div', ns)])));
5130
5262
 
5131
5263
  /***/ },
5132
5264
 
@@ -5160,11 +5292,15 @@ const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.some)((0, c
5160
5292
  }, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))]))]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
5161
5293
  const heads = {
5162
5294
  '.': (0, combinator_1.focus)(openers['.'], ({
5163
- source
5164
- }) => [[source.trimEnd().split('.', 1)[0] + '.'], '']),
5295
+ context: {
5296
+ source
5297
+ }
5298
+ }) => [[source.trimEnd().split('.', 1)[0] + '.']]),
5165
5299
  '(': (0, combinator_1.focus)(openers['('], ({
5166
- source
5167
- }) => [[source.trimEnd().replace(/^\($/, '(1)').replace(/^\((\w+)$/, '($1)')], ''])
5300
+ context: {
5301
+ source
5302
+ }
5303
+ }) => [[source.trimEnd().replace(/^\($/, '(1)').replace(/^\((\w+)$/, '($1)')]])
5168
5304
  };
5169
5305
  function idx(value) {
5170
5306
  switch (value) {
@@ -5268,7 +5404,7 @@ Object.defineProperty(exports, "__esModule", ({
5268
5404
  exports.pagebreak = void 0;
5269
5405
  const combinator_1 = __webpack_require__(3484);
5270
5406
  const dom_1 = __webpack_require__(394);
5271
- exports.pagebreak = (0, combinator_1.block)((0, combinator_1.line)((0, combinator_1.focus)(/^={3,}[^\S\n]*(?:$|\n)/, () => [[(0, dom_1.html)('hr')], ''])));
5407
+ exports.pagebreak = (0, combinator_1.block)((0, combinator_1.line)((0, combinator_1.focus)(/^={3,}[^\S\n]*(?:$|\n)/, () => [[(0, dom_1.html)('hr')]])));
5272
5408
 
5273
5409
  /***/ },
5274
5410
 
@@ -5334,18 +5470,24 @@ exports.cite = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.va
5334
5470
  // Subject page representation.
5335
5471
  // リンクの実装は後で検討
5336
5472
  (0, combinator_1.focus)(/^>>#\S*(?=\s*$)/, ({
5337
- source
5473
+ context: {
5474
+ source
5475
+ }
5338
5476
  }) => [[(0, dom_1.html)('a', {
5339
5477
  class: 'anchor'
5340
- }, source)], '']), (0, combinator_1.focus)(/^>>https?:\/\/\S+(?=\s*$)/, ({
5341
- source
5478
+ }, source)]]), (0, combinator_1.focus)(/^>>https?:\/\/\S+(?=\s*$)/, ({
5479
+ context: {
5480
+ source
5481
+ }
5342
5482
  }) => [[(0, dom_1.html)('a', {
5343
5483
  class: 'anchor',
5344
5484
  href: source.slice(2).trimEnd(),
5345
5485
  target: '_blank'
5346
- }, source)], '']), (0, combinator_1.focus)(/^>>.+(?=\s*$)/, ({
5347
- source
5348
- }) => [[source], ''])]))), ([quotes, node]) => [(0, dom_1.html)('span', typeof node === 'object' ? {
5486
+ }, source)]]), (0, combinator_1.focus)(/^>>.+(?=\s*$)/, ({
5487
+ context: {
5488
+ source
5489
+ }
5490
+ }) => [[source]])]))), ([quotes, node]) => [(0, dom_1.html)('span', typeof node === 'object' ? {
5349
5491
  class: 'cite'
5350
5492
  } : {
5351
5493
  class: 'cite invalid',
@@ -5425,16 +5567,22 @@ const array_1 = __webpack_require__(6876);
5425
5567
  const dom_1 = __webpack_require__(394);
5426
5568
  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))])])));
5427
5569
  const row = (parser, optional) => (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, ({
5428
- source
5570
+ context: {
5571
+ source
5572
+ }
5429
5573
  }) => [[(0, dom_1.html)('tr', {
5430
5574
  class: 'invalid',
5431
5575
  ...(0, util_1.invalid)('table-row', 'syntax', 'Missing the start symbol of the table row')
5432
- }, [(0, dom_1.html)('td', source.replace('\n', ''))])], '']));
5576
+ }, [(0, dom_1.html)('td', source.replace('\n', ''))])]]));
5433
5577
  const align = (0, combinator_1.fmap)((0, combinator_1.open)('|', (0, combinator_1.union)([(0, combinator_1.focus)(/^:-+:?/, ({
5434
- source
5435
- }) => [[source.at(-1) === ':' ? 'center' : 'start'], ''], false), (0, combinator_1.focus)(/^-+:?/, ({
5436
- source
5437
- }) => [[source.at(-1) === ':' ? 'end' : ''], ''], false)])), ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]);
5578
+ context: {
5579
+ source
5580
+ }
5581
+ }) => [[source.at(-1) === ':' ? 'center' : 'start']], false), (0, combinator_1.focus)(/^-+:?/, ({
5582
+ context: {
5583
+ source
5584
+ }
5585
+ }) => [[source.at(-1) === ':' ? 'end' : '']], false)])), ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]);
5438
5586
  const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, combinator_1.trimStart)((0, combinator_1.union)([(0, combinator_1.close)(inline_1.medialink, /^\s*(?=\||$)/), (0, combinator_1.close)(inline_1.media, /^\s*(?=\||$)/), (0, combinator_1.close)(inline_1.shortmedia, /^\s*(?=\||$)/), (0, visibility_1.trimBlank)((0, combinator_1.some)(inline_1.inline, /^\|/, [[/^[|\\]?\s*$/, 9]]))])), /^[^|]*/, true);
5439
5587
  const head = (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, dom_1.defrag)(ns))]);
5440
5588
  const data = (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]);
@@ -5477,10 +5625,12 @@ exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combin
5477
5625
  'data-index': (0, inline_1.dataindex)(ns)
5478
5626
  }, (0, dom_1.defrag)(fillFirstLine(ns)))]))])))), es => [format((0, dom_1.html)('ul', es))])));
5479
5627
  exports.checkbox = (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, ({
5480
- source
5628
+ context: {
5629
+ source
5630
+ }
5481
5631
  }) => [[(0, dom_1.html)('span', {
5482
5632
  class: 'checkbox'
5483
- }, source[1].trimStart() ? '☑' : '☐')], '']);
5633
+ }, source[1].trimStart() ? '☑' : '☐')]]);
5484
5634
  function fillFirstLine(ns) {
5485
5635
  return ns.length === 1 && typeof ns[0] === 'object' && ['UL', 'OL'].includes(ns[0].tagName) ? (0, array_1.unshift)([(0, dom_1.html)('br')], ns) : ns;
5486
5636
  }
@@ -5511,26 +5661,45 @@ const util_1 = __webpack_require__(4992);
5511
5661
  const normalize_1 = __webpack_require__(4490);
5512
5662
  const dom_1 = __webpack_require__(394);
5513
5663
  exports.header = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/^---+[^\S\v\f\r\n]*\r?\n[^\S\n]*(?=\S)/, (0, combinator_1.inits)([(0, combinator_1.rewrite)(({
5514
- source,
5515
5664
  context
5516
- }) => [[], context.header ?? true ? source.slice((0, segment_1.segment)(source).next().value.length) : ''], (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.validate)(({
5665
+ }) => {
5666
+ const {
5667
+ source
5668
+ } = context;
5669
+ if (context.header ?? true) {
5670
+ context.position += (0, segment_1.segment)(source).next().value.length;
5671
+ } else {
5672
+ context.position = source.length;
5673
+ }
5674
+ return [[]];
5675
+ }, (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.validate)(({
5517
5676
  context
5518
5677
  }) => context.header ?? true, (0, combinator_1.focus)(/^---[^\S\v\f\r\n]*\r?\n(?:[A-Za-z][0-9A-Za-z]*(?:-[A-Za-z][0-9A-Za-z]*)*:[ \t]+\S[^\v\f\r\n]*\r?\n){1,100}---[^\S\v\f\r\n]*(?:$|\r?\n)/, (0, combinator_1.convert)(source => (0, normalize_1.normalize)(source.slice(source.indexOf('\n') + 1, source.trimEnd().lastIndexOf('\n'))).replace(/(\S)\s+$/mg, '$1'), (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([field])), es => [(0, dom_1.html)('aside', {
5519
5678
  class: 'header'
5520
5679
  }, [(0, dom_1.html)('details', {
5521
5680
  open: ''
5522
5681
  }, (0, dom_1.defrag)([(0, dom_1.html)('summary', 'Header'), ...es]))])]), false))), ({
5523
- source
5524
- }) => [[(0, dom_1.html)('pre', {
5525
- class: 'invalid',
5526
- translate: 'no',
5527
- ...(0, util_1.invalid)('header', 'syntax', 'Invalid syntax')
5528
- }, (0, normalize_1.normalize)(source))], '']]))), (0, combinator_1.clear)((0, source_1.str)(/^[^\S\v\f\r\n]*\r?\n/))])));
5682
+ context
5683
+ }) => {
5684
+ const {
5685
+ source,
5686
+ position
5687
+ } = context;
5688
+ context.position += source.length;
5689
+ return [[(0, dom_1.html)('pre', {
5690
+ class: 'invalid',
5691
+ translate: 'no',
5692
+ ...(0, util_1.invalid)('header', 'syntax', 'Invalid syntax')
5693
+ }, (0, normalize_1.normalize)(source.slice(position)))]];
5694
+ }]))), (0, combinator_1.clear)((0, source_1.str)(/^[^\S\v\f\r\n]*\r?\n/))])));
5529
5695
  const field = (0, combinator_1.line)(({
5530
- source
5696
+ context: {
5697
+ source,
5698
+ position
5699
+ }
5531
5700
  }) => {
5532
- const name = source.slice(0, source.indexOf(':'));
5533
- const value = source.slice(name.length + 1).trim();
5701
+ const name = source.slice(position, source.indexOf(':', position));
5702
+ const value = source.slice(position + name.length + 1).trim();
5534
5703
  return [[(0, dom_1.html)('span', {
5535
5704
  class: 'field',
5536
5705
  'data-name': name.toLowerCase(),
@@ -5539,7 +5708,7 @@ const field = (0, combinator_1.line)(({
5539
5708
  class: 'field-name'
5540
5709
  }, name), ': ', (0, dom_1.html)('span', {
5541
5710
  class: 'field-value'
5542
- }, value), '\n'])], ''];
5711
+ }, value), '\n'])]];
5543
5712
  });
5544
5713
 
5545
5714
  /***/ },
@@ -5576,12 +5745,16 @@ const htmlentity_1 = __webpack_require__(470);
5576
5745
  const bracket_1 = __webpack_require__(4526);
5577
5746
  const autolink_1 = __webpack_require__(8072);
5578
5747
  const source_1 = __webpack_require__(8745);
5748
+ const stars = (0, source_1.strs)('*');
5579
5749
  exports.inline = (0, combinator_1.lazy)(() => (0, combinator_1.union)([input => {
5580
5750
  const {
5581
- source
5751
+ context: {
5752
+ source,
5753
+ position
5754
+ }
5582
5755
  } = input;
5583
- if (source === '') return;
5584
- switch (source.slice(0, 2)) {
5756
+ if (position === source.length) return;
5757
+ switch (source.slice(position, position + 2)) {
5585
5758
  case '((':
5586
5759
  return (0, annotation_1.annotation)(input);
5587
5760
  case '[[':
@@ -5606,8 +5779,10 @@ exports.inline = (0, combinator_1.lazy)(() => (0, combinator_1.union)([input =>
5606
5779
  return (0, mark_1.mark)(input);
5607
5780
  case '//':
5608
5781
  return (0, italic_1.italic)(input);
5782
+ case '**':
5783
+ return (0, emstrong_1.emstrong)(input) || (0, strong_1.strong)(input) || stars(input);
5609
5784
  }
5610
- switch (source[0]) {
5785
+ switch (source[position]) {
5611
5786
  case '[':
5612
5787
  return (0, link_1.textlink)(input) || (0, ruby_1.ruby)(input);
5613
5788
  case '{':
@@ -5619,7 +5794,7 @@ exports.inline = (0, combinator_1.lazy)(() => (0, combinator_1.union)([input =>
5619
5794
  case '`':
5620
5795
  return (0, code_1.code)(input);
5621
5796
  case '*':
5622
- return (0, emstrong_1.emstrong)(input) || (0, strong_1.strong)(input) || (0, emphasis_1.emphasis)(input);
5797
+ return (0, emphasis_1.emphasis)(input) || stars(input);
5623
5798
  case '&':
5624
5799
  return (0, htmlentity_1.htmlentity)(input);
5625
5800
  }
@@ -5683,9 +5858,9 @@ const combinator_1 = __webpack_require__(3484);
5683
5858
  const inline_1 = __webpack_require__(7973);
5684
5859
  const visibility_1 = __webpack_require__(6364);
5685
5860
  const dom_1 = __webpack_require__(394);
5686
- exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, (0, combinator_1.surround)('((', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[')', 1]])))), '))', false, ([, ns], rest, context) => context.linebreak === 0 ? [[(0, dom_1.html)('sup', {
5861
+ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, (0, combinator_1.surround)('((', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[')', 1]])))), '))', false, ([, ns], context) => context.linebreak === 0 ? [[(0, dom_1.html)('sup', {
5687
5862
  class: 'annotation'
5688
- }, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, visibility_1.trimBlankNodeEnd)(ns)))])], rest] : undefined, undefined, [3 | 16 /* Backtrack.doublebracket */, 1 | 8 /* Backtrack.bracket */])));
5863
+ }, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, visibility_1.trimBlankNodeEnd)(ns)))])]] : undefined, undefined, [3 | 16 /* Backtrack.doublebracket */, 1 | 8 /* Backtrack.bracket */])));
5689
5864
 
5690
5865
  /***/ },
5691
5866
 
@@ -5741,8 +5916,10 @@ const dom_1 = __webpack_require__(394);
5741
5916
  exports.account = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.open)('@', (0, combinator_1.tails)([(0, source_1.str)(/^[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){0,61}[0-9a-z])?)*\//i), (0, source_1.str)(/^[a-z][0-9a-z]*(?:[-.][0-9a-z]+)*/i)])), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/@')}` : `/${source}`} }`, link_1.unsafelink, false), ([el]) => [(0, dom_1.define)(el, {
5742
5917
  class: 'account'
5743
5918
  })]))), ({
5744
- source
5745
- }) => [[source], '']])));
5919
+ context: {
5920
+ source
5921
+ }
5922
+ }) => [[source]]])));
5746
5923
 
5747
5924
  /***/ },
5748
5925
 
@@ -5769,8 +5946,10 @@ const dom_1 = __webpack_require__(394);
5769
5946
  exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('>>', (0, combinator_1.focus)(/^>>(?:[a-z][0-9a-z]*(?:-[0-9a-z]+)*\/)?[0-9a-z]+(?:-[0-9a-z]+)*(?![0-9a-z@#:])/i, (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `/@${source.slice(2).replace('/', '/timeline?at=')}` : `?at=${source.slice(2)}`} }`, link_1.unsafelink, false), ([el]) => [(0, dom_1.define)(el, {
5770
5947
  class: 'anchor'
5771
5948
  })]))), ({
5772
- source
5773
- }) => [[source], '']]))));
5949
+ context: {
5950
+ source
5951
+ }
5952
+ }) => [[source]]]))));
5774
5953
 
5775
5954
  /***/ },
5776
5955
 
@@ -5790,14 +5969,14 @@ const hashtag_1 = __webpack_require__(5764);
5790
5969
  const util_1 = __webpack_require__(4992);
5791
5970
  const dom_1 = __webpack_require__(394);
5792
5971
  // https://example/@user?ch=a+b must be a user channel page or a redirect page going there.
5793
- exports.channel = (0, combinator_1.validate)('@', (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.bind)((0, combinator_1.sequence)([account_1.account, (0, combinator_1.some)(hashtag_1.hashtag)]), (es, rest) => {
5972
+ exports.channel = (0, combinator_1.validate)('@', (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.bind)((0, combinator_1.sequence)([account_1.account, (0, combinator_1.some)(hashtag_1.hashtag)]), es => {
5794
5973
  const source = (0, util_1.stringify)(es);
5795
5974
  const el = es[0];
5796
5975
  const url = `${el.getAttribute('href')}?ch=${source.slice(source.indexOf('#') + 1).replace(/#/g, '+')}`;
5797
5976
  return [[(0, dom_1.define)(el, {
5798
5977
  class: 'channel',
5799
5978
  href: url
5800
- }, source)], rest];
5979
+ }, source)]];
5801
5980
  })));
5802
5981
 
5803
5982
  /***/ },
@@ -5817,13 +5996,17 @@ const source_1 = __webpack_require__(8745);
5817
5996
  const dom_1 = __webpack_require__(394);
5818
5997
  // https://html.spec.whatwg.org/multipage/input.html
5819
5998
  exports.email = (0, combinator_1.rewrite)((0, combinator_1.surround)((0, source_1.str)(/^[0-9a-z]/i), (0, combinator_1.verify)((0, source_1.str)(/^(?:[_.+-](?=[0-9a-z])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=[0-9a-z])){0,61}[0-9a-z])?)*(?![0-9a-z])/i), ([source]) => source.length <= 255 - 1), '', false, undefined, undefined, [3 | 0 /* Backtrack.autolink */]), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, ({
5820
- source
5999
+ context: {
6000
+ source
6001
+ }
5821
6002
  }) => [[(0, dom_1.html)('a', {
5822
6003
  class: 'email',
5823
6004
  href: `mailto:${source}`
5824
- }, source)], ''])), ({
5825
- source
5826
- }) => [[source], '']]));
6005
+ }, source)]])), ({
6006
+ context: {
6007
+ source
6008
+ }
6009
+ }) => [[source]]]));
5827
6010
 
5828
6011
  /***/ },
5829
6012
 
@@ -5846,8 +6029,10 @@ exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, com
5846
6029
  class: 'hashnum',
5847
6030
  href: null
5848
6031
  })]))), ({
5849
- source
5850
- }) => [[source], '']])));
6032
+ context: {
6033
+ source
6034
+ }
6035
+ }) => [[source]]])));
5851
6036
 
5852
6037
  /***/ },
5853
6038
 
@@ -5871,8 +6056,10 @@ exports.emoji = String.raw`\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_P
5871
6056
  exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.open)('#', (0, source_1.str)(new RegExp([/^(?!['_])(?=(?:[0-9]{1,9})?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^'\p{C}\p{S}\p{P}\s]|emoji)))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^'\p{C}\p{S}\p{P}\s]|emoji))+/u.source].join('').replace(/emoji/g, exports.emoji), 'u')), false, [3 | 0 /* Backtrack.autolink */]), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.fmap)((0, combinator_1.convert)(source => `[${source}]{ ${`/hashtags/${source.slice(1)}`} }`, link_1.unsafelink, false), ([el]) => [(0, dom_1.define)(el, {
5872
6057
  class: 'hashtag'
5873
6058
  })]))), ({
5874
- source
5875
- }) => [[source], '']])));
6059
+ context: {
6060
+ source
6061
+ }
6062
+ }) => [[source]]])));
5876
6063
 
5877
6064
  /***/ },
5878
6065
 
@@ -5892,12 +6079,16 @@ const source_1 = __webpack_require__(8745);
5892
6079
  exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['http://', 'https://'], (0, combinator_1.rewrite)((0, combinator_1.open)(/^https?:\/\/(?=[\x21-\x7E])/, (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.verify)(bracket, ns => ns.length > 0),
5893
6080
  // 再帰に注意
5894
6081
  (0, combinator_1.some)(source_1.unescsource, /^[-+*=~^_/,.;:!?]{2}|^[-+*=~^_,.;:!?]?(?=[\\"`|\[\](){}<>]|[^\x21-\x7E]|$)/)]), undefined, [[/^[^\x21-\x7E]|^\$/, 9]])), false, [3 | 0 /* Backtrack.autolink */]), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink, false))), ({
5895
- source
5896
- }) => [[source], '']]))));
6082
+ context: {
6083
+ source
6084
+ }
6085
+ }) => [[source]]]))));
5897
6086
  exports.lineurl = (0, combinator_1.lazy)(() => (0, combinator_1.open)(source_1.linebreak, (0, combinator_1.focus)(/^!?https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, combinator_1.tails)([(0, source_1.str)('!'), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink, false))), ({
5898
- source
5899
- }) => [[source], '']])])), false, [3 | 0 /* Backtrack.autolink */]));
5900
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [[], ''], [3 | 0 /* Backtrack.autolink */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [[], ''], [3 | 0 /* Backtrack.autolink */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [[], ''], [3 | 0 /* Backtrack.autolink */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.unescsource, '"'))), (0, source_1.str)('"'), true, undefined, () => [[], ''], [3 | 0 /* Backtrack.autolink */])]));
6087
+ context: {
6088
+ source
6089
+ }
6090
+ }) => [[source]]])])), false, [3 | 0 /* Backtrack.autolink */]));
6091
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [[]], [3 | 0 /* Backtrack.autolink */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [[]], [3 | 0 /* Backtrack.autolink */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [[]], [3 | 0 /* Backtrack.autolink */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.unescsource, '"'))), (0, source_1.str)('"'), true, undefined, () => [[]], [3 | 0 /* Backtrack.autolink */])]));
5901
6092
 
5902
6093
  /***/ },
5903
6094
 
@@ -5919,41 +6110,51 @@ const array_1 = __webpack_require__(6876);
5919
6110
  const dom_1 = __webpack_require__(394);
5920
6111
  const indexA = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*$/;
5921
6112
  const indexF = new RegExp(indexA.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => String.fromCodePoint(c.codePointAt(0) + 0xFEE0)));
5922
- exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest, {
5923
- recent = []
5924
- }) => [indexA.test(recent[1]) ? recent : [(0, dom_1.html)('span', {
5925
- class: 'paren'
5926
- }, (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], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest, {
5927
- recent = []
5928
- }) => [indexF.test(recent[1]) ? recent : [(0, dom_1.html)('span', {
5929
- class: 'paren'
5930
- }, (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)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, ([as, bs = [], cs], rest, context) => {
6113
+ exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], {
6114
+ source,
6115
+ position,
6116
+ range = 0
6117
+ }) => {
6118
+ const str = source.slice(position - range + 1, position - 1);
6119
+ return indexA.test(str) ? [[as[0], str, cs[0]]] : [[(0, dom_1.html)('span', {
6120
+ class: 'paren'
6121
+ }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))]];
6122
+ }, ([as, bs = []]) => [(0, array_1.unshift)(as, bs)], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], {
6123
+ source,
6124
+ position,
6125
+ range = 0
6126
+ }) => {
6127
+ const str = source.slice(position - range + 1, position - 1);
6128
+ return indexF.test(str) ? [[as[0], str, cs[0]]] : [[(0, dom_1.html)('span', {
6129
+ class: 'paren'
6130
+ }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))]];
6131
+ }, ([as, bs = []]) => [(0, array_1.unshift)(as, bs)]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, ([as, bs = [], cs], context) => {
5931
6132
  if (context.state & 8 /* State.link */) {
5932
6133
  const {
5933
- recent
6134
+ source,
6135
+ position,
6136
+ range = 0
5934
6137
  } = context;
5935
- const head = recent.reduce((a, b) => a + b.length, rest.length);
5936
- if (context.linebreak > 0 || rest[0] !== '{') {
6138
+ const head = position - range;
6139
+ if (context.linebreak !== 0 || source[position] !== '{') {
5937
6140
  (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head);
5938
6141
  } else {
5939
6142
  context.state ^= 8 /* State.link */;
5940
- const result = !(0, combinator_1.isBacktrack)(context, [1 | 64 /* Backtrack.link */], rest) ? (0, link_1.textlink)({
5941
- source: rest,
6143
+ const result = !(0, combinator_1.isBacktrack)(context, [1 | 64 /* Backtrack.link */]) ? (0, link_1.textlink)({
5942
6144
  context
5943
6145
  }) : undefined;
6146
+ context.position = position;
5944
6147
  if (!result) {
5945
6148
  (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head);
5946
6149
  }
5947
6150
  context.state ^= 8 /* State.link */;
5948
- context.recent = recent;
6151
+ context.range = range;
5949
6152
  }
5950
6153
  }
5951
- return [(0, array_1.push)((0, array_1.unshift)(as, bs), cs), rest];
5952
- }, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]),
6154
+ return [(0, array_1.push)((0, array_1.unshift)(as, bs), cs)];
6155
+ }, ([as, bs = []]) => [(0, array_1.unshift)(as, bs)], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []]) => [(0, array_1.unshift)(as, bs)]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []]) => [(0, array_1.unshift)(as, bs)], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []]) => [(0, array_1.unshift)(as, bs)]),
5953
6156
  // 同一行内でしか閉じない以外括弧と同じ挙動
5954
- (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, '"', [['"', 2, false]]))), (0, source_1.str)('"'), true, ([as, bs = [], cs], rest, {
5955
- linebreak = 0
5956
- }) => linebreak > rest.length ? [(0, array_1.unshift)(as, bs), cs[0] + rest] : [(0, array_1.push)((0, array_1.unshift)(as, bs), cs), rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [2 | 8 /* Backtrack.bracket */])]));
6157
+ (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, '"', [['"', 2, false]]))), (0, source_1.str)('"'), true, ([as, bs = [], cs], context) => context.linebreak === 0 ? [(0, array_1.push)((0, array_1.unshift)(as, bs), cs)] : (context.position -= 1, [(0, array_1.unshift)(as, bs)]), ([as, bs = []]) => [(0, array_1.unshift)(as, bs)], [2 | 8 /* Backtrack.bracket */])]));
5957
6158
 
5958
6159
  /***/ },
5959
6160
 
@@ -5968,18 +6169,16 @@ Object.defineProperty(exports, "__esModule", ({
5968
6169
  }));
5969
6170
  exports.code = void 0;
5970
6171
  const combinator_1 = __webpack_require__(3484);
6172
+ const util_1 = __webpack_require__(4992);
5971
6173
  const dom_1 = __webpack_require__(394);
5972
- exports.code = (0, combinator_1.validate)(({
5973
- source,
5974
- context
5975
- }) => source[0] === '`' && !(0, combinator_1.isBacktrack)(context, [1 | 8 /* Backtrack.bracket */], source), (0, combinator_1.match)(/^(`+)(?!`)([^\n]*?)(?:((?<!`)\1(?!`))|$|\n)/, ([whole,, body, closer]) => ({
5976
- source,
5977
- context
5978
- }) => closer ? [[(0, dom_1.html)('code', {
6174
+ exports.code = (0, combinator_1.open)(/^(?=`)/, (0, combinator_1.match)(/^(`+)(?!`)([^\n]*?)(?:((?<!`)\1(?!`))|(?=$|\n))/, ([whole, opener, body, closer]) => () => closer ? [[(0, dom_1.html)('code', {
5979
6175
  'data-src': whole
5980
- }, format(body))], source.slice(whole.length)] : void (0, combinator_1.setBacktrack)(context, [2 | 8 /* Backtrack.bracket */], source.length), true));
6176
+ }, format(body))]] : body ? [[(0, dom_1.html)('code', {
6177
+ class: 'invalid',
6178
+ ...(0, util_1.invalid)('code', 'syntax', `Missing the closing symbol "${opener}"`)
6179
+ }, whole)]] : [[opener]], true), false, [3 | 8 /* Backtrack.bracket */]);
5981
6180
  function format(text) {
5982
- return `${text[0]}${text.at(-1)}` === ' ' && text.trimStart() ? text.slice(1, -1) : text;
6181
+ return text.length > 2 && text[0] === ' ' && text[1] === '`' && text.at(-1) === ' ' ? text.slice(1, -1) : text;
5983
6182
  }
5984
6183
 
5985
6184
  /***/ },
@@ -6000,7 +6199,11 @@ const visibility_1 = __webpack_require__(6364);
6000
6199
  const util_1 = __webpack_require__(4992);
6001
6200
  const array_1 = __webpack_require__(6876);
6002
6201
  const dom_1 = __webpack_require__(394);
6003
- exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('~~', (0, combinator_1.precedence)(0, (0, util_1.repeat)('~~', (0, combinator_1.surround)('', (0, combinator_1.recursion)(4 /* Recursion.inline */, (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)(exports.deletion, '~'), true)]))), '~~', false, ([, bs], rest) => [bs, rest], ([, bs], rest) => [(0, array_1.push)(bs, ["\u001B" /* Command.Escape */]), rest]), nodes => [(0, dom_1.html)('del', (0, dom_1.defrag)(nodes))]))));
6202
+ exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('~~', (0, combinator_1.precedence)(0, (0, util_1.repeat)('~~', (0, combinator_1.surround)('', (0, combinator_1.recursion)(4 /* Recursion.inline */, (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)(exports.deletion, '~'), true)]))), '~~', false, ([, bs], {
6203
+ buffer
6204
+ }) => [(0, array_1.push)(buffer, bs)], ([, bs], {
6205
+ buffer
6206
+ }) => bs && [(0, array_1.push)((0, array_1.push)(buffer, bs), ["\u0018" /* Command.Cancel */])]), nodes => [(0, dom_1.html)('del', (0, dom_1.defrag)(nodes))]))));
6004
6207
 
6005
6208
  /***/ },
6006
6209
 
@@ -6022,7 +6225,7 @@ const source_1 = __webpack_require__(8745);
6022
6225
  const visibility_1 = __webpack_require__(6364);
6023
6226
  const array_1 = __webpack_require__(6876);
6024
6227
  const dom_1 = __webpack_require__(394);
6025
- exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*', '*'), (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((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]));
6228
+ exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*', '*'), (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((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]) => [[(0, dom_1.html)('em', (0, dom_1.defrag)(bs))]], ([as, bs]) => bs && [(0, array_1.unshift)(as, bs)]));
6026
6229
 
6027
6230
  /***/ },
6028
6231
 
@@ -6043,59 +6246,119 @@ const emphasis_1 = __webpack_require__(1354);
6043
6246
  const source_1 = __webpack_require__(8745);
6044
6247
  const visibility_1 = __webpack_require__(6364);
6045
6248
  const util_1 = __webpack_require__(4992);
6046
- const dom_1 = __webpack_require__(394);
6047
6249
  const array_1 = __webpack_require__(6876);
6048
- 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]))])));
6250
+ const dom_1 = __webpack_require__(394);
6251
+ const substrong = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([emphasis_1.emphasis, (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]))])));
6049
6252
  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]))])));
6050
6253
  // 開閉が明示的でない構文は開閉の不明確な記号による再帰的適用を行わず
6051
6254
  // 可能な限り早く閉じるよう解析しなければならない。
6052
6255
  // このため終端記号の後ろを見て終端を中止し同じ構文を再帰的に適用してはならない。
6053
- exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('***', (0, combinator_1.precedence)(0, (0, util_1.repeat)('***', (0, combinator_1.surround)('', (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((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) => {
6256
+ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('***', (0, combinator_1.precedence)(0, (0, util_1.repeat)('***', (0, combinator_1.surround)('', (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((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, emphasis_1.emphasis]))])))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], context) => {
6257
+ const {
6258
+ buffer
6259
+ } = context;
6054
6260
  switch (cs[0]) {
6055
6261
  case '***':
6056
- return [bs, rest];
6262
+ return [bs];
6057
6263
  case '**':
6058
- return (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' ? [[(0, dom_1.html)('em', (0, array_1.unshift)([(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds))), "\u001F" /* Command.Separator */], rest.slice(1)] : [(0, array_1.push)((0, array_1.unshift)(['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], ds), ["\u001F" /* Command.Separator */]), rest])({
6059
- source: rest,
6264
+ return (0, combinator_1.bind)(subemphasis, ds => {
6265
+ const {
6266
+ source
6267
+ } = context;
6268
+ if (source.startsWith('*', context.position)) {
6269
+ context.position += 1;
6270
+ return [[(0, dom_1.html)('em', (0, array_1.push)((0, array_1.push)(buffer, [(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))]), (0, dom_1.defrag)(ds))), "\u001F" /* Command.Separator */]];
6271
+ } else {
6272
+ return [prepend('*', (0, array_1.push)((0, array_1.push)((0, array_1.push)(buffer, [(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))]), (0, dom_1.defrag)(ds)), ["\u001F" /* Command.Separator */]))];
6273
+ }
6274
+ })({
6060
6275
  context
6061
- }) ?? [['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs)), "\u001F" /* Command.Separator */], rest];
6276
+ }) ?? [prepend('*', (0, array_1.push)((0, array_1.push)(buffer, [(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))]), ["\u001F" /* Command.Separator */]))];
6062
6277
  case '*':
6063
- 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))), "\u001F" /* Command.Separator */], rest.slice(2)] : [(0, array_1.push)((0, array_1.unshift)(['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], ds), ["\u001F" /* Command.Separator */]), rest])({
6064
- source: rest,
6278
+ return (0, combinator_1.bind)(substrong, ds => {
6279
+ const {
6280
+ source
6281
+ } = context;
6282
+ if (source.startsWith('**', context.position)) {
6283
+ context.position += 2;
6284
+ return [[(0, dom_1.html)('strong', (0, array_1.push)((0, array_1.push)(buffer, [(0, dom_1.html)('em', (0, dom_1.defrag)(bs))]), (0, dom_1.defrag)(ds))), "\u001F" /* Command.Separator */]];
6285
+ } else {
6286
+ return [prepend('**', (0, array_1.push)((0, array_1.push)((0, array_1.push)(buffer, [(0, dom_1.html)('em', (0, dom_1.defrag)(bs))]), (0, dom_1.defrag)(ds)), ["\u001F" /* Command.Separator */]))];
6287
+ }
6288
+ })({
6065
6289
  context
6066
- }) ?? [['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs)), "\u001F" /* Command.Separator */], rest];
6290
+ }) ?? [prepend('**', (0, array_1.push)((0, array_1.push)(buffer, [(0, dom_1.html)('em', (0, dom_1.defrag)(bs))]), ["\u001F" /* Command.Separator */]))];
6067
6291
  }
6068
- }, ([as, bs], rest) => [(0, array_1.push)((0, array_1.unshift)(as, bs), ["\u001B" /* Command.Escape */]), rest]),
6292
+ }, ([, bs], {
6293
+ buffer
6294
+ }) => bs && [(0, array_1.push)((0, array_1.push)(buffer, bs), ["\u0018" /* Command.Cancel */])]),
6069
6295
  // 3以上の`*`に対してemの適用を保証する
6070
- nodes => [(0, dom_1.html)('em', [(0, dom_1.html)('strong', (0, dom_1.defrag)(nodes))])], (acc, rest, prefix, postfix, state) => {
6071
- const nodes = [];
6072
- let i = postfix;
6073
- if (state) while (i > 0) {
6074
- switch (i) {
6296
+ nodes => [(0, dom_1.html)('em', [(0, dom_1.html)('strong', (0, dom_1.defrag)(nodes))])], (nodes, context, prefix, postfix, state) => {
6297
+ context.position += postfix;
6298
+ if (state) {
6299
+ switch (postfix) {
6300
+ case 0:
6301
+ break;
6075
6302
  case 1:
6076
- acc = [[(0, dom_1.html)('em', acc.flat())]];
6077
- i -= 1;
6303
+ nodes = [(0, dom_1.html)('em', (0, dom_1.defrag)(nodes))];
6078
6304
  break;
6079
6305
  case 2:
6080
- acc = [[(0, dom_1.html)('strong', acc.flat())]];
6081
- i -= 2;
6306
+ nodes = [(0, dom_1.html)('strong', (0, dom_1.defrag)(nodes))];
6082
6307
  break;
6083
6308
  default:
6084
- acc = [[(0, dom_1.html)('em', [(0, dom_1.html)('strong', acc.flat())])]];
6085
- i -= 3;
6309
+ }
6310
+ prefix -= postfix;
6311
+ postfix -= postfix;
6312
+ switch (prefix) {
6313
+ case 0:
6314
+ break;
6315
+ case 1:
6316
+ nodes = (0, combinator_1.bind)(subemphasis, ds => {
6317
+ const {
6318
+ source
6319
+ } = context;
6320
+ if (source.startsWith('*', context.position)) {
6321
+ context.position += 1;
6322
+ return [[(0, dom_1.html)('em', (0, array_1.push)(nodes, (0, dom_1.defrag)(ds)))]];
6323
+ } else {
6324
+ return [prepend('*', (0, array_1.push)(nodes, (0, dom_1.defrag)(ds)))];
6325
+ }
6326
+ })({
6327
+ context
6328
+ })?.[0] ?? prepend('*', nodes);
6329
+ prefix -= 1;
6330
+ break;
6331
+ case 2:
6332
+ nodes = (0, combinator_1.bind)(substrong, ds => {
6333
+ const {
6334
+ source
6335
+ } = context;
6336
+ if (source.startsWith('**', context.position)) {
6337
+ context.position += 2;
6338
+ return [[(0, dom_1.html)('strong', (0, array_1.push)(nodes, (0, dom_1.defrag)(ds)))]];
6339
+ } else {
6340
+ return [prepend('**', (0, array_1.push)(nodes, (0, dom_1.defrag)(ds)))];
6341
+ }
6342
+ })({
6343
+ context
6344
+ })?.[0] ?? prepend('**', nodes);
6345
+ prefix -= 2;
6346
+ break;
6086
6347
  }
6087
6348
  }
6088
6349
  if (prefix > postfix) {
6089
- nodes.push('*'.repeat(prefix - postfix));
6090
- }
6091
- for (let i = 0; i < acc.length; ++i) {
6092
- nodes.push(...acc[i]);
6093
- }
6094
- if (postfix > 0) {
6095
- rest = rest.slice(postfix);
6350
+ nodes = (0, array_1.push)(['*'.repeat(prefix - postfix)], nodes);
6096
6351
  }
6097
- return [nodes, rest];
6352
+ return [nodes];
6098
6353
  }))));
6354
+ function prepend(prefix, nodes) {
6355
+ if (typeof nodes[0] === 'string') {
6356
+ nodes[0] = prefix + nodes[0];
6357
+ } else {
6358
+ (0, array_1.unshift)([prefix], nodes);
6359
+ }
6360
+ return nodes;
6361
+ }
6099
6362
 
6100
6363
  /***/ },
6101
6364
 
@@ -6127,7 +6390,6 @@ Object.defineProperty(exports, "__esModule", ({
6127
6390
  value: true
6128
6391
  }));
6129
6392
  exports.dataindex = exports.signature = exports.index = void 0;
6130
- const parser_1 = __webpack_require__(605);
6131
6393
  const combinator_1 = __webpack_require__(3484);
6132
6394
  const inline_1 = __webpack_require__(7973);
6133
6395
  const indexee_1 = __webpack_require__(7610);
@@ -6136,16 +6398,9 @@ const source_1 = __webpack_require__(8745);
6136
6398
  const visibility_1 = __webpack_require__(6364);
6137
6399
  const array_1 = __webpack_require__(6876);
6138
6400
  const dom_1 = __webpack_require__(394);
6139
- exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(32 /* State.index */, (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)((0, source_1.str)('[#'), (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.inits)([inline_1.inline, exports.signature]), ']', [[']', 1]])))), (0, source_1.str)(']'), false, ([as, bs, cs], rest, context) => {
6140
- if (context.linebreak === 0 && (0, visibility_1.trimBlankNodeEnd)(bs).length > 0) {
6141
- return [[(0, dom_1.html)('a', {
6142
- 'data-index': dataindex(bs)
6143
- }, (0, dom_1.defrag)(bs))], rest];
6144
- }
6145
- return (context.state & 251 /* State.linkers */) === 251 /* State.linkers */ ? [(0, array_1.push)((0, array_1.push)((0, array_1.unshift)(as, bs), cs), ['']), rest] : undefined;
6146
- }, ([as, bs], rest, context) => {
6147
- return (context.state & 251 /* State.linkers */) === 251 /* State.linkers */ ? [(0, array_1.push)((0, array_1.unshift)(as, bs), ['']), rest] : undefined;
6148
- }, [3 | 8 /* Backtrack.bracket */])), ns => {
6401
+ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(32 /* State.index */, (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)((0, source_1.str)('[#'), (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.inits)([inline_1.inline, exports.signature]), ']', [[']', 1]])))), (0, source_1.str)(']'), false, ([, bs], context) => context.linebreak === 0 && (0, visibility_1.trimBlankNodeEnd)(bs).length > 0 ? [[(0, dom_1.html)('a', {
6402
+ 'data-index': dataindex(bs)
6403
+ }, (0, dom_1.defrag)(bs))]] : undefined, undefined, [3 | 8 /* Backtrack.bracket */])), ns => {
6149
6404
  if (ns.length === 1) {
6150
6405
  const el = ns[0];
6151
6406
  return [(0, dom_1.define)(el, {
@@ -6158,20 +6413,13 @@ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(32 /*
6158
6413
  return ns;
6159
6414
  }
6160
6415
  })));
6161
- exports.signature = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('|', (0, combinator_1.surround)((0, source_1.str)(/^\|(?!\\?\s)/), (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]])), /^(?=])/, false, (_, rest, context) => {
6162
- //context.offset ??= 0;
6163
- //context.offset += rest.length;
6164
- const text = (0, parser_1.eval)(sig({
6165
- source: context.recent[1],
6166
- context
6167
- }), []).join('');
6168
- //context.offset -= rest.length;
6169
- const index = (0, indexee_1.identity)('index', undefined, text)?.slice(7);
6416
+ exports.signature = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('|', (0, combinator_1.surround)((0, source_1.str)(/^\|(?!\\?\s)/), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, (0, combinator_1.focus)(/^(?:[^\\[\](){}<>"$`\n]|\\[^\n]?)/, source_1.txt, false)]), ']'), /^(?=])/, false, ([, ns]) => {
6417
+ const index = (0, indexee_1.identity)('index', undefined, ns.join(''))?.slice(7);
6170
6418
  return index ? [[(0, dom_1.html)('span', {
6171
6419
  class: 'indexer',
6172
6420
  'data-index': index
6173
- })], rest] : undefined;
6174
- }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
6421
+ })]] : undefined;
6422
+ }, ([as, bs]) => bs && [(0, array_1.unshift)(as, bs)])));
6175
6423
  function dataindex(ns) {
6176
6424
  if (ns.length === 0) return;
6177
6425
  for (let i = ns.length; i--;) {
@@ -6183,7 +6431,6 @@ function dataindex(ns) {
6183
6431
  }
6184
6432
  }
6185
6433
  exports.dataindex = dataindex;
6186
- const sig = (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]));
6187
6434
 
6188
6435
  /***/ },
6189
6436
 
@@ -6200,7 +6447,7 @@ exports.text = exports.signature = exports.identity = exports.indexee = void 0;
6200
6447
  const combinator_1 = __webpack_require__(3484);
6201
6448
  const dom_1 = __webpack_require__(394);
6202
6449
  function indexee(parser) {
6203
- return (0, combinator_1.fmap)(parser, (ns, _, {
6450
+ return (0, combinator_1.fmap)(parser, (ns, {
6204
6451
  id
6205
6452
  }) => ns.length === 1 ? [(0, dom_1.define)(ns[0], {
6206
6453
  id: identity('index', id, ns[0]),
@@ -6345,7 +6592,7 @@ const dom_1 = __webpack_require__(394);
6345
6592
  exports.indexer = (0, combinator_1.surround)(/^\s+\[(?=\|\S)/, (0, combinator_1.union)([index_1.signature, (0, combinator_1.focus)(/^\|(?=\])/, () => [[(0, dom_1.html)('span', {
6346
6593
  class: 'indexer',
6347
6594
  'data-index': ''
6348
- })], ''])]), /^\]\s*$/);
6595
+ })]])]), /^\]\s*$/);
6349
6596
 
6350
6597
  /***/ },
6351
6598
 
@@ -6407,10 +6654,12 @@ const array_1 = __webpack_require__(6876);
6407
6654
  const dom_1 = __webpack_require__(394);
6408
6655
  // Don't use the symbols already used: !#$%@&*+~=|
6409
6656
  // All syntax surrounded by square brackets shouldn't contain line breaks.
6410
- exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]])))), (0, source_1.str)(']'), false, ([, bs], rest) => [[(0, dom_1.html)('span', {
6657
+ exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.surround)(
6658
+ // ^はabbrで使用済みだが^:などのようにして分離使用可能
6659
+ (0, source_1.str)(/^\[[:^|]/), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]])))), (0, source_1.str)(']'), false, (_, context) => [[(0, dom_1.html)('span', {
6411
6660
  class: 'invalid',
6412
6661
  ...(0, util_1.invalid)('extension', 'syntax', `Invalid start symbol or linebreak`)
6413
- }, (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest], [3 | 8 /* Backtrack.bracket */]));
6662
+ }, context.source.slice(context.position - context.range, context.position))]], ([as, bs]) => bs && [(0, array_1.unshift)(as, bs)], [3 | 8 /* Backtrack.bracket */]));
6414
6663
 
6415
6664
  /***/ },
6416
6665
 
@@ -6443,27 +6692,27 @@ Object.setPrototypeOf(attrspecs, null);
6443
6692
  Object.values(attrspecs).forEach(o => Object.setPrototypeOf(o, null));
6444
6693
  exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/i, (0, combinator_1.union)([(0, combinator_1.surround)(
6445
6694
  // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
6446
- (0, source_1.str)(/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/i), (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), (0, combinator_1.open)((0, source_1.str)(/^[^\S\n]*/), (0, source_1.str)('>'), true), true, ([as, bs = [], cs], rest) => [[elem(as[0].slice(1), false, (0, array_1.push)((0, array_1.unshift)(as, bs), cs), [], [])], rest], ([as, bs = []], rest) => [[elem(as[0].slice(1), false, (0, array_1.unshift)(as, bs), [], [])], rest]), (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, combinator_1.open)((0, source_1.str)(/^[^\S\n]*/), (0, source_1.str)('>'), true), true, ([as, bs = [], cs], rest) => [(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.precedence)(3, (0, combinator_1.recursion)(4 /* Recursion.inline */, (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}>`), 3]]), true))]))), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], rest) => [[elem(tag, true, as, bs, cs)], rest], ([as, bs = []], rest) => [[elem(tag, true, as, bs, [])], rest]), ([, tag]) => tag, new Map())), (0, combinator_1.surround)(
6695
+ (0, source_1.str)(/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/i), (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), (0, combinator_1.open)((0, source_1.str)(/^[^\S\n]*/), (0, source_1.str)('>'), true), true, ([as, bs = [], cs], context) => [[elem(as[0].slice(1), false, (0, array_1.push)((0, array_1.unshift)(as, bs), cs), [], [], context)]], ([as, bs = []], context) => [[elem(as[0].slice(1), false, (0, array_1.unshift)(as, bs), [], [], context)]]), (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, combinator_1.open)((0, source_1.str)(/^[^\S\n]*/), (0, source_1.str)('>'), true), true, ([as, bs = [], cs]) => [(0, array_1.push)((0, array_1.unshift)(as, bs), cs)], ([as, bs = []]) => [(0, array_1.unshift)(as, bs)]), (0, combinator_1.precedence)(3, (0, combinator_1.recursion)(4 /* Recursion.inline */, (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}>`), 3]]), true))]))), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], context) => [[elem(tag, true, as, bs, cs, context)]], ([as, bs = []], context) => [[elem(tag, true, as, bs, [], context)]]), ([, tag]) => tag, new Map())), (0, combinator_1.surround)(
6447
6696
  // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
6448
- (0, source_1.str)(/^<[a-z]{1,16}(?=[^\S\n]|>)/i), (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), (0, combinator_1.open)((0, source_1.str)(/^[^\S\n]*/), (0, source_1.str)('>'), true), true, ([as, bs = [], cs], rest) => [[elem(as[0].slice(1), false, (0, array_1.push)((0, array_1.unshift)(as, bs), cs), [], [])], rest], ([as, bs = []], rest) => [[elem(as[0].slice(1), false, (0, array_1.unshift)(as, bs), [], [])], rest])])));
6697
+ (0, source_1.str)(/^<[a-z]{1,16}(?=[^\S\n]|>)/i), (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), (0, combinator_1.open)((0, source_1.str)(/^[^\S\n]*/), (0, source_1.str)('>'), true), true, ([as, bs = [], cs], context) => [[elem(as[0].slice(1), false, (0, array_1.push)((0, array_1.unshift)(as, bs), cs), [], [], context)]], ([as, bs = []], context) => [[elem(as[0].slice(1), false, (0, array_1.unshift)(as, bs), [], [], context)]])])));
6449
6698
  exports.attribute = (0, combinator_1.union)([(0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/i), (0, source_1.str)(/^[^\S\n]+[^\s<>]+/)]);
6450
- function elem(tag, content, as, bs, cs) {
6451
- if (!tags.includes(tag)) return ielem('tag', `Invalid HTML tag name "${tag}"`, as, bs, cs);
6699
+ function elem(tag, content, as, bs, cs, context) {
6700
+ if (!tags.includes(tag)) return ielem('tag', `Invalid HTML tag name "${tag}"`, context);
6452
6701
  if (content) {
6453
- if (cs.length === 0) return ielem('tag', `Missing the closing HTML tag "</${tag}>"`, as, bs, cs);
6454
- if (bs.length === 0) return ielem('content', `Missing the content`, as, bs, cs);
6455
- if (!(0, visibility_1.isLooseNodeStart)(bs)) return ielem('content', `Missing the visible content in the same line`, as, bs, cs);
6702
+ if (cs.length === 0) return ielem('tag', `Missing the closing HTML tag "</${tag}>"`, context);
6703
+ if (bs.length === 0) return ielem('content', `Missing the content`, context);
6704
+ if (!(0, visibility_1.isLooseNodeStart)(bs)) return ielem('content', `Missing the visible content in the same line`, context);
6456
6705
  }
6457
6706
  const attrs = attributes('html', attrspecs[tag], as.slice(1, as.at(-1) === '>' ? -2 : as.length));
6458
- if (/(?<!\S)invalid(?!\S)/.test(attrs['class'] ?? '')) return ielem('attribute', 'Invalid HTML attribute', as, bs, cs);
6459
- if (as.at(-1) !== '>') return ielem('tag', `Missing the closing bracket ">"`, as, bs, cs);
6707
+ if (/(?<!\S)invalid(?!\S)/.test(attrs['class'] ?? '')) return ielem('attribute', 'Invalid HTML attribute', context);
6708
+ if (as.at(-1) !== '>') return ielem('tag', `Missing the closing symbol ">"`, context);
6460
6709
  return (0, dom_1.html)(tag, attrs, (0, dom_1.defrag)(bs));
6461
6710
  }
6462
- function ielem(type, message, as, bs, cs) {
6711
+ function ielem(type, message, context) {
6463
6712
  return (0, dom_1.html)('span', {
6464
6713
  class: 'invalid',
6465
6714
  ...(0, util_1.invalid)('html', type, message)
6466
- }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)));
6715
+ }, context.source.slice(context.position - context.range, context.position));
6467
6716
  }
6468
6717
  const requiredAttributes = (0, memoize_1.memoize)(spec => Object.entries(spec).flatMap(([k, v]) => v && Object.isFrozen(v) ? [k] : []), new WeakMap());
6469
6718
  function attributes(syntax, spec, params) {
@@ -6505,12 +6754,18 @@ exports.htmlentity = exports.unsafehtmlentity = void 0;
6505
6754
  const combinator_1 = __webpack_require__(3484);
6506
6755
  const util_1 = __webpack_require__(4992);
6507
6756
  const dom_1 = __webpack_require__(394);
6508
- exports.unsafehtmlentity = (0, combinator_1.validate)('&', (0, combinator_1.focus)(/^&[0-9A-Za-z]{1,99};/,
6757
+ exports.unsafehtmlentity = (0, combinator_1.validate)('&', (0, combinator_1.focus)(/^&(?:[0-9A-Za-z]+;?)?/,
6509
6758
  //({ source }) => [[parser(source) ?? `${Command.Error}${source}`], '']));
6510
6759
  ({
6511
- source
6512
- }) => [[parser(source) ?? source], '']));
6513
- exports.htmlentity = (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([text]) => [text.length === 1 || text[0] !== '&' ? text : (0, dom_1.html)('span', {
6760
+ context
6761
+ }) => {
6762
+ const {
6763
+ source
6764
+ } = context;
6765
+ context.position += source.length;
6766
+ return source.length > 1 && source.at(-1) === ';' ? [[parser(source) ?? source]] : [[source]];
6767
+ }));
6768
+ exports.htmlentity = (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([text]) => [length === 1 || text.at(-1) !== ';' ? text : (0, dom_1.html)('span', {
6514
6769
  class: 'invalid',
6515
6770
  ...(0, util_1.invalid)('htmlentity', 'syntax', 'Invalid HTML entity')
6516
6771
  }, text)]);
@@ -6539,7 +6794,11 @@ const visibility_1 = __webpack_require__(6364);
6539
6794
  const util_1 = __webpack_require__(4992);
6540
6795
  const array_1 = __webpack_require__(6876);
6541
6796
  const dom_1 = __webpack_require__(394);
6542
- exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('++', (0, combinator_1.precedence)(0, (0, util_1.repeat)('++', (0, combinator_1.surround)('', (0, combinator_1.recursion)(4 /* Recursion.inline */, (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)(exports.insertion, '+'), true)]))), '++', false, ([, bs], rest) => [bs, rest], ([, bs], rest) => [(0, array_1.push)(bs, ["\u001B" /* Command.Escape */]), rest]), nodes => [(0, dom_1.html)('ins', (0, dom_1.defrag)(nodes))]))));
6797
+ exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('++', (0, combinator_1.precedence)(0, (0, util_1.repeat)('++', (0, combinator_1.surround)('', (0, combinator_1.recursion)(4 /* Recursion.inline */, (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)(exports.insertion, '+'), true)]))), '++', false, ([, bs], {
6798
+ buffer
6799
+ }) => [(0, array_1.push)(buffer, bs)], ([, bs], {
6800
+ buffer
6801
+ }) => bs && [(0, array_1.push)((0, array_1.push)(buffer, bs), ["\u0018" /* Command.Cancel */])]), nodes => [(0, dom_1.html)('ins', (0, dom_1.defrag)(nodes))]))));
6543
6802
 
6544
6803
  /***/ },
6545
6804
 
@@ -6562,7 +6821,11 @@ const dom_1 = __webpack_require__(394);
6562
6821
  // 可読性のため実際にはオブリーク体を指定する。
6563
6822
  // 斜体は単語に使うとかえって見づらく読み飛ばしやすくなるため使わないべきであり
6564
6823
  // ある程度の長さのある文に使うのが望ましい。
6565
- exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('///', (0, combinator_1.precedence)(0, (0, util_1.repeat)('///', (0, combinator_1.surround)('', (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((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.italic)])))), '///', false, ([, bs], rest) => [bs, rest], ([, bs], rest) => [(0, array_1.push)(bs, ["\u001B" /* Command.Escape */]), rest]), nodes => [(0, dom_1.html)('i', (0, dom_1.defrag)(nodes))]))));
6824
+ exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('///', (0, combinator_1.precedence)(0, (0, util_1.repeat)('///', (0, combinator_1.surround)('', (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((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.italic)])))), '///', false, ([, bs], {
6825
+ buffer
6826
+ }) => [(0, array_1.push)(buffer, bs)], ([, bs], {
6827
+ buffer
6828
+ }) => bs && [(0, array_1.push)((0, array_1.push)(buffer, bs), ["\u0018" /* Command.Cancel */])]), nodes => [(0, dom_1.html)('i', (0, dom_1.defrag)(nodes))]))));
6566
6829
 
6567
6830
  /***/ },
6568
6831
 
@@ -6589,26 +6852,38 @@ const optspec = {
6589
6852
  rel: ['nofollow']
6590
6853
  };
6591
6854
  Object.setPrototypeOf(optspec, null);
6592
- exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8 /* State.link */, (0, combinator_1.creation)(10, (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.subsequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]])), ']', true, ([, ns = []], rest, context) => context.linebreak === 0 ? [(0, array_1.push)(ns, ["\u001B" /* Command.Escape */]), rest] : undefined, undefined, [3 | 64 /* Backtrack.link */, 2 | 32 /* Backtrack.ruby */, 3 | 8 /* Backtrack.bracket */])),
6855
+ exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8 /* State.link */, (0, combinator_1.creation)(10, (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.subsequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]])), ']', true, ([, ns = []], context) => context.linebreak === 0 ? [(0, array_1.push)(ns, ["\u001F" /* Command.Separator */])] : undefined, undefined, [3 | 64 /* Backtrack.link */, 2 | 32 /* Backtrack.ruby */, 3 | 8 /* Backtrack.bracket */])),
6593
6856
  // `{ `と`{`で個別にバックトラックが発生し+1nされる。
6594
6857
  // 自己再帰的にパースしてもオプションの不要なパースによる計算量の増加により相殺される。
6595
- (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/, false, undefined, undefined, [3 | 64 /* Backtrack.link */]))]), ([content, params], rest, context) => {
6596
- if (content.at(-1) === "\u001B" /* Command.Escape */) {
6858
+ (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/, false, undefined, ([as, bs], context) => {
6859
+ if (!bs) return;
6860
+ const head = context.position - context.range;
6861
+ (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head);
6862
+ return [(0, array_1.push)((0, array_1.unshift)(as, bs), ["\u0018" /* Command.Cancel */])];
6863
+ }, [3 | 64 /* Backtrack.link */]))]), ([content, params], context) => {
6864
+ if (content.at(-1) === "\u001F" /* Command.Separator */) {
6597
6865
  content.pop();
6598
6866
  if (params === undefined) {
6599
- const head = context.recent.reduce((a, b) => a + b.length, rest.length);
6867
+ const head = context.position - context.range;
6600
6868
  return void (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head);
6601
6869
  }
6602
6870
  } else {
6603
6871
  params = content;
6604
6872
  content = [];
6605
6873
  }
6874
+ if (params.at(-1) === "\u0018" /* Command.Cancel */) {
6875
+ params.pop();
6876
+ return [[(0, dom_1.html)('span', {
6877
+ class: 'invalid',
6878
+ ...(0, util_1.invalid)('link', 'syntax', 'Missing the closing symbol "}"')
6879
+ }, context.source.slice(context.position - context.range, context.position))]];
6880
+ }
6606
6881
  if (content.length !== 0 && (0, visibility_1.trimBlankNodeEnd)(content).length === 0) return;
6607
- return [[parse((0, dom_1.defrag)(content), params, context)], rest];
6882
+ return [[parse((0, dom_1.defrag)(content), params, context)]];
6608
6883
  }))))));
6609
- exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8 /* State.link */ | 4 /* State.media */, (0, combinator_1.validate)(['[', '{'], (0, combinator_1.creation)(10, (0, combinator_1.state)(251 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (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) => [[parse((0, dom_1.defrag)(content), params, context)], rest]))))));
6884
+ exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8 /* State.link */ | 4 /* State.media */, (0, combinator_1.validate)(['[', '{'], (0, combinator_1.creation)(10, (0, combinator_1.state)(251 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], context) => [[parse((0, dom_1.defrag)(content), params, context)]]))))));
6610
6885
  exports.linemedialink = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.medialink]), /^(?=[^\S\n]*(?:$|\n))/);
6611
- exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(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) => [[parse((0, dom_1.defrag)(content), params, context)], rest])));
6886
+ exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(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 = []], context) => [[parse((0, dom_1.defrag)(content), params, context)]])));
6612
6887
  exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)), (0, source_1.str)(/^[^\s{}]+/)]);
6613
6888
  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]|})/i), (0, source_1.str)(/^[^\S\n]+[^\s{}]+/)]);
6614
6889
  function parse(content, params, context) {
@@ -6719,14 +6994,18 @@ const visibility_1 = __webpack_require__(6364);
6719
6994
  const util_1 = __webpack_require__(4992);
6720
6995
  const array_1 = __webpack_require__(6876);
6721
6996
  const dom_1 = __webpack_require__(394);
6722
- exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(251 /* State.linkers */ & ~2 /* State.mark */, (0, combinator_1.validate)('==', (0, combinator_1.precedence)(0, (0, combinator_1.state)(2 /* State.mark */, (0, util_1.repeat)('==', (0, combinator_1.surround)('', (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((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)])))), '==', false, ([, bs], rest) => [bs, rest], ([, bs], rest) => [(0, array_1.push)(bs, ["\u001B" /* Command.Escape */]), rest]), (nodes, {
6997
+ exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(251 /* State.linkers */ & ~2 /* State.mark */, (0, combinator_1.validate)('==', (0, combinator_1.precedence)(0, (0, combinator_1.state)(2 /* State.mark */, (0, util_1.repeat)('==', (0, combinator_1.surround)('', (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((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)])))), '==', false, ([, bs], {
6998
+ buffer
6999
+ }) => [(0, array_1.push)(buffer, bs)], ([, bs], {
7000
+ buffer
7001
+ }) => bs && [(0, array_1.push)((0, array_1.push)(buffer, bs), ["\u0018" /* Command.Cancel */])]), (nodes, {
6723
7002
  id
6724
7003
  }) => {
6725
7004
  const el = (0, dom_1.html)('mark', (0, dom_1.defrag)(nodes));
6726
7005
  (0, dom_1.define)(el, {
6727
7006
  id: (0, indexee_1.identity)('mark', id, (0, indexee_1.signature)(el))
6728
7007
  });
6729
- return el.id ? [el, el.id && (0, dom_1.html)('a', {
7008
+ return el.id ? [el, (0, dom_1.html)('a', {
6730
7009
  href: `#${el.id}`
6731
7010
  })] : [el];
6732
7011
  }))))));
@@ -6749,8 +7028,8 @@ const util_1 = __webpack_require__(4992);
6749
7028
  const dom_1 = __webpack_require__(394);
6750
7029
  const forbiddenCommand = /\\(?:begin|tiny|huge|large)(?![a-z])/i;
6751
7030
  exports.math = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('$', (0, combinator_1.rewrite)((0, combinator_1.union)([(0, combinator_1.surround)(/^\$(?={)/, (0, combinator_1.precedence)(5, bracket), '$', false, undefined, undefined, [3 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)(/^\$(?![\s{}])/, (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.precedence)(5, bracket), (0, combinator_1.some)((0, combinator_1.focus)(/^(?:[ ([](?!\$)|\\[\\{}$#]?|[!%&')\x2A-\x5A\]^_\x61-\x7A|~])/, source_1.escsource, false), '://')]))), /^\$(?![0-9A-Za-z])/, false, undefined, undefined, [3 | 8 /* Backtrack.bracket */])]), ({
6752
- source,
6753
7031
  context: {
7032
+ source,
6754
7033
  caches: {
6755
7034
  math: cache
6756
7035
  } = {}
@@ -6763,7 +7042,7 @@ exports.math = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('$', (0,
6763
7042
  class: 'invalid',
6764
7043
  translate: 'no',
6765
7044
  ...(0, util_1.invalid)('math', 'content', `"${source.match(forbiddenCommand)[0]}" command is forbidden`)
6766
- }, source)], ''])));
7045
+ }, source)]])));
6767
7046
  const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, (0, combinator_1.some)(source_1.escsource, /^[{}$#\n]/)]))), (0, source_1.str)('}'), true));
6768
7047
 
6769
7048
  /***/ },
@@ -6778,6 +7057,7 @@ Object.defineProperty(exports, "__esModule", ({
6778
7057
  value: true
6779
7058
  }));
6780
7059
  exports.linemedia = exports.media = void 0;
7060
+ const parser_1 = __webpack_require__(605);
6781
7061
  const combinator_1 = __webpack_require__(3484);
6782
7062
  const link_1 = __webpack_require__(3628);
6783
7063
  const html_1 = __webpack_require__(5013);
@@ -6785,6 +7065,7 @@ const htmlentity_1 = __webpack_require__(470);
6785
7065
  const source_1 = __webpack_require__(8745);
6786
7066
  const util_1 = __webpack_require__(4992);
6787
7067
  const url_1 = __webpack_require__(1904);
7068
+ const array_1 = __webpack_require__(6876);
6788
7069
  const dom_1 = __webpack_require__(394);
6789
7070
  const optspec = {
6790
7071
  'width': [],
@@ -6793,7 +7074,19 @@ const optspec = {
6793
7074
  rel: undefined
6794
7075
  };
6795
7076
  Object.setPrototypeOf(optspec, null);
6796
- exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* State.media */, (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']')), ']', true, ([, ns = []], rest, context) => context.linebreak === 0 ? [ns, rest] : undefined, undefined, [3 | 4 /* Backtrack.escbracket */])), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/, false, undefined, undefined, [3 | 64 /* Backtrack.link */]))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
7077
+ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* State.media */, (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']')), ']', true, ([, ns = []], context) => context.linebreak === 0 ? [ns] : undefined, undefined, [3 | 4 /* Backtrack.escbracket */])), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/, false, undefined, ([as, bs], context) => {
7078
+ if (!bs) return;
7079
+ const head = context.position - context.range;
7080
+ (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head);
7081
+ return [(0, array_1.push)((0, array_1.unshift)(as, bs), ["\u0018" /* Command.Cancel */])];
7082
+ }, [3 | 64 /* Backtrack.link */]))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], context) => {
7083
+ if (params.at(-1) === "\u0018" /* Command.Cancel */) {
7084
+ params.pop();
7085
+ return [[(0, dom_1.html)('span', {
7086
+ class: 'invalid',
7087
+ ...(0, util_1.invalid)('media', 'syntax', 'Missing the closing symbol "}"')
7088
+ }, '!' + context.source.slice(context.position - context.range, context.position))]];
7089
+ }
6797
7090
  const INSECURE_URI = params.shift();
6798
7091
  // altが空だとエラーが見えないため埋める。
6799
7092
  text ||= (0, link_1.decode)(INSECURE_URI);
@@ -6807,25 +7100,30 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* S
6807
7100
  'data-src': uri?.source
6808
7101
  });
6809
7102
  el.setAttribute('alt', text);
6810
- if (!sanitize(el, uri)) return [[el], rest];
7103
+ if (!sanitize(el, uri)) return [[el]];
6811
7104
  (0, dom_1.define)(el, (0, html_1.attributes)('media', optspec, params));
6812
7105
  // Awaiting the generic support for attr().
6813
7106
  if (el.hasAttribute('aspect-ratio')) {
6814
7107
  el.style.aspectRatio = el.getAttribute('aspect-ratio');
6815
7108
  }
6816
- if (context.state & 8 /* State.link */) return [[el], rest];
6817
- if (cache && cache.tagName !== 'IMG') return [[el], rest];
6818
- return (0, combinator_1.fmap)(link_1.unsafelink, ([link]) => [(0, dom_1.define)(link, {
6819
- class: null,
6820
- target: '_blank'
6821
- }, [el])])({
6822
- source: `{ ${INSECURE_URI}${params.join('')} }${rest}`,
6823
- context
6824
- });
7109
+ if (context.state & 8 /* State.link */) return [[el]];
7110
+ if (cache && cache.tagName !== 'IMG') return [[el]];
7111
+ const {
7112
+ source,
7113
+ position
7114
+ } = context;
7115
+ return (0, combinator_1.fmap)(link_1.unsafelink, ([link]) => {
7116
+ context.source = source;
7117
+ context.position = position;
7118
+ return [(0, dom_1.define)(link, {
7119
+ class: null,
7120
+ target: '_blank'
7121
+ }, [el])];
7122
+ })((0, parser_1.subinput)(`{ ${INSECURE_URI}${params.join('')} }`, context));
6825
7123
  }))))));
6826
7124
  exports.linemedia = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.media]), /^(?=[^\S\n]*(?:$|\n))/);
6827
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.recursion)(6 /* Recursion.terminal */, (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, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (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, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (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, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */])])));
6828
- const option = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^[1-9][0-9]*/)), (0, source_1.str)(/^[x:]/), (0, source_1.str)(/^[1-9][0-9]*(?=[^\S\n]|})/), false, ([[a], [b], [c]], rest) => [b === 'x' ? [`width="${a}"`, `height="${c}"`] : [`aspect-ratio="${a}/${c}"`], rest]), link_1.option]));
7125
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.recursion)(6 /* Recursion.terminal */, (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, undefined, () => [[]], [3 | 4 /* Backtrack.escbracket */]), (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, undefined, () => [[]], [3 | 4 /* Backtrack.escbracket */]), (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, undefined, () => [[]], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true, undefined, () => [[]], [3 | 4 /* Backtrack.escbracket */])])));
7126
+ const option = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^[1-9][0-9]*/)), (0, source_1.str)(/^[x:]/), (0, source_1.str)(/^[1-9][0-9]*(?=[^\S\n]|})/), false, ([[a], [b], [c]]) => [b === 'x' ? [`width="${a}"`, `height="${c}"`] : [`aspect-ratio="${a}/${c}"`]]), link_1.option]));
6829
7127
  function sanitize(target, uri) {
6830
7128
  let type;
6831
7129
  let message;
@@ -6878,62 +7176,82 @@ const visibility_1 = __webpack_require__(6364);
6878
7176
  const dom_1 = __webpack_require__(394);
6879
7177
  const array_1 = __webpack_require__(6876);
6880
7178
  const util_1 = __webpack_require__(4992);
6881
- exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64 /* State.reference */, (0, combinator_1.surround)((0, source_1.str)('[['), (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))]))), ']]', false, ([, ns], rest, context) => {
6882
- if (context.linebreak === 0) {
6883
- return [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, dom_1.defrag)((0, visibility_1.trimBlankNodeEnd)(ns)))])], rest];
7179
+ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64 /* State.reference */, (0, combinator_1.surround)((0, source_1.str)('[['), (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))]))), ']]', false, ([, ns], context) => {
7180
+ const {
7181
+ position,
7182
+ range = 0,
7183
+ linebreak = 0
7184
+ } = context;
7185
+ if (linebreak === 0) {
7186
+ return [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, dom_1.defrag)((0, visibility_1.trimBlankNodeEnd)(ns)))])]];
6884
7187
  } else {
6885
- const head = context.recent.reduce((a, b) => a + b.length, rest.length);
7188
+ const head = position - range;
6886
7189
  (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head, 2);
6887
7190
  }
6888
- }, ([as, bs], rest, context) => {
7191
+ }, ([as, bs], context) => {
7192
+ if (!bs) return;
6889
7193
  const {
6890
- recent
7194
+ source,
7195
+ position,
7196
+ range = 0,
7197
+ linebreak = 0,
7198
+ state = 0
6891
7199
  } = context;
6892
- const head = recent.reduce((a, b) => a + b.length, rest.length);
6893
- if (rest[0] !== ']') {
7200
+ const head = position - range;
7201
+ if (source[position] !== ']') {
6894
7202
  (0, combinator_1.setBacktrack)(context, [2 | 8 /* Backtrack.bracket */], head, 2);
6895
- } else if (context.linebreak > 0) {
7203
+ } else if (linebreak !== 0) {
6896
7204
  (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head, 2);
6897
7205
  } else {
6898
- if (context.state & 128 /* State.annotation */) {
6899
- (0, array_1.push)(bs, [rest[0]]);
7206
+ if (state & 128 /* State.annotation */) {
7207
+ (0, array_1.push)(bs, [source[position]]);
6900
7208
  }
6901
- const source = rest.slice(1);
7209
+ context.position += 1;
6902
7210
  let result;
6903
- if (source[0] !== '{') {
6904
- (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head - 1);
6905
- result = [[], source];
7211
+ if (source[context.position] !== '{') {
7212
+ (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head + 1);
7213
+ result = [[]];
6906
7214
  } else {
6907
- result = !(0, combinator_1.isBacktrack)(context, [1 | 64 /* Backtrack.link */], source) ? (0, link_1.textlink)({
6908
- source,
7215
+ result = !(0, combinator_1.isBacktrack)(context, [1 | 64 /* Backtrack.link */]) ? (0, link_1.textlink)({
6909
7216
  context
6910
7217
  }) : undefined;
6911
- context.recent = recent;
7218
+ context.range = range;
6912
7219
  if (!result) {
6913
- (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head - 1);
6914
- result = [[], source];
7220
+ (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head + 1);
7221
+ result = [[]];
6915
7222
  }
6916
7223
  }
6917
- if ((0, parser_1.exec)(result) === '') {
7224
+ if (context.position === source.length) {
6918
7225
  (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head);
6919
7226
  } else {
6920
- const next = (0, combinator_1.surround)('', (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]), (0, source_1.str)(']'), true, ([, cs = [], ds], rest) => [(0, array_1.push)(cs, ds), rest], ([, cs = []], rest) => {
7227
+ const next = (0, combinator_1.surround)('', (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]), (0, source_1.str)(']'), true, ([, cs = [], ds]) => [(0, array_1.push)(cs, ds)], ([, cs = []]) => {
6921
7228
  (0, combinator_1.setBacktrack)(context, [2 | 64 /* Backtrack.link */], head);
6922
- return [cs, rest];
7229
+ return [cs];
6923
7230
  })({
6924
- source: (0, parser_1.exec)(result),
6925
7231
  context
6926
7232
  });
6927
- if (context.state & 128 /* State.annotation */ && next) {
6928
- (0, array_1.push)((0, array_1.push)(bs, (0, parser_1.eval)(result)), (0, parser_1.eval)(next));
6929
- rest = (0, parser_1.exec)(next);
7233
+ if (state & 128 /* State.annotation */ && next) {
7234
+ return [(0, array_1.push)((0, array_1.push)((0, array_1.unshift)(as, bs), (0, parser_1.eval)(result)), (0, parser_1.eval)(next))];
6930
7235
  }
6931
7236
  }
7237
+ context.position = position;
6932
7238
  }
6933
- return context.state & 128 /* State.annotation */ ? [(0, array_1.unshift)(as, bs), rest] : undefined;
7239
+ return state & 128 /* State.annotation */ ? [(0, array_1.unshift)(as, bs)] : undefined;
6934
7240
  }, [3 | 16 /* Backtrack.doublebracket */, 1 | 8 /* Backtrack.bracket */])));
6935
7241
  // Chicago-Style
6936
- const abbr = (0, combinator_1.surround)((0, source_1.str)('^'), (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/, true, ([, ns], rest) => ns ? [["\u001B" /* Command.Escape */, ns[0].trimEnd()], rest.replace(visibility_1.blank.start, '')] : [[''], `^${rest}`], ([as, bs = ['']], rest) => [[''], as[0] + bs[0] + rest]);
7242
+ const abbr = (0, combinator_1.surround)((0, source_1.str)('^'), (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|/, true, ([, ns], context) => {
7243
+ const {
7244
+ source,
7245
+ position,
7246
+ range = 0
7247
+ } = context;
7248
+ if (!ns) return [['', source.slice(position - range, source[position - 1] === '|' ? position - 1 : position)]];
7249
+ context.position += source.slice(position).match(visibility_1.blank.start)?.[0].length ?? 0;
7250
+ return [["\u001F" /* Command.Separator */, ns[0].trimEnd()]];
7251
+ }, (_, context) => {
7252
+ context.position -= context.range;
7253
+ return [['']];
7254
+ });
6937
7255
  function attributes(ns) {
6938
7256
  switch (ns[0]) {
6939
7257
  case '':
@@ -6941,7 +7259,7 @@ function attributes(ns) {
6941
7259
  class: 'invalid',
6942
7260
  ...(0, util_1.invalid)('reference', 'syntax', 'Invalid abbreviation')
6943
7261
  };
6944
- case "\u001B" /* Command.Escape */:
7262
+ case "\u001F" /* Command.Separator */:
6945
7263
  const abbr = ns[1];
6946
7264
  ns[0] = ns[1] = '';
6947
7265
  return {
@@ -6973,11 +7291,11 @@ const source_1 = __webpack_require__(8745);
6973
7291
  const memoize_1 = __webpack_require__(6925);
6974
7292
  const array_1 = __webpack_require__(6876);
6975
7293
  const dom_1 = __webpack_require__(394);
6976
- exports.remark = (0, combinator_1.lazy)(() => (0, combinator_1.match)(/^\[(%+)\s/, (0, memoize_1.memoize)(([, fence]) => (0, combinator_1.surround)((0, source_1.str)(`[${fence}`), (0, combinator_1.precedence)(4, (0, combinator_1.recursion)(4 /* Recursion.inline */, (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, '%'), (0, source_1.str)(`${fence}]`)), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
7294
+ exports.remark = (0, combinator_1.lazy)(() => (0, combinator_1.match)(/^\[(%+)\s/, (0, memoize_1.memoize)(([, fence]) => (0, combinator_1.surround)((0, source_1.str)(`[${fence}`), (0, combinator_1.precedence)(4, (0, combinator_1.recursion)(4 /* Recursion.inline */, (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, '%'), (0, source_1.str)(`${fence}]`)), true, ([as, bs = [], cs]) => [[(0, dom_1.html)('span', {
6977
7295
  class: 'remark'
6978
7296
  }, [(0, dom_1.html)('input', {
6979
7297
  type: 'checkbox'
6980
- }), (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, {})));
7298
+ }), (0, dom_1.html)('span', (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))])]], ([as, bs]) => bs && [(0, array_1.unshift)(as, bs)]), ([, fence]) => fence.length, {})));
6981
7299
 
6982
7300
  /***/ },
6983
7301
 
@@ -6998,66 +7316,59 @@ const source_1 = __webpack_require__(8745);
6998
7316
  const visibility_1 = __webpack_require__(6364);
6999
7317
  const array_1 = __webpack_require__(6876);
7000
7318
  const dom_1 = __webpack_require__(394);
7001
- exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combinator_1.inits)([(0, combinator_1.dup)((0, combinator_1.surround)('[', text, ']', false, ([, ns], rest) => {
7319
+ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combinator_1.inits)([(0, combinator_1.dup)((0, combinator_1.surround)('[', text, ']', false, ([, ns]) => {
7002
7320
  ns && ns.at(-1) === '' && ns.pop();
7003
- return (0, visibility_1.isTightNodeStart)(ns) ? [ns, rest] : undefined;
7004
- }, undefined, [3 | 32 /* Backtrack.ruby */, 1 | 8 /* Backtrack.bracket */])), (0, combinator_1.dup)((0, combinator_1.surround)('(', text, ')', false, undefined, undefined, [3 | 32 /* Backtrack.ruby */, 1 | 8 /* Backtrack.bracket */]))]), ([texts, rubies], rest, context) => {
7321
+ return (0, visibility_1.isTightNodeStart)(ns) ? [ns] : undefined;
7322
+ }, undefined, [3 | 32 /* Backtrack.ruby */, 1 | 8 /* Backtrack.bracket */])), (0, combinator_1.dup)((0, combinator_1.surround)('(', text, ')', false, undefined, undefined, [3 | 32 /* Backtrack.ruby */, 1 | 8 /* Backtrack.bracket */]))]), ([texts, rubies], context) => {
7005
7323
  if (rubies === undefined) {
7006
- const head = context.recent.reduce((a, b) => a + b.length, rest.length);
7324
+ const head = context.position - context.range;
7007
7325
  return void (0, combinator_1.setBacktrack)(context, [2 | 32 /* Backtrack.ruby */], head);
7008
7326
  }
7009
7327
  switch (true) {
7010
7328
  case rubies.length <= texts.length:
7011
- return [[(0, dom_1.html)('ruby', (0, dom_1.defrag)(texts.reduce((acc, _, i) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), [])))], rest];
7329
+ return [[(0, dom_1.html)('ruby', (0, dom_1.defrag)(texts.reduce((acc, _, i) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), [])))]];
7012
7330
  case texts.length === 1 && [...texts[0]].length >= rubies.length:
7013
- return [[(0, dom_1.html)('ruby', (0, dom_1.defrag)([...texts[0]].reduce((acc, _, i, texts) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), [])))], rest];
7331
+ return [[(0, dom_1.html)('ruby', (0, dom_1.defrag)([...texts[0]].reduce((acc, _, i, texts) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), [])))]];
7014
7332
  default:
7015
- return [[(0, dom_1.html)('ruby', (0, dom_1.defrag)((0, array_1.unshift)([texts.join(' ')], [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies.join(' ').trim()), (0, dom_1.html)('rp', ')')])))], rest];
7333
+ return [[(0, dom_1.html)('ruby', (0, dom_1.defrag)((0, array_1.unshift)([texts.join(' ')], [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies.join(' ').trim()), (0, dom_1.html)('rp', ')')])))]];
7016
7334
  }
7017
7335
  }));
7018
- const text = ({
7019
- source,
7020
- context
7021
- }) => {
7336
+ const text = input => {
7337
+ const {
7338
+ context
7339
+ } = input;
7340
+ const {
7341
+ source
7342
+ } = context;
7022
7343
  const acc = [''];
7023
7344
  let state = false;
7024
- while (source !== '') {
7025
- if (!/^(?:\\[^\n]|[^\\[\](){}<>"$#\n])/.test(source)) break;
7026
- switch (source[0]) {
7027
- // @ts-expect-error
7345
+ for (let {
7346
+ position
7347
+ } = context; position < source.length; position = context.position) {
7348
+ if (!/^(?:\\[^\n]|[^\\[\](){}<>"`$#:^|\n])/.test(source.slice(position, position + 2))) break;
7349
+ switch (source[position]) {
7028
7350
  case '&':
7029
7351
  {
7030
- const result = (0, htmlentity_1.unsafehtmlentity)({
7031
- source,
7032
- context
7033
- });
7034
- if (result) {
7035
- acc[acc.length - 1] += (0, parser_1.eval)(result)[0];
7036
- source = (0, parser_1.exec)(result) ?? source.slice(1);
7037
- continue;
7038
- }
7039
- // fallthrough
7352
+ const result = (0, htmlentity_1.unsafehtmlentity)(input) ?? (0, source_1.txt)(input);
7353
+ acc[acc.length - 1] += (0, parser_1.eval)(result)[0];
7354
+ continue;
7040
7355
  }
7041
7356
  default:
7042
7357
  {
7043
- if (source[0].trimStart() === '') {
7358
+ if (source[position].trimStart() === '') {
7044
7359
  state ||= acc.at(-1).trimStart() !== '';
7045
7360
  acc.push('');
7046
- source = source.slice(1);
7361
+ context.position += 1;
7047
7362
  continue;
7048
7363
  }
7049
- const result = (0, source_1.txt)({
7050
- source,
7051
- context
7052
- });
7053
- acc[acc.length - 1] += (0, parser_1.eval)(result)[0] ?? source.slice(0, source.length - (0, parser_1.exec)(result).length);
7054
- source = (0, parser_1.exec)(result);
7364
+ const result = (0, source_1.txt)(input);
7365
+ acc[acc.length - 1] += (0, parser_1.eval)(result)[0] ?? source.slice(position, context.position);
7055
7366
  continue;
7056
7367
  }
7057
7368
  }
7058
7369
  }
7059
7370
  state ||= acc.at(-1).trimStart() !== '';
7060
- return state ? [acc, source] : undefined;
7371
+ return state ? [acc] : undefined;
7061
7372
  };
7062
7373
  //function attributes(texts: string[], rubies: string[]): Record<string, string> {
7063
7374
  // let attrs: Record<string, string> | undefined;
@@ -7108,11 +7419,12 @@ exports.strong = void 0;
7108
7419
  const combinator_1 = __webpack_require__(3484);
7109
7420
  const inline_1 = __webpack_require__(7973);
7110
7421
  const emstrong_1 = __webpack_require__(365);
7422
+ const emphasis_1 = __webpack_require__(1354);
7111
7423
  const source_1 = __webpack_require__(8745);
7112
7424
  const visibility_1 = __webpack_require__(6364);
7113
7425
  const array_1 = __webpack_require__(6876);
7114
7426
  const dom_1 = __webpack_require__(394);
7115
- exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('**', '*'), (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((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]));
7427
+ exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('**', '*'), (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([emphasis_1.emphasis, (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, emphasis_1.emphasis]))]))))), (0, source_1.str)('**'), false, ([, bs]) => [[(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))]], ([as, bs]) => bs && [(0, array_1.unshift)(as, bs)]));
7116
7428
 
7117
7429
  /***/ },
7118
7430
 
@@ -7128,14 +7440,16 @@ Object.defineProperty(exports, "__esModule", ({
7128
7440
  exports.template = void 0;
7129
7441
  const combinator_1 = __webpack_require__(3484);
7130
7442
  const source_1 = __webpack_require__(8745);
7443
+ const util_1 = __webpack_require__(4992);
7131
7444
  const array_1 = __webpack_require__(6876);
7132
7445
  const dom_1 = __webpack_require__(394);
7133
- exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('{{'), (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}}'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
7446
+ exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('{{'), (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}}'), true, ([as, bs = [], cs]) => [[(0, dom_1.html)('span', {
7134
7447
  class: 'template'
7135
- }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], undefined, [3 | 16 /* Backtrack.doublebracket */, 3 | 4 /* Backtrack.escbracket */]));
7136
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.escsource, '"', [['"', 2, false]]))), (0, source_1.str)('"'), true, ([as, bs = [], cs], rest, {
7137
- linebreak = 0
7138
- }) => linebreak > rest.length ? [(0, array_1.unshift)(as, bs), cs[0] + rest] : [(0, array_1.push)((0, array_1.unshift)(as, bs), cs), rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [3 | 4 /* Backtrack.escbracket */])]));
7448
+ }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))]], ([, bs], context) => bs && [[(0, dom_1.html)('span', {
7449
+ class: 'invalid',
7450
+ ...(0, util_1.invalid)('template', 'syntax', `Missing the closing symbol "}}"`)
7451
+ }, context.source.slice(context.position - context.range, context.position))]], [3 | 16 /* Backtrack.doublebracket */, 3 | 4 /* Backtrack.escbracket */]));
7452
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [[]], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [[]], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [[]], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.escsource, '"', [['"', 2, false]]))), (0, source_1.str)('"'), true, ([as, bs = [], cs], context) => context.linebreak === 0 ? [(0, array_1.push)((0, array_1.unshift)(as, bs), cs)] : (context.position -= 1, [(0, array_1.unshift)(as, bs)]), ([as, bs]) => bs && [(0, array_1.unshift)(as, bs)], [3 | 4 /* Backtrack.escbracket */])]));
7139
7453
 
7140
7454
  /***/ },
7141
7455
 
@@ -7468,18 +7782,24 @@ exports.MAX_INPUT_SIZE = exports.MAX_SEGMENT_SIZE * 10;
7468
7782
  const parser = (0, combinator_1.union)([heading_1.segment, codeblock_1.segment, mathblock_1.segment, extension_1.segment, (0, combinator_1.some)(source_1.contentline, exports.MAX_SEGMENT_SIZE + 1), (0, combinator_1.some)(source_1.emptyline, exports.MAX_SEGMENT_SIZE + 1)]);
7469
7783
  function* segment(source) {
7470
7784
  if (!validate(source, exports.MAX_INPUT_SIZE)) return yield `${"\u0007" /* Command.Error */}Too large input over ${exports.MAX_INPUT_SIZE.toLocaleString('en')} bytes.\n${source.slice(0, 1001)}`;
7471
- while (source !== '') {
7472
- const result = parser({
7473
- source,
7474
- context: {}
7475
- });
7476
- const rest = (0, parser_1.exec)(result);
7477
- const segs = (0, parser_1.eval)(result).length ? (0, parser_1.eval)(result) : [source.slice(0, source.length - rest.length)];
7785
+ const context = {
7786
+ source,
7787
+ position: 0
7788
+ };
7789
+ const input = {
7790
+ context
7791
+ };
7792
+ while (context.position < source.length) {
7793
+ const {
7794
+ position
7795
+ } = context;
7796
+ const result = parser(input);
7797
+ const segs = (0, parser_1.eval)(result).length ? (0, parser_1.eval)(result) : [source.slice(position, context.position)];
7478
7798
  for (let i = 0; i < segs.length; ++i) {
7479
7799
  const seg = segs[i];
7480
7800
  validate(seg, exports.MAX_SEGMENT_SIZE) ? yield seg : yield `${"\u0007" /* Command.Error */}Too large segment over ${exports.MAX_SEGMENT_SIZE.toLocaleString('en')} bytes.\n${seg}`;
7481
7801
  }
7482
- source = rest;
7802
+ (0, parser_1.clean)(context);
7483
7803
  }
7484
7804
  }
7485
7805
  exports.segment = segment;
@@ -7499,7 +7819,7 @@ exports.validate = validate;
7499
7819
  Object.defineProperty(exports, "__esModule", ({
7500
7820
  value: true
7501
7821
  }));
7502
- exports.anyline = exports.emptyline = exports.contentline = exports.str = exports.unescsource = exports.escsource = exports.linebreak = exports.txt = exports.text = void 0;
7822
+ exports.anyline = exports.emptyline = exports.contentline = exports.strs = exports.str = exports.unescsource = exports.escsource = exports.linebreak = exports.txt = exports.text = void 0;
7503
7823
  var text_1 = __webpack_require__(5655);
7504
7824
  Object.defineProperty(exports, "text", ({
7505
7825
  enumerable: true,
@@ -7540,6 +7860,12 @@ Object.defineProperty(exports, "str", ({
7540
7860
  return str_1.str;
7541
7861
  }
7542
7862
  }));
7863
+ Object.defineProperty(exports, "strs", ({
7864
+ enumerable: true,
7865
+ get: function () {
7866
+ return str_1.strs;
7867
+ }
7868
+ }));
7543
7869
  var line_1 = __webpack_require__(702);
7544
7870
  Object.defineProperty(exports, "contentline", ({
7545
7871
  enumerable: true,
@@ -7573,50 +7899,41 @@ Object.defineProperty(exports, "__esModule", ({
7573
7899
  }));
7574
7900
  exports.escsource = void 0;
7575
7901
  const combinator_1 = __webpack_require__(3484);
7576
- const text_1 = __webpack_require__(5655);
7577
7902
  const dom_1 = __webpack_require__(394);
7578
- const delimiter = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
7579
7903
  const escsource = ({
7580
- source,
7581
7904
  context
7582
7905
  }) => {
7583
- if (source === '') return;
7584
- const i = source.search(delimiter);
7585
- switch (i) {
7586
- case -1:
7587
- (0, combinator_1.consume)(source.length, context);
7588
- return [[source], ''];
7589
- case 0:
7906
+ const {
7907
+ source,
7908
+ position
7909
+ } = context;
7910
+ if (position === source.length) return;
7911
+ (0, combinator_1.consume)(1, context);
7912
+ context.position += 1;
7913
+ switch (source[position]) {
7914
+ case '\r':
7915
+ (0, combinator_1.consume)(-1, context);
7916
+ return [[]];
7917
+ case "\u001B" /* Command.Escape */:
7590
7918
  (0, combinator_1.consume)(1, context);
7591
- switch (source[0]) {
7592
- case '\r':
7593
- (0, combinator_1.consume)(-1, context);
7594
- return [[], source.slice(1)];
7595
- case "\u001B" /* Command.Escape */:
7596
- (0, combinator_1.consume)(1, context);
7597
- return [[source.slice(1, 2)], source.slice(2)];
7598
- case '\\':
7599
- switch (source[1]) {
7600
- case undefined:
7601
- return [[source[0]], ''];
7602
- case '\n':
7603
- return [[source[0]], source.slice(1)];
7604
- default:
7605
- (0, combinator_1.consume)(1, context);
7606
- return [[source.slice(0, 2)], source.slice(2)];
7607
- }
7919
+ context.position += 1;
7920
+ return [[source.slice(position + 1, position + 2)]];
7921
+ case '\\':
7922
+ switch (source[position + 1]) {
7923
+ case undefined:
7924
+ return [[source[position]]];
7608
7925
  case '\n':
7609
- context.linebreak ||= source.length;
7610
- return [[(0, dom_1.html)('br')], source.slice(1)];
7926
+ return [[source[position]]];
7611
7927
  default:
7612
- const b = source[0].trimStart() === '';
7613
- const i = b ? source.search(text_1.nonWhitespace) : 1;
7614
- (0, combinator_1.consume)(i - 1, context);
7615
- return [[source.slice(0, i - +b || 1)], source.slice(i - +b || 1)];
7928
+ (0, combinator_1.consume)(1, context);
7929
+ context.position += 1;
7930
+ return [[source.slice(position, position + 2)]];
7616
7931
  }
7932
+ case '\n':
7933
+ context.linebreak ||= source.length - position;
7934
+ return [[(0, dom_1.html)('br')]];
7617
7935
  default:
7618
- (0, combinator_1.consume)(i, context);
7619
- return [[source.slice(0, i)], source.slice(i)];
7936
+ return [[source[position]]];
7620
7937
  }
7621
7938
  };
7622
7939
  exports.escsource = escsource;
@@ -7634,9 +7951,17 @@ Object.defineProperty(exports, "__esModule", ({
7634
7951
  }));
7635
7952
  exports.contentline = exports.emptyline = exports.anyline = void 0;
7636
7953
  const combinator_1 = __webpack_require__(3484);
7637
- exports.anyline = (0, combinator_1.line)(() => [[], '']);
7638
- exports.emptyline = (0, combinator_1.line)(i => (0, combinator_1.isBlank)(i.source) ? [[], ''] : undefined);
7639
- exports.contentline = (0, combinator_1.line)(i => !(0, combinator_1.isBlank)(i.source) ? [[], ''] : undefined);
7954
+ exports.anyline = (0, combinator_1.line)(() => [[]]);
7955
+ exports.emptyline = (0, combinator_1.line)(({
7956
+ context: {
7957
+ source
7958
+ }
7959
+ }) => (0, combinator_1.isBlank)(source) ? [[]] : undefined);
7960
+ exports.contentline = (0, combinator_1.line)(({
7961
+ context: {
7962
+ source
7963
+ }
7964
+ }) => !(0, combinator_1.isBlank)(source) ? [[]] : undefined);
7640
7965
 
7641
7966
  /***/ },
7642
7967
 
@@ -7649,29 +7974,55 @@ exports.contentline = (0, combinator_1.line)(i => !(0, combinator_1.isBlank)(i.s
7649
7974
  Object.defineProperty(exports, "__esModule", ({
7650
7975
  value: true
7651
7976
  }));
7652
- exports.str = void 0;
7977
+ exports.strs = exports.str = void 0;
7653
7978
  const combinator_1 = __webpack_require__(3484);
7654
7979
  function str(pattern, not) {
7655
7980
  const count = typeof pattern === 'object' ? /[^^\\*+][*+]/.test(pattern.source) : false;
7656
7981
  return typeof pattern === 'string' ? ({
7657
- source
7982
+ context
7658
7983
  }) => {
7659
- if (source === '') return;
7660
- if (not && source.slice(pattern.length, pattern.length + not.length) === not) return;
7661
- return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : undefined;
7984
+ const {
7985
+ source,
7986
+ position
7987
+ } = context;
7988
+ if (position === source.length) return;
7989
+ if (!source.startsWith(pattern, position)) return;
7990
+ if (not && source.startsWith(not, position + pattern.length)) return;
7991
+ context.position += pattern.length;
7992
+ return [[pattern]];
7662
7993
  } : ({
7663
- source,
7664
7994
  context
7665
7995
  }) => {
7666
- if (source === '') return;
7667
- const m = source.match(pattern);
7996
+ const {
7997
+ source,
7998
+ position
7999
+ } = context;
8000
+ if (position === source.length) return;
8001
+ const m = source.slice(position).match(pattern);
7668
8002
  if (m === null) return;
7669
8003
  count && (0, combinator_1.consume)(m[0].length, context);
7670
- if (not && source.slice(m[0].length, m[0].length + not.length) === not) return;
7671
- return [[m[0]], source.slice(m[0].length)];
8004
+ if (not && source.slice(position + m[0].length, position + m[0].length + not.length) === not) return;
8005
+ context.position += m[0].length;
8006
+ return [[m[0]]];
7672
8007
  };
7673
8008
  }
7674
8009
  exports.str = str;
8010
+ function strs(pattern) {
8011
+ return ({
8012
+ context
8013
+ }) => {
8014
+ const {
8015
+ source
8016
+ } = context;
8017
+ let acc = '';
8018
+ while (context.position < source.length && source.startsWith(pattern, context.position)) {
8019
+ acc += pattern;
8020
+ context.position += pattern.length;
8021
+ }
8022
+ return [[acc]];
8023
+ };
8024
+ }
8025
+ exports.strs = strs;
7675
8026
 
7676
8027
  /***/ },
7677
8028
 
@@ -7684,59 +8035,41 @@ exports.str = str;
7684
8035
  Object.defineProperty(exports, "__esModule", ({
7685
8036
  value: true
7686
8037
  }));
7687
- exports.isAlphanumeric = exports.linebreak = exports.txt = exports.text = exports.nonAlphanumeric = exports.nonWhitespace = exports.delimiter = void 0;
8038
+ exports.isAlphanumeric = exports.linebreak = exports.txt = exports.text = void 0;
7688
8039
  const combinator_1 = __webpack_require__(3484);
7689
- const str_1 = __webpack_require__(4017);
7690
8040
  const dom_1 = __webpack_require__(394);
7691
- exports.delimiter = /[\s\x00-\x7F()[]{}]|\S#|[0-9A-Za-z]>/u;
7692
- exports.nonWhitespace = /[\S\n]|$/u;
7693
- exports.nonAlphanumeric = /[^0-9A-Za-z]|\S#|[0-9A-Za-z]>|$/u;
7694
- const repeat = (0, str_1.str)(/^(.)\1*/);
7695
- const text = ({
7696
- source,
7697
- context
7698
- }) => {
7699
- if (source === '') return;
7700
- const i = source.search(exports.delimiter);
7701
- switch (i) {
7702
- case -1:
7703
- (0, combinator_1.consume)(source.length, context);
7704
- return [[source], ''];
7705
- case 0:
7706
- (0, combinator_1.consume)(1, context);
7707
- switch (source[0]) {
7708
- case '\r':
7709
- (0, combinator_1.consume)(-1, context);
7710
- return [[], source.slice(1)];
7711
- case "\u001B" /* Command.Escape */:
7712
- case '\\':
7713
- switch (source[1]) {
7714
- case undefined:
7715
- return [[], ''];
7716
- case '\n':
7717
- return [[], source.slice(1)];
7718
- default:
7719
- (0, combinator_1.consume)(1, context);
7720
- return [[source.slice(1, 2)], source.slice(2)];
7721
- }
8041
+ const text = input => {
8042
+ const {
8043
+ context
8044
+ } = input;
8045
+ const {
8046
+ source,
8047
+ position
8048
+ } = context;
8049
+ if (position === source.length) return;
8050
+ (0, combinator_1.consume)(1, context);
8051
+ context.position += 1;
8052
+ switch (source[position]) {
8053
+ case '\r':
8054
+ (0, combinator_1.consume)(-1, context);
8055
+ return [[]];
8056
+ case "\u001B" /* Command.Escape */:
8057
+ case '\\':
8058
+ switch (source[position + 1]) {
8059
+ case undefined:
8060
+ return [[]];
7722
8061
  case '\n':
7723
- context.linebreak ||= source.length;
7724
- return [[(0, dom_1.html)('br')], source.slice(1)];
7725
- case '*':
7726
- case '`':
7727
- return source[1] === source[0] ? repeat({
7728
- source,
7729
- context
7730
- }) : [[source[0]], source.slice(1)];
8062
+ return [[]];
7731
8063
  default:
7732
- const b = source[0].trimStart() === '';
7733
- const i = b || isAlphanumeric(source[0]) ? source.search(b ? exports.nonWhitespace : exports.nonAlphanumeric) || 1 : 1;
7734
- (0, combinator_1.consume)(i - 1, context);
7735
- return b && i === source.length || b && source[i] === '\n' || b && source[i] === '\\' && source[i + 1] === '\n' ? [[], source.slice(i)] : [[source.slice(0, i - +b || 1)], source.slice(i - +b || 1)];
8064
+ (0, combinator_1.consume)(1, context);
8065
+ context.position += 1;
8066
+ return [[source.slice(position + 1, position + 2)]];
7736
8067
  }
8068
+ case '\n':
8069
+ context.linebreak ||= source.length - position;
8070
+ return [[(0, dom_1.html)('br')]];
7737
8071
  default:
7738
- (0, combinator_1.consume)(i, context);
7739
- return [[source.slice(0, i)], source.slice(i)];
8072
+ return [[source[position]]];
7740
8073
  }
7741
8074
  };
7742
8075
  exports.text = text;
@@ -7761,41 +8094,30 @@ Object.defineProperty(exports, "__esModule", ({
7761
8094
  }));
7762
8095
  exports.unescsource = void 0;
7763
8096
  const combinator_1 = __webpack_require__(3484);
7764
- const text_1 = __webpack_require__(5655);
7765
8097
  const dom_1 = __webpack_require__(394);
7766
8098
  const unescsource = ({
7767
- source,
7768
8099
  context
7769
8100
  }) => {
7770
- if (source === '') return;
7771
- const i = source.search(text_1.delimiter);
7772
- switch (i) {
7773
- case -1:
7774
- (0, combinator_1.consume)(source.length, context);
7775
- return [[source], ''];
7776
- case 0:
7777
- {
7778
- (0, combinator_1.consume)(1, context);
7779
- switch (source[0]) {
7780
- case '\r':
7781
- (0, combinator_1.consume)(-1, context);
7782
- return [[], source.slice(1)];
7783
- case "\u001B" /* Command.Escape */:
7784
- (0, combinator_1.consume)(1, context);
7785
- return [[source.slice(1, 2)], source.slice(2)];
7786
- case '\n':
7787
- context.linebreak ||= source.length;
7788
- return [[(0, dom_1.html)('br')], source.slice(1)];
7789
- default:
7790
- const b = source[0].trimStart() === '';
7791
- const i = b || (0, text_1.isAlphanumeric)(source[0]) ? source.search(b ? text_1.nonWhitespace : text_1.nonAlphanumeric) || 1 : 1;
7792
- (0, combinator_1.consume)(i - 1, context);
7793
- return [[source.slice(0, i - +b || 1)], source.slice(i - +b || 1)];
7794
- }
7795
- }
8101
+ const {
8102
+ source,
8103
+ position
8104
+ } = context;
8105
+ if (position === source.length) return;
8106
+ (0, combinator_1.consume)(1, context);
8107
+ context.position += 1;
8108
+ switch (source[position]) {
8109
+ case '\r':
8110
+ (0, combinator_1.consume)(-1, context);
8111
+ return [[]];
8112
+ case "\u001B" /* Command.Escape */:
8113
+ (0, combinator_1.consume)(1, context);
8114
+ context.position += 1;
8115
+ return [[source.slice(position + 1, position + 2)]];
8116
+ case '\n':
8117
+ context.linebreak ||= source.length - position;
8118
+ return [[(0, dom_1.html)('br')]];
7796
8119
  default:
7797
- (0, combinator_1.consume)(i, context);
7798
- return [[source.slice(0, i)], source.slice(i)];
8120
+ return [[source[position]]];
7799
8121
  }
7800
8122
  };
7801
8123
  exports.unescsource = unescsource;
@@ -7820,46 +8142,49 @@ function lineable(parser, trim = -1) {
7820
8142
  return (0, combinator_1.convert)(source => `\r${trim === 0 ? source : trim > 0 ? source.at(-1) === '\n' ? source : source + '\n' : source.at(-1) === '\n' ? source.slice(0, -1) : source}`, parser, trim === 0);
7821
8143
  }
7822
8144
  exports.lineable = lineable;
7823
- function repeat(symbol, parser, cons, termination = (acc, rest, prefix, postfix) => {
7824
- const nodes = [];
8145
+ function repeat(symbol, parser, cons, termination = (nodes, context, prefix, postfix) => {
8146
+ const acc = [];
7825
8147
  if (prefix > 0) {
7826
- nodes.push(symbol[0].repeat(prefix));
7827
- }
7828
- for (let i = 0; i < acc.length; ++i) {
7829
- nodes.push(...acc[i]);
8148
+ acc.push(symbol[0].repeat(prefix));
7830
8149
  }
8150
+ acc.push(...nodes);
7831
8151
  if (postfix > 0) {
7832
- nodes.push(rest.slice(0, postfix));
7833
- rest = rest.slice(postfix);
8152
+ const {
8153
+ source,
8154
+ position
8155
+ } = context;
8156
+ acc.push(source.slice(position, position + postfix));
8157
+ context.position += postfix;
7834
8158
  }
7835
- return [nodes, rest];
8159
+ return [acc];
7836
8160
  }) {
7837
- return input => {
8161
+ return (0, parser_1.failsafe)(input => {
7838
8162
  const {
7839
- source,
7840
8163
  context
7841
8164
  } = input;
7842
- let acc = [];
8165
+ const {
8166
+ source,
8167
+ position
8168
+ } = context;
8169
+ let nodes = [];
7843
8170
  let i = symbol.length;
7844
- while (source[i] === source[0]) ++i;
7845
- let rest = source.slice(i);
8171
+ while (source[context.position + i] === source[context.position]) ++i;
8172
+ context.position += i;
7846
8173
  let state = false;
7847
8174
  for (; i >= symbol.length; i -= symbol.length) {
7848
- if (acc.length > 0 && rest.startsWith(symbol)) {
7849
- acc = [cons(acc.flat(), context)];
7850
- rest = rest.slice(symbol.length);
8175
+ if (nodes.length > 0 && source.startsWith(symbol, context.position)) {
8176
+ nodes = cons(nodes, context);
8177
+ context.position += symbol.length;
7851
8178
  continue;
7852
8179
  }
7853
- const result = parser({
7854
- source: rest,
7855
- context
7856
- });
8180
+ const buf = context.buffer;
8181
+ context.buffer = nodes;
8182
+ const result = parser(input);
8183
+ context.buffer = buf;
7857
8184
  if (result === undefined) break;
7858
- const nodes = (0, parser_1.eval)(result);
7859
- rest = (0, parser_1.exec)(result);
7860
- acc.push(nodes);
8185
+ nodes = (0, parser_1.eval)(result);
7861
8186
  switch (nodes.at(-1)) {
7862
- case "\u001B" /* Command.Escape */:
8187
+ case "\u0018" /* Command.Cancel */:
7863
8188
  nodes.pop();
7864
8189
  state = false;
7865
8190
  break;
@@ -7868,21 +8193,22 @@ function repeat(symbol, parser, cons, termination = (acc, rest, prefix, postfix)
7868
8193
  state = true;
7869
8194
  continue;
7870
8195
  default:
7871
- acc = [cons(acc.flat(), context)];
8196
+ nodes = cons(nodes, context);
7872
8197
  state = true;
7873
8198
  continue;
7874
8199
  }
7875
8200
  break;
7876
8201
  }
7877
- if (acc.length === 0) return;
8202
+ if (nodes.length === 0) return;
7878
8203
  const prefix = i;
7879
8204
  i = 0;
7880
- for (let len = (0, alias_1.min)(prefix, rest.length); i < len && rest[i] === symbol[0];) {
8205
+ for (let len = (0, alias_1.min)(prefix, source.length - context.position); i < len && source[context.position + i] === symbol[0];) {
7881
8206
  ++i;
7882
8207
  }
7883
8208
  const postfix = i;
7884
- return termination(acc, rest, prefix, postfix, state);
7885
- };
8209
+ context.range = context.position - position;
8210
+ return termination(nodes, context, prefix, postfix, state);
8211
+ });
7886
8212
  }
7887
8213
  exports.repeat = repeat;
7888
8214
  function invalid(syntax, type, message) {
@@ -7950,7 +8276,10 @@ var blank;
7950
8276
  blank.start = new RegExp(/^(?:\\?[^\S\r\n]|&IHN;|<wbr[^\S\n]*>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
7951
8277
  })(blank || (exports.blank = blank = {}));
7952
8278
  function visualize(parser) {
7953
- return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blank.line, line => line.replace(/[\\&<]/g, `${"\u001B" /* Command.Escape */}$&`)), (0, combinator_1.verify)(parser, (ns, rest) => !rest && hasVisible(ns)), false), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
8279
+ return (0, combinator_1.union)([(0, combinator_1.convert)(source => source.replace(blank.line, line => line.replace(/[\\&<]/g, `${"\u001B" /* Command.Escape */}$&`)), (0, combinator_1.verify)(parser, (ns, {
8280
+ source,
8281
+ position
8282
+ }) => position === source.length && hasVisible(ns)), false), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
7954
8283
  }
7955
8284
  exports.visualize = visualize;
7956
8285
  function hasVisible(nodes) {
@@ -7960,6 +8289,7 @@ function hasVisible(nodes) {
7960
8289
  if (node && node.trimStart()) return true;
7961
8290
  } else {
7962
8291
  if (node.innerText.trimStart()) return true;
8292
+ if (node.classList.contains('reference')) return true;
7963
8293
  //if (state & State.media ^ State.media &&
7964
8294
  // (node.classList.contains('media') || node.getElementsByClassName('media')[0])) return true;
7965
8295
  }
@@ -7980,32 +8310,38 @@ function tightStart(parser, except) {
7980
8310
  exports.tightStart = tightStart;
7981
8311
  function isTightStart(input, except) {
7982
8312
  const {
7983
- source
8313
+ context
7984
8314
  } = input;
7985
- if (source === '') return true;
7986
- if (except && source.slice(0, except.length) === except) return false;
7987
- switch (source[0]) {
8315
+ const {
8316
+ source,
8317
+ position
8318
+ } = context;
8319
+ if (position === source.length) return true;
8320
+ if (except && source.startsWith(except, position)) return false;
8321
+ switch (source[position]) {
7988
8322
  case ' ':
7989
8323
  case ' ':
7990
8324
  case '\t':
7991
8325
  case '\n':
7992
8326
  return false;
7993
8327
  case '\\':
7994
- return source[1]?.trimStart() !== '';
8328
+ return source[position + 1]?.trimStart() !== '';
7995
8329
  case '&':
7996
8330
  switch (true) {
7997
- case source.length > 2 && source[1] !== ' ' && (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)(input))?.[0]?.trimStart() === '':
8331
+ case source.length - position > 2 && source[position + 1] !== ' ' && (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)(input))?.[0]?.trimStart() === '':
8332
+ context.position = position;
7998
8333
  return false;
7999
8334
  }
8335
+ context.position = position;
8000
8336
  return true;
8001
8337
  case '<':
8002
8338
  switch (true) {
8003
- case source.length >= 5 && source.slice(0, 4) === '<wbr' && (source[5] === '>' || /^<wbr[^\S\n]*>/.test(source)):
8339
+ case source.length - position >= 5 && source.startsWith('<wbr', position) && (source[position + 5] === '>' || /^<wbr[^\S\n]*>/.test(source.slice(position))):
8004
8340
  return false;
8005
8341
  }
8006
8342
  return true;
8007
8343
  default:
8008
- return source[0].trimStart() !== '';
8344
+ return source[position].trimStart() !== '';
8009
8345
  }
8010
8346
  }
8011
8347
  function isLooseNodeStart(nodes) {
@@ -8085,9 +8421,9 @@ function trimBlankNodeEnd(nodes) {
8085
8421
  const skip = nodes.length > 0 && typeof nodes.at(-1) === 'object' && nodes.at(-1)['className'] === 'indexer' ? [nodes.pop()] : [];
8086
8422
  for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes.at(-1), -1);) {
8087
8423
  if (typeof node === 'string') {
8088
- const len = node.trimEnd().length;
8089
- if (len > 0) {
8090
- nodes[nodes.length - 1] = node.slice(0, len);
8424
+ const str = node.trimEnd();
8425
+ if (str.length > 0) {
8426
+ nodes[nodes.length - 1] = str;
8091
8427
  break;
8092
8428
  }
8093
8429
  }
@@ -8561,10 +8897,11 @@ exports.quote = void 0;
8561
8897
  const parser_1 = __webpack_require__(605);
8562
8898
  const cite_1 = __webpack_require__(1200);
8563
8899
  function quote(anchor, range) {
8564
- if ((0, parser_1.exec)((0, cite_1.cite)({
8565
- source: `>>${anchor}`,
8566
- context: {}
8567
- })) !== '') throw new Error(`Invalid anchor: ${anchor}`);
8900
+ const {
8901
+ context
8902
+ } = (0, parser_1.input)('', {});
8903
+ (0, cite_1.cite)((0, parser_1.input)(`>>${anchor}`, context));
8904
+ if (context.position !== context.source.length) throw new Error(`Invalid anchor: ${anchor}`);
8568
8905
  fit(range);
8569
8906
  const node = trim(range.cloneContents());
8570
8907
  if (!node.firstChild) return '';