securemark 0.295.8 → 0.296.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 (40) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/design.md +1 -1
  3. package/dist/index.js +268 -282
  4. package/package.json +1 -1
  5. package/src/combinator/control/constraint/contract.ts +5 -21
  6. package/src/combinator/data/parser/context.ts +3 -1
  7. package/src/combinator/data/parser/sequence.ts +3 -3
  8. package/src/combinator/data/parser.ts +7 -2
  9. package/src/parser/api/normalize.ts +10 -7
  10. package/src/parser/block/extension/figbase.test.ts +3 -0
  11. package/src/parser/block/extension/figbase.ts +1 -1
  12. package/src/parser/block/paragraph.test.ts +2 -2
  13. package/src/parser/block/reply/cite.ts +2 -1
  14. package/src/parser/block/reply/quote.ts +2 -1
  15. package/src/parser/block/reply.ts +2 -1
  16. package/src/parser/inline/annotation.test.ts +4 -5
  17. package/src/parser/inline/annotation.ts +2 -2
  18. package/src/parser/inline/emphasis.ts +3 -3
  19. package/src/parser/inline/emstrong.ts +4 -4
  20. package/src/parser/inline/extension/index.ts +2 -2
  21. package/src/parser/inline/extension/indexer.ts +3 -3
  22. package/src/parser/inline/extension/placeholder.ts +2 -2
  23. package/src/parser/inline/html.ts +2 -1
  24. package/src/parser/inline/htmlentity.test.ts +1 -1
  25. package/src/parser/inline/htmlentity.ts +10 -5
  26. package/src/parser/inline/italic.ts +2 -2
  27. package/src/parser/inline/link.test.ts +5 -4
  28. package/src/parser/inline/link.ts +6 -4
  29. package/src/parser/inline/mark.ts +2 -2
  30. package/src/parser/inline/media.test.ts +5 -2
  31. package/src/parser/inline/media.ts +9 -4
  32. package/src/parser/inline/reference.test.ts +5 -6
  33. package/src/parser/inline/reference.ts +2 -2
  34. package/src/parser/inline/remark.ts +1 -1
  35. package/src/parser/inline/strong.ts +3 -3
  36. package/src/parser/node.ts +17 -0
  37. package/src/parser/source/str.ts +9 -7
  38. package/src/parser/source/text.ts +4 -4
  39. package/src/parser/visibility.ts +53 -75
  40. /package/src/combinator/data/{data.ts → node.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.295.8 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.296.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("Prism"), require("DOMPurify"));
@@ -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
 
@@ -4407,9 +4387,7 @@ Object.defineProperty(exports, "__esModule", ({
4407
4387
  value: true
4408
4388
  }));
4409
4389
  exports.escape = exports.invisibleHTMLEntityNames = exports.normalize = void 0;
4410
- const parser_1 = __webpack_require__(605);
4411
- const context_1 = __webpack_require__(8669);
4412
- const htmlentity_1 = __webpack_require__(470);
4390
+ const dom_1 = __webpack_require__(394);
4413
4391
  const UNICODE_REPLACEMENT_CHARACTER = '\uFFFD';
4414
4392
  function normalize(source) {
4415
4393
  return sanitize(format(source));
@@ -4418,7 +4396,7 @@ exports.normalize = normalize;
4418
4396
  function format(source) {
4419
4397
  return source.replace(/\r\n?|[\u2028\u2029]/g, '\n');
4420
4398
  }
4421
- const invalid = new RegExp([/(?![\t\r\n])[\x00-\x1F\x7F]/g.source, /(?!\u200D)[\u2006\u200B-\u200F\u202A-\u202F\u2060\uFEFF]/g.source
4399
+ const invalid = new RegExp([/(?![\t\r\n])[\x00-\x1F\x7F]/g.source, /(?![\u200C\u200D])[\u2006\u200B-\u200F\u202A-\u202F\u2060\uFEFF]/g.source
4422
4400
  // 後読みが重い
4423
4401
  ///(?<![\u1820\u1821])\u180E/g.source,
4424
4402
  ///[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g.source,
@@ -4429,8 +4407,13 @@ function sanitize(source) {
4429
4407
  // https://dev.w3.org/html5/html-author/charref
4430
4408
  // https://en.wikipedia.org/wiki/Whitespace_character
4431
4409
  exports.invisibleHTMLEntityNames = ['Tab', 'NewLine', 'NonBreakingSpace', 'nbsp', 'shy', 'ensp', 'emsp', 'emsp13', 'emsp14', 'numsp', 'puncsp', 'ThinSpace', 'thinsp', 'VeryThinSpace', 'hairsp', 'ZeroWidthSpace', 'NegativeVeryThinSpace', 'NegativeThinSpace', 'NegativeMediumSpace', 'NegativeThickSpace', 'zwj', 'zwnj', 'lrm', 'rlm', 'MediumSpace', 'NoBreak', 'ApplyFunction', 'af', 'InvisibleTimes', 'it', 'InvisibleComma', 'ic'];
4410
+ const parser = (el => entity => {
4411
+ if (entity === '&NewLine;') return entity;
4412
+ el.innerHTML = entity;
4413
+ return el.textContent;
4414
+ })((0, dom_1.html)('span'));
4432
4415
  const unreadableEscapeHTMLEntityNames = exports.invisibleHTMLEntityNames.filter(name => !['Tab', 'NewLine', 'NonBreakingSpace', 'nbsp', 'zwj', 'zwnj'].includes(name));
4433
- const unreadableEscapeCharacters = unreadableEscapeHTMLEntityNames.map(name => (0, htmlentity_1.unsafehtmlentity)((0, parser_1.input)(`&${name};`, new context_1.Context())).head.value);
4416
+ const unreadableEscapeCharacters = unreadableEscapeHTMLEntityNames.map(name => parser(`&${name};`));
4434
4417
  const unreadableEscapeCharacter = new RegExp(`[${unreadableEscapeCharacters.join('')}]`, 'g');
4435
4418
  // https://www.pandanoir.info/entry/2018/03/11/193000
4436
4419
  // http://anti.rosx.net/etc/memo/002_space.html
@@ -4441,7 +4424,7 @@ const unreadableSpecialCharacters = (/* unused pure expression or super */ null
4441
4424
  // ZERO WIDTH SPACE
4442
4425
  '\u200B',
4443
4426
  // ZERO WIDTH NON-JOINER
4444
- '\u200C',
4427
+ //'\u200C',
4445
4428
  // ZERO WIDTH JOINER
4446
4429
  //'\u200D',
4447
4430
  // LEFT-TO-RIGHT MARK
@@ -4980,7 +4963,7 @@ const parser_1 = __webpack_require__(605);
4980
4963
  const combinator_1 = __webpack_require__(3484);
4981
4964
  const label_1 = __webpack_require__(2178);
4982
4965
  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]))), ([{
4966
+ 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
4967
  value: el
4985
4968
  }]) => {
4986
4969
  const label = el.getAttribute('data-label');
@@ -5776,7 +5759,7 @@ const delimiter = new RegExp(`${cite_1.syntax.source}|${quote_1.syntax.source}`,
5776
5759
  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
5760
  source,
5778
5761
  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)))))]))));
5762
+ }) => 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
5763
 
5781
5764
  /***/ },
5782
5765
 
@@ -5828,7 +5811,7 @@ exports.cite = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.op
5828
5811
  ...(0, util_1.invalid)('cite', 'syntax', 'Invalid syntax')
5829
5812
  }, (0, dom_1.defrag)([`${quotes}>`, typeof node === 'object' ? (0, dom_1.define)(node, {
5830
5813
  'data-depth': `${quotes.length + 1}`
5831
- }, node.innerText.slice(1)) : node.slice(1)]))), new parser_1.Node((0, dom_1.html)('br'))]);
5814
+ }, node.innerText.slice(1)) : node.slice(1)]))), new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.invisible */)]);
5832
5815
  }));
5833
5816
 
5834
5817
  /***/ },
@@ -5856,7 +5839,7 @@ exports.quote = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combina
5856
5839
  math_1.math, autolink_1.autolink, source_1.unescsource])))), (ns, {
5857
5840
  source,
5858
5841
  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', {
5842
+ }) => 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
5843
  class: 'quote'
5861
5844
  }, (0, dom_1.defrag)((0, util_1.unwrap)(ns))))].reverse())), false));
5862
5845
 
@@ -6258,7 +6241,7 @@ const inline_1 = __webpack_require__(7973);
6258
6241
  const visibility_1 = __webpack_require__(6364);
6259
6242
  const util_1 = __webpack_require__(4992);
6260
6243
  const dom_1 = __webpack_require__(394);
6261
- exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, (0, combinator_1.surround)('((', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[')', 1]])))), '))', false, [2, 1 | 4 /* Backtrack.common */, 3 | 128 /* Backtrack.doublebracket */], ([, ns], context) => context.linebreak === 0 ? new parser_1.List([new parser_1.Node((0, dom_1.html)('sup', {
6244
+ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, (0, combinator_1.surround)('((', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */, (0, visibility_1.beforeNonblank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[')', 1]])))), '))', false, [2, 1 | 4 /* Backtrack.common */, 3 | 128 /* Backtrack.doublebracket */], ([, ns], context) => context.linebreak === 0 ? new parser_1.List([new parser_1.Node((0, dom_1.html)('sup', {
6262
6245
  class: 'annotation'
6263
6246
  }, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns))))]))]) : undefined, (_, context) => {
6264
6247
  const {
@@ -6724,7 +6707,7 @@ const source_1 = __webpack_require__(8745);
6724
6707
  const visibility_1 = __webpack_require__(6364);
6725
6708
  const util_1 = __webpack_require__(4992);
6726
6709
  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)));
6710
+ 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
6711
 
6729
6712
  /***/ },
6730
6713
 
@@ -6752,7 +6735,7 @@ const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, comb
6752
6735
  // 開閉が明示的でない構文は開閉の不明確な記号による再帰的適用を行わず
6753
6736
  // 可能な限り早く閉じるよう解析しなければならない。
6754
6737
  // このため終端記号の後ろを見て終端を中止し同じ構文を再帰的に適用してはならない。
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) => {
6738
+ 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
6739
  const {
6757
6740
  buffer
6758
6741
  } = context;
@@ -6908,7 +6891,7 @@ const source_1 = __webpack_require__(8745);
6908
6891
  const visibility_1 = __webpack_require__(6364);
6909
6892
  const util_1 = __webpack_require__(4992);
6910
6893
  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', {
6894
+ 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
6895
  'data-index': dataindex(bs)
6913
6896
  }, (0, dom_1.defrag)((0, util_1.unwrap)(bs))))]) : undefined, undefined)), ns => {
6914
6897
  const el = ns.head.value;
@@ -7100,10 +7083,10 @@ const dom_1 = __webpack_require__(394);
7100
7083
  // 複合生成インデクスを手動で同期させるより最初から重複のない
7101
7084
  // テキストまたはインデクスを付けて同期が必要な機会を減らすのが
7102
7085
  // 継続的編集において最も簡便となる。
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', {
7086
+ 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
7087
  class: 'indexer',
7105
7088
  'data-index': ''
7106
- }))]))]), /\][^\S\n]*(?:$|\n)/y);
7089
+ }))]))]), /\][^\S\n]*(?:$|\n)/y));
7107
7090
 
7108
7091
  /***/ },
7109
7092
 
@@ -7170,7 +7153,7 @@ const dom_1 = __webpack_require__(394);
7170
7153
  // All syntax surrounded by square brackets shouldn't contain line breaks.
7171
7154
  exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.surround)(
7172
7155
  // ^は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', {
7156
+ (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
7157
  class: 'invalid',
7175
7158
  ...(0, util_1.invalid)('extension', 'syntax', `Invalid start symbol or linebreak`)
7176
7159
  }, context.source.slice(context.position - context.range, context.position)))]), ([as, bs]) => bs && as.import(bs)));
@@ -7206,7 +7189,7 @@ Object.setPrototypeOf(attrspecs, null);
7206
7189
  Object.values(attrspecs).forEach(o => Object.setPrototypeOf(o, null));
7207
7190
  exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/<[a-z]+(?=[ >])/yi, (0, combinator_1.union)([(0, combinator_1.surround)(
7208
7191
  // 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)),
7192
+ (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
7193
  // 不可視のHTML構造が可視構造を変化させるべきでない。
7211
7194
  // 可視のHTMLは優先度変更を検討する。
7212
7195
  // このため`<>`記号は将来的に共通構造を変化させる可能性があり
@@ -7280,19 +7263,21 @@ Object.defineProperty(exports, "__esModule", ({
7280
7263
  }));
7281
7264
  exports.htmlentity = exports.unsafehtmlentity = void 0;
7282
7265
  const parser_1 = __webpack_require__(605);
7266
+ const node_1 = __webpack_require__(8068);
7283
7267
  const combinator_1 = __webpack_require__(3484);
7284
7268
  const source_1 = __webpack_require__(8745);
7285
7269
  const util_1 = __webpack_require__(4992);
7286
7270
  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 ?? ''))]));
7271
+ 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
7272
  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', {
7273
+ value,
7274
+ flags
7275
+ }]) => 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
7276
  class: 'invalid',
7292
7277
  ...(0, util_1.invalid)('htmlentity', 'syntax', 'Invalid HTML entity')
7293
7278
  }, value))]));
7294
7279
  const parser = (el => entity => {
7295
- if (entity === '&NewLine;') return ' ';
7280
+ if (entity === '&NewLine;') return entity;
7296
7281
  el.innerHTML = entity;
7297
7282
  return el.textContent;
7298
7283
  })((0, dom_1.html)('span'));
@@ -7342,7 +7327,7 @@ const dom_1 = __webpack_require__(394);
7342
7327
  // 可読性のため実際にはオブリーク体を指定する。
7343
7328
  // 斜体は単語に使うとかえって見づらく読み飛ばしやすくなるため使わないべきであり
7344
7329
  // ある程度の長さのある文に使うのが望ましい。
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], {
7330
+ 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
7331
  buffer
7347
7332
  }) => buffer.import(bs), ([, bs], {
7348
7333
  buffer
@@ -7373,7 +7358,7 @@ const optspec = {
7373
7358
  rel: ['nofollow']
7374
7359
  };
7375
7360
  Object.setPrototypeOf(optspec, null);
7376
- exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combinator_1.subsequence)([(0, combinator_1.constraint)(8 /* State.link */, (0, combinator_1.state)(251 /* State.linkers */, (0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]]))), ']', true, [3 | 4 /* Backtrack.common */ | 64 /* Backtrack.link */, 2 | 32 /* Backtrack.ruby */], ([, ns = new parser_1.List()], context) => {
7361
+ exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combinator_1.subsequence)([(0, combinator_1.constraint)(8 /* State.link */, (0, combinator_1.state)(251 /* State.linkers */, (0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, visibility_1.beforeNonblank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]]))), ']', true, [3 | 4 /* Backtrack.common */ | 64 /* Backtrack.link */, 2 | 32 /* Backtrack.ruby */], ([, ns = new parser_1.List()], context) => {
7377
7362
  if (context.linebreak !== 0) {
7378
7363
  const head = context.position - context.range;
7379
7364
  return void (0, combinator_1.setBacktrack)(context, 2 | 64 /* Backtrack.link */ | 32 /* Backtrack.ruby */, head);
@@ -7387,7 +7372,7 @@ exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combi
7387
7372
  }, {
7388
7373
  value: params = undefined
7389
7374
  } = {}], 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))]);
7375
+ 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
7376
  if (content.last.value === "\u001F" /* Command.Separator */) {
7392
7377
  content.pop();
7393
7378
  if (params === undefined) {
@@ -7413,7 +7398,7 @@ exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8
7413
7398
  }, {
7414
7399
  value: params
7415
7400
  }], 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)]);
7401
+ exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(' ', (0, source_1.str)(/\S+/y)), (0, source_1.str)(/[^\s{}]+/y)]);
7417
7402
  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
7403
  function parse(content, params, context) {
7419
7404
  const INSECURE_URI = params.shift().value;
@@ -7523,7 +7508,7 @@ const indexee_1 = __webpack_require__(7610);
7523
7508
  const visibility_1 = __webpack_require__(6364);
7524
7509
  const util_1 = __webpack_require__(4992);
7525
7510
  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], {
7511
+ 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
7512
  buffer
7528
7513
  }) => buffer.import(bs), ([, bs], {
7529
7514
  buffer
@@ -7613,15 +7598,20 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* S
7613
7598
  return ns;
7614
7599
  })), (0, combinator_1.dup)((0, combinator_1.surround)(/{(?![{}])/y, (0, combinator_1.precedence)(9, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)])), / ?}/y, false, [], undefined, ([as, bs]) => bs && as.import(bs).push(new parser_1.Node("\u0018" /* Command.Cancel */)) && as))]), nodes => nodes.length === 1 ? new parser_1.List([new parser_1.Node(new parser_1.List([new parser_1.Node('')])), nodes.delete(nodes.head)]) : new parser_1.List([new parser_1.Node(new parser_1.List([new parser_1.Node(nodes.head.value.foldl((acc, {
7615
7600
  value
7616
- }) => acc + value, ''))])), nodes.delete(nodes.last)])), ([{
7601
+ }) => acc + value, ''), nodes.head.value.head?.flags)])), nodes.delete(nodes.last)])), ([{
7617
7602
  value: [{
7618
- value: text
7603
+ value: text,
7604
+ flags
7619
7605
  }]
7620
7606
  }, {
7621
7607
  value: params
7622
7608
  }], context) => {
7623
- if (text && text.trimStart() === '') return;
7624
- text = text.trim();
7609
+ if (flags & 1 /* Flag.invisible */) return;
7610
+ if (text) {
7611
+ const tmp = text;
7612
+ text = text.trim();
7613
+ if (text === '' || text[0] !== tmp[0]) return;
7614
+ }
7625
7615
  (0, combinator_1.consume)(100, context);
7626
7616
  if (params.last.value === "\u0018" /* Command.Cancel */) {
7627
7617
  params.pop();
@@ -7711,7 +7701,7 @@ const source_1 = __webpack_require__(8745);
7711
7701
  const visibility_1 = __webpack_require__(6364);
7712
7702
  const util_1 = __webpack_require__(4992);
7713
7703
  const dom_1 = __webpack_require__(394);
7714
- exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64 /* State.reference */, (0, combinator_1.surround)((0, source_1.str)('[['), (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))]))), ']]', false, [2, 1 | 4 /* Backtrack.common */, 3 | 128 /* Backtrack.doublebracket */], ([, ns], context) => {
7704
+ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64 /* State.reference */, (0, combinator_1.surround)((0, source_1.str)('[['), (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.beforeNonblank)((0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))]))), ']]', false, [2, 1 | 4 /* Backtrack.common */, 3 | 128 /* Backtrack.doublebracket */], ([, ns], context) => {
7715
7705
  const {
7716
7706
  position,
7717
7707
  range,
@@ -7801,7 +7791,7 @@ const inline_1 = __webpack_require__(7973);
7801
7791
  const source_1 = __webpack_require__(8745);
7802
7792
  const util_1 = __webpack_require__(4992);
7803
7793
  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', {
7794
+ 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
7795
  class: 'remark'
7806
7796
  }, [(0, dom_1.html)('input', {
7807
7797
  type: 'checkbox'
@@ -7956,7 +7946,7 @@ const source_1 = __webpack_require__(8745);
7956
7946
  const visibility_1 = __webpack_require__(6364);
7957
7947
  const util_1 = __webpack_require__(4992);
7958
7948
  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)));
7949
+ 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
7950
 
7961
7951
  /***/ },
7962
7952
 
@@ -7985,6 +7975,21 @@ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combin
7985
7975
 
7986
7976
  /***/ },
7987
7977
 
7978
+ /***/ 8068
7979
+ (__unused_webpack_module, exports, __webpack_require__) {
7980
+
7981
+ "use strict";
7982
+
7983
+
7984
+ Object.defineProperty(exports, "__esModule", ({
7985
+ value: true
7986
+ }));
7987
+ exports.isInvisibleHTMLEntityName = void 0;
7988
+ const normalize_1 = __webpack_require__(4490);
7989
+ exports.isInvisibleHTMLEntityName = eval(['name => {', 'switch(name){', normalize_1.invisibleHTMLEntityNames.map(name => `case '${name}':`).join(''), 'return true;', 'default:', 'return false;', '}', '}'].join(''));
7990
+
7991
+ /***/ },
7992
+
7988
7993
  /***/ 1657
7989
7994
  (__unused_webpack_module, exports, __webpack_require__) {
7990
7995
 
@@ -8577,11 +8582,11 @@ Object.defineProperty(exports, "__esModule", ({
8577
8582
  exports.strs = exports.str = void 0;
8578
8583
  const parser_1 = __webpack_require__(605);
8579
8584
  const combinator_1 = __webpack_require__(3484);
8580
- function str(pattern) {
8581
- return (0, combinator_1.matcher)(pattern, true);
8585
+ function str(pattern, verify) {
8586
+ return (0, combinator_1.matcher)(pattern, true, verify);
8582
8587
  }
8583
8588
  exports.str = str;
8584
- function strs(pattern) {
8589
+ function strs(pattern, limit = -1) {
8585
8590
  return ({
8586
8591
  context
8587
8592
  }) => {
@@ -8589,11 +8594,11 @@ function strs(pattern) {
8589
8594
  source
8590
8595
  } = context;
8591
8596
  let acc = '';
8592
- for (; context.position < source.length && source.startsWith(pattern, context.position);) {
8597
+ for (let i = 0; i !== limit && context.position < source.length && source.startsWith(pattern, context.position); ++i) {
8593
8598
  acc += pattern;
8594
8599
  context.position += pattern.length;
8595
8600
  }
8596
- return new parser_1.List([new parser_1.Node(acc)]);
8601
+ return acc ? new parser_1.List([new parser_1.Node(acc)]) : undefined;
8597
8602
  };
8598
8603
  }
8599
8604
  exports.strs = strs;
@@ -8645,7 +8650,7 @@ const text = input => {
8645
8650
  return new parser_1.List();
8646
8651
  case '\n':
8647
8652
  context.linebreak ||= source.length - position;
8648
- return new parser_1.List([new parser_1.Node((0, dom_1.html)('br'))]);
8653
+ return new parser_1.List([new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.invisible */)]);
8649
8654
  default:
8650
8655
  if (context.sequential) return new parser_1.List([new parser_1.Node(char)]);
8651
8656
  exports.nonWhitespace.lastIndex = position + 1;
@@ -8657,7 +8662,8 @@ const text = input => {
8657
8662
  (0, combinator_1.consume)(i - 1, context);
8658
8663
  context.position += i - 1;
8659
8664
  const linestart = position === 0 || source[position - 1] === '\n';
8660
- return position === context.position || s && !linestart || lineend ? new parser_1.List() : new parser_1.List([new parser_1.Node(source.slice(position, context.position))]);
8665
+ if (position === context.position || s && !linestart || lineend) return new parser_1.List();
8666
+ return new parser_1.List([new parser_1.Node(source.slice(position, context.position))]);
8661
8667
  }
8662
8668
  };
8663
8669
  exports.text = text;
@@ -9030,18 +9036,18 @@ exports.stringify = stringify;
9030
9036
  Object.defineProperty(exports, "__esModule", ({
9031
9037
  value: true
9032
9038
  }));
9033
- exports.trimBlankNodeEnd = exports.trimBlankEnd = exports.trimBlankStart = exports.trimBlank = exports.isTightNodeStart = exports.isLooseNodeStart = exports.tightStart = exports.blankWith = exports.afterNonblank = exports.visualize = void 0;
9039
+ exports.trimBlankNodeEnd = exports.trimBlankEnd = exports.trimBlank = exports.isTightNodeStart = exports.isLooseNodeStart = exports.beforeNonblank = exports.blankWith = exports.afterNonblank = exports.visualize = void 0;
9034
9040
  const parser_1 = __webpack_require__(605);
9035
9041
  const combinator_1 = __webpack_require__(3484);
9036
- const htmlentity_1 = __webpack_require__(470);
9037
9042
  const normalize_1 = __webpack_require__(4490);
9038
- var blank;
9039
- (function (blank) {
9040
- blank.line = new RegExp(/((?:^|\n)[^\S\n]*(?=\S))((?:[^\S\n]|\\(?=$|\s)|&IHN;|<wbr ?>)+(?=$|\n))/g.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'g');
9041
- blank.start = new RegExp(/(?:[^\S\n]|\\(?=$|\s)|&IHN;|<wbr ?>)+/y.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'y');
9042
- })(blank || (blank = {}));
9043
+ var invisible;
9044
+ (function (invisible) {
9045
+ invisible.line = new RegExp(/((?:^|\n)[^\S\n]*(?=\S))((?:[^\S\n]|\\(?=$|\s)|&IHN;|<wbr ?>)+(?=$|\n))/g.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'g');
9046
+ invisible.start = new RegExp(/(?:[^\S\n]|\\(?=$|\s)|&IHN;|<wbr ?>)+/y.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'y');
9047
+ invisible.unit = new RegExp(/(?:[^\S\n]|\\(?=$|\s)|&IHN;|<wbr ?>)/y.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'y');
9048
+ })(invisible || (invisible = {}));
9043
9049
  function visualize(parser) {
9044
- return (0, combinator_1.convert)(source => source.replace(blank.line, `$1${"\u001B" /* Command.Escape */}$2`), parser);
9050
+ return (0, combinator_1.convert)(source => source.replace(invisible.line, `$1${"\u001B" /* Command.Escape */}$2`), parser);
9045
9051
  }
9046
9052
  exports.visualize = visualize;
9047
9053
  exports.afterNonblank = nonblankWith('');
@@ -9055,11 +9061,11 @@ exports.blankWith = blankWith;
9055
9061
  function nonblankWith(delimiter) {
9056
9062
  return new RegExp([String.raw`(?<!\s|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr ?>)`, typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source].join(''), 'y');
9057
9063
  }
9058
- function tightStart(parser, except) {
9059
- return input => isTightStart(input, except) ? parser(input) : undefined;
9064
+ function beforeNonblank(parser) {
9065
+ return input => isTightStart(input) ? parser(input) : undefined;
9060
9066
  }
9061
- exports.tightStart = tightStart;
9062
- function isTightStart(input, except) {
9067
+ exports.beforeNonblank = beforeNonblank;
9068
+ function isTightStart(input) {
9063
9069
  const {
9064
9070
  context
9065
9071
  } = input;
@@ -9068,74 +9074,51 @@ function isTightStart(input, except) {
9068
9074
  position
9069
9075
  } = context;
9070
9076
  if (position === source.length) return true;
9071
- if (except && source.startsWith(except, position)) return false;
9072
9077
  switch (source[position]) {
9073
9078
  case ' ':
9074
9079
  case ' ':
9075
9080
  case '\t':
9076
9081
  case '\n':
9077
9082
  return false;
9078
- case '\\':
9079
- return source[position + 1]?.trimStart() !== '';
9080
- case '&':
9081
- switch (true) {
9082
- case source.length - position > 2 && source[position + 1] !== ' ' && (0, htmlentity_1.unsafehtmlentity)(input)?.head?.value.trimStart() === '':
9083
- context.position = position;
9084
- return false;
9085
- }
9086
- context.position = position;
9087
- return true;
9088
- case '<':
9089
- switch (true) {
9090
- case source.length - position >= 5 && source.startsWith('<wbr', position) && (source[position + 4] === '>' || source.startsWith(' >', position + 4)):
9091
- return false;
9092
- }
9093
- return true;
9094
9083
  default:
9095
- return source[position].trimStart() !== '';
9084
+ const reg = invisible.unit;
9085
+ reg.lastIndex = position;
9086
+ return !reg.test(source);
9096
9087
  }
9097
9088
  }
9098
9089
  function isLooseNodeStart(nodes) {
9099
9090
  if (nodes.length === 0) return true;
9100
- for (const {
9101
- value: node
9102
- } of nodes) {
9091
+ for (const node of nodes) {
9103
9092
  if (isVisible(node)) return true;
9104
- if (typeof node === 'object' && node.tagName === 'BR') break;
9093
+ if (typeof node.value === 'object' && node.value.tagName === 'BR') break;
9105
9094
  }
9106
9095
  return false;
9107
9096
  }
9108
9097
  exports.isLooseNodeStart = isLooseNodeStart;
9109
9098
  function isTightNodeStart(nodes) {
9110
9099
  if (nodes.length === 0) return true;
9111
- return isVisible(nodes.head.value, 0);
9100
+ return isVisible(nodes.head, 0);
9112
9101
  }
9113
9102
  exports.isTightNodeStart = isTightNodeStart;
9114
9103
  //export function isTightNodeEnd(nodes: readonly (HTMLElement | string)[]): boolean {
9115
9104
  // if (nodes.length === 0) return true;
9116
9105
  // return isVisible(nodes.at(-1)!, -1);
9117
9106
  //}
9118
- function isVisible(node, strpos) {
9119
- switch (typeof node) {
9120
- case 'string':
9121
- const char = node && strpos !== undefined ? node[strpos >= 0 ? strpos : node.length + strpos] : node;
9122
- switch (char) {
9123
- case '':
9124
- case ' ':
9125
- case '\t':
9126
- case '\n':
9127
- return false;
9128
- default:
9129
- return char.trimStart() !== '';
9130
- }
9107
+ function isVisible({
9108
+ value: node,
9109
+ flags
9110
+ }, strpos) {
9111
+ if (flags & 1 /* Flag.invisible */) return false;
9112
+ if (typeof node !== 'string') return true;
9113
+ const str = node && strpos !== undefined ? node[strpos >= 0 ? strpos : node.length + strpos] : node;
9114
+ switch (str) {
9115
+ case '':
9116
+ case ' ':
9117
+ case '\t':
9118
+ case '\n':
9119
+ return false;
9131
9120
  default:
9132
- switch (node.tagName) {
9133
- case 'BR':
9134
- case 'WBR':
9135
- return false;
9136
- default:
9137
- return true;
9138
- }
9121
+ return str.trimStart() !== '';
9139
9122
  }
9140
9123
  }
9141
9124
  function trimBlank(parser) {
@@ -9152,14 +9135,13 @@ function trimBlankStart(parser) {
9152
9135
  position
9153
9136
  } = context;
9154
9137
  if (position === source.length) return;
9155
- const reg = blank.start;
9138
+ const reg = invisible.start;
9156
9139
  reg.lastIndex = position;
9157
9140
  reg.test(source);
9158
9141
  context.position = reg.lastIndex || position;
9159
9142
  return context.position === source.length ? new parser_1.List() : parser(input);
9160
9143
  });
9161
9144
  }
9162
- exports.trimBlankStart = trimBlankStart;
9163
9145
  function trimBlankEnd(parser) {
9164
9146
  return (0, combinator_1.fmap)(parser, trimBlankNodeEnd);
9165
9147
  }
@@ -9184,18 +9166,22 @@ exports.trimBlankEnd = trimBlankEnd;
9184
9166
  // return nodes;
9185
9167
  //}
9186
9168
  function trimBlankNodeEnd(nodes) {
9187
- const skip = nodes.length > 0 && typeof nodes.last?.value === 'object' && nodes.last.value.className === 'indexer' ? nodes.pop() : undefined;
9188
- for (let node = nodes.last; nodes.length > 0 && !isVisible((node = nodes.last).value, -1);) {
9189
- if (typeof node.value === 'string') {
9169
+ const skip = nodes.last && ~nodes.last.flags & 1 /* Flag.invisible */ && typeof nodes.last.value === 'object' ? nodes.last.value.className === 'indexer' : false;
9170
+ for (let node = skip ? nodes.last?.prev : nodes.last; node;) {
9171
+ const visible = ~node.flags & 1 /* Flag.invisible */;
9172
+ if (visible && typeof node.value === 'string') {
9190
9173
  const str = node.value.trimEnd();
9191
9174
  if (str.length > 0) {
9192
9175
  node.value = str;
9193
9176
  break;
9194
9177
  }
9178
+ } else if (visible) {
9179
+ break;
9195
9180
  }
9196
- nodes.pop();
9181
+ const target = node;
9182
+ node = node.prev;
9183
+ nodes.delete(target);
9197
9184
  }
9198
- skip && nodes.push(skip);
9199
9185
  return nodes;
9200
9186
  }
9201
9187
  exports.trimBlankNodeEnd = trimBlankNodeEnd;