securemark 0.235.3 → 0.237.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/securemark.js +220 -114
  3. package/karma.conf.js +1 -1
  4. package/markdown.d.ts +11 -10
  5. package/package-lock.json +91 -54
  6. package/package.json +1 -1
  7. package/src/debug.test.ts +3 -1
  8. package/src/parser/api/bind.ts +7 -3
  9. package/src/parser/api/parse.test.ts +3 -3
  10. package/src/parser/api/parse.ts +8 -11
  11. package/src/parser/block/blockquote.test.ts +1 -1
  12. package/src/parser/block/codeblock.ts +2 -2
  13. package/src/parser/block/dlist.ts +1 -3
  14. package/src/parser/block/extension/aside.test.ts +1 -1
  15. package/src/parser/block/extension/aside.ts +3 -3
  16. package/src/parser/block/extension/example.test.ts +2 -2
  17. package/src/parser/block/extension/example.ts +3 -3
  18. package/src/parser/block/extension/fig.test.ts +22 -20
  19. package/src/parser/block/extension/figure.test.ts +33 -31
  20. package/src/parser/block/extension/figure.ts +33 -4
  21. package/src/parser/block/extension/message.ts +3 -3
  22. package/src/parser/block/extension/placeholder.ts +2 -2
  23. package/src/parser/block/extension/table.ts +6 -6
  24. package/src/parser/block/extension.ts +1 -1
  25. package/src/parser/block/heading.test.ts +1 -1
  26. package/src/parser/block/heading.ts +11 -7
  27. package/src/parser/block/ilist.ts +1 -1
  28. package/src/parser/block/mathblock.ts +2 -2
  29. package/src/parser/block/olist.test.ts +8 -0
  30. package/src/parser/block/olist.ts +7 -7
  31. package/src/parser/block/reply/cite.test.ts +4 -0
  32. package/src/parser/block/reply/cite.ts +1 -0
  33. package/src/parser/block/reply/quote.ts +1 -1
  34. package/src/parser/block/table.ts +1 -1
  35. package/src/parser/block/ulist.test.ts +8 -0
  36. package/src/parser/block/ulist.ts +7 -7
  37. package/src/parser/header.ts +1 -1
  38. package/src/parser/inline/extension/indexee.ts +8 -8
  39. package/src/parser/inline/extension/placeholder.ts +1 -1
  40. package/src/parser/inline/html.ts +7 -7
  41. package/src/parser/inline/htmlentity.ts +1 -1
  42. package/src/parser/inline/link.ts +4 -4
  43. package/src/parser/inline/math.ts +1 -1
  44. package/src/parser/inline/media.ts +3 -3
  45. package/src/parser/inline/reference.ts +1 -1
  46. package/src/parser/inline/ruby.ts +1 -1
  47. package/src/parser/inline.ts +2 -0
  48. package/src/parser/processor/figure.test.ts +72 -44
  49. package/src/parser/processor/figure.ts +79 -20
  50. package/src/parser/processor/footnote.ts +4 -4
  51. package/src/util/quote.ts +1 -0
@@ -1,4 +1,4 @@
1
- /*! securemark v0.235.3 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.237.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
2
2
  require = function () {
3
3
  function r(e, n, t) {
4
4
  function o(i, f) {
@@ -4215,7 +4215,7 @@ require = function () {
4215
4215
  const array_1 = _dereq_('spica/array');
4216
4216
  function bind(target, settings) {
4217
4217
  var _a, _b;
4218
- let context = (0, alias_1.ObjectAssign)({ ...settings }, {
4218
+ const context = (0, alias_1.ObjectAssign)((0, alias_1.ObjectCreate)(settings), {
4219
4219
  host: (_a = settings.host) !== null && _a !== void 0 ? _a : new url_1.ReadonlyURL(global_1.location.pathname, global_1.location.origin),
4220
4220
  footnotes: global_1.undefined,
4221
4221
  chunk: global_1.undefined
@@ -4238,7 +4238,7 @@ require = function () {
4238
4238
  throw new Error('Chunks cannot be updated.');
4239
4239
  const url = (_b = (_a = (0, header_2.headers)(source).find(field => field.toLowerCase().startsWith('url:'))) === null || _a === void 0 ? void 0 : _a.slice(4).trim()) !== null && _b !== void 0 ? _b : '';
4240
4240
  source = (0, normalize_1.normalize)((0, segment_1.validate)(source, segment_1.MAX_INPUT_SIZE) ? source : source.slice(0, segment_1.MAX_INPUT_SIZE + 1));
4241
- context = (0, alias_1.ObjectAssign)({ ...context }, { url: url ? new url_1.ReadonlyURL(url) : global_1.undefined });
4241
+ (0, alias_1.ObjectAssign)(context, { url: url ? new url_1.ReadonlyURL(url) : global_1.undefined });
4242
4242
  const rev = revision = Symbol();
4243
4243
  const sourceSegments = [];
4244
4244
  for (const seg of (0, segment_1.segment)(source)) {
@@ -4530,7 +4530,6 @@ require = function () {
4530
4530
  Object.defineProperty(exports, '__esModule', { value: true });
4531
4531
  exports.parse = void 0;
4532
4532
  const global_1 = _dereq_('spica/global');
4533
- const alias_1 = _dereq_('spica/alias');
4534
4533
  const parser_1 = _dereq_('../../combinator/data/parser');
4535
4534
  const header_1 = _dereq_('../header');
4536
4535
  const block_1 = _dereq_('../block');
@@ -4542,19 +4541,20 @@ require = function () {
4542
4541
  const typed_dom_1 = _dereq_('typed-dom');
4543
4542
  const url_1 = _dereq_('spica/url');
4544
4543
  function parse(source, opts = {}, context) {
4545
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4544
+ var _a, _b, _c, _d, _e, _f, _g;
4546
4545
  if (!(0, segment_1.validate)(source, segment_1.MAX_SEGMENT_SIZE))
4547
4546
  throw new Error(`Too large input over ${ segment_1.MAX_SEGMENT_SIZE.toLocaleString('en') } bytes.`);
4548
4547
  const url = (_b = (_a = (0, header_2.headers)(source).find(field => field.toLowerCase().startsWith('url:'))) === null || _a === void 0 ? void 0 : _a.slice(4).trim()) !== null && _b !== void 0 ? _b : '';
4549
4548
  source = !context ? (0, normalize_1.normalize)(source) : source;
4550
- context = context && url === '' && context.id === opts.id ? context : (0, alias_1.ObjectAssign)((0, alias_1.ObjectCreate)(context !== null && context !== void 0 ? context : {}), opts, {
4551
- host: (_d = (_c = opts.host) !== null && _c !== void 0 ? _c : context === null || context === void 0 ? void 0 : context.host) !== null && _d !== void 0 ? _d : new url_1.ReadonlyURL(global_1.location.pathname, global_1.location.origin),
4549
+ context = {
4552
4550
  url: url ? new url_1.ReadonlyURL(url) : context === null || context === void 0 ? void 0 : context.url,
4553
- id: (_e = opts.id) !== null && _e !== void 0 ? _e : context === null || context === void 0 ? void 0 : context.id,
4551
+ host: (_d = (_c = opts.host) !== null && _c !== void 0 ? _c : context === null || context === void 0 ? void 0 : context.host) !== null && _d !== void 0 ? _d : new url_1.ReadonlyURL(global_1.location.pathname, global_1.location.origin),
4552
+ caches: context === null || context === void 0 ? void 0 : context.caches,
4554
4553
  footnotes: global_1.undefined,
4555
- test: global_1.undefined
4556
- });
4557
- if (((_g = context.host) === null || _g === void 0 ? void 0 : _g.origin) === 'null')
4554
+ test: global_1.undefined,
4555
+ ...opts
4556
+ };
4557
+ if (((_e = context.host) === null || _e === void 0 ? void 0 : _e.origin) === 'null')
4558
4558
  throw new Error(`Invalid host: ${ context.host.href }`);
4559
4559
  const node = (0, typed_dom_1.frag)();
4560
4560
  let index = 0;
@@ -4578,7 +4578,6 @@ require = function () {
4578
4578
  '../segment': 127,
4579
4579
  './header': 59,
4580
4580
  './normalize': 60,
4581
- 'spica/alias': 5,
4582
4581
  'spica/global': 15,
4583
4582
  'spica/url': 24,
4584
4583
  'typed-dom': 26
@@ -4777,8 +4776,8 @@ require = function () {
4777
4776
  class: 'invalid',
4778
4777
  translate: 'no',
4779
4778
  'data-invalid-syntax': 'codeblock',
4780
- 'data-invalid-type': !closer ? 'closer' : 'argument',
4781
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
4779
+ 'data-invalid-type': !closer ? 'fence' : 'argument',
4780
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
4782
4781
  }, `${ opener }${ body }${ closer }`)];
4783
4782
  const file = (_a = path.split('/').pop()) !== null && _a !== void 0 ? _a : '';
4784
4783
  const ext = file && file.includes('.', 1) ? file.split('.').pop() : '';
@@ -4809,8 +4808,6 @@ require = function () {
4809
4808
  exports.dlist = void 0;
4810
4809
  const combinator_1 = _dereq_('../../combinator');
4811
4810
  const inline_1 = _dereq_('../inline');
4812
- const indexer_1 = _dereq_('../inline/extension/indexer');
4813
- const indexee_1 = _dereq_('../inline/extension/indexee');
4814
4811
  const source_1 = _dereq_('../source');
4815
4812
  const locale_1 = _dereq_('../locale');
4816
4813
  const util_1 = _dereq_('../util');
@@ -4831,8 +4828,8 @@ require = function () {
4831
4828
  }, (0, combinator_1.some)(term)),
4832
4829
  (0, combinator_1.some)(desc)
4833
4830
  ]))), es => [(0, typed_dom_1.html)('dl', fillTrailingDescription(es))]))));
4834
- const term = (0, combinator_1.creator)((0, combinator_1.line)((0, indexee_1.indexee)((0, combinator_1.fmap)((0, combinator_1.open)(/^~[^\S\n]+(?=\S)/, (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([
4835
- indexer_1.indexer,
4831
+ const term = (0, combinator_1.creator)((0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.open)(/^~[^\S\n]+(?=\S)/, (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([
4832
+ inline_1.indexer,
4836
4833
  inline_1.inline
4837
4834
  ])))), true), ns => [(0, typed_dom_1.html)('dt', (0, typed_dom_1.defrag)(ns))]))));
4838
4835
  const desc = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)(/^:[^\S\n]+(?=\S)|/, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, /^[~:][^\S\n]+\S/), (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, typed_dom_1.html)('dd', (0, typed_dom_1.defrag)(ns))]), false));
@@ -4843,8 +4840,6 @@ require = function () {
4843
4840
  {
4844
4841
  '../../combinator': 27,
4845
4842
  '../inline': 88,
4846
- '../inline/extension/indexee': 107,
4847
- '../inline/extension/indexer': 108,
4848
4843
  '../locale': 123,
4849
4844
  '../source': 128,
4850
4845
  '../util': 134,
@@ -4870,7 +4865,7 @@ require = function () {
4870
4865
  '~~~',
4871
4866
  '[$',
4872
4867
  '$'
4873
- ], (0, combinator_1.validate)(/^~{3,}|^\[?\$[a-z-]\S+[^\S\n]*(?:$|\n)/, (0, combinator_1.union)([
4868
+ ], (0, combinator_1.validate)(/^~{3,}|^\[?\$[A-Za-z-]\S+[^\S\n]*(?:$|\n)/, (0, combinator_1.union)([
4874
4869
  fig_1.segment,
4875
4870
  figure_1.segment,
4876
4871
  table_1.segment,
@@ -4915,8 +4910,8 @@ require = function () {
4915
4910
  class: 'invalid',
4916
4911
  translate: 'no',
4917
4912
  'data-invalid-syntax': 'aside',
4918
- 'data-invalid-type': !closer ? 'closer' : 'argument',
4919
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
4913
+ 'data-invalid-type': !closer ? 'fence' : 'argument',
4914
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
4920
4915
  }, `${ opener }${ body }${ closer }`)];
4921
4916
  const annotations = (0, typed_dom_1.html)('ol', { class: 'annotations' });
4922
4917
  const references = (0, typed_dom_1.html)('ol', { class: 'references' });
@@ -4934,7 +4929,7 @@ require = function () {
4934
4929
  translate: 'no',
4935
4930
  'data-invalid-syntax': 'aside',
4936
4931
  'data-invalid-type': 'content',
4937
- 'data-invalid-description': 'Missing the title at the first line.'
4932
+ 'data-invalid-message': 'Missing the title at the first line'
4938
4933
  }, `${ opener }${ body }${ closer }`)];
4939
4934
  return [(0, typed_dom_1.html)('aside', {
4940
4935
  id: (0, indexee_1.identity)((0, indexee_1.text)(heading)),
@@ -4970,8 +4965,8 @@ require = function () {
4970
4965
  class: 'invalid',
4971
4966
  translate: 'no',
4972
4967
  'data-invalid-syntax': 'example',
4973
- 'data-invalid-type': !closer ? 'closer' : 'argument',
4974
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
4968
+ 'data-invalid-type': !closer ? 'fence' : 'argument',
4969
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
4975
4970
  }, `${ opener }${ body }${ closer }`)];
4976
4971
  switch (type) {
4977
4972
  case 'markdown': {
@@ -5011,7 +5006,7 @@ require = function () {
5011
5006
  class: 'invalid',
5012
5007
  translate: 'no',
5013
5008
  'data-invalid-syntax': 'example',
5014
- 'data-invalid-description': 'Invalid example type.'
5009
+ 'data-invalid-message': 'Invalid example type'
5015
5010
  }, `${ opener }${ body }${ closer }`)];
5016
5011
  }
5017
5012
  }))));
@@ -5102,6 +5097,8 @@ require = function () {
5102
5097
  const combinator_1 = _dereq_('../../../combinator');
5103
5098
  const source_1 = _dereq_('../../source');
5104
5099
  const label_1 = _dereq_('../../inline/extension/label');
5100
+ const ulist_1 = _dereq_('../ulist');
5101
+ const olist_1 = _dereq_('../olist');
5105
5102
  const table_1 = _dereq_('../table');
5106
5103
  const codeblock_1 = _dereq_('../codeblock');
5107
5104
  const mathblock_1 = _dereq_('../mathblock');
@@ -5115,7 +5112,7 @@ require = function () {
5115
5112
  const typed_dom_1 = _dereq_('typed-dom');
5116
5113
  const memoize_1 = _dereq_('spica/memoize');
5117
5114
  const array_1 = _dereq_('spica/array');
5118
- 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)([
5115
+ exports.segment = (0, combinator_1.block)((0, combinator_1.match)(/^(~{3,})(?:figure[^\S\n]+)?(?=\[?\$[A-Za-z-][^\n]*\n)/, (0, memoize_1.memoize)(([, fence], closer = new RegExp(String.raw`^${ fence }[^\S\n]*(?:$|\n)`)) => (0, combinator_1.close)((0, combinator_1.sequence)([
5119
5116
  (0, combinator_1.line)((0, combinator_1.close)(label_1.segment, /^.*\n/)),
5120
5117
  (0, combinator_1.inits)([
5121
5118
  (0, combinator_1.union)([
@@ -5140,6 +5137,8 @@ require = function () {
5140
5137
  ])),
5141
5138
  (0, combinator_1.inits)([
5142
5139
  (0, combinator_1.block)((0, combinator_1.union)([
5140
+ ulist_1.ulist,
5141
+ olist_1.olist,
5143
5142
  table_1.table,
5144
5143
  codeblock_1.codeblock,
5145
5144
  mathblock_1.mathblock,
@@ -5163,22 +5162,46 @@ require = function () {
5163
5162
  const invalidParam = param.trimStart() !== '';
5164
5163
  const invalidContent = group === '$' && (!content.classList.contains('math') || caption.length > 0);
5165
5164
  const invalid = invalidLabel || invalidParam || invalidContent || global_1.undefined;
5165
+ let type = content.className.split(/\s/)[0];
5166
+ switch (type || content.tagName) {
5167
+ case 'UL':
5168
+ case 'OL':
5169
+ type = 'list';
5170
+ break;
5171
+ case 'TABLE':
5172
+ type = 'table';
5173
+ break;
5174
+ case 'BLOCKQUOTE':
5175
+ type = 'quote';
5176
+ break;
5177
+ case 'A':
5178
+ type = 'media';
5179
+ break;
5180
+ case 'text':
5181
+ case 'code':
5182
+ case 'math':
5183
+ case 'example':
5184
+ case 'invalid':
5185
+ break;
5186
+ default:
5187
+ }
5166
5188
  return {
5189
+ 'data-type': type,
5167
5190
  'data-label': label,
5168
5191
  'data-group': group,
5169
5192
  class: invalid && 'invalid',
5170
5193
  ...invalidLabel && {
5171
5194
  'data-invalid-syntax': 'figure',
5172
5195
  'data-invalid-type': 'label',
5173
- 'data-invalid-description': 'The last part of the fixed label numbers must not be 0.'
5196
+ 'data-invalid-message': 'The last part of the fixed label numbers must not be 0'
5174
5197
  } || invalidParam && {
5175
5198
  'data-invalid-syntax': 'figure',
5176
5199
  'data-invalid-type': 'argument',
5177
- 'data-invalid-description': 'Invalid argument.'
5200
+ 'data-invalid-message': 'Invalid argument'
5178
5201
  } || invalidContent && {
5179
5202
  'data-invalid-syntax': 'figure',
5180
5203
  'data-invalid-type': 'content',
5181
- 'data-invalid-description': 'A figure labeled to define a formula number can contain only a math formula and no caption.'
5204
+ 'data-invalid-message': 'A figure labeled to define a formula number can contain only a math formula and no caption'
5182
5205
  } || global_1.undefined
5183
5206
  };
5184
5207
  }
@@ -5193,7 +5216,9 @@ require = function () {
5193
5216
  '../blockquote': 64,
5194
5217
  '../codeblock': 65,
5195
5218
  '../mathblock': 79,
5219
+ '../olist': 80,
5196
5220
  '../table': 85,
5221
+ '../ulist': 86,
5197
5222
  './example': 69,
5198
5223
  './placeholder': 74,
5199
5224
  './table': 75,
@@ -5228,8 +5253,8 @@ require = function () {
5228
5253
  class: 'invalid',
5229
5254
  translate: 'no',
5230
5255
  'data-invalid-syntax': 'message',
5231
- 'data-invalid-type': !closer ? 'closer' : 'argument',
5232
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
5256
+ 'data-invalid-type': !closer ? 'fence' : 'argument',
5257
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
5233
5258
  }, `${ opener }${ body }${ closer }`)];
5234
5259
  switch (type) {
5235
5260
  case 'note':
@@ -5241,7 +5266,7 @@ require = function () {
5241
5266
  class: 'invalid',
5242
5267
  translate: 'no',
5243
5268
  'data-invalid-syntax': 'message',
5244
- 'data-invalid-description': 'Invalid message type.'
5269
+ 'data-invalid-message': 'Invalid message type'
5245
5270
  }, `${ opener }${ body }${ closer }`)];
5246
5271
  }
5247
5272
  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), [])), [])))];
@@ -5299,8 +5324,8 @@ require = function () {
5299
5324
  class: 'invalid',
5300
5325
  translate: 'no',
5301
5326
  'data-invalid-syntax': 'extension',
5302
- 'data-invalid-type': !closer ? 'closer' : 'syntax',
5303
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid syntax.'
5327
+ 'data-invalid-type': !closer ? 'fence' : 'syntax',
5328
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid syntax'
5304
5329
  }, `${ opener }${ body }${ closer }`)])));
5305
5330
  },
5306
5331
  {
@@ -5333,17 +5358,17 @@ require = function () {
5333
5358
  class: 'invalid',
5334
5359
  translate: 'no',
5335
5360
  'data-invalid-syntax': 'table',
5336
- 'data-invalid-type': !closer ? 'closer' : 'argument',
5337
- 'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
5361
+ 'data-invalid-type': !closer ? 'fence' : 'argument',
5362
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
5338
5363
  }, `${ opener }${ body }${ closer }`)];
5339
5364
  return (_a = (0, parser_1.eval)(parser(body, context))) !== null && _a !== void 0 ? _a : [(0, typed_dom_1.html)('table')];
5340
- }), (source, _, reason) => reason instanceof Error && reason.message === 'Number of columns must be 32 or less.' ? [
5365
+ }), (source, _, reason) => reason instanceof Error && reason.message === 'Number of columns must be 32 or less' ? [
5341
5366
  [(0, typed_dom_1.html)('pre', {
5342
5367
  class: 'invalid',
5343
5368
  translate: 'no',
5344
5369
  'data-invalid-syntax': 'table',
5345
5370
  'data-invalid-type': 'content',
5346
- 'data-invalid-description': reason.message
5371
+ 'data-invalid-message': reason.message
5347
5372
  }, source)],
5348
5373
  ''
5349
5374
  ] : (() => {
@@ -5390,7 +5415,7 @@ require = function () {
5390
5415
  ...valid ? { 'data-highlight-level': +highlight > 1 ? highlight : global_1.undefined } : {
5391
5416
  'data-invalid-syntax': 'table',
5392
5417
  'data-invalid-type': 'syntax',
5393
- 'data-invalid-description': 'Too much highlight level.'
5418
+ 'data-invalid-message': 'Too much highlight level'
5394
5419
  }
5395
5420
  };
5396
5421
  }
@@ -5528,7 +5553,7 @@ require = function () {
5528
5553
  valigns[j] && cell.setAttribute('valign', valigns[j]);
5529
5554
  }
5530
5555
  if (cells.length > 32)
5531
- throw new Error('Number of columns must be 32 or less.');
5556
+ throw new Error('Number of columns must be 32 or less');
5532
5557
  target.appendChild(row);
5533
5558
  switch (target) {
5534
5559
  case thead:
@@ -5583,13 +5608,10 @@ require = function () {
5583
5608
  exports.heading = exports.segment = void 0;
5584
5609
  const combinator_1 = _dereq_('../../combinator');
5585
5610
  const inline_1 = _dereq_('../inline');
5586
- const indexer_1 = _dereq_('../inline/extension/indexer');
5587
- const indexee_1 = _dereq_('../inline/extension/indexee');
5588
5611
  const source_1 = _dereq_('../source');
5589
5612
  const util_1 = _dereq_('../util');
5590
5613
  const typed_dom_1 = _dereq_('typed-dom');
5591
- const array_1 = _dereq_('spica/array');
5592
- exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('#', (0, combinator_1.focus)(/^#{1,6}[^\S\n]+\S[^\n]*(?:\n#{1,6}(?!\S)[^\n]*)*(?:$|\n)/, (0, combinator_1.some)((0, combinator_1.line)(source => [
5614
+ exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('#', (0, combinator_1.focus)(/^#+[^\S\n]+\S[^\n]*(?:\n#+(?!\S)[^\n]*)*(?:$|\n)/, (0, combinator_1.some)((0, combinator_1.line)(source => [
5593
5615
  [source],
5594
5616
  ''
5595
5617
  ])))));
@@ -5604,25 +5626,27 @@ require = function () {
5604
5626
  media: false
5605
5627
  }
5606
5628
  }
5607
- }, (0, combinator_1.line)((0, indexee_1.indexee)((0, combinator_1.fmap)((0, combinator_1.union)([
5629
+ }, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.union)([
5608
5630
  (0, combinator_1.open)((0, source_1.str)(/^##+/), (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([
5609
- indexer_1.indexer,
5631
+ inline_1.indexer,
5610
5632
  inline_1.inline
5611
5633
  ])))), true),
5612
5634
  (0, combinator_1.open)((0, source_1.str)('#'), (0, combinator_1.context)({ syntax: { inline: { autolink: false } } }, (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([
5613
- indexer_1.indexer,
5635
+ inline_1.indexer,
5614
5636
  inline_1.inline
5615
5637
  ]))))), true)
5616
- ]), ns => [(0, typed_dom_1.html)(`h${ (0, array_1.shift)(ns)[0].length }`, (0, typed_dom_1.defrag)(ns))]))))));
5638
+ ]), ([h, ...ns]) => [h.length <= 6 ? (0, typed_dom_1.html)(`h${ h.length }`, (0, typed_dom_1.defrag)(ns)) : (0, typed_dom_1.html)(`h6`, {
5639
+ class: 'invalid',
5640
+ 'data-invalid-syntax': 'heading',
5641
+ 'data-invalid-type': 'syntax',
5642
+ 'data-invalid-message': 'Heading level must be up to 6'
5643
+ }, (0, typed_dom_1.defrag)(ns))]))))));
5617
5644
  },
5618
5645
  {
5619
5646
  '../../combinator': 27,
5620
5647
  '../inline': 88,
5621
- '../inline/extension/indexee': 107,
5622
- '../inline/extension/indexer': 108,
5623
5648
  '../source': 128,
5624
5649
  '../util': 134,
5625
- 'spica/array': 6,
5626
5650
  'typed-dom': 26
5627
5651
  }
5628
5652
  ],
@@ -5669,7 +5693,7 @@ require = function () {
5669
5693
  class: 'invalid',
5670
5694
  'data-invalid-syntax': 'list',
5671
5695
  'data-invalid-type': 'syntax',
5672
- 'data-invalid-description': 'Use "-" instead of "+" or "*".'
5696
+ 'data-invalid-message': 'Use "-" instead of "+" or "*"'
5673
5697
  }, es)])));
5674
5698
  },
5675
5699
  {
@@ -5705,8 +5729,8 @@ require = function () {
5705
5729
  class: 'invalid',
5706
5730
  translate: 'no',
5707
5731
  'data-invalid-syntax': 'mathblock',
5708
- 'data-invalid-type': delim.length > 2 ? 'syntax' : !closer ? 'closer' : 'argument',
5709
- 'data-invalid-description': delim.length > 2 ? 'Invalid syntax' : !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
5732
+ 'data-invalid-type': delim.length > 2 ? 'syntax' : !closer ? 'fence' : 'argument',
5733
+ 'data-invalid-message': delim.length > 2 ? 'Invalid syntax' : !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
5710
5734
  }, `${ opener }${ body }${ closer }`)];
5711
5735
  })));
5712
5736
  },
@@ -5742,17 +5766,20 @@ require = function () {
5742
5766
  (0, combinator_1.match)(new RegExp(`^(?=${ openers['.'].source.replace('?:', '') })`), (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => type(ms[1]))),
5743
5767
  (0, combinator_1.match)(new RegExp(`^(?=${ openers['('].source.replace('?:', '') })`), (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => type(ms[1])))
5744
5768
  ])));
5745
- const list = (type, delim) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([
5769
+ const list = (type, delim) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([
5746
5770
  (0, combinator_1.line)((0, combinator_1.open)(heads[delim], (0, combinator_1.trim)((0, combinator_1.subsequence)([
5747
5771
  ulist_1.checkbox,
5748
- (0, combinator_1.trimStart)((0, combinator_1.some)(inline_1.inline))
5772
+ (0, combinator_1.trimStart)((0, combinator_1.some)((0, combinator_1.union)([
5773
+ inline_1.indexer,
5774
+ inline_1.inline
5775
+ ])))
5749
5776
  ])), true)),
5750
5777
  (0, combinator_1.indent)((0, combinator_1.union)([
5751
5778
  ulist_1.ulist_,
5752
5779
  exports.olist_,
5753
5780
  ilist_1.ilist_
5754
5781
  ]))
5755
- ]), iitem), ns => [(0, typed_dom_1.html)('li', { 'data-marker': ns[0] }, (0, typed_dom_1.defrag)((0, ulist_1.fillFirstLine)((0, array_1.shift)(ns)[1])))])]))), es => [format((0, typed_dom_1.html)('ol', es), type, delim)]);
5782
+ ]), invalid), ns => [(0, typed_dom_1.html)('li', { 'data-marker': ns[0] }, (0, typed_dom_1.defrag)((0, ulist_1.fillFirstLine)((0, array_1.shift)(ns)[1])))]), true)]))), es => [format((0, typed_dom_1.html)('ol', es), type, delim)]);
5756
5783
  const heads = {
5757
5784
  '.': (0, combinator_1.focus)(openers['.'], source => [
5758
5785
  [`${ source.split('.', 1)[0] }.`],
@@ -5763,14 +5790,14 @@ require = function () {
5763
5790
  ''
5764
5791
  ])
5765
5792
  };
5766
- const iitem = (0, combinator_1.rewrite)(source_1.contentline, source => [
5793
+ const invalid = (0, combinator_1.rewrite)(source_1.contentline, source => [
5767
5794
  [
5768
5795
  '',
5769
5796
  (0, typed_dom_1.html)('span', {
5770
5797
  class: 'invalid',
5771
5798
  'data-invalid-syntax': 'listitem',
5772
5799
  'data-invalid-type': 'syntax',
5773
- 'data-invalid-description': 'Fix the indent or the head of the list item.'
5800
+ 'data-invalid-message': 'Fix the indent or the head of the list item'
5774
5801
  }, source.replace('\n', ''))
5775
5802
  ],
5776
5803
  ''
@@ -5926,6 +5953,10 @@ require = function () {
5926
5953
  (0, combinator_1.focus)(/^>>\.[^\S\n]*(?:$|\n)/, () => [
5927
5954
  [(0, typed_dom_1.html)('a', { class: 'anchor' }, '>>.')],
5928
5955
  ''
5956
+ ]),
5957
+ (0, combinator_1.focus)(/^>>#\S*[^\S\n]*(?:$|\n)/, source => [
5958
+ [(0, typed_dom_1.html)('a', { class: 'anchor' }, source)],
5959
+ ''
5929
5960
  ])
5930
5961
  ])
5931
5962
  ]))), ([el, quotes = '']) => [
@@ -5963,7 +5994,7 @@ require = function () {
5963
5994
  class: 'quote invalid',
5964
5995
  'data-invalid-syntax': 'quote',
5965
5996
  'data-invalid-type': 'syntax',
5966
- 'data-invalid-description': `Missing the whitespace after "${ ns[0].split(/[^>]/, 1)[0] }".`
5997
+ 'data-invalid-message': `Missing the whitespace after "${ ns[0].split(/[^>]/, 1)[0] }"`
5967
5998
  }, (0, typed_dom_1.defrag)(ns)),
5968
5999
  (0, typed_dom_1.html)('br')
5969
6000
  ]), false)));
@@ -6037,7 +6068,7 @@ require = function () {
6037
6068
  class: 'invalid',
6038
6069
  'data-invalid-syntax': 'tablerow',
6039
6070
  'data-invalid-type': 'syntax',
6040
- 'data-invalid-description': 'Invalid table row.'
6071
+ 'data-invalid-message': 'Invalid table row'
6041
6072
  }, [(0, typed_dom_1.html)('td', source.replace('\n', ''))])],
6042
6073
  ''
6043
6074
  ])));
@@ -6099,27 +6130,30 @@ require = function () {
6099
6130
  const array_1 = _dereq_('spica/array');
6100
6131
  const source_1 = _dereq_('../source');
6101
6132
  exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.context)({ syntax: { inline: { media: false } } }, exports.ulist_))));
6102
- exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([
6133
+ exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([
6103
6134
  (0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.trim)((0, combinator_1.subsequence)([
6104
6135
  exports.checkbox,
6105
- (0, combinator_1.trimStart)((0, combinator_1.some)(inline_1.inline))
6136
+ (0, combinator_1.trimStart)((0, combinator_1.some)((0, combinator_1.union)([
6137
+ inline_1.indexer,
6138
+ inline_1.inline
6139
+ ])))
6106
6140
  ])), true)),
6107
6141
  (0, combinator_1.indent)((0, combinator_1.union)([
6108
6142
  exports.ulist_,
6109
6143
  olist_1.olist_,
6110
6144
  ilist_1.ilist_
6111
6145
  ]))
6112
- ]), iitem), ns => [(0, typed_dom_1.html)('li', (0, typed_dom_1.defrag)(fillFirstLine(ns)))])])))), es => [format((0, typed_dom_1.html)('ul', es))])));
6146
+ ]), invalid), ns => [(0, typed_dom_1.html)('li', (0, typed_dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, typed_dom_1.html)('ul', es))])));
6113
6147
  exports.checkbox = (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, source => [
6114
6148
  [(0, typed_dom_1.html)('span', { class: 'checkbox' }, source[1].trimStart() ? '\u2611' : '\u2610')],
6115
6149
  ''
6116
6150
  ]);
6117
- const iitem = (0, combinator_1.rewrite)(source_1.contentline, source => [
6151
+ const invalid = (0, combinator_1.rewrite)(source_1.contentline, source => [
6118
6152
  [(0, typed_dom_1.html)('span', {
6119
6153
  class: 'invalid',
6120
6154
  'data-invalid-syntax': 'listitem',
6121
6155
  'data-invalid-type': 'syntax',
6122
- 'data-invalid-description': 'Fix the indent or the head of the list item.'
6156
+ 'data-invalid-message': 'Fix the indent or the head of the list item'
6123
6157
  }, source.replace('\n', ''))],
6124
6158
  ''
6125
6159
  ]);
@@ -6182,7 +6216,7 @@ require = function () {
6182
6216
  translate: 'no',
6183
6217
  'data-invalid-syntax': 'header',
6184
6218
  'data-invalid-type': 'syntax',
6185
- 'data-invalid-description': 'Invalid syntax.'
6219
+ 'data-invalid-message': 'Invalid syntax'
6186
6220
  }, (0, normalize_1.normalize)(source))],
6187
6221
  ''
6188
6222
  ]
@@ -6219,7 +6253,7 @@ require = function () {
6219
6253
  function (_dereq_, module, exports) {
6220
6254
  'use strict';
6221
6255
  Object.defineProperty(exports, '__esModule', { value: true });
6222
- exports.shortmedia = exports.media = exports.inline = void 0;
6256
+ exports.shortmedia = exports.media = exports.indexer = exports.indexee = exports.inline = void 0;
6223
6257
  const combinator_1 = _dereq_('../combinator');
6224
6258
  const escape_1 = _dereq_('./inline/escape');
6225
6259
  const annotation_1 = _dereq_('./inline/annotation');
@@ -6269,6 +6303,20 @@ require = function () {
6269
6303
  bracket_1.bracket,
6270
6304
  source_1.text
6271
6305
  ]);
6306
+ var indexee_1 = _dereq_('./inline/extension/indexee');
6307
+ Object.defineProperty(exports, 'indexee', {
6308
+ enumerable: true,
6309
+ get: function () {
6310
+ return indexee_1.indexee;
6311
+ }
6312
+ });
6313
+ var indexer_1 = _dereq_('./inline/extension/indexer');
6314
+ Object.defineProperty(exports, 'indexer', {
6315
+ enumerable: true,
6316
+ get: function () {
6317
+ return indexer_1.indexer;
6318
+ }
6319
+ });
6272
6320
  var media_2 = _dereq_('./inline/media');
6273
6321
  Object.defineProperty(exports, 'media', {
6274
6322
  enumerable: true,
@@ -6296,6 +6344,8 @@ require = function () {
6296
6344
  './inline/emstrong': 103,
6297
6345
  './inline/escape': 104,
6298
6346
  './inline/extension': 105,
6347
+ './inline/extension/indexee': 107,
6348
+ './inline/extension/indexer': 108,
6299
6349
  './inline/html': 111,
6300
6350
  './inline/htmlentity': 112,
6301
6351
  './inline/insertion': 113,
@@ -6983,8 +7033,8 @@ require = function () {
6983
7033
  const global_1 = _dereq_('spica/global');
6984
7034
  const combinator_1 = _dereq_('../../../combinator');
6985
7035
  const typed_dom_1 = _dereq_('typed-dom');
6986
- function indexee(parser) {
6987
- return (0, combinator_1.fmap)(parser, ([el], _, {id}) => [(0, typed_dom_1.define)(el, { id: id !== '' && identity(text(el)) || global_1.undefined })]);
7036
+ function indexee(parser, optional) {
7037
+ return (0, combinator_1.fmap)(parser, ([el], _, {id}) => [(0, typed_dom_1.define)(el, { id: id !== '' && identity(text(el, optional)) || global_1.undefined })]);
6988
7038
  }
6989
7039
  exports.indexee = indexee;
6990
7040
  function identity(text) {
@@ -6992,11 +7042,13 @@ require = function () {
6992
7042
  return text && `index:${ text.replace(/\s+/g, '_').slice(0, 101).replace(/^(.{97}).{4}$/, '$1...') }`;
6993
7043
  }
6994
7044
  exports.identity = identity;
6995
- function text(source) {
7045
+ function text(source, optional = false) {
6996
7046
  var _a;
6997
- const indexer = source.querySelector('.indexer');
7047
+ const indexer = source.querySelector(':scope > .indexer');
6998
7048
  if (indexer)
6999
7049
  return indexer.getAttribute('data-index');
7050
+ if (optional)
7051
+ return '';
7000
7052
  const target = source.cloneNode(true);
7001
7053
  for (let es = target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference'), i = 0, len = es.length; i < len; ++i) {
7002
7054
  const el = es[i];
@@ -7127,7 +7179,7 @@ require = function () {
7127
7179
  class: 'invalid',
7128
7180
  'data-invalid-syntax': 'extension',
7129
7181
  'data-invalid-type': 'syntax',
7130
- 'data-invalid-description': 'Invalid symbol.'
7182
+ 'data-invalid-message': 'Invalid symbol'
7131
7183
  }, (0, typed_dom_1.defrag)(bs))],
7132
7184
  rest
7133
7185
  ], ([as, bs], rest) => [
@@ -7235,37 +7287,37 @@ require = function () {
7235
7287
  function elem(tag, as, bs, cs, context) {
7236
7288
  var _a, _b, _c, _d, _e, _f;
7237
7289
  if (!tags.includes(tag))
7238
- return invalid('tag', `Invalid HTML tag <${ tag }>.`, as, bs, cs);
7290
+ return invalid('tag', `Invalid HTML tag <${ tag }>`, as, bs, cs);
7239
7291
  switch (tag) {
7240
7292
  case 'sup':
7241
7293
  case 'sub':
7242
7294
  switch (true) {
7243
7295
  case (_b = (_a = context.state) === null || _a === void 0 ? void 0 : _a.in) === null || _b === void 0 ? void 0 : _b.supsub:
7244
- return invalid('nest', `<${ tag }> HTML tag cannot be used in <sup> or <sub> HTML tag.`, as, bs, cs);
7296
+ return invalid('nest', `<${ tag }> HTML tag cannot be used in <sup> or <sub> HTML tag`, as, bs, cs);
7245
7297
  }
7246
7298
  break;
7247
7299
  case 'small':
7248
7300
  switch (true) {
7249
7301
  case (_d = (_c = context.state) === null || _c === void 0 ? void 0 : _c.in) === null || _d === void 0 ? void 0 : _d.supsub:
7250
7302
  case (_f = (_e = context.state) === null || _e === void 0 ? void 0 : _e.in) === null || _f === void 0 ? void 0 : _f.small:
7251
- return invalid('nest', `<${ tag }> HTML tag cannot be used in <sup>, <sub>, or <small> HTML tag.`, as, bs, cs);
7303
+ return invalid('nest', `<${ tag }> HTML tag cannot be used in <sup>, <sub>, or <small> HTML tag`, as, bs, cs);
7252
7304
  }
7253
7305
  break;
7254
7306
  }
7255
7307
  let attrs;
7256
7308
  switch (true) {
7257
7309
  case 'data-invalid-syntax' in (attrs = attributes('html', [], attrspec[tag], as.slice(1, -1))):
7258
- return invalid('attribute', 'Invalid HTML attribute.', as, bs, cs);
7310
+ return invalid('attribute', 'Invalid HTML attribute', as, bs, cs);
7259
7311
  default:
7260
7312
  return (0, typed_dom_1.html)(tag, attrs, bs);
7261
7313
  }
7262
7314
  }
7263
- function invalid(type, description, as, bs, cs) {
7315
+ function invalid(type, message, as, bs, cs) {
7264
7316
  return (0, typed_dom_1.html)('span', {
7265
7317
  class: 'invalid',
7266
7318
  'data-invalid-syntax': 'html',
7267
7319
  'data-invalid-type': type,
7268
- 'data-invalid-description': description
7320
+ 'data-invalid-message': message
7269
7321
  }, (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)));
7270
7322
  }
7271
7323
  const requiredAttributes = (0, memoize_1.memoize)(spec => (0, alias_1.ObjectEntries)(spec).flatMap(([k, v]) => v && (0, alias_1.isFrozen)(v) ? [k] : []), new WeakMap());
@@ -7289,7 +7341,7 @@ require = function () {
7289
7341
  attrs['class'] = (0, array_1.join)(classes, ' ');
7290
7342
  attrs['data-invalid-syntax'] = syntax;
7291
7343
  attrs['data-invalid-type'] = 'argument';
7292
- attrs['data-invalid-description'] = 'Invalid argument.';
7344
+ attrs['data-invalid-message'] = 'Invalid argument';
7293
7345
  }
7294
7346
  return attrs;
7295
7347
  }
@@ -7328,7 +7380,7 @@ require = function () {
7328
7380
  class: 'invalid',
7329
7381
  'data-invalid-syntax': 'htmlentity',
7330
7382
  'data-invalid-type': 'syntax',
7331
- 'data-invalid-description': 'Invalid HTML entity.'
7383
+ 'data-invalid-message': 'Invalid HTML entity'
7332
7384
  }, test.slice(1)) : test]);
7333
7385
  const parse = (0, memoize_1.reduce)((el => entity => {
7334
7386
  if (entity === '&NewLine;')
@@ -7462,13 +7514,13 @@ require = function () {
7462
7514
  exports.resolve = resolve;
7463
7515
  function elem(INSECURE_URI, content, uri, origin) {
7464
7516
  let type;
7465
- let description;
7517
+ let message;
7466
7518
  switch (uri.protocol) {
7467
7519
  case 'http:':
7468
7520
  case 'https:':
7469
7521
  if (INSECURE_URI.slice(0, 2) === '^/' && /\/\.\.?(?:\/|$)/.test(INSECURE_URI.slice(0, INSECURE_URI.search(/[?#]|$/)))) {
7470
7522
  type = 'argument';
7471
- description = 'Dot-segments cannot be used in subresource paths.';
7523
+ message = 'Dot-segments cannot be used in subresource paths';
7472
7524
  break;
7473
7525
  }
7474
7526
  return (0, typed_dom_1.html)('a', {
@@ -7485,14 +7537,14 @@ require = function () {
7485
7537
  return (0, typed_dom_1.html)('a', { href: uri.source }, content);
7486
7538
  }
7487
7539
  type = 'content';
7488
- description = 'Invalid phone number.';
7540
+ message = 'Invalid phone number';
7489
7541
  break;
7490
7542
  }
7491
7543
  return (0, typed_dom_1.html)('a', {
7492
7544
  class: 'invalid',
7493
7545
  'data-invalid-syntax': 'link',
7494
7546
  'data-invalid-type': type !== null && type !== void 0 ? type : type = 'argument',
7495
- 'data-invalid-description': description !== null && description !== void 0 ? description : description = 'Invalid protocol.'
7547
+ 'data-invalid-message': message !== null && message !== void 0 ? message : message = 'Invalid protocol'
7496
7548
  }, content.length === 0 ? INSECURE_URI : content);
7497
7549
  }
7498
7550
  function decode(uri) {
@@ -7576,7 +7628,7 @@ require = function () {
7576
7628
  translate: 'no',
7577
7629
  'data-invalid-syntax': 'math',
7578
7630
  'data-invalid-type': 'content',
7579
- 'data-invalid-description': `"${ source.match(disallowedCommand)[0] }" command is disallowed.`
7631
+ 'data-invalid-message': `"${ source.match(disallowedCommand)[0] }" command is disallowed`
7580
7632
  }, source)],
7581
7633
  ''
7582
7634
  ];
@@ -7708,7 +7760,7 @@ require = function () {
7708
7760
  class: void target.classList.add('invalid'),
7709
7761
  'data-invalid-syntax': 'media',
7710
7762
  'data-invalid-type': 'argument',
7711
- 'data-invalid-description': 'Dot-segments cannot be used in media paths; use subresource paths instead.'
7763
+ 'data-invalid-message': 'Dot-segments cannot be used in media paths; use subresource paths instead'
7712
7764
  });
7713
7765
  return false;
7714
7766
  }
@@ -7718,7 +7770,7 @@ require = function () {
7718
7770
  class: void target.classList.add('invalid'),
7719
7771
  'data-invalid-syntax': 'media',
7720
7772
  'data-invalid-type': 'argument',
7721
- 'data-invalid-description': 'Invalid protocol.'
7773
+ 'data-invalid-message': 'Invalid protocol'
7722
7774
  });
7723
7775
  return false;
7724
7776
  }
@@ -7727,7 +7779,7 @@ require = function () {
7727
7779
  class: void target.classList.add('invalid'),
7728
7780
  'data-invalid-syntax': 'media',
7729
7781
  'data-invalid-type': 'content',
7730
- 'data-invalid-description': `Cannot use invalid HTML entitiy "${ alt.match(/&[0-9A-Za-z]+;/)[0] }".`,
7782
+ 'data-invalid-message': `Cannot use invalid HTML entitiy "${ alt.match(/&[0-9A-Za-z]+;/)[0] }"`,
7731
7783
  alt: (_a = target.getAttribute('alt')) === null || _a === void 0 ? void 0 : _a.replace(/\0/g, '')
7732
7784
  });
7733
7785
  return false;
@@ -7791,7 +7843,7 @@ require = function () {
7791
7843
  class: 'invalid',
7792
7844
  'data-invalid-syntax': 'reference',
7793
7845
  'data-invalid-type': 'syntax',
7794
- 'data-invalid-description': 'Invalid abbr.'
7846
+ 'data-invalid-message': 'Invalid abbr'
7795
7847
  } : { class: 'reference' };
7796
7848
  }
7797
7849
  },
@@ -7898,7 +7950,7 @@ require = function () {
7898
7950
  class: 'invalid',
7899
7951
  'data-invalid-syntax': 'ruby',
7900
7952
  'data-invalid-type': ss === texts ? 'content' : 'argument',
7901
- 'data-invalid-description': 'Invalid HTML entity.'
7953
+ 'data-invalid-message': 'Invalid HTML entity'
7902
7954
  };
7903
7955
  }
7904
7956
  }
@@ -8117,55 +8169,107 @@ require = function () {
8117
8169
  const multimap_1 = _dereq_('spica/multimap');
8118
8170
  const array_1 = _dereq_('spica/array');
8119
8171
  function* figure(target, footnotes, opts = {}) {
8120
- var _a, _b, _c;
8172
+ var _a, _b, _c, _d;
8121
8173
  const refs = new multimap_1.MultiMap((0, array_1.push)((0, array_1.push)((0, array_1.push)([], target.querySelectorAll('a.label:not(.disabled)[data-label]')), (_a = footnotes === null || footnotes === void 0 ? void 0 : footnotes.annotations.querySelectorAll('a.label:not(.disabled)')) !== null && _a !== void 0 ? _a : []), (_b = footnotes === null || footnotes === void 0 ? void 0 : footnotes.references.querySelectorAll('a.label:not(.disabled)')) !== null && _b !== void 0 ? _b : []).map(el => [
8122
8174
  el.getAttribute('data-label'),
8123
8175
  el
8124
8176
  ]));
8177
+ const labels = new global_1.Set();
8125
8178
  const numbers = new global_1.Map();
8126
8179
  let base = '0';
8127
8180
  let bases = base.split('.');
8128
8181
  let index = bases;
8129
- for (let defs = target.querySelectorAll('figure[data-label], h1, h2, h3'), i = 0, len = defs.length; i < len; ++i) {
8182
+ for (let defs = target.querySelectorAll('figure[data-label], h1, h2'), i = 0, len = defs.length; i < len; ++i) {
8130
8183
  yield;
8131
8184
  const def = defs[i];
8132
8185
  if (def.parentNode !== target)
8133
8186
  continue;
8134
- if (bases.length === 1 && def.tagName[0] === 'H')
8187
+ const {tagName, classList} = def;
8188
+ if (bases.length === 1 && tagName[0] === 'H')
8135
8189
  continue;
8136
- const label = def.tagName === 'FIGURE' ? def.getAttribute('data-label') : `$-${ increment(index, def) }`;
8190
+ const label = tagName === 'FIGURE' ? def.getAttribute('data-label') : `$-${ increment(index, def) }`;
8137
8191
  if (label.endsWith('-'))
8138
8192
  continue;
8139
- if (label.endsWith('-0'))
8193
+ if (label.endsWith('-0')) {
8194
+ (0, typed_dom_1.define)(def, {
8195
+ class: void classList.add('invalid'),
8196
+ 'data-invalid-syntax': 'figure',
8197
+ 'data-invalid-type': 'argument',
8198
+ 'data-invalid-message': 'Invalid base index',
8199
+ hidden: null
8200
+ });
8140
8201
  continue;
8141
- if (def.tagName === 'FIGURE' && label.endsWith('.0')) {
8142
- if (label.lastIndexOf('.', label.length - 3) < 0 && !(+((_c = def.previousElementSibling) === null || _c === void 0 ? void 0 : _c.tagName[1]) <= 2))
8202
+ }
8203
+ if (tagName === 'FIGURE' && label.endsWith('.0')) {
8204
+ if (label.lastIndexOf('.', label.length - 3) !== -1) {
8205
+ (0, typed_dom_1.define)(def, {
8206
+ class: void classList.add('invalid'),
8207
+ 'data-invalid-syntax': 'figure',
8208
+ 'data-invalid-type': 'argument',
8209
+ 'data-invalid-message': 'Base index must be $-x.0 format',
8210
+ hidden: null
8211
+ });
8143
8212
  continue;
8144
- if (label.lastIndexOf('.', label.length - 3) > 0)
8213
+ }
8214
+ if (!/^H[1-6]$/.test((_d = (_c = def.previousElementSibling) === null || _c === void 0 ? void 0 : _c.tagName) !== null && _d !== void 0 ? _d : '')) {
8215
+ (0, typed_dom_1.define)(def, {
8216
+ class: void classList.add('invalid'),
8217
+ 'data-invalid-syntax': 'figure',
8218
+ 'data-invalid-type': 'position',
8219
+ 'data-invalid-message': 'Base index declarations must be after level 1 or 2 headings',
8220
+ hidden: null
8221
+ });
8145
8222
  continue;
8223
+ } else {
8224
+ classList.contains('invalid') && (0, typed_dom_1.define)(def, {
8225
+ class: void classList.remove('invalid'),
8226
+ 'data-invalid-syntax': null,
8227
+ 'data-invalid-type': null,
8228
+ 'data-invalid-message': null,
8229
+ hidden: ''
8230
+ });
8231
+ }
8146
8232
  }
8147
8233
  const group = label.split('-', 1)[0];
8148
8234
  let number = (0, label_1.number)(label, numbers.has(group) && !(0, label_1.isFixed)(label) ? (0, array_1.join)(numbers.get(group).split('.').slice(0, bases.length), '.') : base);
8149
8235
  if (number.endsWith('.0')) {
8150
- if (number.split('.').length > 2)
8151
- continue;
8152
- if (group !== '$' || def.tagName === 'FIGURE' && def.firstChild)
8236
+ if (group !== '$' || tagName === 'FIGURE' && def.firstChild)
8153
8237
  continue;
8154
8238
  if (number.startsWith('0.')) {
8155
- number = (0, array_1.join)(index.slice(0).reduce((ns, _, i, bs) => {
8156
- i === ns.length ? bs.length = i : ns[i] = +ns[i] > +bs[i] ? ns[i] : +ns[i] === 0 ? bs[i] : `${ +bs[i] + 1 }`;
8239
+ number = (0, array_1.join)(index.slice(0).reduce((ns, _, i, xs) => {
8240
+ i === ns.length ? xs.length = i : ns[i] = +ns[i] > +xs[i] ? ns[i] : +ns[i] === 0 ? xs[i] : `${ +xs[i] + 1 }`;
8157
8241
  return ns;
8158
8242
  }, number.split('.')), '.');
8159
8243
  }
8160
8244
  base = number;
8161
8245
  bases = index = base.split('.');
8162
- numbers.clear();
8246
+ tagName !== 'FIGURE' && numbers.clear();
8163
8247
  continue;
8164
8248
  }
8165
8249
  !(0, label_1.isFixed)(label) && numbers.set(group, number);
8166
8250
  opts.id !== '' && def.setAttribute('id', `label:${ opts.id ? `${ opts.id }:` : '' }${ label }`);
8167
8251
  const figindex = group === '$' ? `(${ number })` : `${ capitalize(group) }${ group === 'fig' ? '.' : '' } ${ number }`;
8168
8252
  (0, typed_dom_1.define)(def.querySelector(':scope > figcaption > .figindex'), group === '$' ? figindex : `${ figindex }. `);
8253
+ if (labels.has(label)) {
8254
+ if (classList.contains('invalid') && def.getAttribute('data-invalid-message') !== 'Duplicate label')
8255
+ continue;
8256
+ (0, typed_dom_1.define)(def, {
8257
+ id: null,
8258
+ class: void classList.add('invalid'),
8259
+ 'data-invalid-syntax': 'figure',
8260
+ 'data-invalid-type': 'argument',
8261
+ 'data-invalid-message': 'Duplicate label'
8262
+ });
8263
+ continue;
8264
+ } else {
8265
+ labels.add(label);
8266
+ (0, typed_dom_1.define)(def, {
8267
+ class: void classList.remove('invalid'),
8268
+ 'data-invalid-syntax': null,
8269
+ 'data-invalid-type': null,
8270
+ 'data-invalid-message': null
8271
+ });
8272
+ }
8169
8273
  for (const ref of refs.take(label, global_1.Infinity)) {
8170
8274
  if (ref.hash.slice(1) === def.id && ref.innerText === figindex)
8171
8275
  continue;
@@ -8178,7 +8282,7 @@ require = function () {
8178
8282
  class: `${ ref.className } disabled invalid`,
8179
8283
  'data-invalid-syntax': 'label',
8180
8284
  'data-invalid-type': 'reference',
8181
- 'data-invalid-description': 'Missing the reference.'
8285
+ 'data-invalid-message': 'Missing the target figure'
8182
8286
  });
8183
8287
  }
8184
8288
  yield ref;
@@ -8250,10 +8354,10 @@ require = function () {
8250
8354
  style !== null && style !== void 0 ? style : style = abbr ? 'abbr' : 'count';
8251
8355
  if (style === 'count' ? abbr : !abbr) {
8252
8356
  (0, typed_dom_1.define)(ref, {
8253
- class: `${ ref.className } invalid`,
8357
+ class: void ref.classList.add('invalid'),
8254
8358
  'data-invalid-syntax': syntax,
8255
8359
  'data-invalid-type': 'style',
8256
- 'data-invalid-description': `${ syntax[0].toUpperCase() + syntax.slice(1) } style must be consistent.`
8360
+ 'data-invalid-message': `${ syntax[0].toUpperCase() + syntax.slice(1) } style must be consistent`
8257
8361
  });
8258
8362
  }
8259
8363
  if (((_a = ref.firstElementChild) === null || _a === void 0 ? void 0 : _a.getAttribute('hidden')) !== '') {
@@ -8280,7 +8384,7 @@ require = function () {
8280
8384
  class: void ref.classList.remove('invalid'),
8281
8385
  'data-invalid-syntax': null,
8282
8386
  'data-invalid-type': null,
8283
- 'data-invalid-description': null
8387
+ 'data-invalid-message': null
8284
8388
  });
8285
8389
  }
8286
8390
  }
@@ -8293,7 +8397,7 @@ require = function () {
8293
8397
  class: void ref.classList.add('invalid'),
8294
8398
  'data-invalid-syntax': syntax,
8295
8399
  'data-invalid-type': 'content',
8296
- 'data-invalid-description': 'Missing the content.'
8400
+ 'data-invalid-message': 'Missing the content'
8297
8401
  }
8298
8402
  });
8299
8403
  yield ref.appendChild((0, typed_dom_1.html)('a', { href: refId && defId && `#${ defId }` }, marker(defIndex, abbr)));
@@ -9407,6 +9511,7 @@ require = function () {
9407
9511
  'use strict';
9408
9512
  Object.defineProperty(exports, '__esModule', { value: true });
9409
9513
  exports.quote = void 0;
9514
+ const global_1 = _dereq_('spica/global');
9410
9515
  const parser_1 = _dereq_('../combinator/data/parser');
9411
9516
  const cite_1 = _dereq_('../parser/block/reply/cite');
9412
9517
  const typed_dom_1 = _dereq_('typed-dom');
@@ -9441,7 +9546,7 @@ require = function () {
9441
9546
  }
9442
9547
  for (let es = node.querySelectorAll('br'), i = 0, len = es.length; i < len; ++i) {
9443
9548
  const el = es[i];
9444
- if (anchor && el.nextSibling instanceof Element && el.nextSibling.matches('.cite, .quote')) {
9549
+ if (anchor && el.nextSibling instanceof global_1.Element && el.nextSibling.matches('.cite, .quote')) {
9445
9550
  el.replaceWith(`\n>${ el.nextSibling.matches('.quote.invalid') ? ' ' : '' }`);
9446
9551
  continue;
9447
9552
  }
@@ -9468,7 +9573,7 @@ require = function () {
9468
9573
  if ((_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.matches('.cite > .anchor')) {
9469
9574
  return void range.setStart(node.parentElement.previousSibling, 0);
9470
9575
  }
9471
- if (node.nodeName === 'BR' && node.nextSibling instanceof Element && node.nextSibling.matches('.cite, .quote')) {
9576
+ if (node.nodeName === 'BR' && node.nextSibling instanceof global_1.Element && node.nextSibling.matches('.cite, .quote')) {
9472
9577
  return void range.setStart(node.nextSibling.firstChild, 0);
9473
9578
  }
9474
9579
  const offset = range.startOffset;
@@ -9488,6 +9593,7 @@ require = function () {
9488
9593
  {
9489
9594
  '../combinator/data/parser': 47,
9490
9595
  '../parser/block/reply/cite': 83,
9596
+ 'spica/global': 15,
9491
9597
  'typed-dom': 26
9492
9598
  }
9493
9599
  ],