securemark 0.235.1 → 0.236.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/securemark.js +179 -141
  3. package/markdown.d.ts +7 -2
  4. package/package-lock.json +43 -64
  5. package/package.json +3 -3
  6. package/src/debug.test.ts +3 -1
  7. package/src/parser/api/parse.test.ts +3 -3
  8. package/src/parser/block/blockquote.test.ts +1 -1
  9. package/src/parser/block/codeblock.ts +1 -1
  10. package/src/parser/block/extension/aside.test.ts +1 -1
  11. package/src/parser/block/extension/aside.ts +2 -2
  12. package/src/parser/block/extension/example.test.ts +2 -2
  13. package/src/parser/block/extension/example.ts +2 -2
  14. package/src/parser/block/extension/fig.test.ts +20 -20
  15. package/src/parser/block/extension/figure.test.ts +33 -31
  16. package/src/parser/block/extension/figure.ts +8 -4
  17. package/src/parser/block/extension/message.ts +2 -2
  18. package/src/parser/block/extension/placeholder.ts +1 -1
  19. package/src/parser/block/extension/table.ts +5 -5
  20. package/src/parser/block/ilist.ts +1 -1
  21. package/src/parser/block/mathblock.ts +1 -1
  22. package/src/parser/block/olist.ts +1 -1
  23. package/src/parser/block/paragraph.test.ts +1 -1
  24. package/src/parser/block/reply/quote.ts +1 -1
  25. package/src/parser/block/table.ts +1 -1
  26. package/src/parser/block/ulist.ts +1 -1
  27. package/src/parser/header.ts +1 -1
  28. package/src/parser/inline/annotation.ts +3 -3
  29. package/src/parser/inline/bracket.test.ts +10 -10
  30. package/src/parser/inline/bracket.ts +2 -5
  31. package/src/parser/inline/deletion.test.ts +4 -1
  32. package/src/parser/inline/deletion.ts +7 -4
  33. package/src/parser/inline/emphasis.ts +2 -2
  34. package/src/parser/inline/emstrong.ts +4 -4
  35. package/src/parser/inline/extension/placeholder.ts +1 -1
  36. package/src/parser/inline/html.test.ts +25 -17
  37. package/src/parser/inline/html.ts +43 -19
  38. package/src/parser/inline/htmlentity.test.ts +1 -1
  39. package/src/parser/inline/htmlentity.ts +18 -11
  40. package/src/parser/inline/insertion.test.ts +4 -1
  41. package/src/parser/inline/insertion.ts +7 -4
  42. package/src/parser/inline/link.test.ts +3 -0
  43. package/src/parser/inline/link.ts +10 -11
  44. package/src/parser/inline/mark.ts +2 -2
  45. package/src/parser/inline/math.ts +1 -1
  46. package/src/parser/inline/media.test.ts +3 -0
  47. package/src/parser/inline/media.ts +4 -4
  48. package/src/parser/inline/reference.ts +7 -7
  49. package/src/parser/inline/ruby.ts +2 -2
  50. package/src/parser/inline/strong.ts +2 -2
  51. package/src/parser/inline.test.ts +2 -2
  52. package/src/parser/processor/figure.test.ts +33 -29
  53. package/src/parser/processor/figure.ts +25 -3
  54. package/src/parser/processor/footnote.ts +3 -3
  55. package/src/parser/util.ts +38 -32
@@ -1,4 +1,4 @@
1
- /*! securemark v0.235.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.236.0 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) {
@@ -2344,6 +2344,7 @@ require = function () {
2344
2344
  'use strict';
2345
2345
  Object.defineProperty(exports, '__esModule', { value: true });
2346
2346
  exports.SVG = exports.HTML = exports.Shadow = exports.API = void 0;
2347
+ const global_1 = _dereq_('spica/global');
2347
2348
  const alias_1 = _dereq_('spica/alias');
2348
2349
  const proxy_1 = _dereq_('./proxy');
2349
2350
  const dom_1 = _dereq_('./util/dom');
@@ -2363,22 +2364,24 @@ require = function () {
2363
2364
  };
2364
2365
  function builder(tag, baseFactory) {
2365
2366
  return function build(attrs, children, factory) {
2366
- if (typeof attrs === 'function')
2367
- return build(void 0, void 0, attrs);
2368
2367
  if (typeof children === 'function')
2369
2368
  return build(attrs, void 0, children);
2370
- if (attrs !== void 0 && isElChildren(attrs))
2369
+ if (typeof attrs === 'function')
2370
+ return build(void 0, void 0, attrs);
2371
+ if (isElChildren(attrs))
2371
2372
  return build(void 0, attrs, factory);
2372
2373
  const node = formatter(elem(factory, attrs, children));
2373
2374
  return node.nodeType === 1 ? new proxy_1.Elem(node, children) : new proxy_1.Elem(node.host, children, node);
2374
2375
  };
2375
- function isElChildren(children) {
2376
- if (typeof children !== 'object')
2376
+ function isElChildren(param) {
2377
+ if (param === void 0)
2378
+ return false;
2379
+ if (param[global_1.Symbol.iterator])
2377
2380
  return true;
2378
- for (const i in children) {
2379
- if (!(0, alias_1.hasOwnProperty)(children, i))
2381
+ for (const i in param) {
2382
+ if (!(0, alias_1.hasOwnProperty)(param, i))
2380
2383
  continue;
2381
- return typeof children[i] === 'object';
2384
+ return typeof param[i] === 'object' && !!param[i];
2382
2385
  }
2383
2386
  return true;
2384
2387
  }
@@ -2394,7 +2397,8 @@ require = function () {
2394
2397
  {
2395
2398
  './proxy': 14,
2396
2399
  './util/dom': 15,
2397
- 'spica/alias': 4
2400
+ 'spica/alias': 4,
2401
+ 'spica/global': 8
2398
2402
  }
2399
2403
  ],
2400
2404
  14: [
@@ -2808,8 +2812,8 @@ require = function () {
2808
2812
  node.replaceChildren(...typeof children === 'string' ? [children] : children);
2809
2813
  return node;
2810
2814
  }
2811
- function isChildren(o) {
2812
- return !!(o === null || o === void 0 ? void 0 : o[global_1.Symbol.iterator]);
2815
+ function isChildren(param) {
2816
+ return !!(param === null || param === void 0 ? void 0 : param[global_1.Symbol.iterator]);
2813
2817
  }
2814
2818
  exports.isChildren = isChildren;
2815
2819
  function defrag(nodes) {
@@ -4774,7 +4778,7 @@ require = function () {
4774
4778
  translate: 'no',
4775
4779
  'data-invalid-syntax': 'codeblock',
4776
4780
  'data-invalid-type': !closer ? 'closer' : 'argument',
4777
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
4781
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
4778
4782
  }, `${ opener }${ body }${ closer }`)];
4779
4783
  const file = (_a = path.split('/').pop()) !== null && _a !== void 0 ? _a : '';
4780
4784
  const ext = file && file.includes('.', 1) ? file.split('.').pop() : '';
@@ -4912,7 +4916,7 @@ require = function () {
4912
4916
  translate: 'no',
4913
4917
  'data-invalid-syntax': 'aside',
4914
4918
  'data-invalid-type': !closer ? 'closer' : 'argument',
4915
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
4919
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
4916
4920
  }, `${ opener }${ body }${ closer }`)];
4917
4921
  const annotations = (0, typed_dom_1.html)('ol', { class: 'annotations' });
4918
4922
  const references = (0, typed_dom_1.html)('ol', { class: 'references' });
@@ -4930,7 +4934,7 @@ require = function () {
4930
4934
  translate: 'no',
4931
4935
  'data-invalid-syntax': 'aside',
4932
4936
  'data-invalid-type': 'content',
4933
- 'data-invalid-description': 'Missing the title at the first line.'
4937
+ 'data-invalid-message': 'Missing the title at the first line'
4934
4938
  }, `${ opener }${ body }${ closer }`)];
4935
4939
  return [(0, typed_dom_1.html)('aside', {
4936
4940
  id: (0, indexee_1.identity)((0, indexee_1.text)(heading)),
@@ -4967,7 +4971,7 @@ require = function () {
4967
4971
  translate: 'no',
4968
4972
  'data-invalid-syntax': 'example',
4969
4973
  'data-invalid-type': !closer ? 'closer' : 'argument',
4970
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
4974
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
4971
4975
  }, `${ opener }${ body }${ closer }`)];
4972
4976
  switch (type) {
4973
4977
  case 'markdown': {
@@ -5007,7 +5011,7 @@ require = function () {
5007
5011
  class: 'invalid',
5008
5012
  translate: 'no',
5009
5013
  'data-invalid-syntax': 'example',
5010
- 'data-invalid-description': 'Invalid example type.'
5014
+ 'data-invalid-message': 'Invalid example type'
5011
5015
  }, `${ opener }${ body }${ closer }`)];
5012
5016
  }
5013
5017
  }))));
@@ -5098,6 +5102,8 @@ require = function () {
5098
5102
  const combinator_1 = _dereq_('../../../combinator');
5099
5103
  const source_1 = _dereq_('../../source');
5100
5104
  const label_1 = _dereq_('../../inline/extension/label');
5105
+ const ulist_1 = _dereq_('../ulist');
5106
+ const olist_1 = _dereq_('../olist');
5101
5107
  const table_1 = _dereq_('../table');
5102
5108
  const codeblock_1 = _dereq_('../codeblock');
5103
5109
  const mathblock_1 = _dereq_('../mathblock');
@@ -5136,6 +5142,8 @@ require = function () {
5136
5142
  ])),
5137
5143
  (0, combinator_1.inits)([
5138
5144
  (0, combinator_1.block)((0, combinator_1.union)([
5145
+ ulist_1.ulist,
5146
+ olist_1.olist,
5139
5147
  table_1.table,
5140
5148
  codeblock_1.codeblock,
5141
5149
  mathblock_1.mathblock,
@@ -5150,7 +5158,7 @@ require = function () {
5150
5158
  (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))))))
5151
5159
  ])
5152
5160
  ])), ([label, param, content, ...caption]) => [(0, typed_dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [
5153
- (0, typed_dom_1.html)('div', { class: 'figcontent' }, [content]),
5161
+ (0, typed_dom_1.html)('div', [content]),
5154
5162
  (0, typed_dom_1.html)('figcaption', (0, array_1.unshift)([(0, typed_dom_1.html)('span', { class: 'figindex' })], (0, typed_dom_1.defrag)(caption)))
5155
5163
  ])])));
5156
5164
  function attributes(label, param, content, caption) {
@@ -5166,15 +5174,15 @@ require = function () {
5166
5174
  ...invalidLabel && {
5167
5175
  'data-invalid-syntax': 'figure',
5168
5176
  'data-invalid-type': 'label',
5169
- 'data-invalid-description': 'The last part of the fixed label numbers must not be 0.'
5177
+ 'data-invalid-message': 'The last part of the fixed label numbers must not be 0'
5170
5178
  } || invalidParam && {
5171
5179
  'data-invalid-syntax': 'figure',
5172
5180
  'data-invalid-type': 'argument',
5173
- 'data-invalid-description': 'Invalid argument.'
5181
+ 'data-invalid-message': 'Invalid argument'
5174
5182
  } || invalidContent && {
5175
5183
  'data-invalid-syntax': 'figure',
5176
5184
  'data-invalid-type': 'content',
5177
- 'data-invalid-description': 'A figure labeled to define a formula number can contain only a math formula and no caption.'
5185
+ 'data-invalid-message': 'A figure labeled to define a formula number can contain only a math formula and no caption'
5178
5186
  } || global_1.undefined
5179
5187
  };
5180
5188
  }
@@ -5189,7 +5197,9 @@ require = function () {
5189
5197
  '../blockquote': 64,
5190
5198
  '../codeblock': 65,
5191
5199
  '../mathblock': 79,
5200
+ '../olist': 80,
5192
5201
  '../table': 85,
5202
+ '../ulist': 86,
5193
5203
  './example': 69,
5194
5204
  './placeholder': 74,
5195
5205
  './table': 75,
@@ -5225,7 +5235,7 @@ require = function () {
5225
5235
  translate: 'no',
5226
5236
  'data-invalid-syntax': 'message',
5227
5237
  'data-invalid-type': !closer ? 'closer' : 'argument',
5228
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
5238
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
5229
5239
  }, `${ opener }${ body }${ closer }`)];
5230
5240
  switch (type) {
5231
5241
  case 'note':
@@ -5237,7 +5247,7 @@ require = function () {
5237
5247
  class: 'invalid',
5238
5248
  translate: 'no',
5239
5249
  'data-invalid-syntax': 'message',
5240
- 'data-invalid-description': 'Invalid message type.'
5250
+ 'data-invalid-message': 'Invalid message type'
5241
5251
  }, `${ opener }${ body }${ closer }`)];
5242
5252
  }
5243
5253
  return [(0, typed_dom_1.html)('div', { class: `message type-${ type }` }, (0, array_1.unshift)([(0, typed_dom_1.html)('h6', title(type))], [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, parser_1.eval)(content(seg, context), [])), [])))];
@@ -5296,7 +5306,7 @@ require = function () {
5296
5306
  translate: 'no',
5297
5307
  'data-invalid-syntax': 'extension',
5298
5308
  'data-invalid-type': !closer ? 'closer' : 'syntax',
5299
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid syntax.'
5309
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid syntax'
5300
5310
  }, `${ opener }${ body }${ closer }`)])));
5301
5311
  },
5302
5312
  {
@@ -5330,16 +5340,16 @@ require = function () {
5330
5340
  translate: 'no',
5331
5341
  'data-invalid-syntax': 'table',
5332
5342
  'data-invalid-type': !closer ? 'closer' : 'argument',
5333
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
5343
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
5334
5344
  }, `${ opener }${ body }${ closer }`)];
5335
5345
  return (_a = (0, parser_1.eval)(parser(body, context))) !== null && _a !== void 0 ? _a : [(0, typed_dom_1.html)('table')];
5336
- }), (source, _, reason) => reason instanceof Error && reason.message === 'Number of columns must be 32 or less.' ? [
5346
+ }), (source, _, reason) => reason instanceof Error && reason.message === 'Number of columns must be 32 or less' ? [
5337
5347
  [(0, typed_dom_1.html)('pre', {
5338
5348
  class: 'invalid',
5339
5349
  translate: 'no',
5340
5350
  'data-invalid-syntax': 'table',
5341
5351
  'data-invalid-type': 'content',
5342
- 'data-invalid-description': reason.message
5352
+ 'data-invalid-message': reason.message
5343
5353
  }, source)],
5344
5354
  ''
5345
5355
  ] : (() => {
@@ -5386,7 +5396,7 @@ require = function () {
5386
5396
  ...valid ? { 'data-highlight-level': +highlight > 1 ? highlight : global_1.undefined } : {
5387
5397
  'data-invalid-syntax': 'table',
5388
5398
  'data-invalid-type': 'syntax',
5389
- 'data-invalid-description': 'Too much highlight level.'
5399
+ 'data-invalid-message': 'Too much highlight level'
5390
5400
  }
5391
5401
  };
5392
5402
  }
@@ -5524,7 +5534,7 @@ require = function () {
5524
5534
  valigns[j] && cell.setAttribute('valign', valigns[j]);
5525
5535
  }
5526
5536
  if (cells.length > 32)
5527
- throw new Error('Number of columns must be 32 or less.');
5537
+ throw new Error('Number of columns must be 32 or less');
5528
5538
  target.appendChild(row);
5529
5539
  switch (target) {
5530
5540
  case thead:
@@ -5665,7 +5675,7 @@ require = function () {
5665
5675
  class: 'invalid',
5666
5676
  'data-invalid-syntax': 'list',
5667
5677
  'data-invalid-type': 'syntax',
5668
- 'data-invalid-description': 'Use "-" instead of "+" or "*".'
5678
+ 'data-invalid-message': 'Use "-" instead of "+" or "*"'
5669
5679
  }, es)])));
5670
5680
  },
5671
5681
  {
@@ -5702,7 +5712,7 @@ require = function () {
5702
5712
  translate: 'no',
5703
5713
  'data-invalid-syntax': 'mathblock',
5704
5714
  'data-invalid-type': delim.length > 2 ? 'syntax' : !closer ? 'closer' : 'argument',
5705
- 'data-invalid-description': delim.length > 2 ? 'Invalid syntax' : !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
5715
+ 'data-invalid-message': delim.length > 2 ? 'Invalid syntax' : !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
5706
5716
  }, `${ opener }${ body }${ closer }`)];
5707
5717
  })));
5708
5718
  },
@@ -5766,7 +5776,7 @@ require = function () {
5766
5776
  class: 'invalid',
5767
5777
  'data-invalid-syntax': 'listitem',
5768
5778
  'data-invalid-type': 'syntax',
5769
- 'data-invalid-description': 'Fix the indent or the head of the list item.'
5779
+ 'data-invalid-message': 'Fix the indent or the head of the list item'
5770
5780
  }, source.replace('\n', ''))
5771
5781
  ],
5772
5782
  ''
@@ -5959,7 +5969,7 @@ require = function () {
5959
5969
  class: 'quote invalid',
5960
5970
  'data-invalid-syntax': 'quote',
5961
5971
  'data-invalid-type': 'syntax',
5962
- 'data-invalid-description': `Missing the whitespace after "${ ns[0].split(/[^>]/, 1)[0] }".`
5972
+ 'data-invalid-message': `Missing the whitespace after "${ ns[0].split(/[^>]/, 1)[0] }"`
5963
5973
  }, (0, typed_dom_1.defrag)(ns)),
5964
5974
  (0, typed_dom_1.html)('br')
5965
5975
  ]), false)));
@@ -6033,7 +6043,7 @@ require = function () {
6033
6043
  class: 'invalid',
6034
6044
  'data-invalid-syntax': 'tablerow',
6035
6045
  'data-invalid-type': 'syntax',
6036
- 'data-invalid-description': 'Invalid table row.'
6046
+ 'data-invalid-message': 'Invalid table row'
6037
6047
  }, [(0, typed_dom_1.html)('td', source.replace('\n', ''))])],
6038
6048
  ''
6039
6049
  ])));
@@ -6115,7 +6125,7 @@ require = function () {
6115
6125
  class: 'invalid',
6116
6126
  'data-invalid-syntax': 'listitem',
6117
6127
  'data-invalid-type': 'syntax',
6118
- 'data-invalid-description': 'Fix the indent or the head of the list item.'
6128
+ 'data-invalid-message': 'Fix the indent or the head of the list item'
6119
6129
  }, source.replace('\n', ''))],
6120
6130
  ''
6121
6131
  ]);
@@ -6178,7 +6188,7 @@ require = function () {
6178
6188
  translate: 'no',
6179
6189
  'data-invalid-syntax': 'header',
6180
6190
  'data-invalid-type': 'syntax',
6181
- 'data-invalid-description': 'Invalid syntax.'
6191
+ 'data-invalid-message': 'Invalid syntax'
6182
6192
  }, (0, normalize_1.normalize)(source))],
6183
6193
  ''
6184
6194
  ]
@@ -6328,7 +6338,7 @@ require = function () {
6328
6338
  }
6329
6339
  },
6330
6340
  state: global_1.undefined
6331
- }, (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)))]))));
6341
+ }, (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)))]))));
6332
6342
  },
6333
6343
  {
6334
6344
  '../../combinator': 27,
@@ -6606,16 +6616,8 @@ require = function () {
6606
6616
  const typed_dom_1 = _dereq_('typed-dom');
6607
6617
  const array_1 = _dereq_('spica/array');
6608
6618
  const index = /^(?:[0-9]+(?:\.[0-9]+)*|[A-Za-z])/;
6609
- const indexFW = new RegExp(index.source.replace(/[019AZaz](?!,)/g, c => String.fromCharCode(c.charCodeAt(0) + 65248)));
6610
6619
  exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.union)([
6611
- (0, combinator_1.surround)((0, source_1.str)('('), (0, source_1.str)(index), (0, source_1.str)(')'), false, ([as, bs = [], cs], rest) => [
6612
- (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)),
6613
- rest
6614
- ]),
6615
- (0, combinator_1.surround)((0, source_1.str)('\uFF08'), (0, source_1.str)(indexFW), (0, source_1.str)('\uFF09'), false, ([as, bs = [], cs], rest) => [
6616
- (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)),
6617
- rest
6618
- ]),
6620
+ (0, combinator_1.surround)((0, source_1.str)('('), (0, source_1.str)(index), (0, source_1.str)(')')),
6619
6621
  (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)(inline_1.inline, ')'), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [
6620
6622
  [(0, typed_dom_1.html)('span', { class: 'paren' }, (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))],
6621
6623
  rest
@@ -6623,6 +6625,7 @@ require = function () {
6623
6625
  (0, array_1.unshift)(as, bs),
6624
6626
  rest
6625
6627
  ]),
6628
+ (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')),
6626
6629
  (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) => [
6627
6630
  [(0, typed_dom_1.html)('span', { class: 'paren' }, (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))],
6628
6631
  rest
@@ -6715,8 +6718,11 @@ require = function () {
6715
6718
  const util_1 = _dereq_('../util');
6716
6719
  const typed_dom_1 = _dereq_('typed-dom');
6717
6720
  const array_1 = _dereq_('spica/array');
6718
- 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) => [
6719
- [(0, typed_dom_1.html)('del', (0, typed_dom_1.defrag)((0, util_1.trimNodeEndBR)(bs)))],
6721
+ 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)([
6722
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n?/, '~~')),
6723
+ (0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, '~'), true)
6724
+ ])), (0, source_1.str)('~~'), false, ([, bs], rest) => [
6725
+ [(0, typed_dom_1.html)('del', (0, typed_dom_1.defrag)(bs))],
6720
6726
  rest
6721
6727
  ], ([as, bs], rest) => [
6722
6728
  (0, array_1.unshift)(as, bs),
@@ -6746,7 +6752,7 @@ require = function () {
6746
6752
  const array_1 = _dereq_('spica/array');
6747
6753
  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)([
6748
6754
  strong_1.strong,
6749
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*/)),
6755
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', '*')),
6750
6756
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6751
6757
  ])), '*'), (0, source_1.str)('*'), false, ([, bs], rest) => [
6752
6758
  [(0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))],
@@ -6779,16 +6785,16 @@ require = function () {
6779
6785
  const typed_dom_1 = _dereq_('typed-dom');
6780
6786
  const array_1 = _dereq_('spica/array');
6781
6787
  const substrong = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([
6782
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*\*/)),
6788
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', '**')),
6783
6789
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6784
6790
  ])));
6785
6791
  const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([
6786
6792
  strong_1.strong,
6787
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*/)),
6793
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', '*')),
6788
6794
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6789
6795
  ])));
6790
6796
  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)([
6791
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*/)),
6797
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', '*')),
6792
6798
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6793
6799
  ]))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], rest, context) => {
6794
6800
  var _a, _b;
@@ -7127,7 +7133,7 @@ require = function () {
7127
7133
  class: 'invalid',
7128
7134
  'data-invalid-syntax': 'extension',
7129
7135
  'data-invalid-type': 'syntax',
7130
- 'data-invalid-description': 'Invalid symbol.'
7136
+ 'data-invalid-message': 'Invalid symbol'
7131
7137
  }, (0, typed_dom_1.defrag)(bs))],
7132
7138
  rest
7133
7139
  ], ([as, bs], rest) => [
@@ -7177,11 +7183,11 @@ require = function () {
7177
7183
  (0, alias_1.ObjectSetPrototypeOf)(attrspec, null);
7178
7184
  (0, alias_1.ObjectValues)(attrspec).forEach(o => (0, alias_1.ObjectSetPrototypeOf)(o, null));
7179
7185
  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)([
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) => [
7186
+ (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) => [
7181
7187
  [(0, typed_dom_1.html)(tag, attributes('html', [], attrspec[tag], bs))],
7182
7188
  rest
7183
7189
  ]), ([, tag]) => tag)),
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)((() => {
7190
+ (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)((() => {
7185
7191
  switch (tag) {
7186
7192
  case 'sup':
7187
7193
  case 'sub':
@@ -7203,12 +7209,28 @@ require = function () {
7203
7209
  default:
7204
7210
  return {};
7205
7211
  }
7206
- })(), (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), `</${ tag }>`)), `</${ tag }>`), (0, source_1.str)(`</${ tag }>`), false, ([as, bs, cs], rest, context) => [
7207
- [elem(tag, as, (0, util_1.trimNodeEndBR)((0, typed_dom_1.defrag)(bs)), cs, context)],
7212
+ })(), (0, combinator_1.some)((0, combinator_1.union)([
7213
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n?/, `</${ tag }>`)),
7214
+ (0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, '</'), true)
7215
+ ]), `</${ tag }>`)), `</${ tag }>`), (0, source_1.str)(`</${ tag }>`), false, ([as, bs, cs], rest, context) => [
7216
+ [elem(tag, as, (0, typed_dom_1.defrag)(bs), cs, context)],
7208
7217
  rest
7209
7218
  ])), ([, tag]) => tag)),
7210
- (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) => [
7211
- [elem(tag, as, (0, util_1.trimNodeEndBR)((0, typed_dom_1.defrag)(bs)), cs, {})],
7219
+ (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)([
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, {})],
7224
+ rest
7225
+ ], ([as, bs], rest) => as.length === 1 ? [
7226
+ (0, array_1.unshift)(as, bs),
7227
+ rest
7228
+ ] : global_1.undefined)), ([, tag]) => tag)),
7229
+ (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)([
7230
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n?/, `</${ tag }>`)),
7231
+ (0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, '</'), true)
7232
+ ]), `</${ tag }>`), `</${ tag }>`), (0, source_1.str)(`</${ tag }>`), false, ([as, bs, cs], rest) => [
7233
+ [elem(tag, as, (0, typed_dom_1.defrag)(bs), cs, {})],
7212
7234
  rest
7213
7235
  ], ([as, bs], rest) => as.length === 1 ? [
7214
7236
  (0, array_1.unshift)(as, bs),
@@ -7219,37 +7241,37 @@ require = function () {
7219
7241
  function elem(tag, as, bs, cs, context) {
7220
7242
  var _a, _b, _c, _d, _e, _f;
7221
7243
  if (!tags.includes(tag))
7222
- return invalid('tag', `Invalid HTML tag <${ tag }>.`, as, bs, cs);
7244
+ return invalid('tag', `Invalid HTML tag <${ tag }>`, as, bs, cs);
7223
7245
  switch (tag) {
7224
7246
  case 'sup':
7225
7247
  case 'sub':
7226
7248
  switch (true) {
7227
7249
  case (_b = (_a = context.state) === null || _a === void 0 ? void 0 : _a.in) === null || _b === void 0 ? void 0 : _b.supsub:
7228
- return invalid('nest', `<${ tag }> HTML tag cannot be used in <sup> or <sub> HTML tag.`, as, bs, cs);
7250
+ return invalid('nest', `<${ tag }> HTML tag cannot be used in <sup> or <sub> HTML tag`, as, bs, cs);
7229
7251
  }
7230
7252
  break;
7231
7253
  case 'small':
7232
7254
  switch (true) {
7233
7255
  case (_d = (_c = context.state) === null || _c === void 0 ? void 0 : _c.in) === null || _d === void 0 ? void 0 : _d.supsub:
7234
7256
  case (_f = (_e = context.state) === null || _e === void 0 ? void 0 : _e.in) === null || _f === void 0 ? void 0 : _f.small:
7235
- return invalid('nest', `<${ tag }> HTML tag cannot be used in <sup>, <sub>, or <small> HTML tag.`, as, bs, cs);
7257
+ return invalid('nest', `<${ tag }> HTML tag cannot be used in <sup>, <sub>, or <small> HTML tag`, as, bs, cs);
7236
7258
  }
7237
7259
  break;
7238
7260
  }
7239
7261
  let attrs;
7240
7262
  switch (true) {
7241
- case as[as.length - 1] !== '>' || 'data-invalid-syntax' in (attrs = attributes('html', [], attrspec[tag], as.slice(1, -1))):
7242
- return invalid('attribute', 'Invalid HTML attribute.', as, bs, cs);
7263
+ case 'data-invalid-syntax' in (attrs = attributes('html', [], attrspec[tag], as.slice(1, -1))):
7264
+ return invalid('attribute', 'Invalid HTML attribute', as, bs, cs);
7243
7265
  default:
7244
7266
  return (0, typed_dom_1.html)(tag, attrs, bs);
7245
7267
  }
7246
7268
  }
7247
- function invalid(type, description, as, bs, cs) {
7269
+ function invalid(type, message, as, bs, cs) {
7248
7270
  return (0, typed_dom_1.html)('span', {
7249
7271
  class: 'invalid',
7250
7272
  'data-invalid-syntax': 'html',
7251
7273
  'data-invalid-type': type,
7252
- 'data-invalid-description': description
7274
+ 'data-invalid-message': message
7253
7275
  }, (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)));
7254
7276
  }
7255
7277
  const requiredAttributes = (0, memoize_1.memoize)(spec => (0, alias_1.ObjectEntries)(spec).flatMap(([k, v]) => v && (0, alias_1.isFrozen)(v) ? [k] : []), new WeakMap());
@@ -7273,7 +7295,7 @@ require = function () {
7273
7295
  attrs['class'] = (0, array_1.join)(classes, ' ');
7274
7296
  attrs['data-invalid-syntax'] = syntax;
7275
7297
  attrs['data-invalid-type'] = 'argument';
7276
- attrs['data-invalid-description'] = 'Invalid argument.';
7298
+ attrs['data-invalid-message'] = 'Invalid argument';
7277
7299
  }
7278
7300
  return attrs;
7279
7301
  }
@@ -7297,21 +7319,35 @@ require = function () {
7297
7319
  'use strict';
7298
7320
  Object.defineProperty(exports, '__esModule', { value: true });
7299
7321
  exports.htmlentity = exports.unsafehtmlentity = void 0;
7322
+ const global_1 = _dereq_('spica/global');
7300
7323
  const combinator_1 = _dereq_('../../combinator');
7301
7324
  const typed_dom_1 = _dereq_('typed-dom');
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 }`],
7304
- ''
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', {
7325
+ const memoize_1 = _dereq_('spica/memoize');
7326
+ exports.unsafehtmlentity = (0, combinator_1.creator)((0, combinator_1.validate)('&', (0, combinator_1.focus)(/^&[0-9A-Za-z]+;/, entity => {
7327
+ var _a;
7328
+ return [
7329
+ [(_a = parse(entity)) !== null && _a !== void 0 ? _a : `\0${ entity }`],
7330
+ ''
7331
+ ];
7332
+ })));
7333
+ exports.htmlentity = (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([test]) => [test[0] === '\0' ? (0, typed_dom_1.html)('span', {
7307
7334
  class: 'invalid',
7308
7335
  'data-invalid-syntax': 'htmlentity',
7309
7336
  'data-invalid-type': 'syntax',
7310
- 'data-invalid-description': 'Invalid HTML entity.'
7311
- }, str.slice(1)) : str]);
7337
+ 'data-invalid-message': 'Invalid HTML entity'
7338
+ }, test.slice(1)) : test]);
7339
+ const parse = (0, memoize_1.reduce)((el => entity => {
7340
+ if (entity === '&NewLine;')
7341
+ return ' ';
7342
+ el.innerHTML = entity;
7343
+ const text = el.textContent;
7344
+ return entity === text ? global_1.undefined : text;
7345
+ })((0, typed_dom_1.html)('b')));
7312
7346
  },
7313
7347
  {
7314
7348
  '../../combinator': 27,
7349
+ 'spica/global': 15,
7350
+ 'spica/memoize': 18,
7315
7351
  'typed-dom': 26
7316
7352
  }
7317
7353
  ],
@@ -7326,8 +7362,11 @@ require = function () {
7326
7362
  const util_1 = _dereq_('../util');
7327
7363
  const typed_dom_1 = _dereq_('typed-dom');
7328
7364
  const array_1 = _dereq_('spica/array');
7329
- 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) => [
7330
- [(0, typed_dom_1.html)('ins', (0, typed_dom_1.defrag)((0, util_1.trimNodeEndBR)(bs)))],
7365
+ 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)([
7366
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n?/, '++')),
7367
+ (0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, '+'), true)
7368
+ ])), (0, source_1.str)('++'), false, ([, bs], rest) => [
7369
+ [(0, typed_dom_1.html)('ins', (0, typed_dom_1.defrag)(bs))],
7331
7370
  rest
7332
7371
  ], ([as, bs], rest) => [
7333
7372
  (0, array_1.unshift)(as, bs),
@@ -7382,18 +7421,18 @@ require = function () {
7382
7421
  autolink: false
7383
7422
  }
7384
7423
  }
7385
- }, (0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/)), ']'), ']', true)
7424
+ }, (0, util_1.trimSpaceStart)((0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/)))), ']', true)
7386
7425
  ]))),
7387
7426
  (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([
7388
7427
  exports.uri,
7389
7428
  (0, combinator_1.some)(exports.option)
7390
- ]), /^[^\S\n]?}/))
7429
+ ]), /^[^\S\n]*}/))
7391
7430
  ]))), ([params, content = []], rest, context) => {
7392
7431
  var _a, _b, _c, _d, _e, _f;
7393
7432
  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'))
7394
7433
  return;
7395
7434
  const INSECURE_URI = params.shift();
7396
- 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);
7435
+ 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);
7397
7436
  if (el.classList.contains('invalid'))
7398
7437
  return [
7399
7438
  [el],
@@ -7405,14 +7444,13 @@ require = function () {
7405
7444
  ];
7406
7445
  }))));
7407
7446
  exports.uri = (0, combinator_1.union)([
7408
- (0, combinator_1.open)(/^[^\S\n]/, (0, source_1.str)(/^\S+/)),
7447
+ (0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)),
7409
7448
  (0, source_1.str)(/^[^\s{}]+/)
7410
7449
  ]);
7411
7450
  exports.option = (0, combinator_1.union)([
7412
7451
  (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+nofollow(?=[^\S\n]|})/), () => [` rel="nofollow"`]),
7413
7452
  (0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|})/),
7414
- (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+(?=})/), () => []),
7415
- (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[^\n{}]+/), opt => [` \\${ opt.slice(1) }`])
7453
+ (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[^\s{}]+/), opt => [` \\${ opt.slice(1) }`])
7416
7454
  ]);
7417
7455
  function resolve(uri, host, source) {
7418
7456
  switch (true) {
@@ -7430,13 +7468,13 @@ require = function () {
7430
7468
  exports.resolve = resolve;
7431
7469
  function elem(INSECURE_URI, content, uri, origin) {
7432
7470
  let type;
7433
- let description;
7471
+ let message;
7434
7472
  switch (uri.protocol) {
7435
7473
  case 'http:':
7436
7474
  case 'https:':
7437
7475
  if (INSECURE_URI.slice(0, 2) === '^/' && /\/\.\.?(?:\/|$)/.test(INSECURE_URI.slice(0, INSECURE_URI.search(/[?#]|$/)))) {
7438
7476
  type = 'argument';
7439
- description = 'Dot-segments cannot be used in subresource paths.';
7477
+ message = 'Dot-segments cannot be used in subresource paths';
7440
7478
  break;
7441
7479
  }
7442
7480
  return (0, typed_dom_1.html)('a', {
@@ -7453,14 +7491,14 @@ require = function () {
7453
7491
  return (0, typed_dom_1.html)('a', { href: uri.source }, content);
7454
7492
  }
7455
7493
  type = 'content';
7456
- description = 'Invalid phone number.';
7494
+ message = 'Invalid phone number';
7457
7495
  break;
7458
7496
  }
7459
7497
  return (0, typed_dom_1.html)('a', {
7460
7498
  class: 'invalid',
7461
7499
  'data-invalid-syntax': 'link',
7462
7500
  'data-invalid-type': type !== null && type !== void 0 ? type : type = 'argument',
7463
- 'data-invalid-description': description !== null && description !== void 0 ? description : description = 'Invalid protocol.'
7501
+ 'data-invalid-message': message !== null && message !== void 0 ? message : message = 'Invalid protocol'
7464
7502
  }, content.length === 0 ? INSECURE_URI : content);
7465
7503
  }
7466
7504
  function decode(uri) {
@@ -7499,7 +7537,7 @@ require = function () {
7499
7537
  const typed_dom_1 = _dereq_('typed-dom');
7500
7538
  const array_1 = _dereq_('spica/array');
7501
7539
  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)([
7502
- (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/==/)),
7540
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', '==')),
7503
7541
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '='), inline_1.inline)
7504
7542
  ]))), (0, source_1.str)('=='), false, ([, bs], rest) => [
7505
7543
  [(0, typed_dom_1.html)('mark', (0, typed_dom_1.defrag)(bs))],
@@ -7544,7 +7582,7 @@ require = function () {
7544
7582
  translate: 'no',
7545
7583
  'data-invalid-syntax': 'math',
7546
7584
  'data-invalid-type': 'content',
7547
- 'data-invalid-description': `"${ source.match(disallowedCommand)[0] }" command is disallowed.`
7585
+ 'data-invalid-message': `"${ source.match(disallowedCommand)[0] }" command is disallowed`
7548
7586
  }, source)],
7549
7587
  ''
7550
7588
  ];
@@ -7597,7 +7635,7 @@ require = function () {
7597
7635
  (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([
7598
7636
  link_1.uri,
7599
7637
  (0, combinator_1.some)(option)
7600
- ]), /^[^\S\n]?}/))
7638
+ ]), /^[^\S\n]*}/))
7601
7639
  ]))), ([as, bs]) => bs ? [
7602
7640
  [(0, array_1.join)(as).trim() || (0, array_1.join)(as)],
7603
7641
  bs
@@ -7676,7 +7714,7 @@ require = function () {
7676
7714
  class: void target.classList.add('invalid'),
7677
7715
  'data-invalid-syntax': 'media',
7678
7716
  'data-invalid-type': 'argument',
7679
- 'data-invalid-description': 'Dot-segments cannot be used in media paths; use subresource paths instead.'
7717
+ 'data-invalid-message': 'Dot-segments cannot be used in media paths; use subresource paths instead'
7680
7718
  });
7681
7719
  return false;
7682
7720
  }
@@ -7686,7 +7724,7 @@ require = function () {
7686
7724
  class: void target.classList.add('invalid'),
7687
7725
  'data-invalid-syntax': 'media',
7688
7726
  'data-invalid-type': 'argument',
7689
- 'data-invalid-description': 'Invalid protocol.'
7727
+ 'data-invalid-message': 'Invalid protocol'
7690
7728
  });
7691
7729
  return false;
7692
7730
  }
@@ -7695,7 +7733,7 @@ require = function () {
7695
7733
  class: void target.classList.add('invalid'),
7696
7734
  'data-invalid-syntax': 'media',
7697
7735
  'data-invalid-type': 'content',
7698
- 'data-invalid-description': `Cannot use invalid HTML entitiy "${ alt.match(/&[0-9A-Za-z]+;/)[0] }".`,
7736
+ 'data-invalid-message': `Cannot use invalid HTML entitiy "${ alt.match(/&[0-9A-Za-z]+;/)[0] }"`,
7699
7737
  alt: (_a = target.getAttribute('alt')) === null || _a === void 0 ? void 0 : _a.replace(/\0/g, '')
7700
7738
  });
7701
7739
  return false;
@@ -7741,16 +7779,16 @@ require = function () {
7741
7779
  state: global_1.undefined
7742
7780
  }, (0, combinator_1.subsequence)([
7743
7781
  abbr,
7744
- (0, combinator_1.focus)('^', c => [
7782
+ (0, combinator_1.focus)(/^\^[^\S\n]*/, source => [
7745
7783
  [
7746
7784
  '',
7747
- c
7785
+ source
7748
7786
  ],
7749
7787
  ''
7750
7788
  ]),
7751
- (0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/)
7752
- ])), ']]')), ']]'), ns => [(0, typed_dom_1.html)('sup', attributes(ns), (0, util_1.trimNode)((0, typed_dom_1.defrag)(ns)))]))));
7753
- 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)]));
7789
+ (0, util_1.trimSpaceStart)((0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/))
7790
+ ])))), ']]'), ns => [(0, typed_dom_1.html)('sup', attributes(ns), (0, util_1.trimNodeEnd)((0, typed_dom_1.defrag)(ns)))]))));
7791
+ 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)]));
7754
7792
  function attributes(ns) {
7755
7793
  return typeof ns[0] === 'object' && ns[0].tagName === 'ABBR' ? {
7756
7794
  class: 'reference',
@@ -7759,7 +7797,7 @@ require = function () {
7759
7797
  class: 'invalid',
7760
7798
  'data-invalid-syntax': 'reference',
7761
7799
  'data-invalid-type': 'syntax',
7762
- 'data-invalid-description': 'Invalid abbr.'
7800
+ 'data-invalid-message': 'Invalid abbr'
7763
7801
  } : { class: 'reference' };
7764
7802
  }
7765
7803
  },
@@ -7859,14 +7897,14 @@ require = function () {
7859
7897
  rubies
7860
7898
  ]) {
7861
7899
  for (let i = 0; i < ss.length; ++i) {
7862
- if (!ss[i].includes('\0'))
7900
+ if (ss[i].indexOf('\0') === -1)
7863
7901
  continue;
7864
7902
  ss[i] = ss[i].replace(/\0/g, '');
7865
7903
  attrs !== null && attrs !== void 0 ? attrs : attrs = {
7866
7904
  class: 'invalid',
7867
7905
  'data-invalid-syntax': 'ruby',
7868
7906
  'data-invalid-type': ss === texts ? 'content' : 'argument',
7869
- 'data-invalid-description': 'Invalid HTML entity.'
7907
+ 'data-invalid-message': 'Invalid HTML entity'
7870
7908
  };
7871
7909
  }
7872
7910
  }
@@ -7915,7 +7953,7 @@ require = function () {
7915
7953
  const typed_dom_1 = _dereq_('typed-dom');
7916
7954
  const array_1 = _dereq_('spica/array');
7917
7955
  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)(/\*\*/)),
7956
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.blank)('', '**')),
7919
7957
  (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
7920
7958
  ])), '*'), (0, source_1.str)('**'), false, ([, bs], rest) => [
7921
7959
  [(0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))],
@@ -8090,6 +8128,7 @@ require = function () {
8090
8128
  el.getAttribute('data-label'),
8091
8129
  el
8092
8130
  ]));
8131
+ const labels = new global_1.Set();
8093
8132
  const numbers = new global_1.Map();
8094
8133
  let base = '0';
8095
8134
  let bases = base.split('.');
@@ -8134,6 +8173,26 @@ require = function () {
8134
8173
  opts.id !== '' && def.setAttribute('id', `label:${ opts.id ? `${ opts.id }:` : '' }${ label }`);
8135
8174
  const figindex = group === '$' ? `(${ number })` : `${ capitalize(group) }${ group === 'fig' ? '.' : '' } ${ number }`;
8136
8175
  (0, typed_dom_1.define)(def.querySelector(':scope > figcaption > .figindex'), group === '$' ? figindex : `${ figindex }. `);
8176
+ if (labels.has(label)) {
8177
+ if (def.classList.contains('invalid') && def.getAttribute('data-invalid-message') !== 'Duplicate label')
8178
+ continue;
8179
+ (0, typed_dom_1.define)(def, {
8180
+ id: null,
8181
+ class: void def.classList.add('invalid'),
8182
+ 'data-invalid-syntax': 'figure',
8183
+ 'data-invalid-type': 'argument',
8184
+ 'data-invalid-message': 'Duplicate label'
8185
+ });
8186
+ continue;
8187
+ } else {
8188
+ labels.add(label);
8189
+ (0, typed_dom_1.define)(def, {
8190
+ class: void def.classList.remove('invalid'),
8191
+ 'data-invalid-syntax': null,
8192
+ 'data-invalid-type': null,
8193
+ 'data-invalid-message': null
8194
+ });
8195
+ }
8137
8196
  for (const ref of refs.take(label, global_1.Infinity)) {
8138
8197
  if (ref.hash.slice(1) === def.id && ref.innerText === figindex)
8139
8198
  continue;
@@ -8146,7 +8205,7 @@ require = function () {
8146
8205
  class: `${ ref.className } disabled invalid`,
8147
8206
  'data-invalid-syntax': 'label',
8148
8207
  'data-invalid-type': 'reference',
8149
- 'data-invalid-description': 'Missing the reference.'
8208
+ 'data-invalid-message': 'Missing the reference'
8150
8209
  });
8151
8210
  }
8152
8211
  yield ref;
@@ -8221,7 +8280,7 @@ require = function () {
8221
8280
  class: `${ ref.className } invalid`,
8222
8281
  'data-invalid-syntax': syntax,
8223
8282
  'data-invalid-type': 'style',
8224
- 'data-invalid-description': `${ syntax[0].toUpperCase() + syntax.slice(1) } style must be consistent.`
8283
+ 'data-invalid-message': `${ syntax[0].toUpperCase() + syntax.slice(1) } style must be consistent`
8225
8284
  });
8226
8285
  }
8227
8286
  if (((_a = ref.firstElementChild) === null || _a === void 0 ? void 0 : _a.getAttribute('hidden')) !== '') {
@@ -8248,7 +8307,7 @@ require = function () {
8248
8307
  class: void ref.classList.remove('invalid'),
8249
8308
  'data-invalid-syntax': null,
8250
8309
  'data-invalid-type': null,
8251
- 'data-invalid-description': null
8310
+ 'data-invalid-message': null
8252
8311
  });
8253
8312
  }
8254
8313
  }
@@ -8261,7 +8320,7 @@ require = function () {
8261
8320
  class: void ref.classList.add('invalid'),
8262
8321
  'data-invalid-syntax': syntax,
8263
8322
  'data-invalid-type': 'content',
8264
- 'data-invalid-description': 'Missing the content.'
8323
+ 'data-invalid-message': 'Missing the content'
8265
8324
  }
8266
8325
  });
8267
8326
  yield ref.appendChild((0, typed_dom_1.html)('a', { href: refId && defId && `#${ defId }` }, marker(defIndex, abbr)));
@@ -8705,18 +8764,19 @@ require = function () {
8705
8764
  function (_dereq_, module, exports) {
8706
8765
  'use strict';
8707
8766
  Object.defineProperty(exports, '__esModule', { value: true });
8708
- exports.stringify = exports.trimNodeEndBR = exports.trimNodeEnd = exports.trimNode = exports.isStartTightNodes = exports.startTight = exports.isStartLoose = exports.startLoose = exports.visualize = exports.delimiter = void 0;
8767
+ exports.stringify = exports.trimNodeEnd = exports.trimSpaceStart = exports.isStartTightNodes = exports.startTight = exports.isStartLoose = exports.startLoose = exports.visualize = exports.blank = void 0;
8709
8768
  const global_1 = _dereq_('spica/global');
8710
8769
  const parser_1 = _dereq_('../combinator/data/parser');
8711
8770
  const combinator_1 = _dereq_('../combinator');
8712
8771
  const htmlentity_1 = _dereq_('./inline/htmlentity');
8713
8772
  const source_1 = _dereq_('./source');
8714
8773
  const normalize_1 = _dereq_('./api/normalize');
8774
+ const memoize_1 = _dereq_('spica/memoize');
8715
8775
  const array_1 = _dereq_('spica/array');
8716
- function delimiter(opener) {
8717
- return new RegExp(String.raw`^(?:\s+|\\\s|&(?:${ normalize_1.invisibleHTMLEntityNames.join('|') });|<wbr>)?${ opener.source }`);
8776
+ function blank(prefix, suffix) {
8777
+ return new RegExp(String.raw`^${ prefix && prefix.source }(?:\\\s|[^\S\n]+|\n|&(?:${ normalize_1.invisibleHTMLEntityNames.join('|') });|<wbr>)?${ typeof suffix === 'string' ? suffix.replace(/[*+()\[\]]/g, '\\$&') : suffix.source }`);
8718
8778
  }
8719
- exports.delimiter = delimiter;
8779
+ exports.blank = blank;
8720
8780
  function visualize(parser) {
8721
8781
  const blankline = new RegExp(String.raw`^(?:\\$|\\?[^\S\n]|&(?:${ normalize_1.invisibleHTMLEntityNames.join('|') });|<wbr>)+$`, 'gm');
8722
8782
  return (0, combinator_1.union)([
@@ -8750,18 +8810,17 @@ require = function () {
8750
8810
  return false;
8751
8811
  }
8752
8812
  function startLoose(parser, except) {
8753
- return (source, context) => isStartLoose(source, context, except) ? parser(source, context) : global_1.undefined;
8813
+ return (source, context) => (0, exports.isStartLoose)(source, context, except) ? parser(source, context) : global_1.undefined;
8754
8814
  }
8755
8815
  exports.startLoose = startLoose;
8756
- function isStartLoose(source, context, except) {
8816
+ exports.isStartLoose = (0, memoize_1.reduce)((source, context, except) => {
8757
8817
  return isStartTight(source.replace(/^[^\S\n]+/, ''), context, except);
8758
- }
8759
- exports.isStartLoose = isStartLoose;
8818
+ }, (source, _, except = '') => `${ source }\0${ except }`);
8760
8819
  function startTight(parser, except) {
8761
8820
  return (source, context) => isStartTight(source, context, except) ? parser(source, context) : global_1.undefined;
8762
8821
  }
8763
8822
  exports.startTight = startTight;
8764
- function isStartTight(source, context, except) {
8823
+ const isStartTight = (0, memoize_1.reduce)((source, context, except) => {
8765
8824
  var _a, _b, _c;
8766
8825
  if (source === '')
8767
8826
  return true;
@@ -8790,7 +8849,7 @@ require = function () {
8790
8849
  default:
8791
8850
  return source[0].trimStart() !== '';
8792
8851
  }
8793
- }
8852
+ }, (source, _, except = '') => `${ source }\0${ except }`);
8794
8853
  function isStartTightNodes(nodes) {
8795
8854
  if (nodes.length === 0)
8796
8855
  return true;
@@ -8822,25 +8881,10 @@ require = function () {
8822
8881
  }
8823
8882
  }
8824
8883
  }
8825
- function trimNode(nodes) {
8826
- return trimNodeStart(trimNodeEnd(nodes));
8827
- }
8828
- exports.trimNode = trimNode;
8829
- function trimNodeStart(nodes) {
8830
- for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
8831
- if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer')
8832
- break;
8833
- if (typeof node === 'string') {
8834
- const pos = node.length - node.trimStart().length;
8835
- if (pos > 0) {
8836
- nodes[0] = node.slice(pos);
8837
- break;
8838
- }
8839
- }
8840
- nodes.shift();
8841
- }
8842
- return nodes;
8884
+ function trimSpaceStart(parser) {
8885
+ return (0, combinator_1.convert)((0, memoize_1.reduce)(source => source.replace(/^[^\S\n]+/, '')), parser);
8843
8886
  }
8887
+ exports.trimSpaceStart = trimSpaceStart;
8844
8888
  function trimNodeEnd(nodes) {
8845
8889
  const skip = nodes.length > 0 && typeof nodes[nodes.length - 1] === 'object' && nodes[nodes.length - 1]['className'] === 'indexer' ? [nodes.pop()] : [];
8846
8890
  for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
@@ -8856,13 +8900,6 @@ require = function () {
8856
8900
  return (0, array_1.push)(nodes, skip);
8857
8901
  }
8858
8902
  exports.trimNodeEnd = trimNodeEnd;
8859
- function trimNodeEndBR(nodes) {
8860
- if (nodes.length === 0)
8861
- return nodes;
8862
- const node = nodes[nodes.length - 1];
8863
- return typeof node === 'object' && node.tagName === 'BR' ? (0, array_1.pop)(nodes)[0] : nodes;
8864
- }
8865
- exports.trimNodeEndBR = trimNodeEndBR;
8866
8903
  function stringify(nodes) {
8867
8904
  let acc = '';
8868
8905
  for (let i = 0; i < nodes.length; ++i) {
@@ -8884,7 +8921,8 @@ require = function () {
8884
8921
  './inline/htmlentity': 112,
8885
8922
  './source': 128,
8886
8923
  'spica/array': 6,
8887
- 'spica/global': 15
8924
+ 'spica/global': 15,
8925
+ 'spica/memoize': 18
8888
8926
  }
8889
8927
  ],
8890
8928
  135: [