securemark 0.234.2 → 0.235.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/securemark.js +173 -158
  3. package/package-lock.json +40 -37
  4. package/package.json +1 -1
  5. package/src/combinator/control/constraint/block.ts +0 -2
  6. package/src/combinator/control/constraint/contract.ts +1 -1
  7. package/src/combinator/control/manipulation/context.test.ts +4 -4
  8. package/src/combinator/control/manipulation/context.ts +7 -0
  9. package/src/combinator/control/manipulation/match.ts +1 -1
  10. package/src/combinator/control/manipulation/resource.ts +6 -3
  11. package/src/combinator/control/manipulation/scope.ts +1 -1
  12. package/src/combinator/control/manipulation/surround.ts +3 -4
  13. package/src/combinator/data/parser/inits.ts +1 -1
  14. package/src/combinator/data/parser/sequence.ts +1 -1
  15. package/src/combinator/data/parser/some.ts +41 -21
  16. package/src/combinator/data/parser.ts +33 -7
  17. package/src/parser/api/bind.test.ts +3 -3
  18. package/src/parser/api/normalize.ts +7 -6
  19. package/src/parser/api/parse.test.ts +12 -5
  20. package/src/parser/block/blockquote.test.ts +1 -1
  21. package/src/parser/block/extension/aside.test.ts +1 -1
  22. package/src/parser/block/extension/example.test.ts +2 -2
  23. package/src/parser/block/extension/fig.test.ts +20 -20
  24. package/src/parser/block/extension/figure.test.ts +31 -28
  25. package/src/parser/block/extension/figure.ts +4 -2
  26. package/src/parser/block/extension/table.ts +6 -6
  27. package/src/parser/block/heading.test.ts +1 -1
  28. package/src/parser/block.ts +1 -2
  29. package/src/parser/inline/bracket.ts +3 -3
  30. package/src/parser/inline/emphasis.ts +7 -10
  31. package/src/parser/inline/emstrong.ts +7 -8
  32. package/src/parser/inline/extension/index.test.ts +19 -18
  33. package/src/parser/inline/extension/index.ts +3 -4
  34. package/src/parser/inline/extension/indexer.test.ts +1 -0
  35. package/src/parser/inline/extension/indexer.ts +1 -0
  36. package/src/parser/inline/html.ts +7 -11
  37. package/src/parser/inline/htmlentity.ts +8 -11
  38. package/src/parser/inline/link.ts +3 -4
  39. package/src/parser/inline/mark.ts +3 -6
  40. package/src/parser/inline/media.ts +8 -5
  41. package/src/parser/inline/ruby.ts +3 -4
  42. package/src/parser/inline/strong.test.ts +1 -1
  43. package/src/parser/inline/strong.ts +7 -10
  44. package/src/parser/inline.test.ts +0 -1
  45. package/src/parser/processor/figure.test.ts +28 -28
  46. package/src/parser/processor/figure.ts +1 -1
  47. package/src/parser/util.ts +14 -51
@@ -1,4 +1,4 @@
1
- /*! securemark v0.234.2 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.235.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
2
2
  require = function () {
3
3
  function r(e, n, t) {
4
4
  function o(i, f) {
@@ -3318,10 +3318,14 @@ require = function () {
3318
3318
  }
3319
3319
  exports.guard = guard;
3320
3320
  function reset(base, parser) {
3321
+ if (isEmpty(base))
3322
+ return parser;
3321
3323
  return (source, context) => parser(source, inherit((0, alias_1.ObjectCreate)(context), base));
3322
3324
  }
3323
3325
  exports.reset = reset;
3324
3326
  function context(base, parser) {
3327
+ if (isEmpty(base))
3328
+ return parser;
3325
3329
  const override = (0, memoize_1.memoize)(context => inherit((0, alias_1.ObjectCreate)(context), base), new global_1.WeakMap());
3326
3330
  return (source, context) => parser(source, override(context));
3327
3331
  }
@@ -3347,6 +3351,11 @@ require = function () {
3347
3351
  return target[prop] = source[prop];
3348
3352
  }
3349
3353
  });
3354
+ function isEmpty(context) {
3355
+ for (const _ in context)
3356
+ return false;
3357
+ return true;
3358
+ }
3350
3359
  },
3351
3360
  {
3352
3361
  'spica/alias': 5,
@@ -3569,11 +3578,20 @@ require = function () {
3569
3578
  if (typeof cost === 'function')
3570
3579
  return creator(1, cost);
3571
3580
  return (source, context) => {
3572
- const {resources} = context;
3573
- if ((resources === null || resources === void 0 ? void 0 : resources.budget) <= 0)
3581
+ const {
3582
+ resources = {
3583
+ budget: 1,
3584
+ recursion: 1
3585
+ }
3586
+ } = context;
3587
+ if (resources.budget <= 0)
3574
3588
  throw new Error('Too many creations.');
3589
+ if (resources.recursion <= 0)
3590
+ throw new Error('Too much recursion.');
3591
+ --resources.recursion;
3575
3592
  const result = parser(source, context);
3576
- if (result && resources) {
3593
+ ++resources.recursion;
3594
+ if (result) {
3577
3595
  resources.budget -= cost;
3578
3596
  }
3579
3597
  return result;
@@ -3656,7 +3674,6 @@ require = function () {
3656
3674
  const global_1 = _dereq_('spica/global');
3657
3675
  const parser_1 = _dereq_('../../data/parser');
3658
3676
  const fmap_1 = _dereq_('../monad/fmap');
3659
- const resource_1 = _dereq_('./resource');
3660
3677
  const array_1 = _dereq_('spica/array');
3661
3678
  function surround(opener, parser, closer, optional = false, f, g) {
3662
3679
  switch (typeof opener) {
@@ -3704,18 +3721,18 @@ require = function () {
3704
3721
  function match(pattern) {
3705
3722
  switch (typeof pattern) {
3706
3723
  case 'string':
3707
- return (0, resource_1.creator)(source => source.slice(0, pattern.length) === pattern ? [
3724
+ return source => source.slice(0, pattern.length) === pattern ? [
3708
3725
  [],
3709
3726
  source.slice(pattern.length)
3710
- ] : global_1.undefined);
3727
+ ] : global_1.undefined;
3711
3728
  case 'object':
3712
- return (0, resource_1.creator)(source => {
3729
+ return source => {
3713
3730
  const m = source.match(pattern);
3714
3731
  return m ? [
3715
3732
  [],
3716
3733
  source.slice(m[0].length)
3717
3734
  ] : global_1.undefined;
3718
- });
3735
+ };
3719
3736
  }
3720
3737
  }
3721
3738
  function open(opener, parser, optional = false) {
@@ -3734,7 +3751,6 @@ require = function () {
3734
3751
  {
3735
3752
  '../../data/parser': 47,
3736
3753
  '../monad/fmap': 46,
3737
- './resource': 40,
3738
3754
  'spica/array': 6,
3739
3755
  'spica/global': 15
3740
3756
  }
@@ -3807,7 +3823,37 @@ require = function () {
3807
3823
  function (_dereq_, module, exports) {
3808
3824
  'use strict';
3809
3825
  Object.defineProperty(exports, '__esModule', { value: true });
3810
- exports.check = exports.exec = exports.eval = void 0;
3826
+ exports.check = exports.exec = exports.eval = exports.Delimiters = void 0;
3827
+ class Delimiters {
3828
+ constructor() {
3829
+ this.stack = [];
3830
+ this.matchers = {};
3831
+ }
3832
+ push(delimiter) {
3833
+ var _a;
3834
+ var _b;
3835
+ const {signature, matcher} = delimiter;
3836
+ this.stack.push(signature);
3837
+ (_a = (_b = this.matchers)[signature]) !== null && _a !== void 0 ? _a : _b[signature] = matcher;
3838
+ }
3839
+ pop() {
3840
+ this.stack.pop();
3841
+ }
3842
+ match(source) {
3843
+ const {stack, matchers} = this;
3844
+ const log = {};
3845
+ for (let i = 0; i < stack.length; ++i) {
3846
+ const sig = stack[i];
3847
+ if (sig in log)
3848
+ continue;
3849
+ if (matchers[sig](source))
3850
+ return true;
3851
+ log[sig] = false;
3852
+ }
3853
+ return false;
3854
+ }
3855
+ }
3856
+ exports.Delimiters = Delimiters;
3811
3857
  function eval_(result, default_) {
3812
3858
  return result ? result[0] : default_;
3813
3859
  }
@@ -3906,28 +3952,52 @@ require = function () {
3906
3952
  exports.some = void 0;
3907
3953
  const global_1 = _dereq_('spica/global');
3908
3954
  const parser_1 = _dereq_('../parser');
3955
+ const memoize_1 = _dereq_('spica/memoize');
3909
3956
  const array_1 = _dereq_('spica/array');
3957
+ const signature = pattern => {
3958
+ switch (typeof pattern) {
3959
+ case 'undefined':
3960
+ return signature('');
3961
+ case 'string':
3962
+ return `s:${ pattern }`;
3963
+ case 'object':
3964
+ return `r/${ pattern.source }/${ pattern.flags }`;
3965
+ }
3966
+ };
3967
+ const matcher = (0, memoize_1.memoize)(pattern => {
3968
+ switch (typeof pattern) {
3969
+ case 'undefined':
3970
+ return () => false;
3971
+ case 'string':
3972
+ return source => source.slice(0, pattern.length) === pattern;
3973
+ case 'object':
3974
+ return (0, memoize_1.reduce)(source => pattern.test(source));
3975
+ }
3976
+ }, signature);
3910
3977
  function some(parser, until, deep, limit = -1) {
3911
3978
  if (typeof until === 'number')
3912
3979
  return some(parser, global_1.undefined, deep, until);
3913
- const match = typeof until === 'string' && until !== global_1.undefined ? source => source.slice(0, until.length) === until : source => !!until && until.test(source);
3914
- const delim = typeof deep === 'string' && deep !== global_1.undefined ? source => source.slice(0, deep.length) === deep : source => !!deep && deep.test(source);
3915
- let memory = '';
3980
+ const match = matcher(until);
3981
+ const delimiter = {
3982
+ signature: signature(deep),
3983
+ matcher: matcher(deep)
3984
+ };
3916
3985
  return (source, context) => {
3917
- var _a, _b, _c;
3918
- if (source === memory)
3986
+ var _a, _b;
3987
+ if (source === '')
3919
3988
  return;
3920
3989
  let rest = source;
3921
3990
  let nodes;
3922
- if (context && deep) {
3923
- context.delimiters ? context.delimiters.push(delim) : context.delimiters = [delim];
3991
+ if (deep && context) {
3992
+ (_a = context.delimiters) !== null && _a !== void 0 ? _a : context.delimiters = new parser_1.Delimiters();
3993
+ context.delimiters.push(delimiter);
3924
3994
  }
3925
3995
  while (true) {
3926
3996
  if (rest === '')
3927
3997
  break;
3928
3998
  if (match(rest))
3929
3999
  break;
3930
- if ((_a = context === null || context === void 0 ? void 0 : context.delimiters) === null || _a === void 0 ? void 0 : _a.some(match => match(rest)))
4000
+ if ((_b = context.delimiters) === null || _b === void 0 ? void 0 : _b.match(rest))
3931
4001
  break;
3932
4002
  const result = parser(rest, context);
3933
4003
  if (!result)
@@ -3937,10 +4007,9 @@ require = function () {
3937
4007
  if (limit >= 0 && source.length - rest.length > limit)
3938
4008
  break;
3939
4009
  }
3940
- if (context && deep) {
3941
- ((_b = context.delimiters) === null || _b === void 0 ? void 0 : _b.length) > 1 ? (_c = context.delimiters) === null || _c === void 0 ? void 0 : _c.pop() : context.delimiters = global_1.undefined;
4010
+ if (deep && context.delimiters) {
4011
+ context.delimiters.pop();
3942
4012
  }
3943
- memory = limit < 0 && rest || memory;
3944
4013
  return nodes && rest.length < source.length ? [
3945
4014
  nodes,
3946
4015
  rest
@@ -3952,7 +4021,8 @@ require = function () {
3952
4021
  {
3953
4022
  '../parser': 47,
3954
4023
  'spica/array': 6,
3955
- 'spica/global': 15
4024
+ 'spica/global': 15,
4025
+ 'spica/memoize': 18
3956
4026
  }
3957
4027
  ],
3958
4028
  51: [
@@ -4373,10 +4443,9 @@ require = function () {
4373
4443
  function (_dereq_, module, exports) {
4374
4444
  'use strict';
4375
4445
  Object.defineProperty(exports, '__esModule', { value: true });
4376
- exports.escape = exports.normalize = void 0;
4446
+ exports.escape = exports.invisibleHTMLEntityNames = exports.normalize = void 0;
4377
4447
  const parser_1 = _dereq_('../../combinator/data/parser');
4378
4448
  const htmlentity_1 = _dereq_('../inline/htmlentity');
4379
- const util_1 = _dereq_('../util');
4380
4449
  const UNICODE_REPLACEMENT_CHARACTER = '\uFFFD';
4381
4450
  function normalize(source) {
4382
4451
  return sanitize(format(source));
@@ -4388,7 +4457,9 @@ require = function () {
4388
4457
  function sanitize(source) {
4389
4458
  return source.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]|[\u2006\u200B-\u200F\u202A-\u202F\u2060\uFEFF]|(^|[^\u1820\u1821])\u180E/g, `$1${ UNICODE_REPLACEMENT_CHARACTER }`).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]?|[\uDC00-\uDFFF]/g, char => char.length === 1 ? UNICODE_REPLACEMENT_CHARACTER : char);
4390
4459
  }
4391
- const unreadableHTMLEntityNames = [
4460
+ exports.invisibleHTMLEntityNames = [
4461
+ 'Tab',
4462
+ 'NewLine',
4392
4463
  'NonBreakingSpace',
4393
4464
  'nbsp',
4394
4465
  'shy',
@@ -4420,7 +4491,8 @@ require = function () {
4420
4491
  'InvisibleComma',
4421
4492
  'ic'
4422
4493
  ];
4423
- const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0, util_1.stringify)((0, parser_1.eval)((0, htmlentity_1.htmlentity)(`&${ name };`, {}))));
4494
+ const unreadableHTMLEntityNames = exports.invisibleHTMLEntityNames.slice(2);
4495
+ const unreadableEscapableCharacters = unreadableHTMLEntityNames.map(name => (0, parser_1.eval)((0, htmlentity_1.unsafehtmlentity)(`&${ name };`, {}))[0]);
4424
4496
  const unreadableEscapableCharacter = new RegExp(`[${ [...new Set(unreadableEscapableCharacters)].join('') }]`, 'g');
4425
4497
  const unreadableSpecialCharacters = [
4426
4498
  '\u2006',
@@ -4445,8 +4517,7 @@ require = function () {
4445
4517
  },
4446
4518
  {
4447
4519
  '../../combinator/data/parser': 47,
4448
- '../inline/htmlentity': 112,
4449
- '../util': 134
4520
+ '../inline/htmlentity': 112
4450
4521
  }
4451
4522
  ],
4452
4523
  61: [
@@ -4552,7 +4623,12 @@ require = function () {
4552
4623
  const paragraph_1 = _dereq_('./block/paragraph');
4553
4624
  const typed_dom_1 = _dereq_('typed-dom');
4554
4625
  const random_1 = _dereq_('spica/random');
4555
- exports.block = (0, combinator_1.creator)(error((0, combinator_1.reset)({ resources: { budget: 100 * 1000 } }, (0, combinator_1.union)([
4626
+ exports.block = (0, combinator_1.creator)(error((0, combinator_1.reset)({
4627
+ resources: {
4628
+ budget: 100 * 1000,
4629
+ recursion: 200
4630
+ }
4631
+ }, (0, combinator_1.union)([
4556
4632
  source_1.emptyline,
4557
4633
  horizontalrule_1.horizontalrule,
4558
4634
  heading_1.heading,
@@ -4575,8 +4651,7 @@ require = function () {
4575
4651
  [
4576
4652
  (0, typed_dom_1.html)('h1', {
4577
4653
  id: id !== '' ? `error:${ (0, random_1.rnd0Z)(8) }` : global_1.undefined,
4578
- class: 'error',
4579
- translate: 'no'
4654
+ class: 'error'
4580
4655
  }, reason instanceof Error ? `${ reason.name }: ${ reason.message }` : `UnknownError: ${ reason }`),
4581
4656
  (0, typed_dom_1.html)('pre', {
4582
4657
  class: 'error',
@@ -5035,6 +5110,7 @@ require = function () {
5035
5110
  const util_1 = _dereq_('../../util');
5036
5111
  const typed_dom_1 = _dereq_('typed-dom');
5037
5112
  const memoize_1 = _dereq_('spica/memoize');
5113
+ const array_1 = _dereq_('spica/array');
5038
5114
  exports.segment = (0, combinator_1.block)((0, combinator_1.match)(/^(~{3,})(?:figure[^\S\n]+)?(?=\[?\$[A-Za-z-][^\n]*\n(?:[^\n]*\n)*?\1[^\S\n]*(?:$|\n))/, (0, memoize_1.memoize)(([, fence], closer = new RegExp(String.raw`^${ fence }[^\S\n]*(?:$|\n)`)) => (0, combinator_1.close)((0, combinator_1.sequence)([
5039
5115
  (0, combinator_1.line)((0, combinator_1.close)(label_1.segment, /^.*\n/)),
5040
5116
  (0, combinator_1.inits)([
@@ -5075,8 +5151,7 @@ require = function () {
5075
5151
  ])
5076
5152
  ])), ([label, param, content, ...caption]) => [(0, typed_dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [
5077
5153
  (0, typed_dom_1.html)('div', { class: 'figcontent' }, [content]),
5078
- (0, typed_dom_1.html)('span', { class: 'figindex' }),
5079
- (0, typed_dom_1.html)('figcaption', (0, typed_dom_1.defrag)(caption))
5154
+ (0, typed_dom_1.html)('figcaption', (0, array_1.unshift)([(0, typed_dom_1.html)('span', { class: 'figindex' })], (0, typed_dom_1.defrag)(caption)))
5080
5155
  ])])));
5081
5156
  function attributes(label, param, content, caption) {
5082
5157
  const group = label.split('-', 1)[0];
@@ -5118,6 +5193,7 @@ require = function () {
5118
5193
  './example': 69,
5119
5194
  './placeholder': 74,
5120
5195
  './table': 75,
5196
+ 'spica/array': 6,
5121
5197
  'spica/global': 15,
5122
5198
  'spica/memoize': 18,
5123
5199
  'typed-dom': 26
@@ -5235,6 +5311,7 @@ require = function () {
5235
5311
  exports.table = exports.segment_ = exports.segment = void 0;
5236
5312
  const global_1 = _dereq_('spica/global');
5237
5313
  const alias_1 = _dereq_('spica/alias');
5314
+ const parser_1 = _dereq_('../../../combinator/data/parser');
5238
5315
  const combinator_1 = _dereq_('../../../combinator');
5239
5316
  const inline_1 = _dereq_('../../inline');
5240
5317
  const source_1 = _dereq_('../../source');
@@ -5245,23 +5322,17 @@ require = function () {
5245
5322
  const opener = /^(~{3,})table(?!\S)([^\n]*)(?:$|\n)/;
5246
5323
  exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 10000))));
5247
5324
  exports.segment_ = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 10000, false))), false);
5248
- exports.table = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.recover)((0, combinator_1.bind)((0, combinator_1.fence)(opener, 10000), ([body, closer, opener, delim, param], _, context) => {
5325
+ exports.table = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.recover)((0, combinator_1.fmap)((0, combinator_1.fence)(opener, 10000), ([body, closer, opener, delim, param], _, context) => {
5249
5326
  var _a;
5250
5327
  if (!closer || param.trimStart())
5251
- return [
5252
- [(0, typed_dom_1.html)('pre', {
5253
- class: 'invalid',
5254
- translate: 'no',
5255
- 'data-invalid-syntax': 'table',
5256
- 'data-invalid-type': !closer ? 'closer' : 'argument',
5257
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
5258
- }, `${ opener }${ body }${ closer }`)],
5259
- ''
5260
- ];
5261
- return (_a = parser(body, context)) !== null && _a !== void 0 ? _a : [
5262
- [(0, typed_dom_1.html)('table')],
5263
- ''
5264
- ];
5328
+ return [(0, typed_dom_1.html)('pre', {
5329
+ class: 'invalid',
5330
+ translate: 'no',
5331
+ 'data-invalid-syntax': 'table',
5332
+ 'data-invalid-type': !closer ? 'closer' : 'argument',
5333
+ 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
5334
+ }, `${ opener }${ body }${ closer }`)];
5335
+ return (_a = (0, parser_1.eval)(parser(body, context))) !== null && _a !== void 0 ? _a : [(0, typed_dom_1.html)('table')];
5265
5336
  }), (source, _, reason) => reason instanceof Error && reason.message === 'Number of columns must be 32 or less.' ? [
5266
5337
  [(0, typed_dom_1.html)('pre', {
5267
5338
  class: 'invalid',
@@ -5490,6 +5561,7 @@ require = function () {
5490
5561
  },
5491
5562
  {
5492
5563
  '../../../combinator': 27,
5564
+ '../../../combinator/data/parser': 47,
5493
5565
  '../../inline': 88,
5494
5566
  '../../locale': 123,
5495
5567
  '../../source': 128,
@@ -6535,7 +6607,7 @@ require = function () {
6535
6607
  const array_1 = _dereq_('spica/array');
6536
6608
  const index = /^(?:[0-9]+(?:\.[0-9]+)*|[A-Za-z])/;
6537
6609
  const indexFW = new RegExp(index.source.replace(/[019AZaz](?!,)/g, c => String.fromCharCode(c.charCodeAt(0) + 65248)));
6538
- exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([
6610
+ exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.union)([
6539
6611
  (0, combinator_1.surround)((0, source_1.str)('('), (0, source_1.str)(index), (0, source_1.str)(')'), false, ([as, bs = [], cs], rest) => [
6540
6612
  (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)),
6541
6613
  rest
@@ -6570,7 +6642,7 @@ require = function () {
6570
6642
  (0, array_1.unshift)(as, bs),
6571
6643
  rest
6572
6644
  ])
6573
- ]));
6645
+ ])));
6574
6646
  },
6575
6647
  {
6576
6648
  '../../combinator': 27,
@@ -6672,16 +6744,13 @@ require = function () {
6672
6744
  const util_1 = _dereq_('../util');
6673
6745
  const typed_dom_1 = _dereq_('typed-dom');
6674
6746
  const array_1 = _dereq_('spica/array');
6675
- exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, combinator_1.close)((0, source_1.str)('*'), /^(?!\*)/), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
6747
+ exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('*'), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
6676
6748
  strong_1.strong,
6677
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*`)),
6749
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*/)),
6678
6750
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6679
- ]))), (0, source_1.str)('*'), false, ([as, bs, cs], rest) => (0, util_1.isEndTightNodes)(bs) ? [
6751
+ ])), '*'), (0, source_1.str)('*'), false, ([, bs], rest) => [
6680
6752
  [(0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))],
6681
6753
  rest
6682
- ] : [
6683
- (0, array_1.unshift)(as, bs),
6684
- cs[0] + rest
6685
6754
  ], ([as, bs], rest) => [
6686
6755
  (0, array_1.unshift)(as, bs),
6687
6756
  rest
@@ -6710,24 +6779,19 @@ require = function () {
6710
6779
  const typed_dom_1 = _dereq_('typed-dom');
6711
6780
  const array_1 = _dereq_('spica/array');
6712
6781
  const substrong = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([
6713
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*\*`)),
6782
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*\*/)),
6714
6783
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6715
6784
  ])));
6716
6785
  const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([
6717
6786
  strong_1.strong,
6718
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*`)),
6787
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*/)),
6719
6788
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6720
6789
  ])));
6721
6790
  exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('***'), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
6722
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*`)),
6791
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*/)),
6723
6792
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6724
- ]))), (0, source_1.str)(/^\*{1,3}/), false, ([as, bs, cs], rest, context) => {
6793
+ ]))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], rest, context) => {
6725
6794
  var _a, _b;
6726
- if (!(0, util_1.isEndTightNodes)(bs))
6727
- return [
6728
- (0, array_1.unshift)(as, bs),
6729
- cs[0] + rest
6730
- ];
6731
6795
  switch (cs[0]) {
6732
6796
  case '***':
6733
6797
  return [
@@ -6735,7 +6799,7 @@ require = function () {
6735
6799
  rest
6736
6800
  ];
6737
6801
  case '**':
6738
- return (_a = (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' && (0, util_1.isEndTightNodes)(ds) ? [
6802
+ return (_a = (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' ? [
6739
6803
  [(0, typed_dom_1.html)('em', (0, array_1.unshift)([(0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))], (0, typed_dom_1.defrag)(ds)))],
6740
6804
  rest.slice(1)
6741
6805
  ] : [
@@ -6752,7 +6816,7 @@ require = function () {
6752
6816
  rest
6753
6817
  ];
6754
6818
  case '*':
6755
- return (_b = (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' && (0, util_1.isEndTightNodes)(ds) ? [
6819
+ return (_b = (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' ? [
6756
6820
  [(0, typed_dom_1.html)('strong', (0, array_1.unshift)([(0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))], (0, typed_dom_1.defrag)(ds)))],
6757
6821
  rest.slice(2)
6758
6822
  ] : [
@@ -6869,18 +6933,18 @@ require = function () {
6869
6933
  autolink: false
6870
6934
  }
6871
6935
  }
6872
- }, (0, combinator_1.open)((0, source_1.str)(/^\|?/, false), (0, combinator_1.some)((0, combinator_1.union)([
6936
+ }, (0, combinator_1.some)((0, combinator_1.union)([
6873
6937
  signature,
6874
6938
  inline_1.inline
6875
- ]), ']', /^\\?\n/), true)))), ']'), ns => [(0, typed_dom_1.html)('a', (0, util_1.trimNodeEnd)((0, typed_dom_1.defrag)(ns)))])), ([el]) => [(0, typed_dom_1.define)(el, {
6939
+ ]), ']', /^\\?\n/)))), ']'), ns => [(0, typed_dom_1.html)('a', (0, util_1.trimNodeEnd)((0, typed_dom_1.defrag)(ns)))])), ([el]) => [(0, typed_dom_1.define)(el, {
6876
6940
  id: el.id ? null : global_1.undefined,
6877
6941
  class: 'index',
6878
6942
  href: el.id ? `#${ el.id }` : global_1.undefined
6879
6943
  }, el.childNodes)]))));
6880
- const signature = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.open)('|#', (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
6944
+ const signature = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.open)(/^\s+\|#/, (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
6881
6945
  bracket,
6882
6946
  source_1.txt
6883
- ]), ']', /^\\?\n/))), ns => [(0, typed_dom_1.html)('span', {
6947
+ ]), ']'))), ns => [(0, typed_dom_1.html)('span', {
6884
6948
  class: 'indexer',
6885
6949
  'data-index': (0, indexee_1.identity)((0, array_1.join)(ns)).slice(6)
6886
6950
  })])));
@@ -7113,8 +7177,8 @@ require = function () {
7113
7177
  (0, alias_1.ObjectSetPrototypeOf)(attrspec, null);
7114
7178
  (0, alias_1.ObjectValues)(attrspec).forEach(o => (0, alias_1.ObjectSetPrototypeOf)(o, null));
7115
7179
  exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('<', (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/, (0, combinator_1.union)([
7116
- (0, combinator_1.match)(/^(?=<(wbr)(?=[^\S\n]|>))/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, source_1.str)(`<${ tag }`), (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), (0, source_1.str)('>'), true, ([, as = []], rest) => [
7117
- [(0, typed_dom_1.html)(tag, attributes('html', [], attrspec[tag], as))],
7180
+ (0, combinator_1.match)(/^(?=<(wbr)(?=[^\S\n]|>))/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)(`<${ tag }`, (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), '>', true, ([, bs = []], rest) => [
7181
+ [(0, typed_dom_1.html)(tag, attributes('html', [], attrspec[tag], bs))],
7118
7182
  rest
7119
7183
  ]), ([, tag]) => tag)),
7120
7184
  (0, combinator_1.match)(/^(?=<(sup|sub|small|bdo|bdi)(?=[^\S\n]|>))/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.validate)(`<${ tag }`, `</${ tag }>`, (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${ tag }`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)('>'), true), (0, util_1.startLoose)((0, combinator_1.context)((() => {
@@ -7176,8 +7240,6 @@ require = function () {
7176
7240
  switch (true) {
7177
7241
  case as[as.length - 1] !== '>' || 'data-invalid-syntax' in (attrs = attributes('html', [], attrspec[tag], as.slice(1, -1))):
7178
7242
  return invalid('attribute', 'Invalid HTML attribute.', as, bs, cs);
7179
- case cs.length === 0:
7180
- return invalid('closer', `Missing the closing HTML tag <${ tag }>.`, as, bs, cs);
7181
7243
  default:
7182
7244
  return (0, typed_dom_1.html)(tag, attrs, bs);
7183
7245
  }
@@ -7237,17 +7299,16 @@ require = function () {
7237
7299
  exports.htmlentity = exports.unsafehtmlentity = void 0;
7238
7300
  const combinator_1 = _dereq_('../../combinator');
7239
7301
  const typed_dom_1 = _dereq_('typed-dom');
7240
- const parser = (0, typed_dom_1.html)('textarea');
7241
- exports.unsafehtmlentity = (0, combinator_1.creator)((0, combinator_1.validate)('&', (0, combinator_1.fmap)((0, combinator_1.focus)(/^&(?!NewLine;)[0-9A-Za-z]+;/, entity => [
7242
- [(parser.innerHTML = entity, parser.value)],
7302
+ exports.unsafehtmlentity = (0, combinator_1.creator)((0, combinator_1.validate)('&', (0, combinator_1.focus)(/^&(?!NewLine;)[0-9A-Za-z]+;/, (parser => entity => (parser.innerHTML = entity, entity = parser.textContent, [
7303
+ [`${ entity[0] !== '&' || entity.length === 1 ? '' : '\0' }${ entity }`],
7243
7304
  ''
7244
- ]), ([str]) => [str[0] !== '&' || str.length < 3 ? str : `\0${ str }`])));
7245
- exports.htmlentity = (0, combinator_1.creator)((0, combinator_1.validate)('&', (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([str]) => [str[0] === '\0' ? (0, typed_dom_1.html)('span', {
7305
+ ]))((0, typed_dom_1.html)('b')))));
7306
+ exports.htmlentity = (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([str]) => [str[0] === '\0' ? (0, typed_dom_1.html)('span', {
7246
7307
  class: 'invalid',
7247
7308
  'data-invalid-syntax': 'htmlentity',
7248
7309
  'data-invalid-type': 'syntax',
7249
7310
  'data-invalid-description': 'Invalid HTML entity.'
7250
- }, str.slice(1)) : str])));
7311
+ }, str.slice(1)) : str]);
7251
7312
  },
7252
7313
  {
7253
7314
  '../../combinator': 27,
@@ -7300,10 +7361,10 @@ require = function () {
7300
7361
  const url_1 = _dereq_('spica/url');
7301
7362
  const optspec = { rel: ['nofollow'] };
7302
7363
  (0, alias_1.ObjectSetPrototypeOf)(optspec, null);
7303
- exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.creator)(10, (0, combinator_1.bind)((0, combinator_1.validate)([
7364
+ exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.creator)(10, (0, combinator_1.validate)([
7304
7365
  '[',
7305
7366
  '{'
7306
- ], '}', '\n', (0, combinator_1.guard)(context => {
7367
+ ], '}', '\n', (0, combinator_1.bind)((0, combinator_1.guard)(context => {
7307
7368
  var _a, _b, _c;
7308
7369
  return (_c = (_b = (_a = context.syntax) === null || _a === void 0 ? void 0 : _a.inline) === null || _b === void 0 ? void 0 : _b.link) !== null && _c !== void 0 ? _c : true;
7309
7370
  }, (0, combinator_1.reverse)((0, combinator_1.tails)([
@@ -7327,7 +7388,7 @@ require = function () {
7327
7388
  exports.uri,
7328
7389
  (0, combinator_1.some)(exports.option)
7329
7390
  ]), /^[^\S\n]?}/))
7330
- ])))), ([params, content = []], rest, context) => {
7391
+ ]))), ([params, content = []], rest, context) => {
7331
7392
  var _a, _b, _c, _d, _e, _f;
7332
7393
  if ((_a = (0, parser_1.eval)((0, combinator_1.some)(autolink_1.autolink)((0, util_1.stringify)(content), context))) === null || _a === void 0 ? void 0 : _a.some(node => typeof node === 'object'))
7333
7394
  return;
@@ -7342,7 +7403,7 @@ require = function () {
7342
7403
  [(0, typed_dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))],
7343
7404
  rest
7344
7405
  ];
7345
- })));
7406
+ }))));
7346
7407
  exports.uri = (0, combinator_1.union)([
7347
7408
  (0, combinator_1.open)(/^[^\S\n]/, (0, source_1.str)(/^\S+/)),
7348
7409
  (0, source_1.str)(/^[^\s{}]+/)
@@ -7438,14 +7499,11 @@ require = function () {
7438
7499
  const typed_dom_1 = _dereq_('typed-dom');
7439
7500
  const array_1 = _dereq_('spica/array');
7440
7501
  exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('=='), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
7441
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)('==')),
7502
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/==/)),
7442
7503
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '='), inline_1.inline)
7443
- ]))), (0, source_1.str)('=='), false, ([as, bs, cs], rest) => (0, util_1.isEndTightNodes)(bs) ? [
7504
+ ]))), (0, source_1.str)('=='), false, ([, bs], rest) => [
7444
7505
  [(0, typed_dom_1.html)('mark', (0, typed_dom_1.defrag)(bs))],
7445
7506
  rest
7446
- ] : [
7447
- (0, array_1.unshift)(as, bs),
7448
- cs[0] + rest
7449
7507
  ], ([as, bs], rest) => [
7450
7508
  (0, array_1.unshift)(as, bs),
7451
7509
  rest
@@ -7524,10 +7582,10 @@ require = function () {
7524
7582
  rel: global_1.undefined
7525
7583
  };
7526
7584
  (0, alias_1.ObjectSetPrototypeOf)(optspec, null);
7527
- exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.creator)(10, (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.open)('!', (0, combinator_1.validate)([
7528
- '[',
7529
- '{'
7530
- ], '}', '\n', (0, combinator_1.guard)(context => {
7585
+ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.creator)(10, (0, combinator_1.validate)([
7586
+ '![',
7587
+ '!{'
7588
+ ], '}', '\n', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.open)('!', (0, combinator_1.guard)(context => {
7531
7589
  var _a, _b, _c;
7532
7590
  return (_c = (_b = (_a = context.syntax) === null || _a === void 0 ? void 0 : _a.inline) === null || _b === void 0 ? void 0 : _b.media) !== null && _c !== void 0 ? _c : true;
7533
7591
  }, (0, combinator_1.tails)([
@@ -7540,7 +7598,7 @@ require = function () {
7540
7598
  link_1.uri,
7541
7599
  (0, combinator_1.some)(option)
7542
7600
  ]), /^[^\S\n]?}/))
7543
- ])))), ([as, bs]) => bs ? [
7601
+ ]))), ([as, bs]) => bs ? [
7544
7602
  [(0, array_1.join)(as).trim() || (0, array_1.join)(as)],
7545
7603
  bs
7546
7604
  ] : [
@@ -7569,7 +7627,7 @@ require = function () {
7569
7627
  rest
7570
7628
  ];
7571
7629
  return (0, combinator_1.fmap)(link_1.link, ([link]) => [(0, typed_dom_1.define)(link, { target: '_blank' }, [el])])(`{ ${ INSECURE_URI }${ (0, array_1.join)(params) } }${ rest }`, context);
7572
- })));
7630
+ }))));
7573
7631
  const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([
7574
7632
  (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([
7575
7633
  htmlentity_1.unsafehtmlentity,
@@ -7727,10 +7785,10 @@ require = function () {
7727
7785
  const util_1 = _dereq_('../util');
7728
7786
  const typed_dom_1 = _dereq_('typed-dom');
7729
7787
  const array_1 = _dereq_('spica/array');
7730
- exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.validate)('[', ')', '\n', (0, combinator_1.sequence)([
7788
+ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('[', ')', '\n', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.sequence)([
7731
7789
  (0, combinator_1.surround)('[', (0, combinator_1.focus)(/^(?:\\[^\n]|[^\\\[\]\n])+(?=]\()/, text), ']'),
7732
7790
  (0, combinator_1.surround)('(', (0, combinator_1.focus)(/^(?:\\[^\n]|[^\\\(\)\n])+(?=\))/, text), ')')
7733
- ])), ([texts]) => (0, util_1.isStartTightNodes)(texts)), ([texts, rubies], rest) => {
7791
+ ]), ([texts]) => (0, util_1.isStartTightNodes)(texts)), ([texts, rubies], rest) => {
7734
7792
  const tail = typeof texts[texts.length - 1] === 'object' ? [texts.pop()] : [];
7735
7793
  tail.length === 0 && texts[texts.length - 1] === '' && texts.pop();
7736
7794
  switch (true) {
@@ -7762,7 +7820,7 @@ require = function () {
7762
7820
  rest
7763
7821
  ];
7764
7822
  }
7765
- })));
7823
+ }))));
7766
7824
  const text = (0, combinator_1.creator)((source, context) => {
7767
7825
  var _a;
7768
7826
  const acc = [''];
@@ -7856,15 +7914,12 @@ require = function () {
7856
7914
  const util_1 = _dereq_('../util');
7857
7915
  const typed_dom_1 = _dereq_('typed-dom');
7858
7916
  const array_1 = _dereq_('spica/array');
7859
- exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, combinator_1.close)((0, source_1.str)('**'), /^(?!\*)/), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
7860
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*\*`)),
7917
+ exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('**'), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
7918
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*\*/)),
7861
7919
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
7862
- ]))), (0, source_1.str)('**'), false, ([as, bs, cs], rest) => (0, util_1.isEndTightNodes)(bs) ? [
7920
+ ])), '*'), (0, source_1.str)('**'), false, ([, bs], rest) => [
7863
7921
  [(0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))],
7864
7922
  rest
7865
- ] : [
7866
- (0, array_1.unshift)(as, bs),
7867
- cs[0] + rest
7868
7923
  ], ([as, bs], rest) => [
7869
7924
  (0, array_1.unshift)(as, bs),
7870
7925
  rest
@@ -8078,7 +8133,7 @@ require = function () {
8078
8133
  !(0, label_1.isFixed)(label) && numbers.set(group, number);
8079
8134
  opts.id !== '' && def.setAttribute('id', `label:${ opts.id ? `${ opts.id }:` : '' }${ label }`);
8080
8135
  const figindex = group === '$' ? `(${ number })` : `${ capitalize(group) }${ group === 'fig' ? '.' : '' } ${ number }`;
8081
- (0, typed_dom_1.define)(def.querySelector(':scope > .figindex'), group === '$' ? figindex : `${ figindex }. `);
8136
+ (0, typed_dom_1.define)(def.querySelector(':scope > figcaption > .figindex'), group === '$' ? figindex : `${ figindex }. `);
8082
8137
  for (const ref of refs.take(label, global_1.Infinity)) {
8083
8138
  if (ref.hash.slice(1) === def.id && ref.innerText === figindex)
8084
8139
  continue;
@@ -8650,53 +8705,20 @@ require = function () {
8650
8705
  function (_dereq_, module, exports) {
8651
8706
  'use strict';
8652
8707
  Object.defineProperty(exports, '__esModule', { value: true });
8653
- exports.stringify = exports.trimNodeEndBR = exports.trimNodeEnd = exports.trimNode = exports.isEndTightNodes = exports.isStartTightNodes = exports.startTight = exports.isStartLoose = exports.startLoose = exports.visualize = exports.delimiter = void 0;
8708
+ exports.stringify = exports.trimNodeEndBR = exports.trimNodeEnd = exports.trimNode = exports.isStartTightNodes = exports.startTight = exports.isStartLoose = exports.startLoose = exports.visualize = exports.delimiter = void 0;
8654
8709
  const global_1 = _dereq_('spica/global');
8655
8710
  const parser_1 = _dereq_('../combinator/data/parser');
8656
8711
  const combinator_1 = _dereq_('../combinator');
8657
8712
  const htmlentity_1 = _dereq_('./inline/htmlentity');
8658
8713
  const source_1 = _dereq_('./source');
8714
+ const normalize_1 = _dereq_('./api/normalize');
8659
8715
  const array_1 = _dereq_('spica/array');
8660
- const invisibleHTMLEntityNames = [
8661
- 'Tab',
8662
- 'NewLine',
8663
- 'NonBreakingSpace',
8664
- 'nbsp',
8665
- 'shy',
8666
- 'ensp',
8667
- 'emsp',
8668
- 'emsp13',
8669
- 'emsp14',
8670
- 'numsp',
8671
- 'puncsp',
8672
- 'ThinSpace',
8673
- 'thinsp',
8674
- 'VeryThinSpace',
8675
- 'hairsp',
8676
- 'ZeroWidthSpace',
8677
- 'NegativeVeryThinSpace',
8678
- 'NegativeThinSpace',
8679
- 'NegativeMediumSpace',
8680
- 'NegativeThickSpace',
8681
- 'zwj',
8682
- 'zwnj',
8683
- 'lrm',
8684
- 'rlm',
8685
- 'MediumSpace',
8686
- 'NoBreak',
8687
- 'ApplyFunction',
8688
- 'af',
8689
- 'InvisibleTimes',
8690
- 'it',
8691
- 'InvisibleComma',
8692
- 'ic'
8693
- ];
8694
- const blankline = new RegExp(String.raw`^(?:\\$|\\?[^\S\n]|&(?:${ invisibleHTMLEntityNames.join('|') });|<wbr>)+$`, 'gm');
8695
8716
  function delimiter(opener) {
8696
- return new RegExp(String.raw`^(?:\s+|\\\s|&(?:${ invisibleHTMLEntityNames.join('|') });|<wbr>)?${ opener }`);
8717
+ return new RegExp(String.raw`^(?:\s+|\\\s|&(?:${ normalize_1.invisibleHTMLEntityNames.join('|') });|<wbr>)?${ opener.source }`);
8697
8718
  }
8698
8719
  exports.delimiter = delimiter;
8699
8720
  function visualize(parser) {
8721
+ const blankline = new RegExp(String.raw`^(?:\\$|\\?[^\S\n]|&(?:${ normalize_1.invisibleHTMLEntityNames.join('|') });|<wbr>)+$`, 'gm');
8700
8722
  return (0, combinator_1.union)([
8701
8723
  (0, combinator_1.convert)(source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context))),
8702
8724
  (0, combinator_1.some)((0, combinator_1.union)([
@@ -8732,21 +8754,19 @@ require = function () {
8732
8754
  }
8733
8755
  exports.startLoose = startLoose;
8734
8756
  function isStartLoose(source, context, except) {
8735
- var _a;
8736
- source && (source = source.replace(/^[^\S\n]+/, ''));
8737
- if (source === '')
8738
- return true;
8739
- return source.slice(0, (_a = except === null || except === void 0 ? void 0 : except.length) !== null && _a !== void 0 ? _a : 0) !== except && isStartTight(source, context);
8757
+ return isStartTight(source.replace(/^[^\S\n]+/, ''), context, except);
8740
8758
  }
8741
8759
  exports.isStartLoose = isStartLoose;
8742
- function startTight(parser) {
8743
- return (source, context) => isStartTight(source, context) ? parser(source, context) : global_1.undefined;
8760
+ function startTight(parser, except) {
8761
+ return (source, context) => isStartTight(source, context, except) ? parser(source, context) : global_1.undefined;
8744
8762
  }
8745
8763
  exports.startTight = startTight;
8746
- function isStartTight(source, context) {
8764
+ function isStartTight(source, context, except) {
8747
8765
  var _a, _b, _c;
8748
8766
  if (source === '')
8749
8767
  return true;
8768
+ if (except && source.slice(0, except.length) === except)
8769
+ return false;
8750
8770
  switch (source[0]) {
8751
8771
  case ' ':
8752
8772
  case '\u3000':
@@ -8777,12 +8797,6 @@ require = function () {
8777
8797
  return isVisible(nodes[0], 0);
8778
8798
  }
8779
8799
  exports.isStartTightNodes = isStartTightNodes;
8780
- function isEndTightNodes(nodes) {
8781
- if (nodes.length === 0)
8782
- return true;
8783
- return isVisible(nodes[nodes.length - 1], -1);
8784
- }
8785
- exports.isEndTightNodes = isEndTightNodes;
8786
8800
  function isVisible(node, strpos) {
8787
8801
  switch (typeof node) {
8788
8802
  case 'string':
@@ -8866,6 +8880,7 @@ require = function () {
8866
8880
  {
8867
8881
  '../combinator': 27,
8868
8882
  '../combinator/data/parser': 47,
8883
+ './api/normalize': 60,
8869
8884
  './inline/htmlentity': 112,
8870
8885
  './source': 128,
8871
8886
  'spica/array': 6,