securemark 0.295.7 → 0.295.9

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 (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +243 -298
  3. package/package.json +1 -1
  4. package/src/combinator/control/constraint/contract.ts +5 -21
  5. package/src/combinator/data/parser/context.ts +3 -1
  6. package/src/combinator/data/parser/sequence.ts +3 -3
  7. package/src/combinator/data/parser.ts +5 -2
  8. package/src/parser/api/normalize.ts +1 -1
  9. package/src/parser/block/extension/figbase.test.ts +3 -0
  10. package/src/parser/block/extension/figbase.ts +1 -1
  11. package/src/parser/block/paragraph.test.ts +2 -2
  12. package/src/parser/block/reply/cite.ts +2 -1
  13. package/src/parser/block/reply/quote.ts +2 -1
  14. package/src/parser/block/reply.ts +2 -1
  15. package/src/parser/inline/emphasis.ts +3 -3
  16. package/src/parser/inline/emstrong.ts +4 -4
  17. package/src/parser/inline/extension/index.ts +2 -2
  18. package/src/parser/inline/extension/indexer.ts +3 -3
  19. package/src/parser/inline/extension/placeholder.ts +2 -2
  20. package/src/parser/inline/html.ts +2 -1
  21. package/src/parser/inline/htmlentity.test.ts +1 -1
  22. package/src/parser/inline/htmlentity.ts +10 -5
  23. package/src/parser/inline/italic.ts +2 -2
  24. package/src/parser/inline/link.ts +4 -2
  25. package/src/parser/inline/mark.ts +2 -2
  26. package/src/parser/inline/math.test.ts +10 -2
  27. package/src/parser/inline/math.ts +2 -2
  28. package/src/parser/inline/remark.ts +1 -1
  29. package/src/parser/inline/strong.ts +3 -3
  30. package/src/parser/node.ts +10 -0
  31. package/src/parser/source/str.ts +9 -7
  32. package/src/parser/source/text.ts +10 -42
  33. package/src/parser/visibility.ts +38 -69
  34. /package/src/combinator/data/{data.ts → node.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.295.7 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.295.9 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"));
@@ -2603,42 +2603,18 @@ Object.defineProperty(exports, "__esModule", ({
2603
2603
  value: true
2604
2604
  }));
2605
2605
  exports.verify = exports.validate = void 0;
2606
- const parser_1 = __webpack_require__(605);
2607
2606
  const combinator_1 = __webpack_require__(3484);
2608
2607
  function validate(pattern, parser) {
2609
2608
  if (typeof pattern === 'function') return guard(pattern, parser);
2610
2609
  const match = (0, combinator_1.matcher)(pattern, false);
2611
- return input => {
2612
- const {
2613
- context
2614
- } = input;
2615
- const {
2616
- source,
2617
- position
2618
- } = context;
2619
- if (position === source.length) return;
2620
- if (!match(input)) return;
2621
- return parser(input);
2622
- };
2610
+ return input => match(input) ? parser(input) : undefined;
2623
2611
  }
2624
2612
  exports.validate = validate;
2625
2613
  function guard(f, parser) {
2626
2614
  return input => f(input) ? parser(input) : undefined;
2627
2615
  }
2628
2616
  function verify(parser, cond) {
2629
- return (0, parser_1.failsafe)(input => {
2630
- const {
2631
- context
2632
- } = input;
2633
- const {
2634
- source,
2635
- position
2636
- } = context;
2637
- if (position === source.length) return;
2638
- const result = parser(input);
2639
- if (result && !cond(result, context)) return;
2640
- return result;
2641
- });
2617
+ return (0, combinator_1.bind)(parser, (nodes, context) => cond(nodes, context) ? nodes : undefined);
2642
2618
  }
2643
2619
  exports.verify = verify;
2644
2620
 
@@ -3260,151 +3236,6 @@ exports.fmap = fmap;
3260
3236
 
3261
3237
  /***/ },
3262
3238
 
3263
- /***/ 3602
3264
- (__unused_webpack_module, exports) {
3265
-
3266
- "use strict";
3267
-
3268
-
3269
- Object.defineProperty(exports, "__esModule", ({
3270
- value: true
3271
- }));
3272
- exports.List = void 0;
3273
- class List {
3274
- constructor(nodes) {
3275
- this.length = 0;
3276
- this.head = undefined;
3277
- this.last = undefined;
3278
- if (nodes === undefined) return;
3279
- for (let i = 0; i < nodes.length; ++i) {
3280
- this.push(nodes[i]);
3281
- }
3282
- }
3283
- get tail() {
3284
- return this.head?.next;
3285
- }
3286
- insert(node, before) {
3287
- if (before === undefined) return this.push(node);
3288
- if (before === this.head) return this.unshift(node);
3289
- if (++this.length === 1) {
3290
- return this.head = this.last = node;
3291
- }
3292
- const next = node.next = before;
3293
- const prev = node.prev = next.prev;
3294
- return next.prev = prev.next = node;
3295
- }
3296
- delete(node) {
3297
- if (--this.length === 0) {
3298
- this.head = this.last = undefined;
3299
- } else {
3300
- const {
3301
- next,
3302
- prev
3303
- } = node;
3304
- prev === undefined ? this.head = next : prev.next = next;
3305
- next === undefined ? this.last = prev : next.prev = prev;
3306
- }
3307
- node.next = node.prev = undefined;
3308
- return node;
3309
- }
3310
- unshift(node) {
3311
- if (++this.length === 1) {
3312
- return this.head = this.last = node;
3313
- }
3314
- node.next = this.head;
3315
- return this.head = this.head.prev = node;
3316
- }
3317
- push(node) {
3318
- if (++this.length === 1) {
3319
- return this.head = this.last = node;
3320
- }
3321
- node.prev = this.last;
3322
- return this.last = this.last.next = node;
3323
- }
3324
- shift() {
3325
- if (this.length === 0) return;
3326
- return this.delete(this.head);
3327
- }
3328
- pop() {
3329
- if (this.length === 0) return;
3330
- return this.delete(this.last);
3331
- }
3332
- import(list, before) {
3333
- if (list.length === 0) return this;
3334
- if (this.length === 0) {
3335
- this.head = list.head;
3336
- this.last = list.last;
3337
- this.length = list.length;
3338
- list.clear();
3339
- return this;
3340
- }
3341
- const head = list.head;
3342
- const last = list.last;
3343
- const next = last.next = before;
3344
- const prev = head.prev = before?.prev ?? this.last;
3345
- next === undefined ? this.last = last : next.prev = last;
3346
- prev.next = head;
3347
- this.length += list.length;
3348
- list.clear();
3349
- return this;
3350
- }
3351
- clear() {
3352
- this.length = 0;
3353
- this.head = this.last = undefined;
3354
- }
3355
- *[Symbol.iterator]() {
3356
- for (let node = this.head; node && this.head;) {
3357
- const next = node.next;
3358
- yield node;
3359
- node = next;
3360
- }
3361
- }
3362
- flatMap(f) {
3363
- const acc = new List();
3364
- for (let node = this.head; node && this.head;) {
3365
- const next = node.next;
3366
- acc.import(f(node));
3367
- node = next;
3368
- }
3369
- return acc;
3370
- }
3371
- foldl(f, acc) {
3372
- for (let node = this.head; node && this.head;) {
3373
- const next = node.next;
3374
- acc = f(acc, node);
3375
- node = next;
3376
- }
3377
- return acc;
3378
- }
3379
- foldr(f, acc) {
3380
- for (let node = this.last; node && this.head;) {
3381
- const prev = node.prev;
3382
- acc = f(node, acc);
3383
- node = prev;
3384
- }
3385
- return acc;
3386
- }
3387
- find(f) {
3388
- for (let node = this.head; node && this.head;) {
3389
- const next = node.next;
3390
- if (f(node)) return node;
3391
- node = next;
3392
- }
3393
- }
3394
- }
3395
- exports.List = List;
3396
- (function (List) {
3397
- class Node {
3398
- constructor() {
3399
- this.next = undefined;
3400
- this.prev = undefined;
3401
- }
3402
- }
3403
- List.Node = Node;
3404
- })(List || (exports.List = List = {}));
3405
-
3406
- /***/ },
3407
-
3408
3239
  /***/ 385
3409
3240
  (__unused_webpack_module, exports, __webpack_require__) {
3410
3241
 
@@ -3562,6 +3393,151 @@ exports.Delimiters = Delimiters;
3562
3393
 
3563
3394
  /***/ },
3564
3395
 
3396
+ /***/ 1610
3397
+ (__unused_webpack_module, exports) {
3398
+
3399
+ "use strict";
3400
+
3401
+
3402
+ Object.defineProperty(exports, "__esModule", ({
3403
+ value: true
3404
+ }));
3405
+ exports.List = void 0;
3406
+ class List {
3407
+ constructor(nodes) {
3408
+ this.length = 0;
3409
+ this.head = undefined;
3410
+ this.last = undefined;
3411
+ if (nodes === undefined) return;
3412
+ for (let i = 0; i < nodes.length; ++i) {
3413
+ this.push(nodes[i]);
3414
+ }
3415
+ }
3416
+ get tail() {
3417
+ return this.head?.next;
3418
+ }
3419
+ insert(node, before) {
3420
+ if (before === undefined) return this.push(node);
3421
+ if (before === this.head) return this.unshift(node);
3422
+ if (++this.length === 1) {
3423
+ return this.head = this.last = node;
3424
+ }
3425
+ const next = node.next = before;
3426
+ const prev = node.prev = next.prev;
3427
+ return next.prev = prev.next = node;
3428
+ }
3429
+ delete(node) {
3430
+ if (--this.length === 0) {
3431
+ this.head = this.last = undefined;
3432
+ } else {
3433
+ const {
3434
+ next,
3435
+ prev
3436
+ } = node;
3437
+ prev === undefined ? this.head = next : prev.next = next;
3438
+ next === undefined ? this.last = prev : next.prev = prev;
3439
+ }
3440
+ node.next = node.prev = undefined;
3441
+ return node;
3442
+ }
3443
+ unshift(node) {
3444
+ if (++this.length === 1) {
3445
+ return this.head = this.last = node;
3446
+ }
3447
+ node.next = this.head;
3448
+ return this.head = this.head.prev = node;
3449
+ }
3450
+ push(node) {
3451
+ if (++this.length === 1) {
3452
+ return this.head = this.last = node;
3453
+ }
3454
+ node.prev = this.last;
3455
+ return this.last = this.last.next = node;
3456
+ }
3457
+ shift() {
3458
+ if (this.length === 0) return;
3459
+ return this.delete(this.head);
3460
+ }
3461
+ pop() {
3462
+ if (this.length === 0) return;
3463
+ return this.delete(this.last);
3464
+ }
3465
+ import(list, before) {
3466
+ if (list.length === 0) return this;
3467
+ if (this.length === 0) {
3468
+ this.head = list.head;
3469
+ this.last = list.last;
3470
+ this.length = list.length;
3471
+ list.clear();
3472
+ return this;
3473
+ }
3474
+ const head = list.head;
3475
+ const last = list.last;
3476
+ const next = last.next = before;
3477
+ const prev = head.prev = before?.prev ?? this.last;
3478
+ next === undefined ? this.last = last : next.prev = last;
3479
+ prev.next = head;
3480
+ this.length += list.length;
3481
+ list.clear();
3482
+ return this;
3483
+ }
3484
+ clear() {
3485
+ this.length = 0;
3486
+ this.head = this.last = undefined;
3487
+ }
3488
+ *[Symbol.iterator]() {
3489
+ for (let node = this.head; node && this.head;) {
3490
+ const next = node.next;
3491
+ yield node;
3492
+ node = next;
3493
+ }
3494
+ }
3495
+ flatMap(f) {
3496
+ const acc = new List();
3497
+ for (let node = this.head; node && this.head;) {
3498
+ const next = node.next;
3499
+ acc.import(f(node));
3500
+ node = next;
3501
+ }
3502
+ return acc;
3503
+ }
3504
+ foldl(f, acc) {
3505
+ for (let node = this.head; node && this.head;) {
3506
+ const next = node.next;
3507
+ acc = f(acc, node);
3508
+ node = next;
3509
+ }
3510
+ return acc;
3511
+ }
3512
+ foldr(f, acc) {
3513
+ for (let node = this.last; node && this.head;) {
3514
+ const prev = node.prev;
3515
+ acc = f(node, acc);
3516
+ node = prev;
3517
+ }
3518
+ return acc;
3519
+ }
3520
+ find(f) {
3521
+ for (let node = this.head; node && this.head;) {
3522
+ const next = node.next;
3523
+ if (f(node)) return node;
3524
+ node = next;
3525
+ }
3526
+ }
3527
+ }
3528
+ exports.List = List;
3529
+ (function (List) {
3530
+ class Node {
3531
+ constructor() {
3532
+ this.next = undefined;
3533
+ this.prev = undefined;
3534
+ }
3535
+ }
3536
+ List.Node = Node;
3537
+ })(List || (exports.List = List = {}));
3538
+
3539
+ /***/ },
3540
+
3565
3541
  /***/ 605
3566
3542
  (__unused_webpack_module, exports, __webpack_require__) {
3567
3543
 
@@ -3572,17 +3548,18 @@ Object.defineProperty(exports, "__esModule", ({
3572
3548
  value: true
3573
3549
  }));
3574
3550
  exports.failsafe = exports.subinput = exports.input = exports.Context = exports.Node = exports.List = void 0;
3575
- const data_1 = __webpack_require__(3602);
3551
+ const node_1 = __webpack_require__(1610);
3576
3552
  Object.defineProperty(exports, "List", ({
3577
3553
  enumerable: true,
3578
3554
  get: function () {
3579
- return data_1.List;
3555
+ return node_1.List;
3580
3556
  }
3581
3557
  }));
3582
3558
  const delimiter_1 = __webpack_require__(385);
3583
3559
  class Node {
3584
- constructor(value) {
3560
+ constructor(value, flags = 0) {
3585
3561
  this.value = value;
3562
+ this.flags = flags;
3586
3563
  this.next = undefined;
3587
3564
  this.prev = undefined;
3588
3565
  }
@@ -3813,7 +3790,7 @@ function constraint(state, positive, parser) {
3813
3790
  };
3814
3791
  }
3815
3792
  exports.constraint = constraint;
3816
- function matcher(pattern, advance) {
3793
+ function matcher(pattern, advance, verify) {
3817
3794
  const count = typeof pattern === 'object' ? /[^^\\*+][*+]/.test(pattern.source) : false;
3818
3795
  switch (typeof pattern) {
3819
3796
  case 'string':
@@ -3825,6 +3802,7 @@ function matcher(pattern, advance) {
3825
3802
  position
3826
3803
  } = context;
3827
3804
  if (!source.startsWith(pattern, position)) return;
3805
+ if (verify?.(source, position, pattern.length) === false) return;
3828
3806
  if (advance) {
3829
3807
  context.position += pattern.length;
3830
3808
  }
@@ -3842,6 +3820,7 @@ function matcher(pattern, advance) {
3842
3820
  if (!pattern.test(source)) return;
3843
3821
  const src = source.slice(position, pattern.lastIndex);
3844
3822
  count && consume(src.length, context);
3823
+ if (verify?.(source, position, src.length) === false) return;
3845
3824
  if (advance) {
3846
3825
  context.position += src.length;
3847
3826
  }
@@ -3888,7 +3867,7 @@ exports.inits = inits;
3888
3867
  /***/ },
3889
3868
 
3890
3869
  /***/ 3989
3891
- (__unused_webpack_module, exports) {
3870
+ (__unused_webpack_module, exports, __webpack_require__) {
3892
3871
 
3893
3872
  "use strict";
3894
3873
 
@@ -3897,9 +3876,10 @@ Object.defineProperty(exports, "__esModule", ({
3897
3876
  value: true
3898
3877
  }));
3899
3878
  exports.sequence = void 0;
3879
+ const parser_1 = __webpack_require__(605);
3900
3880
  function sequence(parsers) {
3901
3881
  if (parsers.length === 1) return parsers[0];
3902
- return input => {
3882
+ return (0, parser_1.failsafe)(input => {
3903
3883
  const {
3904
3884
  context
3905
3885
  } = input;
@@ -3915,7 +3895,7 @@ function sequence(parsers) {
3915
3895
  nodes = nodes?.import(result) ?? result;
3916
3896
  }
3917
3897
  return nodes;
3918
- };
3898
+ });
3919
3899
  }
3920
3900
  exports.sequence = sequence;
3921
3901
 
@@ -4980,7 +4960,7 @@ const parser_1 = __webpack_require__(605);
4980
4960
  const combinator_1 = __webpack_require__(3484);
4981
4961
  const label_1 = __webpack_require__(2178);
4982
4962
  const dom_1 = __webpack_require__(394);
4983
- exports.figbase = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/\[?\$-(?:[0-9]+\.)*0\]?(?:$|[ \n])/y, (0, combinator_1.line)((0, combinator_1.union)([label_1.label]))), ([{
4963
+ exports.figbase = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/\[?\$-(?:[0-9]+\.)*0\]?[^\S\n]*(?:$|\n)/y, (0, combinator_1.line)((0, combinator_1.union)([label_1.label]))), ([{
4984
4964
  value: el
4985
4965
  }]) => {
4986
4966
  const label = el.getAttribute('data-label');
@@ -5776,7 +5756,7 @@ const delimiter = new RegExp(`${cite_1.syntax.source}|${quote_1.syntax.source}`,
5776
5756
  exports.reply = (0, combinator_1.block)((0, combinator_1.validate)(cite_1.syntax, (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([cite_1.cite, quote_1.quote, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, delimiter), (0, visibility_1.visualize)((0, combinator_1.fmap)((0, combinator_1.some)(inline_1.inline), (ns, {
5777
5757
  source,
5778
5758
  position
5779
- }) => source[position - 1] === '\n' ? ns : ns.push(new parser_1.Node((0, dom_1.html)('br'))) && ns)))])), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('p', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns)))))]))));
5759
+ }) => source[position - 1] === '\n' ? ns : ns.push(new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.invisible */)) && ns)))])), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('p', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns)))))]))));
5780
5760
 
5781
5761
  /***/ },
5782
5762
 
@@ -5828,7 +5808,7 @@ exports.cite = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.op
5828
5808
  ...(0, util_1.invalid)('cite', 'syntax', 'Invalid syntax')
5829
5809
  }, (0, dom_1.defrag)([`${quotes}>`, typeof node === 'object' ? (0, dom_1.define)(node, {
5830
5810
  'data-depth': `${quotes.length + 1}`
5831
- }, node.innerText.slice(1)) : node.slice(1)]))), new parser_1.Node((0, dom_1.html)('br'))]);
5811
+ }, node.innerText.slice(1)) : node.slice(1)]))), new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.invisible */)]);
5832
5812
  }));
5833
5813
 
5834
5814
  /***/ },
@@ -5856,7 +5836,7 @@ exports.quote = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combina
5856
5836
  math_1.math, autolink_1.autolink, source_1.unescsource])))), (ns, {
5857
5837
  source,
5858
5838
  position
5859
- }) => new parser_1.List([new parser_1.Node(source[position - 1] === '\n' ? ns.pop().value : (0, dom_1.html)('br')), new parser_1.Node((0, dom_1.html)('span', {
5839
+ }) => new parser_1.List([new parser_1.Node(source[position - 1] === '\n' ? ns.pop().value : (0, dom_1.html)('br'), 1 /* Flag.invisible */), new parser_1.Node((0, dom_1.html)('span', {
5860
5840
  class: 'quote'
5861
5841
  }, (0, dom_1.defrag)((0, util_1.unwrap)(ns))))].reverse())), false));
5862
5842
 
@@ -6724,7 +6704,7 @@ const source_1 = __webpack_require__(8745);
6724
6704
  const visibility_1 = __webpack_require__(6364);
6725
6705
  const util_1 = __webpack_require__(4992);
6726
6706
  const dom_1 = __webpack_require__(394);
6727
- exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)(/\*(?!\*)/y), (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, '*', visibility_1.afterNonblank), strong_1.strong]))))), (0, source_1.str)('*'), false, [], ([, bs]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('em', (0, dom_1.defrag)((0, util_1.unwrap)(bs))))]), ([as, bs]) => bs && as.import(bs)));
6707
+ exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*', (source, position, range) => !source.startsWith('*', position + range)), (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.beforeNonblank)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank), strong_1.strong]))))), (0, source_1.str)('*'), false, [], ([, bs]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('em', (0, dom_1.defrag)((0, util_1.unwrap)(bs))))]), ([as, bs]) => bs && as.import(bs)));
6728
6708
 
6729
6709
  /***/ },
6730
6710
 
@@ -6752,7 +6732,7 @@ const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, comb
6752
6732
  // 開閉が明示的でない構文は開閉の不明確な記号による再帰的適用を行わず
6753
6733
  // 可能な限り早く閉じるよう解析しなければならない。
6754
6734
  // このため終端記号の後ろを見て終端を中止し同じ構文を再帰的に適用してはならない。
6755
- exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('***', (0, combinator_1.surround)('', (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank)]))), (0, source_1.str)(/\*{1,3}/y), false, [], ([, bs, cs], context) => {
6735
+ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('***', (0, combinator_1.surround)('', (0, visibility_1.beforeNonblank)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank)]))), (0, source_1.strs)('*', 3), false, [], ([, bs, cs], context) => {
6756
6736
  const {
6757
6737
  buffer
6758
6738
  } = context;
@@ -6908,7 +6888,7 @@ const source_1 = __webpack_require__(8745);
6908
6888
  const visibility_1 = __webpack_require__(6364);
6909
6889
  const util_1 = __webpack_require__(4992);
6910
6890
  const dom_1 = __webpack_require__(394);
6911
- 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, [3 | 4 /* Backtrack.common */], ([, bs], context) => context.linebreak === 0 && (0, visibility_1.trimBlankNodeEnd)(bs).length > 0 ? new parser_1.List([new parser_1.Node((0, dom_1.html)('a', {
6891
+ 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.beforeNonblank)((0, combinator_1.some)((0, combinator_1.inits)([inline_1.inline, exports.signature]), ']', [[']', 1]])))), (0, source_1.str)(']'), false, [3 | 4 /* Backtrack.common */], ([, bs], context) => context.linebreak === 0 && (0, visibility_1.trimBlankNodeEnd)(bs).length > 0 ? new parser_1.List([new parser_1.Node((0, dom_1.html)('a', {
6912
6892
  'data-index': dataindex(bs)
6913
6893
  }, (0, dom_1.defrag)((0, util_1.unwrap)(bs))))]) : undefined, undefined)), ns => {
6914
6894
  const el = ns.head.value;
@@ -7100,10 +7080,10 @@ const dom_1 = __webpack_require__(394);
7100
7080
  // 複合生成インデクスを手動で同期させるより最初から重複のない
7101
7081
  // テキストまたはインデクスを付けて同期が必要な機会を減らすのが
7102
7082
  // 継続的編集において最も簡便となる。
7103
- exports.indexer = (0, combinator_1.surround)(/ \[(?=\|\S)/y, (0, combinator_1.union)([index_1.signature, (0, combinator_1.focus)(/\|(?=\])/y, () => new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
7083
+ exports.indexer = (0, combinator_1.validate)(' [|', (0, combinator_1.surround)(/ \[(?=\|\S)/y, (0, combinator_1.union)([index_1.signature, (0, combinator_1.focus)(/\|(?=\])/y, () => new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
7104
7084
  class: 'indexer',
7105
7085
  'data-index': ''
7106
- }))]))]), /\][^\S\n]*(?:$|\n)/y);
7086
+ }))]))]), /\][^\S\n]*(?:$|\n)/y));
7107
7087
 
7108
7088
  /***/ },
7109
7089
 
@@ -7170,7 +7150,7 @@ const dom_1 = __webpack_require__(394);
7170
7150
  // All syntax surrounded by square brackets shouldn't contain line breaks.
7171
7151
  exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.surround)(
7172
7152
  // ^はabbrで使用済みだが^:などのようにして分離使用可能
7173
- (0, source_1.str)(/\[[:^|]/y), (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, [3 | 4 /* Backtrack.common */], (_, context) => new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
7153
+ (0, source_1.str)(/\[[:^|]/y), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.beforeNonblank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]])))), (0, source_1.str)(']'), false, [3 | 4 /* Backtrack.common */], (_, context) => new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
7174
7154
  class: 'invalid',
7175
7155
  ...(0, util_1.invalid)('extension', 'syntax', `Invalid start symbol or linebreak`)
7176
7156
  }, context.source.slice(context.position - context.range, context.position)))]), ([as, bs]) => bs && as.import(bs)));
@@ -7206,7 +7186,7 @@ Object.setPrototypeOf(attrspecs, null);
7206
7186
  Object.values(attrspecs).forEach(o => Object.setPrototypeOf(o, null));
7207
7187
  exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/<[a-z]+(?=[ >])/yi, (0, combinator_1.union)([(0, combinator_1.surround)(
7208
7188
  // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
7209
- (0, source_1.str)(/<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[ >])/y), (0, combinator_1.precedence)(9, (0, combinator_1.some)((0, combinator_1.union)([exports.attribute]))), (0, combinator_1.open)((0, source_1.str)(/ ?/y), (0, source_1.str)('>'), true), true, [], ([as, bs = new parser_1.List(), cs], context) => new parser_1.List([new parser_1.Node(elem(as.head.value.slice(1), false, [...(0, util_1.unwrap)(as.import(bs).import(cs))], new parser_1.List(), new parser_1.List(), context))]), ([as, bs = new parser_1.List()], context) => new parser_1.List([new parser_1.Node(elem(as.head.value.slice(1), false, [...(0, util_1.unwrap)(as.import(bs))], new parser_1.List(), new parser_1.List(), context))])), (0, combinator_1.match)(new RegExp(String.raw`<(${TAGS.join('|')})(?=[ >])`, 'y'), (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.precedence)(9, (0, combinator_1.some)(exports.attribute)), (0, combinator_1.open)((0, source_1.str)(/ ?/y), (0, source_1.str)('>'), true), true, [], ([as, bs = new parser_1.List(), cs]) => as.import(bs).import(cs), ([as, bs = new parser_1.List()]) => as.import(bs)),
7189
+ (0, source_1.str)(/<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[ >])/y), (0, combinator_1.precedence)(9, (0, combinator_1.some)((0, combinator_1.union)([exports.attribute]))), (0, combinator_1.open)((0, source_1.str)(/ ?/y), (0, source_1.str)('>'), true), true, [], ([as, bs = new parser_1.List(), cs], context) => new parser_1.List([new parser_1.Node(elem(as.head.value.slice(1), false, [...(0, util_1.unwrap)(as.import(bs).import(cs))], new parser_1.List(), new parser_1.List(), context), as.head.value === '<wbr' ? 1 /* Flag.invisible */ : 0 /* Flag.none */)]), ([as, bs = new parser_1.List()], context) => new parser_1.List([new parser_1.Node(elem(as.head.value.slice(1), false, [...(0, util_1.unwrap)(as.import(bs))], new parser_1.List(), new parser_1.List(), context))])), (0, combinator_1.match)(new RegExp(String.raw`<(${TAGS.join('|')})(?=[ >])`, 'y'), (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.precedence)(9, (0, combinator_1.some)(exports.attribute)), (0, combinator_1.open)((0, source_1.str)(/ ?/y), (0, source_1.str)('>'), true), true, [], ([as, bs = new parser_1.List(), cs]) => as.import(bs).import(cs), ([as, bs = new parser_1.List()]) => as.import(bs)),
7210
7190
  // 不可視のHTML構造が可視構造を変化させるべきでない。
7211
7191
  // 可視のHTMLは優先度変更を検討する。
7212
7192
  // このため`<>`記号は将来的に共通構造を変化させる可能性があり
@@ -7280,19 +7260,21 @@ Object.defineProperty(exports, "__esModule", ({
7280
7260
  }));
7281
7261
  exports.htmlentity = exports.unsafehtmlentity = void 0;
7282
7262
  const parser_1 = __webpack_require__(605);
7263
+ const node_1 = __webpack_require__(8068);
7283
7264
  const combinator_1 = __webpack_require__(3484);
7284
7265
  const source_1 = __webpack_require__(8745);
7285
7266
  const util_1 = __webpack_require__(4992);
7286
7267
  const dom_1 = __webpack_require__(394);
7287
- exports.unsafehtmlentity = (0, combinator_1.surround)((0, source_1.str)('&'), (0, source_1.str)(/[0-9A-Za-z]+/y), (0, source_1.str)(';'), false, [3 | 8 /* Backtrack.unescapable */], ([as, bs, cs]) => new parser_1.List([new parser_1.Node(parser(as.head.value + bs.head.value + cs.head.value))]), ([as, bs]) => new parser_1.List([new parser_1.Node(as.head.value + (bs?.head?.value ?? ''))]));
7268
+ exports.unsafehtmlentity = (0, combinator_1.surround)((0, source_1.str)('&'), (0, source_1.str)(/[0-9A-Za-z]+/y), (0, source_1.str)(';'), false, [3 | 8 /* Backtrack.unescapable */], ([as, bs, cs]) => new parser_1.List([new parser_1.Node(parser(as.head.value + bs.head.value + cs.head.value), (0, node_1.isinvisibleHTMLEntityName)(bs.head.value) ? 1 /* Flag.invisible */ : 0 /* Flag.none */)]), ([as, bs]) => new parser_1.List([new parser_1.Node(as.head.value + (bs?.head?.value ?? ''))]));
7288
7269
  exports.htmlentity = (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([{
7289
- value
7290
- }]) => new parser_1.List([length === 1 || value.at(-1) !== ';' ? new parser_1.Node(value) : new parser_1.Node((0, dom_1.html)('span', {
7270
+ value,
7271
+ flags
7272
+ }]) => new parser_1.List([value.length === 1 || value.at(-1) !== ';' ? new parser_1.Node(value, flags) : new parser_1.Node((0, dom_1.html)('span', {
7291
7273
  class: 'invalid',
7292
7274
  ...(0, util_1.invalid)('htmlentity', 'syntax', 'Invalid HTML entity')
7293
7275
  }, value))]));
7294
7276
  const parser = (el => entity => {
7295
- if (entity === '&NewLine;') return ' ';
7277
+ if (entity === '&NewLine;') return entity;
7296
7278
  el.innerHTML = entity;
7297
7279
  return el.textContent;
7298
7280
  })((0, dom_1.html)('span'));
@@ -7342,7 +7324,7 @@ const dom_1 = __webpack_require__(394);
7342
7324
  // 可読性のため実際にはオブリーク体を指定する。
7343
7325
  // 斜体は単語に使うとかえって見づらく読み飛ばしやすくなるため使わないべきであり
7344
7326
  // ある程度の長さのある文に使うのが望ましい。
7345
- exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('///', (0, combinator_1.surround)('', (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), '///', visibility_1.afterNonblank)), '///', false, [], ([, bs], {
7327
+ exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('///', (0, combinator_1.surround)('', (0, visibility_1.beforeNonblank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), '///', visibility_1.afterNonblank)), '///', false, [], ([, bs], {
7346
7328
  buffer
7347
7329
  }) => buffer.import(bs), ([, bs], {
7348
7330
  buffer
@@ -7387,7 +7369,7 @@ exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combi
7387
7369
  }, {
7388
7370
  value: params = undefined
7389
7371
  } = {}], context) => {
7390
- if (context.state & 8 /* State.link */) return new parser_1.List([new parser_1.Node(context.source.slice(context.position - context.range, context.position))]);
7372
+ if (context.state & 8 /* State.link */) return new parser_1.List([new parser_1.Node(context.source.slice(context.position - context.range, context.position).replace(/\\($|.)/g, '$1'))]);
7391
7373
  if (content.last.value === "\u001F" /* Command.Separator */) {
7392
7374
  content.pop();
7393
7375
  if (params === undefined) {
@@ -7413,7 +7395,7 @@ exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8
7413
7395
  }, {
7414
7396
  value: params
7415
7397
  }], context) => new parser_1.List([new parser_1.Node(parse(content, params, context))])))));
7416
- exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(/ /y, (0, source_1.str)(/\S+/y)), (0, source_1.str)(/[^\s{}]+/y)]);
7398
+ exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(' ', (0, source_1.str)(/\S+/y)), (0, source_1.str)(/[^\s{}]+/y)]);
7417
7399
  exports.option = (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/ nofollow(?=[ }])/y), () => new parser_1.List([new parser_1.Node(' rel="nofollow"')])), (0, source_1.str)(/ [a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[ }])/yi), (0, source_1.str)(/ [^\s{}]+/y)]);
7418
7400
  function parse(content, params, context) {
7419
7401
  const INSECURE_URI = params.shift().value;
@@ -7523,7 +7505,7 @@ const indexee_1 = __webpack_require__(7610);
7523
7505
  const visibility_1 = __webpack_require__(6364);
7524
7506
  const util_1 = __webpack_require__(4992);
7525
7507
  const dom_1 = __webpack_require__(394);
7526
- exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('==', (0, combinator_1.surround)('', (0, visibility_1.tightStart)((0, combinator_1.state)(2 /* State.mark */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), '==', visibility_1.afterNonblank))), '==', false, [], ([, bs], {
7508
+ exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('==', (0, combinator_1.surround)('', (0, visibility_1.beforeNonblank)((0, combinator_1.state)(2 /* State.mark */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), '==', visibility_1.afterNonblank))), '==', false, [], ([, bs], {
7527
7509
  buffer
7528
7510
  }) => buffer.import(bs), ([, bs], {
7529
7511
  buffer
@@ -7559,7 +7541,7 @@ const source_1 = __webpack_require__(8745);
7559
7541
  const util_1 = __webpack_require__(4992);
7560
7542
  const dom_1 = __webpack_require__(394);
7561
7543
  const forbiddenCommand = /\\(?:begin|tiny|huge|large)(?![a-z])|:\/\//i;
7562
- exports.math = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.union)([(0, combinator_1.surround)(/\$(?={)/y, (0, combinator_1.precedence)(4, bracket), '$', false, [3 | 16 /* Backtrack.escapable */]), (0, combinator_1.surround)(/\$(?![\s{}])/y, (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(source_1.escsource, /\s?\$|[`"{}\n]/y), (0, combinator_1.precedence)(4, bracket)]))), /\$(?![-0-9A-Za-z])/y, false, [3 | 16 /* Backtrack.escapable */])]), ({
7544
+ exports.math = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.union)([(0, combinator_1.surround)(/\$(?={)/y, (0, combinator_1.precedence)(4, bracket), '$', false, [3 | 16 /* Backtrack.escapable */]), (0, combinator_1.surround)(/\$(?![\s{}])/y, (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(source_1.escsource, /\$|[`"{}\n]/y), (0, combinator_1.precedence)(4, bracket)]))), /(?<!\s)\$(?![-0-9A-Za-z])/y, false, [3 | 16 /* Backtrack.escapable */])]), ({
7563
7545
  context: {
7564
7546
  source,
7565
7547
  caches: {
@@ -7801,7 +7783,7 @@ const inline_1 = __webpack_require__(7973);
7801
7783
  const source_1 = __webpack_require__(8745);
7802
7784
  const util_1 = __webpack_require__(4992);
7803
7785
  const dom_1 = __webpack_require__(394);
7804
- exports.remark = (0, combinator_1.lazy)(() => (0, combinator_1.fallback)((0, combinator_1.surround)((0, source_1.str)(/\[%(?=[ \n])/y), (0, combinator_1.precedence)(3, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /[ \n]%\]/y, [[/[ \n]%\]/y, 3]]))), (0, combinator_1.close)(source_1.text, (0, source_1.str)(`%]`)), true, [], ([as, bs = new parser_1.List(), cs]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
7786
+ exports.remark = (0, combinator_1.lazy)(() => (0, combinator_1.fallback)((0, combinator_1.surround)((0, source_1.str)(/\[%(?=[ \n])/y), (0, combinator_1.precedence)(3, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /[ \n]%\]/y, [[/[ \n]%\]/y, 3]]))), (0, combinator_1.close)(source_1.text, (0, source_1.str)('%]')), true, [], ([as, bs = new parser_1.List(), cs]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
7805
7787
  class: 'remark'
7806
7788
  }, [(0, dom_1.html)('input', {
7807
7789
  type: 'checkbox'
@@ -7956,7 +7938,7 @@ const source_1 = __webpack_require__(8745);
7956
7938
  const visibility_1 = __webpack_require__(6364);
7957
7939
  const util_1 = __webpack_require__(4992);
7958
7940
  const dom_1 = __webpack_require__(394);
7959
- exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)(/\*\*(?!\*)/y), (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, '*', visibility_1.afterNonblank), emphasis_1.emphasis]))))), (0, source_1.str)('**'), false, [], ([, bs]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('strong', (0, dom_1.defrag)((0, util_1.unwrap)(bs))))]), ([as, bs]) => bs && as.import(bs)));
7941
+ exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('**', (source, position, range) => !source.startsWith('*', position + range)), (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, visibility_1.beforeNonblank)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank), emphasis_1.emphasis]))))), (0, source_1.str)('**'), false, [], ([, bs]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('strong', (0, dom_1.defrag)((0, util_1.unwrap)(bs))))]), ([as, bs]) => bs && as.import(bs)));
7960
7942
 
7961
7943
  /***/ },
7962
7944
 
@@ -7985,6 +7967,24 @@ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combin
7985
7967
 
7986
7968
  /***/ },
7987
7969
 
7970
+ /***/ 8068
7971
+ (__unused_webpack_module, exports, __webpack_require__) {
7972
+
7973
+ "use strict";
7974
+
7975
+
7976
+ Object.defineProperty(exports, "__esModule", ({
7977
+ value: true
7978
+ }));
7979
+ exports.isinvisibleHTMLEntityName = void 0;
7980
+ const normalize_1 = __webpack_require__(4490);
7981
+ function isinvisibleHTMLEntityName(name) {
7982
+ return normalize_1.invisibleHTMLEntityNames.includes(name);
7983
+ }
7984
+ exports.isinvisibleHTMLEntityName = isinvisibleHTMLEntityName;
7985
+
7986
+ /***/ },
7987
+
7988
7988
  /***/ 1657
7989
7989
  (__unused_webpack_module, exports, __webpack_require__) {
7990
7990
 
@@ -8577,11 +8577,11 @@ Object.defineProperty(exports, "__esModule", ({
8577
8577
  exports.strs = exports.str = void 0;
8578
8578
  const parser_1 = __webpack_require__(605);
8579
8579
  const combinator_1 = __webpack_require__(3484);
8580
- function str(pattern) {
8581
- return (0, combinator_1.matcher)(pattern, true);
8580
+ function str(pattern, verify) {
8581
+ return (0, combinator_1.matcher)(pattern, true, verify);
8582
8582
  }
8583
8583
  exports.str = str;
8584
- function strs(pattern) {
8584
+ function strs(pattern, limit = -1) {
8585
8585
  return ({
8586
8586
  context
8587
8587
  }) => {
@@ -8589,11 +8589,11 @@ function strs(pattern) {
8589
8589
  source
8590
8590
  } = context;
8591
8591
  let acc = '';
8592
- for (; context.position < source.length && source.startsWith(pattern, context.position);) {
8592
+ for (let i = 0; i !== limit && context.position < source.length && source.startsWith(pattern, context.position); ++i) {
8593
8593
  acc += pattern;
8594
8594
  context.position += pattern.length;
8595
8595
  }
8596
- return new parser_1.List([new parser_1.Node(acc)]);
8596
+ return acc ? new parser_1.List([new parser_1.Node(acc)]) : undefined;
8597
8597
  };
8598
8598
  }
8599
8599
  exports.strs = strs;
@@ -8613,7 +8613,6 @@ exports.isAlphanumeric = exports.next = exports.canSkip = exports.txt = exports.
8613
8613
  const parser_1 = __webpack_require__(605);
8614
8614
  const combinator_1 = __webpack_require__(3484);
8615
8615
  const dom_1 = __webpack_require__(394);
8616
- //const delimiter = /(?=[\\!@#$&"`\[\](){}<>()[]{}*%|\r\n]|([+~=])\1|\/{3}|\s(?:\\?(?:$|\s)|[$%])|:\/\/)/g;
8617
8616
  exports.nonWhitespace = /[^ \t ]/g;
8618
8617
  const text = input => {
8619
8618
  const {
@@ -8637,16 +8636,17 @@ const text = input => {
8637
8636
  case '\n':
8638
8637
  return new parser_1.List();
8639
8638
  default:
8639
+ const flags = source[position + 1].trimStart() ? 0 /* Flag.none */ : 1 /* Flag.invisible */;
8640
8640
  (0, combinator_1.consume)(1, context);
8641
8641
  context.position += 1;
8642
- return new parser_1.List([new parser_1.Node(source.slice(position + 1, context.position))]);
8642
+ return new parser_1.List([new parser_1.Node(source.slice(position + 1, context.position), flags)]);
8643
8643
  }
8644
8644
  case '\r':
8645
8645
  (0, combinator_1.consume)(-1, context);
8646
8646
  return new parser_1.List();
8647
8647
  case '\n':
8648
8648
  context.linebreak ||= source.length - position;
8649
- return new parser_1.List([new parser_1.Node((0, dom_1.html)('br'))]);
8649
+ return new parser_1.List([new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.invisible */)]);
8650
8650
  default:
8651
8651
  if (context.sequential) return new parser_1.List([new parser_1.Node(char)]);
8652
8652
  exports.nonWhitespace.lastIndex = position + 1;
@@ -8658,7 +8658,10 @@ const text = input => {
8658
8658
  (0, combinator_1.consume)(i - 1, context);
8659
8659
  context.position += i - 1;
8660
8660
  const linestart = position === 0 || source[position - 1] === '\n';
8661
- return position === context.position || s && !linestart || lineend ? new parser_1.List() : new parser_1.List([new parser_1.Node(source.slice(position, context.position))]);
8661
+ if (position === context.position || s && !linestart || lineend) return new parser_1.List();
8662
+ const str = source.slice(position, context.position);
8663
+ const flags = str.length === 1 && str.trimStart() === '' ? 1 /* Flag.invisible */ : 0 /* Flag.none */;
8664
+ return new parser_1.List([new parser_1.Node(str, flags)]);
8662
8665
  }
8663
8666
  };
8664
8667
  exports.text = text;
@@ -8758,44 +8761,9 @@ function isAlphanumeric(char) {
8758
8761
  return '0' <= char && char <= '9' || 'A' <= char && char <= 'Z' || 'a' <= char && char <= 'z';
8759
8762
  }
8760
8763
  exports.isAlphanumeric = isAlphanumeric;
8761
- //const dict = new class {
8762
- // constructor() {
8763
- // [
8764
- // '\\',
8765
- // '!',
8766
- // '@',
8767
- // '#',
8768
- // '$',
8769
- // '&',
8770
- // '"',
8771
- // '`',
8772
- // '[',
8773
- // ']',
8774
- // '(',
8775
- // ')',
8776
- // '{',
8777
- // '}',
8778
- // '<',
8779
- // '>',
8780
- // '(',
8781
- // ')',
8782
- // '[',
8783
- // ']',
8784
- // '{',
8785
- // '}',
8786
- // '*',
8787
- // '%',
8788
- // '|',
8789
- // '\r',
8790
- // '\n',
8791
- // ].forEach(c =>
8792
- // this[c.charCodeAt(0)] = undefined);
8793
- // }
8794
- //};
8795
8764
  function seek(source, position, state) {
8796
8765
  for (let i = position + 1; i < source.length; ++i) {
8797
8766
  const fst = source[i];
8798
- //if (fst.charCodeAt(0) in dict) return i;
8799
8767
  switch (fst) {
8800
8768
  case '\\':
8801
8769
  case '!':
@@ -9066,15 +9034,15 @@ exports.stringify = stringify;
9066
9034
  Object.defineProperty(exports, "__esModule", ({
9067
9035
  value: true
9068
9036
  }));
9069
- exports.trimBlankNodeEnd = exports.trimBlankEnd = exports.trimBlankStart = exports.trimBlank = exports.isTightNodeStart = exports.isLooseNodeStart = exports.tightStart = exports.blankWith = exports.afterNonblank = exports.visualize = void 0;
9037
+ exports.trimBlankNodeEnd = exports.trimBlankEnd = exports.trimBlankStart = exports.trimBlank = exports.isTightNodeStart = exports.isLooseNodeStart = exports.beforeNonblank = exports.blankWith = exports.afterNonblank = exports.visualize = void 0;
9070
9038
  const parser_1 = __webpack_require__(605);
9071
9039
  const combinator_1 = __webpack_require__(3484);
9072
- const htmlentity_1 = __webpack_require__(470);
9073
9040
  const normalize_1 = __webpack_require__(4490);
9074
9041
  var blank;
9075
9042
  (function (blank) {
9076
9043
  blank.line = new RegExp(/((?:^|\n)[^\S\n]*(?=\S))((?:[^\S\n]|\\(?=$|\s)|&IHN;|<wbr ?>)+(?=$|\n))/g.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'g');
9077
9044
  blank.start = new RegExp(/(?:[^\S\n]|\\(?=$|\s)|&IHN;|<wbr ?>)+/y.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'y');
9045
+ blank.unit = new RegExp(/(?:[^\S\n]|\\(?=$|\s)|&IHN;|<wbr ?>)/y.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'y');
9078
9046
  })(blank || (blank = {}));
9079
9047
  function visualize(parser) {
9080
9048
  return (0, combinator_1.convert)(source => source.replace(blank.line, `$1${"\u001B" /* Command.Escape */}$2`), parser);
@@ -9091,11 +9059,11 @@ exports.blankWith = blankWith;
9091
9059
  function nonblankWith(delimiter) {
9092
9060
  return new RegExp([String.raw`(?<!\s|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr ?>)`, typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source].join(''), 'y');
9093
9061
  }
9094
- function tightStart(parser, except) {
9095
- return input => isTightStart(input, except) ? parser(input) : undefined;
9062
+ function beforeNonblank(parser) {
9063
+ return input => isTightStart(input) ? parser(input) : undefined;
9096
9064
  }
9097
- exports.tightStart = tightStart;
9098
- function isTightStart(input, except) {
9065
+ exports.beforeNonblank = beforeNonblank;
9066
+ function isTightStart(input) {
9099
9067
  const {
9100
9068
  context
9101
9069
  } = input;
@@ -9104,74 +9072,50 @@ function isTightStart(input, except) {
9104
9072
  position
9105
9073
  } = context;
9106
9074
  if (position === source.length) return true;
9107
- if (except && source.startsWith(except, position)) return false;
9108
9075
  switch (source[position]) {
9109
9076
  case ' ':
9110
9077
  case ' ':
9111
9078
  case '\t':
9112
9079
  case '\n':
9113
9080
  return false;
9114
- case '\\':
9115
- return source[position + 1]?.trimStart() !== '';
9116
- case '&':
9117
- switch (true) {
9118
- case source.length - position > 2 && source[position + 1] !== ' ' && (0, htmlentity_1.unsafehtmlentity)(input)?.head?.value.trimStart() === '':
9119
- context.position = position;
9120
- return false;
9121
- }
9122
- context.position = position;
9123
- return true;
9124
- case '<':
9125
- switch (true) {
9126
- case source.length - position >= 5 && source.startsWith('<wbr', position) && (source[position + 4] === '>' || source.startsWith(' >', position + 4)):
9127
- return false;
9128
- }
9129
- return true;
9130
9081
  default:
9131
- return source[position].trimStart() !== '';
9082
+ const reg = blank.unit;
9083
+ reg.lastIndex = position;
9084
+ return !reg.test(source);
9132
9085
  }
9133
9086
  }
9134
9087
  function isLooseNodeStart(nodes) {
9135
9088
  if (nodes.length === 0) return true;
9136
- for (const {
9137
- value: node
9138
- } of nodes) {
9089
+ for (const node of nodes) {
9139
9090
  if (isVisible(node)) return true;
9140
- if (typeof node === 'object' && node.tagName === 'BR') break;
9091
+ if (typeof node.value === 'object' && node.value.tagName === 'BR') break;
9141
9092
  }
9142
9093
  return false;
9143
9094
  }
9144
9095
  exports.isLooseNodeStart = isLooseNodeStart;
9145
9096
  function isTightNodeStart(nodes) {
9146
9097
  if (nodes.length === 0) return true;
9147
- return isVisible(nodes.head.value, 0);
9098
+ return isVisible(nodes.head, 0);
9148
9099
  }
9149
9100
  exports.isTightNodeStart = isTightNodeStart;
9150
9101
  //export function isTightNodeEnd(nodes: readonly (HTMLElement | string)[]): boolean {
9151
9102
  // if (nodes.length === 0) return true;
9152
9103
  // return isVisible(nodes.at(-1)!, -1);
9153
9104
  //}
9154
- function isVisible(node, strpos) {
9155
- switch (typeof node) {
9156
- case 'string':
9157
- const char = node && strpos !== undefined ? node[strpos >= 0 ? strpos : node.length + strpos] : node;
9158
- switch (char) {
9159
- case '':
9160
- case ' ':
9161
- case '\t':
9162
- case '\n':
9163
- return false;
9164
- default:
9165
- return char.trimStart() !== '';
9166
- }
9105
+ function isVisible({
9106
+ value: node,
9107
+ flags
9108
+ }, strpos) {
9109
+ if (strpos === undefined || typeof node !== 'string') return !(flags & 1 /* Flag.invisible */);
9110
+ const char = node && node[strpos && node.length + strpos];
9111
+ switch (char) {
9112
+ case '':
9113
+ case ' ':
9114
+ case '\t':
9115
+ case '\n':
9116
+ return false;
9167
9117
  default:
9168
- switch (node.tagName) {
9169
- case 'BR':
9170
- case 'WBR':
9171
- return false;
9172
- default:
9173
- return true;
9174
- }
9118
+ return char.trimStart() !== '';
9175
9119
  }
9176
9120
  }
9177
9121
  function trimBlank(parser) {
@@ -9220,8 +9164,8 @@ exports.trimBlankEnd = trimBlankEnd;
9220
9164
  // return nodes;
9221
9165
  //}
9222
9166
  function trimBlankNodeEnd(nodes) {
9223
- const skip = nodes.length > 0 && typeof nodes.last?.value === 'object' && nodes.last.value.className === 'indexer' ? nodes.pop() : undefined;
9224
- for (let node = nodes.last; nodes.length > 0 && !isVisible((node = nodes.last).value, -1);) {
9167
+ const skip = typeof nodes.last?.value === 'object' && nodes.last.value.className === 'indexer';
9168
+ for (let node = skip ? nodes.last?.prev : nodes.last; node && !isVisible(node, -1);) {
9225
9169
  if (typeof node.value === 'string') {
9226
9170
  const str = node.value.trimEnd();
9227
9171
  if (str.length > 0) {
@@ -9229,9 +9173,10 @@ function trimBlankNodeEnd(nodes) {
9229
9173
  break;
9230
9174
  }
9231
9175
  }
9232
- nodes.pop();
9176
+ const target = node;
9177
+ node = node.prev;
9178
+ nodes.delete(target);
9233
9179
  }
9234
- skip && nodes.push(skip);
9235
9180
  return nodes;
9236
9181
  }
9237
9182
  exports.trimBlankNodeEnd = trimBlankNodeEnd;