securemark 0.260.4 → 0.261.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 (53) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +12 -12
  3. package/design.md +0 -4
  4. package/dist/index.js +268 -243
  5. package/markdown.d.ts +7 -23
  6. package/package.json +6 -6
  7. package/src/combinator/data/parser/context/memo.ts +4 -0
  8. package/src/combinator/data/parser/context.ts +25 -16
  9. package/src/combinator/data/parser.ts +0 -1
  10. package/src/parser/api/bind.ts +2 -1
  11. package/src/parser/api/parse.test.ts +1 -1
  12. package/src/parser/api/parse.ts +2 -1
  13. package/src/parser/block/blockquote.test.ts +2 -2
  14. package/src/parser/block/dlist.test.ts +1 -1
  15. package/src/parser/block/extension/example.test.ts +1 -1
  16. package/src/parser/block/extension/fig.test.ts +1 -1
  17. package/src/parser/block/heading.test.ts +2 -2
  18. package/src/parser/block/paragraph.test.ts +1 -4
  19. package/src/parser/block/reply/cite.test.ts +5 -0
  20. package/src/parser/block/reply/cite.ts +5 -4
  21. package/src/parser/context.ts +8 -7
  22. package/src/parser/inline/autolink/anchor.test.ts +1 -0
  23. package/src/parser/inline/autolink/email.test.ts +3 -0
  24. package/src/parser/inline/autolink/email.ts +1 -1
  25. package/src/parser/inline/autolink/hashnum.test.ts +1 -2
  26. package/src/parser/inline/autolink/hashnum.ts +1 -1
  27. package/src/parser/inline/autolink/hashtag.test.ts +15 -12
  28. package/src/parser/inline/autolink/hashtag.ts +3 -3
  29. package/src/parser/inline/autolink/url.test.ts +1 -1
  30. package/src/parser/inline/autolink/url.ts +1 -1
  31. package/src/parser/inline/autolink.ts +14 -5
  32. package/src/parser/inline/deletion.test.ts +2 -2
  33. package/src/parser/inline/emphasis.test.ts +26 -35
  34. package/src/parser/inline/emphasis.ts +5 -12
  35. package/src/parser/inline/escape.ts +1 -10
  36. package/src/parser/inline/extension/index.test.ts +2 -2
  37. package/src/parser/inline/extension/index.ts +1 -1
  38. package/src/parser/inline/insertion.test.ts +2 -2
  39. package/src/parser/inline/link.test.ts +1 -1
  40. package/src/parser/inline/link.ts +2 -2
  41. package/src/parser/inline/mark.test.ts +1 -1
  42. package/src/parser/inline/media.ts +2 -2
  43. package/src/parser/inline/ruby.ts +10 -6
  44. package/src/parser/inline/strong.test.ts +25 -32
  45. package/src/parser/inline/strong.ts +4 -8
  46. package/src/parser/inline/template.ts +1 -1
  47. package/src/parser/inline.test.ts +18 -91
  48. package/src/parser/inline.ts +0 -3
  49. package/src/parser/locale/ja.ts +1 -9
  50. package/src/parser/locale.test.ts +1 -1
  51. package/src/parser/source/text.test.ts +9 -4
  52. package/src/parser/source/text.ts +9 -16
  53. package/src/parser/inline/emstrong.ts +0 -62
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.260.4 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.261.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("DOMPurify"), require("Prism"));
@@ -64,9 +64,9 @@ __exportStar(__webpack_require__(256), exports);
64
64
  Object.defineProperty(exports, "__esModule", ({
65
65
  value: true
66
66
  }));
67
- exports.ObjectSetPrototypeOf = exports.ObjectGetPrototypeOf = exports.ObjectCreate = exports.ObjectAssign = exports.toString = exports.isEnumerable = exports.isPrototypeOf = exports.hasOwnProperty = exports.isArray = exports.sign = exports.round = exports.random = exports.min = exports.max = exports.floor = exports.ceil = exports.abs = exports.parseInt = exports.parseFloat = exports.isSafeInteger = exports.isNaN = exports.isInteger = exports.isFinite = exports[NaN] = void 0;
67
+ exports.ObjectSetPrototypeOf = exports.ObjectGetPrototypeOf = exports.ObjectCreate = exports.ObjectAssign = exports.toString = exports.isEnumerable = exports.isPrototypeOf = exports.hasOwnProperty = exports.isArray = exports.sqrt = exports.log = exports.tan = exports.cos = exports.sign = exports.round = exports.random = exports.min = exports.max = exports.floor = exports.ceil = exports.abs = exports.parseInt = exports.parseFloat = exports.isSafeInteger = exports.isNaN = exports.isInteger = exports.isFinite = exports[NaN] = void 0;
68
68
  exports[NaN] = Number.NaN, exports.isFinite = Number.isFinite, exports.isInteger = Number.isInteger, exports.isNaN = Number.isNaN, exports.isSafeInteger = Number.isSafeInteger, exports.parseFloat = Number.parseFloat, exports.parseInt = Number.parseInt;
69
- exports.abs = Math.abs, exports.ceil = Math.ceil, exports.floor = Math.floor, exports.max = Math.max, exports.min = Math.min, exports.random = Math.random, exports.round = Math.round, exports.sign = Math.sign;
69
+ exports.abs = Math.abs, exports.ceil = Math.ceil, exports.floor = Math.floor, exports.max = Math.max, exports.min = Math.min, exports.random = Math.random, exports.round = Math.round, exports.sign = Math.sign, exports.cos = Math.cos, exports.tan = Math.tan, exports.log = Math.log, exports.sqrt = Math.sqrt;
70
70
  exports.isArray = Array.isArray;
71
71
  exports.hasOwnProperty = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);
72
72
  exports.isPrototypeOf = Object.prototype.isPrototypeOf.call.bind(Object.prototype.isPrototypeOf);
@@ -356,6 +356,8 @@ exports.Cache = void 0;
356
356
 
357
357
  const global_1 = __webpack_require__(4128);
358
358
 
359
+ const alias_1 = __webpack_require__(5406);
360
+
359
361
  const clock_1 = __webpack_require__(7681);
360
362
 
361
363
  const invlist_1 = __webpack_require__(7452);
@@ -364,20 +366,23 @@ const heap_1 = __webpack_require__(818);
364
366
 
365
367
  const assign_1 = __webpack_require__(4401);
366
368
 
367
- const tuple_1 = __webpack_require__(5341);
368
-
369
369
  class Cache {
370
370
  constructor(capacity, opts = {}) {
371
371
  this.settings = {
372
+ window: 0,
372
373
  capacity: 0,
373
374
  space: global_1.Infinity,
374
375
  age: global_1.Infinity,
375
376
  earlyExpiring: false,
376
- limit: 950,
377
377
  capture: {
378
378
  delete: true,
379
379
  clear: true
380
- }
380
+ },
381
+ resolution: 1,
382
+ offset: 0,
383
+ block: 20,
384
+ sweep: 10,
385
+ limit: 950
381
386
  };
382
387
  this.overlap = 0;
383
388
  this.SIZE = 0;
@@ -387,31 +392,8 @@ class Cache {
387
392
  LFU: new invlist_1.List()
388
393
  };
389
394
  this.expiries = new heap_1.Heap((a, b) => a.value.expiry - b.value.expiry);
390
- this.stats = {
391
- LRU: (0, tuple_1.tuple)(0, 0),
392
- LFU: (0, tuple_1.tuple)(0, 0),
393
-
394
- slide() {
395
- const {
396
- LRU,
397
- LFU
398
- } = this;
399
- LRU[1] = LRU[0];
400
- LRU[0] = 0;
401
- LFU[1] = LFU[0];
402
- LFU[0] = 0;
403
- },
404
-
405
- clear() {
406
- const {
407
- LRU,
408
- LFU
409
- } = this;
410
- LRU[0] = LRU[1] = 0;
411
- LFU[0] = LFU[1] = 0;
412
- }
413
-
414
- };
395
+ this.misses = 0;
396
+ this.sweep = 0;
415
397
  this.ratio = 500;
416
398
 
417
399
  if (typeof capacity === 'object') {
@@ -419,15 +401,19 @@ class Cache {
419
401
  capacity = opts.capacity ?? 0;
420
402
  }
421
403
 
422
- (0, assign_1.extend)(this.settings, opts, {
404
+ const settings = (0, assign_1.extend)(this.settings, opts, {
423
405
  capacity
424
406
  });
425
- this.capacity = this.settings.capacity;
407
+ this.capacity = settings.capacity;
426
408
  if (this.capacity >= 1 === false) throw new Error(`Spica: Cache: Capacity must be 1 or more.`);
427
- this.space = this.settings.space;
428
- this.limit = this.settings.limit;
429
- this.earlyExpiring = this.settings.earlyExpiring;
430
- this.disposer = this.settings.disposer;
409
+ this.window = settings.window || this.capacity;
410
+ if (this.window * 1000 < this.capacity) throw new Error(`Spica: Cache: Window must be 0.1% of capacity or more.`);
411
+ this.space = settings.space;
412
+ this.block = settings.block;
413
+ this.limit = settings.limit;
414
+ this.earlyExpiring = settings.earlyExpiring;
415
+ this.disposer = settings.disposer;
416
+ this.stats = new Stats(this.window, settings.resolution, settings.offset);
431
417
  }
432
418
 
433
419
  get length() {
@@ -452,7 +438,7 @@ class Cache {
452
438
 
453
439
  ensure(margin, skip) {
454
440
  let size = skip?.value.size ?? 0;
455
- if (margin - size <= 0) return;
441
+ if (margin - size <= 0) return true;
456
442
  const {
457
443
  LRU,
458
444
  LFU
@@ -474,7 +460,6 @@ class Cache {
474
460
  target = LFU.last !== skip ? LFU.last : LFU.length >= 2 ? LFU.last.prev : skip;
475
461
 
476
462
  if (target !== skip) {
477
- if (this.ratio > 500) break;
478
463
  LRU.unshiftNode(target);
479
464
  ++this.overlap;
480
465
  }
@@ -482,6 +467,18 @@ class Cache {
482
467
  // fallthrough
483
468
 
484
469
  default:
470
+ if (this.misses * 100 > LRU.length * this.block) {
471
+ this.sweep ||= LRU.length * this.settings.sweep / 100 + 1 | 0;
472
+
473
+ if (this.sweep > 0) {
474
+ LRU.head = LRU.head.next.next;
475
+ --this.sweep;
476
+ this.sweep ||= -(0, alias_1.round)(LRU.length * this.settings.sweep / 100 * 99 / 100);
477
+ } else {
478
+ ++this.sweep;
479
+ }
480
+ }
481
+
485
482
  target = LRU.last !== skip ? LRU.last : LRU.length >= 2 ? LRU.last.prev : LFU.last;
486
483
  }
487
484
 
@@ -489,6 +486,8 @@ class Cache {
489
486
  skip = skip?.list && skip;
490
487
  size = skip?.value.size ?? 0;
491
488
  }
489
+
490
+ return !!skip?.list;
492
491
  }
493
492
 
494
493
  put(key, value, {
@@ -503,10 +502,9 @@ class Cache {
503
502
  const expiry = age === global_1.Infinity ? global_1.Infinity : (0, clock_1.now)() + age;
504
503
  const node = this.memory.get(key);
505
504
 
506
- if (node) {
505
+ if (node && this.ensure(size, node)) {
507
506
  const val = node.value.value;
508
507
  const index = node.value;
509
- this.ensure(size, node);
510
508
  this.SIZE += size - index.size;
511
509
  index.size = size;
512
510
  index.expiry = expiry;
@@ -550,10 +548,16 @@ class Cache {
550
548
 
551
549
  get(key) {
552
550
  const node = this.memory.get(key);
553
- if (!node) return;
551
+
552
+ if (!node) {
553
+ ++this.misses;
554
+ return;
555
+ }
556
+
554
557
  const expiry = node.value.expiry;
555
558
 
556
559
  if (expiry !== global_1.Infinity && expiry < (0, clock_1.now)()) {
560
+ ++this.misses;
557
561
  this.evict(node, true);
558
562
  return;
559
563
  } // Optimization for memoize.
@@ -561,7 +565,9 @@ class Cache {
561
565
 
562
566
  if (this.capacity > 3 && node === node.list.head) return node.value.value;
563
567
  this.access(node);
564
- this.slide();
568
+ this.adjust();
569
+ this.misses &&= 0;
570
+ this.sweep = 0;
565
571
  return node.value.value;
566
572
  }
567
573
 
@@ -588,6 +594,8 @@ class Cache {
588
594
  }
589
595
 
590
596
  clear() {
597
+ this.misses = 0;
598
+ this.sweep = 0;
591
599
  this.overlap = 0;
592
600
  this.SIZE = 0;
593
601
  this.ratio = 500;
@@ -620,31 +628,26 @@ class Cache {
620
628
  return;
621
629
  }
622
630
 
623
- slide() {
624
- const {
625
- LRU,
626
- LFU
627
- } = this.stats;
631
+ adjust() {
628
632
  const {
629
633
  capacity,
630
634
  ratio,
631
635
  limit,
636
+ stats,
632
637
  indexes
633
638
  } = this;
634
- const window = capacity;
635
- const total = LRU[0] + LFU[0];
636
- total === window && this.stats.slide();
637
- if (total * 1000 % capacity || !LRU[1] || !LFU[1]) return;
639
+ if (stats.subtotal() * 1000 % capacity || !stats.full()) return;
638
640
  const lenR = indexes.LRU.length;
639
641
  const lenF = indexes.LFU.length;
640
- const lenV = this.overlap;
641
- const r = (lenF + lenV) * 1000 / (lenR + lenF || 1) | 0;
642
- const rateR0 = rate(window, LRU[0], LRU[0] + LFU[0], LRU[1], LRU[1] + LFU[1], 0) * r;
643
- const rateF0 = rate(window, LFU[0], LRU[0] + LFU[0], LFU[1], LRU[1] + LFU[1], 0) * (1000 - r);
644
- const rateF1 = rate(window, LFU[1], LRU[1] + LFU[1], LFU[0], LRU[0] + LFU[0], 5) * (1000 - r); // 操作頻度を超えてキャッシュ比率を増減させても余剰比率の消化が追いつかず無駄
642
+ const lenO = this.overlap;
643
+ const leverage = (lenF + lenO) * 1000 / (lenR + lenF) | 0;
644
+ const rateR0 = stats.rateLRU() * leverage;
645
+ const rateF0 = stats.rateLFU() * (1000 - leverage);
646
+ const rateF1 = stats.offset && stats.rateLFU(true) * (1000 - leverage); // 操作頻度を超えてキャッシュ比率を増減させても余剰比率の消化が追いつかず無駄
645
647
  // LRUの下限設定ではLRU拡大の要否を迅速に判定できないためLFUのヒット率低下の検出で代替する
646
648
 
647
- if (ratio > 0 && (rateR0 > rateF0 || rateF0 < rateF1 * 0.95)) {
649
+ if (ratio > 0 && (rateR0 > rateF0 || stats.offset && rateF0 * 100 < rateF1 * (100 - stats.offset))) {
650
+ //rateR0 <= rateF0 && rateF0 * 100 < rateF1 * (100 - stats.offset) && console.debug(0);
648
651
  if (lenR >= capacity * (1000 - ratio) / 1000) {
649
652
  //ratio % 100 || ratio === 1000 || console.debug('-', ratio, LRU, LFU);
650
653
  --this.ratio;
@@ -682,13 +685,100 @@ class Cache {
682
685
 
683
686
  exports.Cache = Cache;
684
687
 
685
- function rate(window, currHits, currTotal, prevHits, prevTotal, offset) {
686
- const prevRate = prevHits * 100 / prevTotal | 0;
687
- const currRatio = currTotal * 100 / window - offset | 0;
688
- if (currRatio <= 0) return prevRate * 100;
689
- const currRate = currHits * 100 / currTotal | 0;
690
- const prevRatio = 100 - currRatio;
691
- return currRate * currRatio + prevRate * prevRatio;
688
+ class Stats {
689
+ constructor(window, resolution, offset) {
690
+ this.window = window;
691
+ this.resolution = resolution;
692
+ this.offset = offset;
693
+ this.max = (0, alias_1.ceil)(this.resolution * (100 + this.offset) / 100) + 1;
694
+ this.LRU = [0];
695
+ this.LFU = [0];
696
+ }
697
+
698
+ get length() {
699
+ return this.LRU.length;
700
+ }
701
+
702
+ full() {
703
+ return this.length === this.max;
704
+ }
705
+
706
+ rateLRU(offset = false) {
707
+ return rate(this.window, this.LRU, this.LFU, +offset && this.offset);
708
+ }
709
+
710
+ rateLFU(offset = false) {
711
+ return rate(this.window, this.LFU, this.LRU, +offset && this.offset);
712
+ }
713
+
714
+ subtotal() {
715
+ const {
716
+ LRU,
717
+ LFU,
718
+ window,
719
+ resolution,
720
+ offset
721
+ } = this;
722
+
723
+ if (offset && LRU[0] + LFU[0] >= window * offset / 100) {
724
+ if (this.length === 1) {
725
+ this.slide();
726
+ } else {
727
+ LRU[1] += LRU[0];
728
+ LFU[1] += LFU[0];
729
+ LRU[0] = 0;
730
+ LFU[0] = 0;
731
+ }
732
+ }
733
+
734
+ const subtotal = LRU[+offset && 1] + LFU[+offset && 1] || 0;
735
+ subtotal >= window / resolution && this.slide();
736
+ return LRU[0] + LFU[0];
737
+ }
738
+
739
+ slide() {
740
+ const {
741
+ LRU,
742
+ LFU,
743
+ max
744
+ } = this;
745
+
746
+ if (LRU.length === max) {
747
+ LRU.pop();
748
+ LFU.pop();
749
+ }
750
+
751
+ LRU.unshift(0);
752
+ LFU.unshift(0);
753
+ }
754
+
755
+ clear() {
756
+ this.LRU = [0];
757
+ this.LFU = [0];
758
+ }
759
+
760
+ }
761
+
762
+ function rate(window, hits1, hits2, offset) {
763
+ let total = 0;
764
+ let hits = 0;
765
+ let ratio = 100;
766
+
767
+ for (let i = 0, len = hits1.length; i < len; ++i) {
768
+ const subtotal = hits1[i] + hits2[i];
769
+ if (subtotal === 0) continue;
770
+ offset = i + 1 === len ? 0 : offset;
771
+ const subratio = (0, alias_1.min)(subtotal * 100 / window, ratio) - offset;
772
+ offset = offset && subratio < 0 ? -subratio : 0;
773
+ if (subratio <= 0) continue;
774
+ const rate = window * subratio / subtotal;
775
+ total += subtotal * rate;
776
+ hits += hits1[i] * rate;
777
+ ratio -= subratio;
778
+ if (ratio <= 0) break;
779
+ }
780
+
781
+ return hits * 10000 / total | 0;
692
782
  }
693
783
 
694
784
  /***/ }),
@@ -1671,25 +1761,6 @@ function random(len) {
1671
1761
 
1672
1762
  /***/ }),
1673
1763
 
1674
- /***/ 5341:
1675
- /***/ ((__unused_webpack_module, exports) => {
1676
-
1677
- "use strict";
1678
-
1679
-
1680
- Object.defineProperty(exports, "__esModule", ({
1681
- value: true
1682
- }));
1683
- exports.tuple = void 0;
1684
-
1685
- function tuple(...as) {
1686
- return as;
1687
- }
1688
-
1689
- exports.tuple = tuple;
1690
-
1691
- /***/ }),
1692
-
1693
1764
  /***/ 5177:
1694
1765
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1695
1766
 
@@ -2888,12 +2959,16 @@ const parser_1 = __webpack_require__(6728);
2888
2959
  const memo_1 = __webpack_require__(1090);
2889
2960
 
2890
2961
  function reset(base, parser) {
2962
+ if (!('memo' in base)) {
2963
+ base.memo = global_1.undefined;
2964
+ }
2965
+
2891
2966
  const changes = global_1.Object.entries(base);
2892
2967
  const values = (0, global_1.Array)(changes.length);
2893
2968
  return ({
2894
2969
  source,
2895
2970
  context
2896
- }) => apply(parser, source, (0, alias_1.ObjectCreate)(context), changes, values);
2971
+ }) => apply(parser, source, (0, alias_1.ObjectCreate)(context), changes, values, true);
2897
2972
  }
2898
2973
 
2899
2974
  exports.reset = reset;
@@ -2909,18 +2984,25 @@ function context(base, parser) {
2909
2984
 
2910
2985
  exports.context = context;
2911
2986
 
2912
- function apply(parser, source, context, changes, values) {
2987
+ function apply(parser, source, context, changes, values, reset = false) {
2913
2988
  if (context) for (let i = 0; i < changes.length; ++i) {
2914
2989
  const change = changes[i];
2915
2990
  const prop = change[0];
2916
2991
 
2917
2992
  switch (prop) {
2918
2993
  case 'resources':
2919
- if (prop in context && !(0, alias_1.hasOwnProperty)(context, prop)) break; // @ts-expect-error
2920
-
2994
+ if (!reset) break;
2995
+ if (prop in context && !(0, alias_1.hasOwnProperty)(context, prop)) break;
2921
2996
  context[prop] = (0, alias_1.ObjectCreate)(change[1]);
2922
2997
  break;
2923
2998
 
2999
+ case 'memo':
3000
+ if (!reset) break;
3001
+ context.memo = new memo_1.Memo({
3002
+ targets: context.memo?.targets
3003
+ });
3004
+ break;
3005
+
2924
3006
  default:
2925
3007
  values[i] = context[prop];
2926
3008
  context[prop] = change[1];
@@ -2935,8 +3017,11 @@ function apply(parser, source, context, changes, values) {
2935
3017
  const prop = change[0];
2936
3018
 
2937
3019
  switch (prop) {
2938
- case 'resources':
2939
- break;
3020
+ case 'resources': // @ts-expect-error
3021
+
3022
+ case 'memo':
3023
+ if (!reset) break;
3024
+ // fallthrough
2940
3025
 
2941
3026
  default:
2942
3027
  context[prop] = values[i];
@@ -2953,26 +3038,25 @@ function syntax(syntax, prec, cost, state, parser) {
2953
3038
  }) => {
2954
3039
  if (source === '') return;
2955
3040
  const memo = context.memo ??= new memo_1.Memo();
2956
- context.memorable ??= ~0;
2957
3041
  context.offset ??= 0;
2958
3042
  const position = source.length + context.offset;
2959
- const st0 = context.state ?? 0;
2960
- const st1 = context.state = st0 | state;
2961
- const cache = syntax && memo.get(position, syntax, st1);
3043
+ const stateOuter = context.state ?? 0;
3044
+ const stateInner = context.state = stateOuter | state;
3045
+ const cache = syntax && stateInner & memo.targets && memo.get(position, syntax, stateInner);
2962
3046
  const result = cache ? cache.length === 0 ? global_1.undefined : [cache[0], source.slice(cache[1])] : parser({
2963
3047
  source,
2964
3048
  context
2965
3049
  });
2966
3050
 
2967
- if (syntax && st0 & context.memorable) {
2968
- cache ?? memo.set(position, syntax, st1, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result, '').length);
3051
+ if (syntax && stateOuter & memo.targets) {
3052
+ cache ?? memo.set(position, syntax, stateInner, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result, '').length);
2969
3053
  }
2970
3054
 
2971
- if (result && !st0 && memo.length >= position + 2) {
3055
+ if (result && !stateOuter && memo.length >= position + 2) {
2972
3056
  memo.clear(position + 2);
2973
3057
  }
2974
3058
 
2975
- context.state = st0;
3059
+ context.state = stateOuter;
2976
3060
  return result;
2977
3061
  }));
2978
3062
  }
@@ -3200,8 +3284,11 @@ Object.defineProperty(exports, "__esModule", ({
3200
3284
  exports.Memo = void 0;
3201
3285
 
3202
3286
  class Memo {
3203
- constructor() {
3287
+ constructor({
3288
+ targets = ~0
3289
+ } = {}) {
3204
3290
  this.memory = [];
3291
+ this.targets = targets;
3205
3292
  }
3206
3293
 
3207
3294
  get length() {
@@ -3595,6 +3682,8 @@ const global_1 = __webpack_require__(4128);
3595
3682
 
3596
3683
  const parser_1 = __webpack_require__(6728);
3597
3684
 
3685
+ const memo_1 = __webpack_require__(1090);
3686
+
3598
3687
  const segment_1 = __webpack_require__(9002);
3599
3688
 
3600
3689
  const header_1 = __webpack_require__(5702);
@@ -3616,9 +3705,11 @@ const array_1 = __webpack_require__(8112);
3616
3705
  function bind(target, settings) {
3617
3706
  let context = { ...settings,
3618
3707
  host: settings.host ?? new url_1.ReadonlyURL(global_1.location.pathname, global_1.location.origin),
3619
- memorable: 236
3620
- /* State.backtrackable */
3708
+ memo: new memo_1.Memo({
3709
+ targets: 236
3710
+ /* State.backtrackers */
3621
3711
 
3712
+ })
3622
3713
  };
3623
3714
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
3624
3715
  const blocks = [];
@@ -3958,6 +4049,8 @@ const global_1 = __webpack_require__(4128);
3958
4049
 
3959
4050
  const parser_1 = __webpack_require__(6728);
3960
4051
 
4052
+ const memo_1 = __webpack_require__(1090);
4053
+
3961
4054
  const segment_1 = __webpack_require__(9002);
3962
4055
 
3963
4056
  const header_1 = __webpack_require__(5702);
@@ -3988,9 +4081,11 @@ function parse(source, opts = {}, context) {
3988
4081
  ...(context?.resources && {
3989
4082
  resources: context.resources
3990
4083
  }),
3991
- memorable: 236
3992
- /* State.backtrackable */
4084
+ memo: new memo_1.Memo({
4085
+ targets: 236
4086
+ /* State.backtrackers */
3993
4087
 
4088
+ })
3994
4089
  };
3995
4090
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
3996
4091
  const node = (0, dom_1.frag)();
@@ -5478,15 +5573,16 @@ const source_1 = __webpack_require__(6743);
5478
5573
 
5479
5574
  const dom_1 = __webpack_require__(3252);
5480
5575
 
5481
- exports.cite = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.validate)('>>', (0, combinator_1.reverse)((0, combinator_1.tails)([(0, source_1.str)(/^>*(?=>>[^>\s]+[^\S\n]*(?:$|\n))/), (0, combinator_1.union)([anchor_1.anchor, // Subject page representation.
5576
+ exports.cite = (0, combinator_1.creation)(1, false, (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.validate)('>>', (0, combinator_1.reverse)((0, combinator_1.tails)([(0, source_1.str)(/^>*(?=>>[^>\s]+\s*$)/), (0, combinator_1.union)([anchor_1.anchor, // Subject page representation.
5482
5577
  // リンクの実装は後で検討
5483
- (0, combinator_1.focus)(/^>>\.[^\S\n]*(?:$|\n)/, () => [[(0, dom_1.html)('a', {
5578
+ (0, combinator_1.focus)(/^>>\.(?=\s*$)/, () => [[(0, dom_1.html)('a', {
5484
5579
  class: 'anchor'
5485
- }, '>>.')], '']), (0, combinator_1.focus)(/^>>#\S*[^\S\n]*(?:$|\n)/, ({
5580
+ }, '>>.')], '']), (0, combinator_1.focus)(/^>>#\S*(?=\s*$)/, ({
5486
5581
  source
5487
5582
  }) => [[(0, dom_1.html)('a', {
5488
5583
  class: 'anchor'
5489
- }, source)], '']), (0, combinator_1.focus)(/^>>https?:\/\/\w\S*[^\S\n]*(?:$|\n)/, ({
5584
+ }, source)], '']), // Support all domains, but don't support IP(v6) addresses.
5585
+ (0, combinator_1.focus)(/^>>https?:\/\/[^\p{C}\p{S}\p{P}\s]\S*(?=\s*$)/u, ({
5490
5586
  source
5491
5587
  }) => [[(0, dom_1.html)('a', {
5492
5588
  class: 'anchor',
@@ -5816,8 +5912,6 @@ const deletion_1 = __webpack_require__(7501);
5816
5912
 
5817
5913
  const mark_1 = __webpack_require__(2480);
5818
5914
 
5819
- const emstrong_1 = __webpack_require__(6132);
5820
-
5821
5915
  const emphasis_1 = __webpack_require__(3867);
5822
5916
 
5823
5917
  const strong_1 = __webpack_require__(8072);
@@ -5836,7 +5930,7 @@ const bracket_1 = __webpack_require__(5196);
5836
5930
 
5837
5931
  const source_1 = __webpack_require__(6743);
5838
5932
 
5839
- exports.inline = (0, combinator_1.union)([escape_1.escape, annotation_1.annotation, reference_1.reference, template_1.template, comment_1.comment, math_1.math, extension_1.extension, ruby_1.ruby, link_1.link, media_1.media, html_1.html, insertion_1.insertion, deletion_1.deletion, mark_1.mark, emstrong_1.emstrong, strong_1.strong, emphasis_1.emphasis, code_1.code, htmlentity_1.htmlentity, shortmedia_1.shortmedia, autolink_1.autolink, bracket_1.bracket, source_1.text]);
5933
+ exports.inline = (0, combinator_1.union)([escape_1.escape, annotation_1.annotation, reference_1.reference, template_1.template, comment_1.comment, math_1.math, extension_1.extension, ruby_1.ruby, link_1.link, media_1.media, html_1.html, insertion_1.insertion, deletion_1.deletion, mark_1.mark, strong_1.strong, emphasis_1.emphasis, code_1.code, htmlentity_1.htmlentity, shortmedia_1.shortmedia, autolink_1.autolink, bracket_1.bracket, source_1.text]);
5840
5934
 
5841
5935
  var indexee_1 = __webpack_require__(1269);
5842
5936
 
@@ -5948,13 +6042,21 @@ exports.autolink = (0, combinator_1.fmap)((0, combinator_1.validate)(/^(?:[@#>0-
5948
6042
  /* State.autolink */
5949
6043
  , false, (0, combinator_1.syntax)(2
5950
6044
  /* Syntax.autolink */
5951
- , 1, 1, 0
5952
- /* State.none */
6045
+ , 1, 1, ~1
6046
+ /* State.shortcut */
5953
6047
  , (0, combinator_1.some)((0, combinator_1.union)([url_1.url, email_1.email, // Escape unmatched email-like strings.
5954
- (0, source_1.str)(/^[0-9a-z]+(?:[.+_-][0-9a-z]+)*(?:@(?:[0-9a-z]+(?:[.-][0-9a-z]+)*)?)*/i), channel_1.channel, account_1.account, // Escape unmatched account-like strings.
6048
+ (0, combinator_1.focus)(/^[0-9a-z](?:[_.+-](?=[0-9a-z])|[0-9a-z])*(?:@(?:[0-9a-z]+(?:[.-][0-9a-z]+)*)?)*/i, ({
6049
+ source
6050
+ }) => {
6051
+ if (source.length > 255 || source.includes('@')) return [[source], ''];
6052
+ const i = source.indexOf('_');
6053
+ if (i === -1) return [[source], ''];
6054
+ return [[source.slice(0, i)], source.slice(i)];
6055
+ }), channel_1.channel, account_1.account, // Escape unmatched account-like strings.
5955
6056
  (0, source_1.str)(/^@+[0-9a-z]*(?:-[0-9a-z]+)*/i), // Escape invalid leading characters.
5956
- (0, source_1.str)(new RegExp(/^(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])(?=#)/u.source.replace('emoji', hashtag_1.emoji), 'u')), hashtag_1.hashtag, hashnum_1.hashnum, // Escape unmatched hashtag-like strings.
5957
- (0, source_1.str)(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])*/u.source.replace('emoji', hashtag_1.emoji), 'u')), anchor_1.anchor]))))), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)]);
6057
+ (0, source_1.str)(new RegExp(/^(?:[^\p{C}\p{S}\p{P}\s]|emoji)(?=#)/u.source.replace('emoji', hashtag_1.emoji), 'u')), hashtag_1.hashtag, hashnum_1.hashnum, // Escape unmatched hashtag-like strings.
6058
+ (0, source_1.str)(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|')*/u.source.replace('emoji', hashtag_1.emoji), 'u')), // Escape invalid leading characters.
6059
+ (0, source_1.str)(/^[0-9\p{Sc}](?=>)/u), anchor_1.anchor]))))), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)]);
5958
6060
 
5959
6061
  /***/ }),
5960
6062
 
@@ -6070,7 +6172,7 @@ const source_1 = __webpack_require__(6743);
6070
6172
  const dom_1 = __webpack_require__(3252); // https://html.spec.whatwg.org/multipage/input.html
6071
6173
 
6072
6174
 
6073
- exports.email = (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:[.+_-](?=[^\W_])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*(?![0-9a-z])/i), ([source]) => source.length <= 255), ({
6175
+ exports.email = (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:[_.+-](?=[0-9a-z])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*(?![0-9a-z])/i), ([source]) => source.length <= 255), ({
6074
6176
  source
6075
6177
  }) => [[(0, dom_1.html)('a', {
6076
6178
  class: 'email',
@@ -6102,7 +6204,7 @@ const dom_1 = __webpack_require__(3252);
6102
6204
 
6103
6205
  exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.constraint)(1
6104
6206
  /* State.shortcut */
6105
- , false, (0, combinator_1.open)('#', (0, source_1.str)(new RegExp(/^[0-9]{1,16}(?![^\p{C}\p{S}\p{P}\s]|emoji|['_])/u.source.replace(/emoji/, hashtag_1.emoji), 'u')))), (0, combinator_1.convert)(source => `[${source}]{ ${source.slice(1)} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
6207
+ , false, (0, combinator_1.open)('#', (0, source_1.str)(new RegExp(/^[0-9]{1,16}(?![^\p{C}\p{S}\p{P}\s]|emoji|')/u.source.replace(/emoji/, hashtag_1.emoji), 'u')))), (0, combinator_1.convert)(source => `[${source}]{ ${source.slice(1)} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
6106
6208
  class: 'hashnum',
6107
6209
  href: null
6108
6210
  })]));
@@ -6133,7 +6235,7 @@ const dom_1 = __webpack_require__(3252); // https://example/hashtags/a must be a
6133
6235
  exports.emoji = String.raw`\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F`;
6134
6236
  exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.constraint)(1
6135
6237
  /* State.shortcut */
6136
- , false, (0, combinator_1.open)('#', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*\//i), ([source]) => source.length <= 253 + 1), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/^(?=[0-9]{0,127}_?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|_(?=[^\p{C}\p{S}\p{P}\s]|emoji)){1,128}/u.source, /(?!_?(?:[^\p{C}\p{S}\p{P}\s]|emoji)|')/u.source].join('').replace(/emoji/g, exports.emoji), 'u')), ([source]) => source.length <= 128)]))), (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/hashtags/')}` : `/hashtags/${source.slice(1)}`} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
6238
+ , false, (0, combinator_1.open)('#', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*\//i), ([source]) => source.length <= 253 + 1), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/^(?=(?:[0-9]{1,127}_?)?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji|'))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|(?<!')'|_(?=[^\p{C}\p{S}\p{P}\s]|emoji|')){1,128}/u.source, /(?!_?(?:[^\p{C}\p{S}\p{P}\s]|emoji|(?<!')'))/u.source].join('').replace(/emoji/g, exports.emoji), 'u')), ([source]) => source.length <= 128)]))), (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/hashtags/')}` : `/hashtags/${source.slice(1)}`} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
6137
6239
  class: 'hashtag'
6138
6240
  }, el.innerText)]));
6139
6241
 
@@ -6156,7 +6258,7 @@ const link_1 = __webpack_require__(9628);
6156
6258
 
6157
6259
  const source_1 = __webpack_require__(6743);
6158
6260
 
6159
- const closer = /^[-+*=~^,.;:!?]*(?=[\\"`|\[\](){}<>]|$)/;
6261
+ const closer = /^[-+*=~^_,.;:!?]*(?=[\\"`|\[\](){}<>]|$)/;
6160
6262
  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.focus)(/^[\x21-\x7E]+/, (0, combinator_1.some)((0, combinator_1.union)([bracket, (0, combinator_1.some)(source_1.unescsource, closer)])))), (0, combinator_1.convert)(url => `{ ${url} }`, (0, combinator_1.union)([link_1.unsafelink])))));
6161
6263
  const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.precedence)(2, (0, combinator_1.union)([(0, combinator_1.surround)('(', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')'), ')', true), (0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']'), ']', true), (0, combinator_1.surround)('{', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}'), '}', true), (0, combinator_1.surround)('"', (0, combinator_1.precedence)(8, (0, combinator_1.some)(source_1.unescsource, '"')), '"', true)]))));
6162
6264
 
@@ -6331,10 +6433,6 @@ const combinator_1 = __webpack_require__(2087);
6331
6433
 
6332
6434
  const inline_1 = __webpack_require__(1160);
6333
6435
 
6334
- const emstrong_1 = __webpack_require__(6132);
6335
-
6336
- const strong_1 = __webpack_require__(8072);
6337
-
6338
6436
  const source_1 = __webpack_require__(6743);
6339
6437
 
6340
6438
  const visibility_1 = __webpack_require__(7618);
@@ -6343,65 +6441,11 @@ const dom_1 = __webpack_require__(3252);
6343
6441
 
6344
6442
  const array_1 = __webpack_require__(8112);
6345
6443
 
6346
- exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*'), (0, combinator_1.syntax)(0
6444
+ exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('_'), (0, combinator_1.syntax)(0
6347
6445
  /* Syntax.none */
6348
6446
  , 1, 1, 0
6349
6447
  /* State.none */
6350
- , (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([strong_1.strong, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, strong_1.strong, exports.emphasis]))])), '*')), (0, source_1.str)('*'), false, ([, bs], rest) => [[(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]));
6351
-
6352
- /***/ }),
6353
-
6354
- /***/ 6132:
6355
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6356
-
6357
- "use strict";
6358
-
6359
-
6360
- Object.defineProperty(exports, "__esModule", ({
6361
- value: true
6362
- }));
6363
- exports.emstrong = void 0;
6364
-
6365
- const combinator_1 = __webpack_require__(2087);
6366
-
6367
- const inline_1 = __webpack_require__(1160);
6368
-
6369
- const strong_1 = __webpack_require__(8072);
6370
-
6371
- const emphasis_1 = __webpack_require__(3867);
6372
-
6373
- const source_1 = __webpack_require__(6743);
6374
-
6375
- const visibility_1 = __webpack_require__(7618);
6376
-
6377
- const dom_1 = __webpack_require__(3252);
6378
-
6379
- const array_1 = __webpack_require__(8112);
6380
-
6381
- 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]))])));
6382
- 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]))])));
6383
- exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('***'), (0, combinator_1.syntax)(0
6384
- /* Syntax.none */
6385
- , 1, 1, 0
6386
- /* State.none */
6387
- , (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)])))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], rest, context) => {
6388
- switch (cs[0]) {
6389
- case '***':
6390
- return [[(0, dom_1.html)('em', [(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))])], rest];
6391
-
6392
- case '**':
6393
- 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)))], rest.slice(1)] : [(0, array_1.unshift)(['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], ds), rest])({
6394
- source: rest,
6395
- context
6396
- }) ?? [['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest];
6397
-
6398
- case '*':
6399
- return (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' ? [[(0, dom_1.html)('strong', (0, array_1.unshift)([(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds)))], rest.slice(2)] : [(0, array_1.unshift)(['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], ds), rest])({
6400
- source: rest,
6401
- context
6402
- }) ?? [['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest];
6403
- }
6404
- }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]));
6448
+ , (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('_')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '_'), exports.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]));
6405
6449
 
6406
6450
  /***/ }),
6407
6451
 
@@ -6427,19 +6471,11 @@ exports.escape = (0, combinator_1.union)([({
6427
6471
  source,
6428
6472
  context
6429
6473
  }) => {
6430
- if (source.length < 3) return;
6431
-
6432
6474
  switch (source[0]) {
6433
- case '*':
6434
- if (source.length < 4) return;
6435
- return source[3] === source[0] && source[2] === source[0] && source[1] === source[0] ? repeat({
6436
- source,
6437
- context
6438
- }) : global_1.undefined;
6439
-
6440
6475
  case '+':
6441
6476
  case '~':
6442
6477
  case '=':
6478
+ if (!source[2]) return;
6443
6479
  return source[2] === source[0] && source[1] === source[0] ? repeat({
6444
6480
  source,
6445
6481
  context
@@ -6502,10 +6538,12 @@ const dom_1 = __webpack_require__(3252);
6502
6538
 
6503
6539
  exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.constraint)(32
6504
6540
  /* State.index */
6505
- , false, (0, combinator_1.syntax)(1024
6541
+ , false, (0, combinator_1.syntax)(2048
6506
6542
  /* Syntax.index */
6507
- , 2, 1, 254
6508
- /* State.linkable */
6543
+ , 2, 1, 250
6544
+ /* State.linkers */
6545
+ | 4
6546
+ /* State.media */
6509
6547
  , (0, visibility_1.startTight)((0, combinator_1.open)((0, source_1.stropt)(/^\|?/), (0, visibility_1.trimBlankEnd)((0, combinator_1.some)((0, combinator_1.union)([signature, inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]])), true)))), ']', false, ([, ns], rest) => [[(0, dom_1.html)('a', (0, dom_1.defrag)(ns))], rest])), ([el]) => [(0, dom_1.define)(el, {
6510
6548
  id: el.id ? null : global_1.undefined,
6511
6549
  class: 'index',
@@ -6707,7 +6745,7 @@ const array_1 = __webpack_require__(8112); // Don't use the symbols already used
6707
6745
  // All syntax surrounded by square brackets shouldn't contain line breaks.
6708
6746
 
6709
6747
 
6710
- exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[:', '[^'], (0, combinator_1.surround)((0, source_1.str)(/^\[[:^]/), (0, combinator_1.syntax)(512
6748
+ exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[:', '[^'], (0, combinator_1.surround)((0, source_1.str)(/^\[[:^]/), (0, combinator_1.syntax)(1024
6711
6749
  /* Syntax.placeholder */
6712
6750
  , 2, 1, 0
6713
6751
  /* State.none */
@@ -6928,8 +6966,10 @@ const textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8
6928
6966
  /* State.link */
6929
6967
  , false, (0, combinator_1.syntax)(256
6930
6968
  /* Syntax.link */
6931
- , 2, 10, 254
6932
- /* State.linkable */
6969
+ , 2, 10, 250
6970
+ /* State.linkers */
6971
+ | 4
6972
+ /* State.media */
6933
6973
  , (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)([inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]]), ']', true)), (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) => {
6934
6974
  return parse(content, params, rest, context);
6935
6975
  }))));
@@ -6939,10 +6979,8 @@ const medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8
6939
6979
  /* State.media */
6940
6980
  , false, (0, combinator_1.syntax)(256
6941
6981
  /* Syntax.link */
6942
- , 2, 10, 254
6943
- /* State.linkable */
6944
- ^ 4
6945
- /* State.media */
6982
+ , 2, 10, 250
6983
+ /* State.linkers */
6946
6984
  , (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(content, params, rest, context)))));
6947
6985
  exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => parse(content, params, rest, context)))));
6948
6986
  exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)), (0, source_1.str)(/^[^\s{}]+/)]);
@@ -7172,8 +7210,8 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '
7172
7210
  /* State.media */
7173
7211
  , false, (0, combinator_1.syntax)(64
7174
7212
  /* Syntax.media */
7175
- , 2, 10, 0
7176
- /* State.none */
7213
+ , 2, 10, ~8
7214
+ /* State.link */
7177
7215
  , (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.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']', [[/^\\?\n/, 9]]), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
7178
7216
  const INSECURE_URI = params.shift();
7179
7217
  const url = new url_1.ReadonlyURL((0, link_1.resolve)(INSECURE_URI, context.host ?? global_1.location, context.url ?? context.host ?? global_1.location), context.host?.href || global_1.location.href);
@@ -7195,7 +7233,7 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '
7195
7233
  if (context.state & 8
7196
7234
  /* State.link */
7197
7235
  ) return [[el], rest];
7198
- if (cache && cache.tagName !== 'IMG') return (0, combinator_1.creation)(10, (..._) => [[el], rest])({
7236
+ if (cache && cache.tagName !== 'IMG') return (0, combinator_1.creation)(10, _ => [[el], rest])({
7199
7237
  source: '!',
7200
7238
  context
7201
7239
  });
@@ -7279,7 +7317,7 @@ const dom_1 = __webpack_require__(3252);
7279
7317
 
7280
7318
  exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('[[', (0, combinator_1.constraint)(64
7281
7319
  /* State.reference */
7282
- , false, (0, combinator_1.syntax)(4096
7320
+ , false, (0, combinator_1.syntax)(8192
7283
7321
  /* Syntax.reference */
7284
7322
  , 6, 1, 128
7285
7323
  /* State.annotation */
@@ -7335,11 +7373,17 @@ const dom_1 = __webpack_require__(3252);
7335
7373
 
7336
7374
  const array_1 = __webpack_require__(8112);
7337
7375
 
7338
- exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.syntax)(0
7339
- /* Syntax.none */
7340
- , 2, 1, 0
7341
- /* State.none */
7342
- , (0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.sequence)([(0, combinator_1.surround)('[', (0, combinator_1.focus)(/^(?:\\[^\n]|[^\\[\](){}"\n])+(?=]\()/, text), ']'), (0, combinator_1.surround)('(', (0, combinator_1.focus)(/^(?:\\[^\n]|[^\\[\](){}"\n])+(?=\))/, text), ')')]), ([texts]) => (0, visibility_1.isStartTightNodes)(texts)), ([texts, rubies]) => {
7376
+ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.syntax)(512
7377
+ /* Syntax.ruby */
7378
+ , 2, 1, -1
7379
+ /* State.all */
7380
+ , (0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.sequence)([(0, combinator_1.surround)('[', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ']'), (0, combinator_1.surround)('(', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ')')]), ([texts, rubies], _, context) => [(0, parser_1.eval)(text({
7381
+ source: texts,
7382
+ context
7383
+ }), [])[0] ?? '', (0, parser_1.eval)(text({
7384
+ source: rubies,
7385
+ context
7386
+ }), [])[0] ?? '']), ([texts, rubies]) => texts && rubies && (0, visibility_1.isStartTightNodes)(texts)), ([texts, rubies]) => {
7343
7387
  texts[texts.length - 1] === '' && texts.pop();
7344
7388
 
7345
7389
  switch (true) {
@@ -7458,8 +7502,6 @@ const combinator_1 = __webpack_require__(2087);
7458
7502
 
7459
7503
  const inline_1 = __webpack_require__(1160);
7460
7504
 
7461
- const emstrong_1 = __webpack_require__(6132);
7462
-
7463
7505
  const source_1 = __webpack_require__(6743);
7464
7506
 
7465
7507
  const visibility_1 = __webpack_require__(7618);
@@ -7468,11 +7510,11 @@ const dom_1 = __webpack_require__(3252);
7468
7510
 
7469
7511
  const array_1 = __webpack_require__(8112);
7470
7512
 
7471
- exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('**'), (0, combinator_1.syntax)(0
7513
+ exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*'), (0, combinator_1.syntax)(0
7472
7514
  /* Syntax.none */
7473
7515
  , 1, 1, 0
7474
7516
  /* State.none */
7475
- , (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('**')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, exports.strong]))])), '*')), (0, source_1.str)('**'), false, ([, bs], rest) => [[(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]));
7517
+ , (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), exports.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]));
7476
7518
 
7477
7519
  /***/ }),
7478
7520
 
@@ -7499,8 +7541,8 @@ const array_1 = __webpack_require__(8112);
7499
7541
 
7500
7542
  exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('{{', (0, combinator_1.syntax)(0
7501
7543
  /* Syntax.none */
7502
- , 2, 1, 0
7503
- /* State.none */
7544
+ , 2, 1, -1
7545
+ /* State.all */
7504
7546
  , (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), '}}', true, ([, ns = []], rest) => [[(0, dom_1.html)('span', {
7505
7547
  class: 'template'
7506
7548
  }, `{{${ns.join('').replace(/\x1B/g, '')}}}`)], rest]));
@@ -7598,16 +7640,7 @@ Object.defineProperty(exports, "__esModule", ({
7598
7640
  exports.japanese = void 0;
7599
7641
 
7600
7642
  function japanese(char) {
7601
- switch (char) {
7602
- case '、':
7603
- case '。':
7604
- case '!':
7605
- case '?':
7606
- return true;
7607
-
7608
- default:
7609
- return false;
7610
- }
7643
+ return /^[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?]/u.test(char);
7611
7644
  }
7612
7645
 
7613
7646
  exports.japanese = japanese;
@@ -8286,9 +8319,10 @@ const str_1 = __webpack_require__(2790);
8286
8319
 
8287
8320
  const dom_1 = __webpack_require__(3252);
8288
8321
 
8289
- exports.delimiter = /[\s\x00-\x7F]|\S[#>]|[()、。!?][^\S\n]*(?=\\\n)/;
8322
+ exports.delimiter = /[\s\x00-\x7F]|\S[#>]|[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?][^\S\n]*(?=\\\n)/u;
8290
8323
  exports.nonWhitespace = /[\S\n]|$/;
8291
8324
  exports.nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/;
8325
+ const nssb = /^[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?][^\S\n]*(?=\\\n)/u;
8292
8326
  const repeat = (0, str_1.str)(/^(.)\1*/);
8293
8327
  exports.text = (0, combinator_1.creation)(1, false, ({
8294
8328
  source,
@@ -8305,25 +8339,15 @@ exports.text = (0, combinator_1.creation)(1, false, ({
8305
8339
  switch (source[0]) {
8306
8340
  case '\x1B':
8307
8341
  case '\\':
8308
- switch (source[1]) {
8309
- case '、':
8310
- case '。':
8311
- case '!':
8312
- case '?':
8313
- return (0, exports.text)({
8314
- source: source.slice(1),
8315
- context
8316
- });
8317
- }
8318
-
8319
- break;
8342
+ if (!nssb.test(source.slice(1))) break;
8343
+ return (0, exports.text)({
8344
+ source: source.slice(1),
8345
+ context
8346
+ });
8320
8347
 
8321
- case '、':
8322
- case '。':
8323
- case '':
8324
- case '?':
8325
- const i = source.slice(1).search(exports.nonWhitespace) + 1;
8326
- if (i > 0 && source.slice(i, i + 2) === '\\\n') return [[source[0], (0, dom_1.html)('span', {
8348
+ default:
8349
+ const i = source.match(nssb)?.[0].length ?? -1;
8350
+ if (i !== -1) return [[source[0], (0, dom_1.html)('span', {
8327
8351
  class: 'linebreak'
8328
8352
  })], source.slice(i + 2)];
8329
8353
  }
@@ -8347,6 +8371,7 @@ exports.text = (0, combinator_1.creation)(1, false, ({
8347
8371
  case '\n':
8348
8372
  return [[(0, dom_1.html)('br')], source.slice(1)];
8349
8373
 
8374
+ case '_':
8350
8375
  case '*':
8351
8376
  case '+':
8352
8377
  case '~':