securemark 0.234.3 → 0.235.2

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 (56) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/securemark.js +210 -171
  3. package/markdown.d.ts +5 -2
  4. package/package-lock.json +40 -37
  5. package/package.json +1 -1
  6. package/src/combinator/control/constraint/block.ts +0 -2
  7. package/src/combinator/control/constraint/contract.ts +1 -1
  8. package/src/combinator/control/manipulation/context.test.ts +4 -4
  9. package/src/combinator/control/manipulation/context.ts +7 -0
  10. package/src/combinator/control/manipulation/match.ts +1 -1
  11. package/src/combinator/control/manipulation/resource.ts +6 -3
  12. package/src/combinator/control/manipulation/scope.ts +1 -1
  13. package/src/combinator/control/manipulation/surround.ts +3 -4
  14. package/src/combinator/data/parser/inits.ts +1 -1
  15. package/src/combinator/data/parser/sequence.ts +1 -1
  16. package/src/combinator/data/parser/some.ts +41 -21
  17. package/src/combinator/data/parser.ts +33 -7
  18. package/src/parser/api/bind.test.ts +3 -3
  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 +5 -3
  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/annotation.ts +3 -3
  30. package/src/parser/inline/bracket.test.ts +10 -10
  31. package/src/parser/inline/bracket.ts +5 -8
  32. package/src/parser/inline/deletion.test.ts +4 -1
  33. package/src/parser/inline/deletion.ts +7 -4
  34. package/src/parser/inline/emphasis.ts +3 -6
  35. package/src/parser/inline/emstrong.ts +7 -8
  36. package/src/parser/inline/extension/index.test.ts +19 -18
  37. package/src/parser/inline/extension/index.ts +3 -4
  38. package/src/parser/inline/extension/indexer.test.ts +1 -0
  39. package/src/parser/inline/extension/indexer.ts +1 -0
  40. package/src/parser/inline/html.test.ts +25 -17
  41. package/src/parser/inline/html.ts +39 -15
  42. package/src/parser/inline/insertion.test.ts +4 -1
  43. package/src/parser/inline/insertion.ts +7 -4
  44. package/src/parser/inline/link.test.ts +3 -0
  45. package/src/parser/inline/link.ts +9 -11
  46. package/src/parser/inline/mark.ts +3 -6
  47. package/src/parser/inline/media.test.ts +3 -0
  48. package/src/parser/inline/media.ts +9 -6
  49. package/src/parser/inline/reference.ts +6 -6
  50. package/src/parser/inline/ruby.ts +3 -4
  51. package/src/parser/inline/strong.test.ts +1 -1
  52. package/src/parser/inline/strong.ts +3 -6
  53. package/src/parser/inline.test.ts +2 -3
  54. package/src/parser/processor/figure.test.ts +28 -28
  55. package/src/parser/processor/figure.ts +1 -1
  56. package/src/parser/util.ts +43 -39
@@ -1,4 +1,4 @@
1
- /*! securemark v0.234.3 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.235.2 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: [
@@ -4553,7 +4623,12 @@ require = function () {
4553
4623
  const paragraph_1 = _dereq_('./block/paragraph');
4554
4624
  const typed_dom_1 = _dereq_('typed-dom');
4555
4625
  const random_1 = _dereq_('spica/random');
4556
- 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)([
4557
4632
  source_1.emptyline,
4558
4633
  horizontalrule_1.horizontalrule,
4559
4634
  heading_1.heading,
@@ -4576,8 +4651,7 @@ require = function () {
4576
4651
  [
4577
4652
  (0, typed_dom_1.html)('h1', {
4578
4653
  id: id !== '' ? `error:${ (0, random_1.rnd0Z)(8) }` : global_1.undefined,
4579
- class: 'error',
4580
- translate: 'no'
4654
+ class: 'error'
4581
4655
  }, reason instanceof Error ? `${ reason.name }: ${ reason.message }` : `UnknownError: ${ reason }`),
4582
4656
  (0, typed_dom_1.html)('pre', {
4583
4657
  class: 'error',
@@ -5036,6 +5110,7 @@ require = function () {
5036
5110
  const util_1 = _dereq_('../../util');
5037
5111
  const typed_dom_1 = _dereq_('typed-dom');
5038
5112
  const memoize_1 = _dereq_('spica/memoize');
5113
+ const array_1 = _dereq_('spica/array');
5039
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)([
5040
5115
  (0, combinator_1.line)((0, combinator_1.close)(label_1.segment, /^.*\n/)),
5041
5116
  (0, combinator_1.inits)([
@@ -5075,9 +5150,8 @@ require = function () {
5075
5150
  (0, combinator_1.block)((0, locale_1.localize)((0, combinator_1.context)({ syntax: { inline: { media: false } } }, (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)(inline_1.inline))))))
5076
5151
  ])
5077
5152
  ])), ([label, param, content, ...caption]) => [(0, typed_dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [
5078
- (0, typed_dom_1.html)('div', { class: 'figcontent' }, [content]),
5079
- (0, typed_dom_1.html)('span', { class: 'figindex' }),
5080
- (0, typed_dom_1.html)('figcaption', (0, typed_dom_1.defrag)(caption))
5153
+ (0, typed_dom_1.html)('div', [content]),
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)))
5081
5155
  ])])));
5082
5156
  function attributes(label, param, content, caption) {
5083
5157
  const group = label.split('-', 1)[0];
@@ -5119,6 +5193,7 @@ require = function () {
5119
5193
  './example': 69,
5120
5194
  './placeholder': 74,
5121
5195
  './table': 75,
5196
+ 'spica/array': 6,
5122
5197
  'spica/global': 15,
5123
5198
  'spica/memoize': 18,
5124
5199
  'typed-dom': 26
@@ -5236,6 +5311,7 @@ require = function () {
5236
5311
  exports.table = exports.segment_ = exports.segment = void 0;
5237
5312
  const global_1 = _dereq_('spica/global');
5238
5313
  const alias_1 = _dereq_('spica/alias');
5314
+ const parser_1 = _dereq_('../../../combinator/data/parser');
5239
5315
  const combinator_1 = _dereq_('../../../combinator');
5240
5316
  const inline_1 = _dereq_('../../inline');
5241
5317
  const source_1 = _dereq_('../../source');
@@ -5246,23 +5322,17 @@ require = function () {
5246
5322
  const opener = /^(~{3,})table(?!\S)([^\n]*)(?:$|\n)/;
5247
5323
  exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 10000))));
5248
5324
  exports.segment_ = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 10000, false))), false);
5249
- 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) => {
5250
5326
  var _a;
5251
5327
  if (!closer || param.trimStart())
5252
- return [
5253
- [(0, typed_dom_1.html)('pre', {
5254
- class: 'invalid',
5255
- translate: 'no',
5256
- 'data-invalid-syntax': 'table',
5257
- 'data-invalid-type': !closer ? 'closer' : 'argument',
5258
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
5259
- }, `${ opener }${ body }${ closer }`)],
5260
- ''
5261
- ];
5262
- return (_a = parser(body, context)) !== null && _a !== void 0 ? _a : [
5263
- [(0, typed_dom_1.html)('table')],
5264
- ''
5265
- ];
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')];
5266
5336
  }), (source, _, reason) => reason instanceof Error && reason.message === 'Number of columns must be 32 or less.' ? [
5267
5337
  [(0, typed_dom_1.html)('pre', {
5268
5338
  class: 'invalid',
@@ -5491,6 +5561,7 @@ require = function () {
5491
5561
  },
5492
5562
  {
5493
5563
  '../../../combinator': 27,
5564
+ '../../../combinator/data/parser': 47,
5494
5565
  '../../inline': 88,
5495
5566
  '../../locale': 123,
5496
5567
  '../../source': 128,
@@ -6257,7 +6328,7 @@ require = function () {
6257
6328
  }
6258
6329
  },
6259
6330
  state: global_1.undefined
6260
- }, (0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, ')', /^\\?\n/)])), '))')), '))'), ns => [(0, typed_dom_1.html)('sup', { class: 'annotation' }, (0, util_1.trimNode)((0, typed_dom_1.defrag)(ns)))]))));
6331
+ }, (0, util_1.trimSpaceStart)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, ')', /^\\?\n/)]))))), '))'), ns => [(0, typed_dom_1.html)('sup', { class: 'annotation' }, (0, util_1.trimNodeEnd)((0, typed_dom_1.defrag)(ns)))]))));
6261
6332
  },
6262
6333
  {
6263
6334
  '../../combinator': 27,
@@ -6535,16 +6606,8 @@ require = function () {
6535
6606
  const typed_dom_1 = _dereq_('typed-dom');
6536
6607
  const array_1 = _dereq_('spica/array');
6537
6608
  const index = /^(?:[0-9]+(?:\.[0-9]+)*|[A-Za-z])/;
6538
- const indexFW = new RegExp(index.source.replace(/[019AZaz](?!,)/g, c => String.fromCharCode(c.charCodeAt(0) + 65248)));
6539
- exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([
6540
- (0, combinator_1.surround)((0, source_1.str)('('), (0, source_1.str)(index), (0, source_1.str)(')'), false, ([as, bs = [], cs], rest) => [
6541
- (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)),
6542
- rest
6543
- ]),
6544
- (0, combinator_1.surround)((0, source_1.str)('\uFF08'), (0, source_1.str)(indexFW), (0, source_1.str)('\uFF09'), false, ([as, bs = [], cs], rest) => [
6545
- (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)),
6546
- rest
6547
- ]),
6609
+ exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.union)([
6610
+ (0, combinator_1.surround)((0, source_1.str)('('), (0, source_1.str)(index), (0, source_1.str)(')')),
6548
6611
  (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)(inline_1.inline, ')'), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [
6549
6612
  [(0, typed_dom_1.html)('span', { class: 'paren' }, (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))],
6550
6613
  rest
@@ -6552,6 +6615,7 @@ require = function () {
6552
6615
  (0, array_1.unshift)(as, bs),
6553
6616
  rest
6554
6617
  ]),
6618
+ (0, combinator_1.surround)((0, source_1.str)('\uFF08'), (0, source_1.str)(new RegExp(index.source.replace(/[09AZaz.]/g, c => String.fromCharCode(c.charCodeAt(0) + 65248)))), (0, source_1.str)('\uFF09')),
6555
6619
  (0, combinator_1.surround)((0, source_1.str)('\uFF08'), (0, combinator_1.some)(inline_1.inline, '\uFF09'), (0, source_1.str)('\uFF09'), true, ([as, bs = [], cs], rest) => [
6556
6620
  [(0, typed_dom_1.html)('span', { class: 'paren' }, (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))],
6557
6621
  rest
@@ -6571,7 +6635,7 @@ require = function () {
6571
6635
  (0, array_1.unshift)(as, bs),
6572
6636
  rest
6573
6637
  ])
6574
- ]));
6638
+ ])));
6575
6639
  },
6576
6640
  {
6577
6641
  '../../combinator': 27,
@@ -6644,8 +6708,11 @@ require = function () {
6644
6708
  const util_1 = _dereq_('../util');
6645
6709
  const typed_dom_1 = _dereq_('typed-dom');
6646
6710
  const array_1 = _dereq_('spica/array');
6647
- exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('~~'), (0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '~~')]), (0, source_1.str)('~~'), false, ([, bs], rest) => [
6648
- [(0, typed_dom_1.html)('del', (0, typed_dom_1.defrag)((0, util_1.trimNodeEndBR)(bs)))],
6711
+ exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('~~'), (0, combinator_1.some)((0, combinator_1.union)([
6712
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n?/, /~~/)),
6713
+ (0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, '~'), true)
6714
+ ])), (0, source_1.str)('~~'), false, ([, bs], rest) => [
6715
+ [(0, typed_dom_1.html)('del', (0, typed_dom_1.defrag)(bs))],
6649
6716
  rest
6650
6717
  ], ([as, bs], rest) => [
6651
6718
  (0, array_1.unshift)(as, bs),
@@ -6675,14 +6742,11 @@ require = function () {
6675
6742
  const array_1 = _dereq_('spica/array');
6676
6743
  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)([
6677
6744
  strong_1.strong,
6678
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*`)),
6745
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', /\*/)),
6679
6746
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6680
- ])), '*'), (0, source_1.str)('*'), false, ([as, bs, cs], rest) => (0, util_1.isEndTightNodes)(bs) ? [
6747
+ ])), '*'), (0, source_1.str)('*'), false, ([, bs], rest) => [
6681
6748
  [(0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))],
6682
6749
  rest
6683
- ] : [
6684
- (0, array_1.unshift)(as, bs),
6685
- cs[0] + rest
6686
6750
  ], ([as, bs], rest) => [
6687
6751
  (0, array_1.unshift)(as, bs),
6688
6752
  rest
@@ -6711,24 +6775,19 @@ require = function () {
6711
6775
  const typed_dom_1 = _dereq_('typed-dom');
6712
6776
  const array_1 = _dereq_('spica/array');
6713
6777
  const substrong = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([
6714
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*\*`)),
6778
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', /\*\*/)),
6715
6779
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6716
6780
  ])));
6717
6781
  const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([
6718
6782
  strong_1.strong,
6719
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*`)),
6783
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', /\*/)),
6720
6784
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6721
6785
  ])));
6722
6786
  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)([
6723
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*`)),
6787
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', /\*/)),
6724
6788
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6725
- ]))), (0, source_1.str)(/^\*{1,3}/), false, ([as, bs, cs], rest, context) => {
6789
+ ]))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], rest, context) => {
6726
6790
  var _a, _b;
6727
- if (!(0, util_1.isEndTightNodes)(bs))
6728
- return [
6729
- (0, array_1.unshift)(as, bs),
6730
- cs[0] + rest
6731
- ];
6732
6791
  switch (cs[0]) {
6733
6792
  case '***':
6734
6793
  return [
@@ -6736,7 +6795,7 @@ require = function () {
6736
6795
  rest
6737
6796
  ];
6738
6797
  case '**':
6739
- return (_a = (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' && (0, util_1.isEndTightNodes)(ds) ? [
6798
+ return (_a = (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' ? [
6740
6799
  [(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)))],
6741
6800
  rest.slice(1)
6742
6801
  ] : [
@@ -6753,7 +6812,7 @@ require = function () {
6753
6812
  rest
6754
6813
  ];
6755
6814
  case '*':
6756
- return (_b = (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' && (0, util_1.isEndTightNodes)(ds) ? [
6815
+ return (_b = (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' ? [
6757
6816
  [(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)))],
6758
6817
  rest.slice(2)
6759
6818
  ] : [
@@ -6870,18 +6929,18 @@ require = function () {
6870
6929
  autolink: false
6871
6930
  }
6872
6931
  }
6873
- }, (0, combinator_1.open)((0, source_1.str)(/^\|?/, false), (0, combinator_1.some)((0, combinator_1.union)([
6932
+ }, (0, combinator_1.some)((0, combinator_1.union)([
6874
6933
  signature,
6875
6934
  inline_1.inline
6876
- ]), ']', /^\\?\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, {
6935
+ ]), ']', /^\\?\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, {
6877
6936
  id: el.id ? null : global_1.undefined,
6878
6937
  class: 'index',
6879
6938
  href: el.id ? `#${ el.id }` : global_1.undefined
6880
6939
  }, el.childNodes)]))));
6881
- 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)([
6940
+ 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)([
6882
6941
  bracket,
6883
6942
  source_1.txt
6884
- ]), ']', /^\\?\n/))), ns => [(0, typed_dom_1.html)('span', {
6943
+ ]), ']'))), ns => [(0, typed_dom_1.html)('span', {
6885
6944
  class: 'indexer',
6886
6945
  'data-index': (0, indexee_1.identity)((0, array_1.join)(ns)).slice(6)
6887
6946
  })])));
@@ -7114,11 +7173,11 @@ require = function () {
7114
7173
  (0, alias_1.ObjectSetPrototypeOf)(attrspec, null);
7115
7174
  (0, alias_1.ObjectValues)(attrspec).forEach(o => (0, alias_1.ObjectSetPrototypeOf)(o, null));
7116
7175
  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)([
7117
- (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) => [
7176
+ (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])), /^\s*>/, true, ([, bs = []], rest) => [
7118
7177
  [(0, typed_dom_1.html)(tag, attributes('html', [], attrspec[tag], bs))],
7119
7178
  rest
7120
7179
  ]), ([, tag]) => tag)),
7121
- (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)((() => {
7180
+ (0, combinator_1.match)(/^(?=<(sup|sub|small)(?=[^\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)(/^\s*>/), true), (0, util_1.startLoose)((0, combinator_1.context)((() => {
7122
7181
  switch (tag) {
7123
7182
  case 'sup':
7124
7183
  case 'sub':
@@ -7140,12 +7199,28 @@ require = function () {
7140
7199
  default:
7141
7200
  return {};
7142
7201
  }
7143
- })(), (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), `</${ tag }>`)), `</${ tag }>`), (0, source_1.str)(`</${ tag }>`), false, ([as, bs, cs], rest, context) => [
7144
- [elem(tag, as, (0, util_1.trimNodeEndBR)((0, typed_dom_1.defrag)(bs)), cs, context)],
7202
+ })(), (0, combinator_1.some)((0, combinator_1.union)([
7203
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n?/, `</${ tag }>`)),
7204
+ (0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, '</'), true)
7205
+ ]), `</${ tag }>`)), `</${ tag }>`), (0, source_1.str)(`</${ tag }>`), false, ([as, bs, cs], rest, context) => [
7206
+ [elem(tag, as, (0, typed_dom_1.defrag)(bs), cs, context)],
7145
7207
  rest
7146
7208
  ])), ([, tag]) => tag)),
7147
- (0, combinator_1.match)(/^(?=<([a-z]+)(?=[^\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.some)((0, combinator_1.union)([inline_1.inline]), `</${ tag }>`), `</${ tag }>`), (0, source_1.str)(`</${ tag }>`), false, ([as, bs, cs], rest) => [
7148
- [elem(tag, as, (0, util_1.trimNodeEndBR)((0, typed_dom_1.defrag)(bs)), cs, {})],
7209
+ (0, combinator_1.match)(/^(?=<(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)(/^\s*>/), true), (0, util_1.startLoose)((0, combinator_1.some)((0, combinator_1.union)([
7210
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n?/, `</${ tag }>`)),
7211
+ (0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, '</'), true)
7212
+ ]), `</${ tag }>`), `</${ tag }>`), (0, source_1.str)(`</${ tag }>`), false, ([as, bs, cs], rest) => [
7213
+ [elem(tag, as, (0, typed_dom_1.defrag)(bs), cs, {})],
7214
+ rest
7215
+ ], ([as, bs], rest) => as.length === 1 ? [
7216
+ (0, array_1.unshift)(as, bs),
7217
+ rest
7218
+ ] : global_1.undefined)), ([, tag]) => tag)),
7219
+ (0, combinator_1.match)(/^(?=<([a-z]+)(?=[^\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)(/^\s*>/), true), (0, util_1.startLoose)((0, combinator_1.some)((0, combinator_1.union)([
7220
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n?/, `</${ tag }>`)),
7221
+ (0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, '</'), true)
7222
+ ]), `</${ tag }>`), `</${ tag }>`), (0, source_1.str)(`</${ tag }>`), false, ([as, bs, cs], rest) => [
7223
+ [elem(tag, as, (0, typed_dom_1.defrag)(bs), cs, {})],
7149
7224
  rest
7150
7225
  ], ([as, bs], rest) => as.length === 1 ? [
7151
7226
  (0, array_1.unshift)(as, bs),
@@ -7175,10 +7250,8 @@ require = function () {
7175
7250
  }
7176
7251
  let attrs;
7177
7252
  switch (true) {
7178
- case as[as.length - 1] !== '>' || 'data-invalid-syntax' in (attrs = attributes('html', [], attrspec[tag], as.slice(1, -1))):
7253
+ case 'data-invalid-syntax' in (attrs = attributes('html', [], attrspec[tag], as.slice(1, -1))):
7179
7254
  return invalid('attribute', 'Invalid HTML attribute.', as, bs, cs);
7180
- case cs.length === 0:
7181
- return invalid('closer', `Missing the closing HTML tag <${ tag }>.`, as, bs, cs);
7182
7255
  default:
7183
7256
  return (0, typed_dom_1.html)(tag, attrs, bs);
7184
7257
  }
@@ -7265,8 +7338,11 @@ require = function () {
7265
7338
  const util_1 = _dereq_('../util');
7266
7339
  const typed_dom_1 = _dereq_('typed-dom');
7267
7340
  const array_1 = _dereq_('spica/array');
7268
- exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('++'), (0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '++')]), (0, source_1.str)('++'), false, ([, bs], rest) => [
7269
- [(0, typed_dom_1.html)('ins', (0, typed_dom_1.defrag)((0, util_1.trimNodeEndBR)(bs)))],
7341
+ exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('++'), (0, combinator_1.some)((0, combinator_1.union)([
7342
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n?/, /\+\+/)),
7343
+ (0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, '+'), true)
7344
+ ])), (0, source_1.str)('++'), false, ([, bs], rest) => [
7345
+ [(0, typed_dom_1.html)('ins', (0, typed_dom_1.defrag)(bs))],
7270
7346
  rest
7271
7347
  ], ([as, bs], rest) => [
7272
7348
  (0, array_1.unshift)(as, bs),
@@ -7300,10 +7376,10 @@ require = function () {
7300
7376
  const url_1 = _dereq_('spica/url');
7301
7377
  const optspec = { rel: ['nofollow'] };
7302
7378
  (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)([
7379
+ exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.creator)(10, (0, combinator_1.validate)([
7304
7380
  '[',
7305
7381
  '{'
7306
- ], '}', '\n', (0, combinator_1.guard)(context => {
7382
+ ], '}', '\n', (0, combinator_1.bind)((0, combinator_1.guard)(context => {
7307
7383
  var _a, _b, _c;
7308
7384
  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
7385
  }, (0, combinator_1.reverse)((0, combinator_1.tails)([
@@ -7321,18 +7397,18 @@ require = function () {
7321
7397
  autolink: false
7322
7398
  }
7323
7399
  }
7324
- }, (0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/)), ']'), ']', true)
7400
+ }, (0, util_1.trimSpaceStart)((0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/)))), ']', true)
7325
7401
  ]))),
7326
7402
  (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([
7327
7403
  exports.uri,
7328
7404
  (0, combinator_1.some)(exports.option)
7329
- ]), /^[^\S\n]?}/))
7330
- ])))), ([params, content = []], rest, context) => {
7405
+ ]), /^[^\S\n]*}/))
7406
+ ]))), ([params, content = []], rest, context) => {
7331
7407
  var _a, _b, _c, _d, _e, _f;
7332
7408
  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
7409
  return;
7334
7410
  const INSECURE_URI = params.shift();
7335
- const el = elem(INSECURE_URI, (0, util_1.trimNode)((0, typed_dom_1.defrag)(content)), new url_1.ReadonlyURL(resolve(INSECURE_URI, (_b = context.host) !== null && _b !== void 0 ? _b : global_1.location, (_d = (_c = context.url) !== null && _c !== void 0 ? _c : context.host) !== null && _d !== void 0 ? _d : global_1.location), ((_e = context.host) === null || _e === void 0 ? void 0 : _e.href) || global_1.location.href), ((_f = context.host) === null || _f === void 0 ? void 0 : _f.origin) || global_1.location.origin);
7411
+ const el = elem(INSECURE_URI, (0, util_1.trimNodeEnd)((0, typed_dom_1.defrag)(content)), new url_1.ReadonlyURL(resolve(INSECURE_URI, (_b = context.host) !== null && _b !== void 0 ? _b : global_1.location, (_d = (_c = context.url) !== null && _c !== void 0 ? _c : context.host) !== null && _d !== void 0 ? _d : global_1.location), ((_e = context.host) === null || _e === void 0 ? void 0 : _e.href) || global_1.location.href), ((_f = context.host) === null || _f === void 0 ? void 0 : _f.origin) || global_1.location.origin);
7336
7412
  if (el.classList.contains('invalid'))
7337
7413
  return [
7338
7414
  [el],
@@ -7342,16 +7418,15 @@ require = function () {
7342
7418
  [(0, typed_dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))],
7343
7419
  rest
7344
7420
  ];
7345
- })));
7421
+ }))));
7346
7422
  exports.uri = (0, combinator_1.union)([
7347
- (0, combinator_1.open)(/^[^\S\n]/, (0, source_1.str)(/^\S+/)),
7423
+ (0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)),
7348
7424
  (0, source_1.str)(/^[^\s{}]+/)
7349
7425
  ]);
7350
7426
  exports.option = (0, combinator_1.union)([
7351
7427
  (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+nofollow(?=[^\S\n]|})/), () => [` rel="nofollow"`]),
7352
7428
  (0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|})/),
7353
- (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+(?=})/), () => []),
7354
- (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[^\n{}]+/), opt => [` \\${ opt.slice(1) }`])
7429
+ (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[^\s{}]+/), opt => [` \\${ opt.slice(1) }`])
7355
7430
  ]);
7356
7431
  function resolve(uri, host, source) {
7357
7432
  switch (true) {
@@ -7438,14 +7513,11 @@ require = function () {
7438
7513
  const typed_dom_1 = _dereq_('typed-dom');
7439
7514
  const array_1 = _dereq_('spica/array');
7440
7515
  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)('==')),
7516
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', /==/)),
7442
7517
  (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) ? [
7518
+ ]))), (0, source_1.str)('=='), false, ([, bs], rest) => [
7444
7519
  [(0, typed_dom_1.html)('mark', (0, typed_dom_1.defrag)(bs))],
7445
7520
  rest
7446
- ] : [
7447
- (0, array_1.unshift)(as, bs),
7448
- cs[0] + rest
7449
7521
  ], ([as, bs], rest) => [
7450
7522
  (0, array_1.unshift)(as, bs),
7451
7523
  rest
@@ -7524,10 +7596,10 @@ require = function () {
7524
7596
  rel: global_1.undefined
7525
7597
  };
7526
7598
  (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 => {
7599
+ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.creator)(10, (0, combinator_1.validate)([
7600
+ '![',
7601
+ '!{'
7602
+ ], '}', '\n', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.open)('!', (0, combinator_1.guard)(context => {
7531
7603
  var _a, _b, _c;
7532
7604
  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
7605
  }, (0, combinator_1.tails)([
@@ -7539,8 +7611,8 @@ require = function () {
7539
7611
  (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([
7540
7612
  link_1.uri,
7541
7613
  (0, combinator_1.some)(option)
7542
- ]), /^[^\S\n]?}/))
7543
- ])))), ([as, bs]) => bs ? [
7614
+ ]), /^[^\S\n]*}/))
7615
+ ]))), ([as, bs]) => bs ? [
7544
7616
  [(0, array_1.join)(as).trim() || (0, array_1.join)(as)],
7545
7617
  bs
7546
7618
  ] : [
@@ -7569,7 +7641,7 @@ require = function () {
7569
7641
  rest
7570
7642
  ];
7571
7643
  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
- })));
7644
+ }))));
7573
7645
  const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([
7574
7646
  (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([
7575
7647
  htmlentity_1.unsafehtmlentity,
@@ -7683,16 +7755,16 @@ require = function () {
7683
7755
  state: global_1.undefined
7684
7756
  }, (0, combinator_1.subsequence)([
7685
7757
  abbr,
7686
- (0, combinator_1.focus)('^', c => [
7758
+ (0, combinator_1.focus)(/^\^[^\S\n]*/, source => [
7687
7759
  [
7688
7760
  '',
7689
- c
7761
+ source
7690
7762
  ],
7691
7763
  ''
7692
7764
  ]),
7693
- (0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/)
7694
- ])), ']]')), ']]'), ns => [(0, typed_dom_1.html)('sup', attributes(ns), (0, util_1.trimNode)((0, typed_dom_1.defrag)(ns)))]))));
7695
- const abbr = (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?![0-9]+\s?[|\]])[0-9A-Za-z]+(?:(?:-|(?=\W)(?!'\d)'?(?!\.\d)\.?(?!,\S),? ?)[0-9A-Za-z]+)*(?:-|'?\.?,? ?)?/)]), /^\|?(?=]])|^\|[^\S\n]/), (_, rest, context) => (0, util_1.isStartLoose)(rest, context)), ([source]) => [(0, typed_dom_1.html)('abbr', source)]));
7765
+ (0, util_1.trimSpaceStart)((0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/))
7766
+ ])))), ']]'), ns => [(0, typed_dom_1.html)('sup', attributes(ns), (0, util_1.trimNodeEnd)((0, typed_dom_1.defrag)(ns)))]))));
7767
+ const abbr = (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?![0-9]+\s?[|\]])[0-9A-Za-z]+(?:(?:-|(?=\W)(?!'\d)'?(?!\.\d)\.?(?!,\S),? ?)[0-9A-Za-z]+)*(?:-|'?\.?,? ?)?/)]), /^\|?(?=]])|^\|[^\S\n]+/), (_, rest, context) => (0, util_1.isStartLoose)(rest, context)), ([source]) => [(0, typed_dom_1.html)('abbr', source)]));
7696
7768
  function attributes(ns) {
7697
7769
  return typeof ns[0] === 'object' && ns[0].tagName === 'ABBR' ? {
7698
7770
  class: 'reference',
@@ -7727,10 +7799,10 @@ require = function () {
7727
7799
  const util_1 = _dereq_('../util');
7728
7800
  const typed_dom_1 = _dereq_('typed-dom');
7729
7801
  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)([
7802
+ 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
7803
  (0, combinator_1.surround)('[', (0, combinator_1.focus)(/^(?:\\[^\n]|[^\\\[\]\n])+(?=]\()/, text), ']'),
7732
7804
  (0, combinator_1.surround)('(', (0, combinator_1.focus)(/^(?:\\[^\n]|[^\\\(\)\n])+(?=\))/, text), ')')
7733
- ])), ([texts]) => (0, util_1.isStartTightNodes)(texts)), ([texts, rubies], rest) => {
7805
+ ]), ([texts]) => (0, util_1.isStartTightNodes)(texts)), ([texts, rubies], rest) => {
7734
7806
  const tail = typeof texts[texts.length - 1] === 'object' ? [texts.pop()] : [];
7735
7807
  tail.length === 0 && texts[texts.length - 1] === '' && texts.pop();
7736
7808
  switch (true) {
@@ -7762,7 +7834,7 @@ require = function () {
7762
7834
  rest
7763
7835
  ];
7764
7836
  }
7765
- })));
7837
+ }))));
7766
7838
  const text = (0, combinator_1.creator)((source, context) => {
7767
7839
  var _a;
7768
7840
  const acc = [''];
@@ -7857,14 +7929,11 @@ require = function () {
7857
7929
  const typed_dom_1 = _dereq_('typed-dom');
7858
7930
  const array_1 = _dereq_('spica/array');
7859
7931
  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)([
7860
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*\*`)),
7932
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', /\*\*/)),
7861
7933
  (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) ? [
7934
+ ])), '*'), (0, source_1.str)('**'), false, ([, bs], rest) => [
7863
7935
  [(0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))],
7864
7936
  rest
7865
- ] : [
7866
- (0, array_1.unshift)(as, bs),
7867
- cs[0] + rest
7868
7937
  ], ([as, bs], rest) => [
7869
7938
  (0, array_1.unshift)(as, bs),
7870
7939
  rest
@@ -8078,7 +8147,7 @@ require = function () {
8078
8147
  !(0, label_1.isFixed)(label) && numbers.set(group, number);
8079
8148
  opts.id !== '' && def.setAttribute('id', `label:${ opts.id ? `${ opts.id }:` : '' }${ label }`);
8080
8149
  const figindex = group === '$' ? `(${ number })` : `${ capitalize(group) }${ group === 'fig' ? '.' : '' } ${ number }`;
8081
- (0, typed_dom_1.define)(def.querySelector(':scope > .figindex'), group === '$' ? figindex : `${ figindex }. `);
8150
+ (0, typed_dom_1.define)(def.querySelector(':scope > figcaption > .figindex'), group === '$' ? figindex : `${ figindex }. `);
8082
8151
  for (const ref of refs.take(label, global_1.Infinity)) {
8083
8152
  if (ref.hash.slice(1) === def.id && ref.innerText === figindex)
8084
8153
  continue;
@@ -8650,18 +8719,19 @@ require = function () {
8650
8719
  function (_dereq_, module, exports) {
8651
8720
  'use strict';
8652
8721
  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;
8722
+ exports.stringify = exports.trimNodeEnd = exports.trimSpaceStart = exports.isStartTightNodes = exports.startTight = exports.isStartLoose = exports.startLoose = exports.visualize = exports.blank = void 0;
8654
8723
  const global_1 = _dereq_('spica/global');
8655
8724
  const parser_1 = _dereq_('../combinator/data/parser');
8656
8725
  const combinator_1 = _dereq_('../combinator');
8657
8726
  const htmlentity_1 = _dereq_('./inline/htmlentity');
8658
8727
  const source_1 = _dereq_('./source');
8659
8728
  const normalize_1 = _dereq_('./api/normalize');
8729
+ const memoize_1 = _dereq_('spica/memoize');
8660
8730
  const array_1 = _dereq_('spica/array');
8661
- function delimiter(opener) {
8662
- return new RegExp(String.raw`^(?:\s+|\\\s|&(?:${ normalize_1.invisibleHTMLEntityNames.join('|') });|<wbr>)?${ opener }`);
8731
+ function blank(prefix, suffix) {
8732
+ return new RegExp(String.raw`^${ prefix && prefix.source }(?:\\\s|[^\S\n]+|\n|&(?:${ normalize_1.invisibleHTMLEntityNames.join('|') });|<wbr>)?${ typeof suffix === 'string' ? suffix : suffix.source }`);
8663
8733
  }
8664
- exports.delimiter = delimiter;
8734
+ exports.blank = blank;
8665
8735
  function visualize(parser) {
8666
8736
  const blankline = new RegExp(String.raw`^(?:\\$|\\?[^\S\n]|&(?:${ normalize_1.invisibleHTMLEntityNames.join('|') });|<wbr>)+$`, 'gm');
8667
8737
  return (0, combinator_1.union)([
@@ -8695,21 +8765,17 @@ require = function () {
8695
8765
  return false;
8696
8766
  }
8697
8767
  function startLoose(parser, except) {
8698
- return (source, context) => isStartLoose(source, context, except) ? parser(source, context) : global_1.undefined;
8768
+ return (source, context) => (0, exports.isStartLoose)(source, context, except) ? parser(source, context) : global_1.undefined;
8699
8769
  }
8700
8770
  exports.startLoose = startLoose;
8701
- function isStartLoose(source, context, except) {
8702
- source && (source = source.replace(/^[^\S\n]+/, ''));
8703
- if (source === '')
8704
- return true;
8705
- return isStartTight(source, context, except);
8706
- }
8707
- exports.isStartLoose = isStartLoose;
8771
+ exports.isStartLoose = (0, memoize_1.reduce)((source, context, except) => {
8772
+ return isStartTight(source.replace(/^[^\S\n]+/, ''), context, except);
8773
+ }, (source, _, except = '') => `${ source }\0${ except }`);
8708
8774
  function startTight(parser, except) {
8709
8775
  return (source, context) => isStartTight(source, context, except) ? parser(source, context) : global_1.undefined;
8710
8776
  }
8711
8777
  exports.startTight = startTight;
8712
- function isStartTight(source, context, except) {
8778
+ const isStartTight = (0, memoize_1.reduce)((source, context, except) => {
8713
8779
  var _a, _b, _c;
8714
8780
  if (source === '')
8715
8781
  return true;
@@ -8738,19 +8804,13 @@ require = function () {
8738
8804
  default:
8739
8805
  return source[0].trimStart() !== '';
8740
8806
  }
8741
- }
8807
+ }, (source, _, except = '') => `${ source }\0${ except }`);
8742
8808
  function isStartTightNodes(nodes) {
8743
8809
  if (nodes.length === 0)
8744
8810
  return true;
8745
8811
  return isVisible(nodes[0], 0);
8746
8812
  }
8747
8813
  exports.isStartTightNodes = isStartTightNodes;
8748
- function isEndTightNodes(nodes) {
8749
- if (nodes.length === 0)
8750
- return true;
8751
- return isVisible(nodes[nodes.length - 1], -1);
8752
- }
8753
- exports.isEndTightNodes = isEndTightNodes;
8754
8814
  function isVisible(node, strpos) {
8755
8815
  switch (typeof node) {
8756
8816
  case 'string':
@@ -8776,25 +8836,10 @@ require = function () {
8776
8836
  }
8777
8837
  }
8778
8838
  }
8779
- function trimNode(nodes) {
8780
- return trimNodeStart(trimNodeEnd(nodes));
8781
- }
8782
- exports.trimNode = trimNode;
8783
- function trimNodeStart(nodes) {
8784
- for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
8785
- if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer')
8786
- break;
8787
- if (typeof node === 'string') {
8788
- const pos = node.length - node.trimStart().length;
8789
- if (pos > 0) {
8790
- nodes[0] = node.slice(pos);
8791
- break;
8792
- }
8793
- }
8794
- nodes.shift();
8795
- }
8796
- return nodes;
8839
+ function trimSpaceStart(parser) {
8840
+ return (0, combinator_1.convert)((0, memoize_1.reduce)(source => source.replace(/^[^\S\n]+/, '')), parser);
8797
8841
  }
8842
+ exports.trimSpaceStart = trimSpaceStart;
8798
8843
  function trimNodeEnd(nodes) {
8799
8844
  const skip = nodes.length > 0 && typeof nodes[nodes.length - 1] === 'object' && nodes[nodes.length - 1]['className'] === 'indexer' ? [nodes.pop()] : [];
8800
8845
  for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
@@ -8810,13 +8855,6 @@ require = function () {
8810
8855
  return (0, array_1.push)(nodes, skip);
8811
8856
  }
8812
8857
  exports.trimNodeEnd = trimNodeEnd;
8813
- function trimNodeEndBR(nodes) {
8814
- if (nodes.length === 0)
8815
- return nodes;
8816
- const node = nodes[nodes.length - 1];
8817
- return typeof node === 'object' && node.tagName === 'BR' ? (0, array_1.pop)(nodes)[0] : nodes;
8818
- }
8819
- exports.trimNodeEndBR = trimNodeEndBR;
8820
8858
  function stringify(nodes) {
8821
8859
  let acc = '';
8822
8860
  for (let i = 0; i < nodes.length; ++i) {
@@ -8838,7 +8876,8 @@ require = function () {
8838
8876
  './inline/htmlentity': 112,
8839
8877
  './source': 128,
8840
8878
  'spica/array': 6,
8841
- 'spica/global': 15
8879
+ 'spica/global': 15,
8880
+ 'spica/memoize': 18
8842
8881
  }
8843
8882
  ],
8844
8883
  135: [