securemark 0.236.0 → 0.237.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/securemark.js +184 -99
  3. package/karma.conf.js +1 -1
  4. package/markdown.d.ts +9 -10
  5. package/package-lock.json +81 -47
  6. package/package.json +1 -1
  7. package/src/parser/api/bind.ts +7 -3
  8. package/src/parser/api/parse.test.ts +2 -2
  9. package/src/parser/api/parse.ts +8 -11
  10. package/src/parser/block/blockquote.test.ts +1 -1
  11. package/src/parser/block/codeblock.test.ts +5 -2
  12. package/src/parser/block/codeblock.ts +43 -25
  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 +1 -1
  16. package/src/parser/block/extension/example.test.ts +2 -2
  17. package/src/parser/block/extension/example.ts +1 -1
  18. package/src/parser/block/extension/fig.test.ts +22 -20
  19. package/src/parser/block/extension/figure.test.ts +33 -33
  20. package/src/parser/block/extension/figure.ts +26 -1
  21. package/src/parser/block/extension/message.ts +1 -1
  22. package/src/parser/block/extension/placeholder.ts +1 -1
  23. package/src/parser/block/extension/table.ts +1 -1
  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/mathblock.ts +1 -1
  28. package/src/parser/block/olist.test.ts +8 -0
  29. package/src/parser/block/olist.ts +6 -6
  30. package/src/parser/block/reply/cite.test.ts +4 -0
  31. package/src/parser/block/reply/cite.ts +1 -0
  32. package/src/parser/block/ulist.test.ts +8 -0
  33. package/src/parser/block/ulist.ts +6 -6
  34. package/src/parser/inline/comment.ts +1 -1
  35. package/src/parser/inline/extension/indexee.ts +8 -8
  36. package/src/parser/inline.ts +2 -0
  37. package/src/parser/processor/figure.test.ts +70 -46
  38. package/src/parser/processor/figure.ts +58 -21
  39. package/src/parser/processor/footnote.ts +1 -1
  40. package/src/util/quote.ts +1 -0
@@ -1,4 +1,4 @@
1
- /*! securemark v0.236.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.237.2 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
2
2
  require = function () {
3
3
  function r(e, n, t) {
4
4
  function o(i, f) {
@@ -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
@@ -4754,41 +4753,49 @@ require = function () {
4754
4753
  const parser_1 = _dereq_('../../combinator/data/parser');
4755
4754
  const combinator_1 = _dereq_('../../combinator');
4756
4755
  const autolink_1 = _dereq_('../autolink');
4757
- const source_1 = _dereq_('../source');
4758
4756
  const typed_dom_1 = _dereq_('typed-dom');
4759
- const array_1 = _dereq_('spica/array');
4760
- const opener = /^(`{3,})(?!`)(\S*)([^\n]*)(?:$|\n)/;
4761
- const language = /^[0-9a-z]+(?:-[a-z][0-9a-z]*)*$/;
4757
+ const opener = /^(`{3,})(?!`)([^\n]*)(?:$|\n)/;
4758
+ const language = /^[0-9a-z]+(?:-[a-z][0-9a-z]*)*$/i;
4762
4759
  exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('```', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 300))));
4763
4760
  exports.segment_ = (0, combinator_1.block)((0, combinator_1.validate)('```', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 300, false))), false);
4764
- exports.codeblock = (0, combinator_1.block)((0, combinator_1.validate)('```', (0, combinator_1.fmap)((0, combinator_1.fence)(opener, 300), ([body, closer, opener, delim, lang, param], _, context) => {
4765
- var _a, _b, _c, _d;
4766
- [lang, param] = language.test(lang) ? [
4767
- lang,
4768
- param
4769
- ] : [
4770
- '',
4771
- lang + param
4772
- ];
4773
- param = param.trim();
4774
- const path = (0, array_1.join)((0, parser_1.eval)((0, combinator_1.some)(source_1.escsource, /^\s/)(param, context), []));
4775
- if (!closer || param !== path)
4761
+ exports.codeblock = (0, combinator_1.block)((0, combinator_1.validate)('```', (0, combinator_1.fmap)((0, combinator_1.fence)(opener, 300), ([body, closer, opener, delim, param], _, context) => {
4762
+ var _a, _b, _c, _d, _e, _f;
4763
+ const params = (_b = (_a = param.match(/(?:\\.?|\S)+/g)) === null || _a === void 0 ? void 0 : _a.reduce((params, value, i) => {
4764
+ var _a, _b, _c;
4765
+ let name;
4766
+ switch (true) {
4767
+ case i === 0 && value[0] === param[0] && language.test(value):
4768
+ name = 'lang';
4769
+ value = value.toLowerCase();
4770
+ break;
4771
+ case /^\d+(?:[,-]\d+)*$/.test(value):
4772
+ name = 'line';
4773
+ break;
4774
+ default:
4775
+ name = 'path';
4776
+ if (!params.lang) {
4777
+ const file = (_a = value.split('/').pop()) !== null && _a !== void 0 ? _a : '';
4778
+ params.lang = file && file.includes('.', 1) ? (_c = (_b = file.split('.').pop()) === null || _b === void 0 ? void 0 : _b.match(language)) === null || _c === void 0 ? void 0 : _c[0].toLowerCase() : params.lang;
4779
+ }
4780
+ }
4781
+ name in params ? params.invalid = `Duplicate ${ name } value` : params[name] = value;
4782
+ return params;
4783
+ }, {})) !== null && _b !== void 0 ? _b : {};
4784
+ if (!closer || params.invalid)
4776
4785
  return [(0, typed_dom_1.html)('pre', {
4777
4786
  class: 'invalid',
4778
4787
  translate: 'no',
4779
4788
  'data-invalid-syntax': 'codeblock',
4780
- 'data-invalid-type': !closer ? 'closer' : 'argument',
4781
- 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
4789
+ 'data-invalid-type': !closer ? 'fence' : 'argument',
4790
+ 'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : params.invalid
4782
4791
  }, `${ opener }${ body }${ closer }`)];
4783
- const file = (_a = path.split('/').pop()) !== null && _a !== void 0 ? _a : '';
4784
- const ext = file && file.includes('.', 1) ? file.split('.').pop() : '';
4785
- lang = language.test(lang || ext) ? lang || ext : lang && 'invalid';
4786
4792
  const el = (0, typed_dom_1.html)('pre', {
4787
- class: lang ? `code language-${ lang }` : 'text',
4793
+ class: params.lang ? `code language-${ params.lang }` : 'text',
4788
4794
  translate: 'no',
4789
- 'data-lang': lang || global_1.undefined,
4790
- 'data-path': path || global_1.undefined
4791
- }, lang ? ((_d = (_c = (_b = context.caches) === null || _b === void 0 ? void 0 : _b.code) === null || _c === void 0 ? void 0 : _c.get(`${ lang }\n${ body.slice(0, -1) }`)) === null || _d === void 0 ? void 0 : _d.cloneNode(true).childNodes) || body.slice(0, -1) || global_1.undefined : (0, typed_dom_1.defrag)((0, parser_1.eval)((0, combinator_1.some)(autolink_1.autolink)(body.slice(0, -1), context), [])));
4795
+ 'data-lang': params.lang || global_1.undefined,
4796
+ 'data-line': params.line || global_1.undefined,
4797
+ 'data-path': params.path || global_1.undefined
4798
+ }, params.lang ? ((_f = (_d = (_c = context.caches) === null || _c === void 0 ? void 0 : _c.code) === null || _d === void 0 ? void 0 : _d.get(`${ (_e = params.lang) !== null && _e !== void 0 ? _e : '' }\n${ body.slice(0, -1) }`)) === null || _f === void 0 ? void 0 : _f.cloneNode(true).childNodes) || body.slice(0, -1) || global_1.undefined : (0, typed_dom_1.defrag)((0, parser_1.eval)((0, combinator_1.some)(autolink_1.autolink)(body.slice(0, -1), context), [])));
4792
4799
  return [el];
4793
4800
  })));
4794
4801
  },
@@ -4796,8 +4803,6 @@ require = function () {
4796
4803
  '../../combinator': 27,
4797
4804
  '../../combinator/data/parser': 47,
4798
4805
  '../autolink': 62,
4799
- '../source': 128,
4800
- 'spica/array': 6,
4801
4806
  'spica/global': 15,
4802
4807
  'typed-dom': 26
4803
4808
  }
@@ -4809,8 +4814,6 @@ require = function () {
4809
4814
  exports.dlist = void 0;
4810
4815
  const combinator_1 = _dereq_('../../combinator');
4811
4816
  const inline_1 = _dereq_('../inline');
4812
- const indexer_1 = _dereq_('../inline/extension/indexer');
4813
- const indexee_1 = _dereq_('../inline/extension/indexee');
4814
4817
  const source_1 = _dereq_('../source');
4815
4818
  const locale_1 = _dereq_('../locale');
4816
4819
  const util_1 = _dereq_('../util');
@@ -4831,8 +4834,8 @@ require = function () {
4831
4834
  }, (0, combinator_1.some)(term)),
4832
4835
  (0, combinator_1.some)(desc)
4833
4836
  ]))), 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,
4837
+ 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)([
4838
+ inline_1.indexer,
4836
4839
  inline_1.inline
4837
4840
  ])))), true), ns => [(0, typed_dom_1.html)('dt', (0, typed_dom_1.defrag)(ns))]))));
4838
4841
  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 +4846,6 @@ require = function () {
4843
4846
  {
4844
4847
  '../../combinator': 27,
4845
4848
  '../inline': 88,
4846
- '../inline/extension/indexee': 107,
4847
- '../inline/extension/indexer': 108,
4848
4849
  '../locale': 123,
4849
4850
  '../source': 128,
4850
4851
  '../util': 134,
@@ -4870,7 +4871,7 @@ require = function () {
4870
4871
  '~~~',
4871
4872
  '[$',
4872
4873
  '$'
4873
- ], (0, combinator_1.validate)(/^~{3,}|^\[?\$[a-z-]\S+[^\S\n]*(?:$|\n)/, (0, combinator_1.union)([
4874
+ ], (0, combinator_1.validate)(/^~{3,}|^\[?\$[A-Za-z-]\S+[^\S\n]*(?:$|\n)/, (0, combinator_1.union)([
4874
4875
  fig_1.segment,
4875
4876
  figure_1.segment,
4876
4877
  table_1.segment,
@@ -4915,7 +4916,7 @@ require = function () {
4915
4916
  class: 'invalid',
4916
4917
  translate: 'no',
4917
4918
  'data-invalid-syntax': 'aside',
4918
- 'data-invalid-type': !closer ? 'closer' : 'argument',
4919
+ 'data-invalid-type': !closer ? 'fence' : 'argument',
4919
4920
  'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
4920
4921
  }, `${ opener }${ body }${ closer }`)];
4921
4922
  const annotations = (0, typed_dom_1.html)('ol', { class: 'annotations' });
@@ -4970,7 +4971,7 @@ require = function () {
4970
4971
  class: 'invalid',
4971
4972
  translate: 'no',
4972
4973
  'data-invalid-syntax': 'example',
4973
- 'data-invalid-type': !closer ? 'closer' : 'argument',
4974
+ 'data-invalid-type': !closer ? 'fence' : 'argument',
4974
4975
  'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
4975
4976
  }, `${ opener }${ body }${ closer }`)];
4976
4977
  switch (type) {
@@ -5117,7 +5118,7 @@ require = function () {
5117
5118
  const typed_dom_1 = _dereq_('typed-dom');
5118
5119
  const memoize_1 = _dereq_('spica/memoize');
5119
5120
  const array_1 = _dereq_('spica/array');
5120
- 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)([
5121
+ 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)([
5121
5122
  (0, combinator_1.line)((0, combinator_1.close)(label_1.segment, /^.*\n/)),
5122
5123
  (0, combinator_1.inits)([
5123
5124
  (0, combinator_1.union)([
@@ -5167,7 +5168,31 @@ require = function () {
5167
5168
  const invalidParam = param.trimStart() !== '';
5168
5169
  const invalidContent = group === '$' && (!content.classList.contains('math') || caption.length > 0);
5169
5170
  const invalid = invalidLabel || invalidParam || invalidContent || global_1.undefined;
5171
+ let type = content.className.split(/\s/)[0];
5172
+ switch (type || content.tagName) {
5173
+ case 'UL':
5174
+ case 'OL':
5175
+ type = 'list';
5176
+ break;
5177
+ case 'TABLE':
5178
+ type = 'table';
5179
+ break;
5180
+ case 'BLOCKQUOTE':
5181
+ type = 'quote';
5182
+ break;
5183
+ case 'A':
5184
+ type = 'media';
5185
+ break;
5186
+ case 'text':
5187
+ case 'code':
5188
+ case 'math':
5189
+ case 'example':
5190
+ case 'invalid':
5191
+ break;
5192
+ default:
5193
+ }
5170
5194
  return {
5195
+ 'data-type': type,
5171
5196
  'data-label': label,
5172
5197
  'data-group': group,
5173
5198
  class: invalid && 'invalid',
@@ -5234,7 +5259,7 @@ require = function () {
5234
5259
  class: 'invalid',
5235
5260
  translate: 'no',
5236
5261
  'data-invalid-syntax': 'message',
5237
- 'data-invalid-type': !closer ? 'closer' : 'argument',
5262
+ 'data-invalid-type': !closer ? 'fence' : 'argument',
5238
5263
  'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
5239
5264
  }, `${ opener }${ body }${ closer }`)];
5240
5265
  switch (type) {
@@ -5305,7 +5330,7 @@ require = function () {
5305
5330
  class: 'invalid',
5306
5331
  translate: 'no',
5307
5332
  'data-invalid-syntax': 'extension',
5308
- 'data-invalid-type': !closer ? 'closer' : 'syntax',
5333
+ 'data-invalid-type': !closer ? 'fence' : 'syntax',
5309
5334
  'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid syntax'
5310
5335
  }, `${ opener }${ body }${ closer }`)])));
5311
5336
  },
@@ -5339,7 +5364,7 @@ require = function () {
5339
5364
  class: 'invalid',
5340
5365
  translate: 'no',
5341
5366
  'data-invalid-syntax': 'table',
5342
- 'data-invalid-type': !closer ? 'closer' : 'argument',
5367
+ 'data-invalid-type': !closer ? 'fence' : 'argument',
5343
5368
  'data-invalid-message': !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
5344
5369
  }, `${ opener }${ body }${ closer }`)];
5345
5370
  return (_a = (0, parser_1.eval)(parser(body, context))) !== null && _a !== void 0 ? _a : [(0, typed_dom_1.html)('table')];
@@ -5589,13 +5614,10 @@ require = function () {
5589
5614
  exports.heading = exports.segment = void 0;
5590
5615
  const combinator_1 = _dereq_('../../combinator');
5591
5616
  const inline_1 = _dereq_('../inline');
5592
- const indexer_1 = _dereq_('../inline/extension/indexer');
5593
- const indexee_1 = _dereq_('../inline/extension/indexee');
5594
5617
  const source_1 = _dereq_('../source');
5595
5618
  const util_1 = _dereq_('../util');
5596
5619
  const typed_dom_1 = _dereq_('typed-dom');
5597
- const array_1 = _dereq_('spica/array');
5598
- 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 => [
5620
+ 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 => [
5599
5621
  [source],
5600
5622
  ''
5601
5623
  ])))));
@@ -5610,25 +5632,27 @@ require = function () {
5610
5632
  media: false
5611
5633
  }
5612
5634
  }
5613
- }, (0, combinator_1.line)((0, indexee_1.indexee)((0, combinator_1.fmap)((0, combinator_1.union)([
5635
+ }, (0, combinator_1.line)((0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.union)([
5614
5636
  (0, combinator_1.open)((0, source_1.str)(/^##+/), (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([
5615
- indexer_1.indexer,
5637
+ inline_1.indexer,
5616
5638
  inline_1.inline
5617
5639
  ])))), true),
5618
5640
  (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)([
5619
- indexer_1.indexer,
5641
+ inline_1.indexer,
5620
5642
  inline_1.inline
5621
5643
  ]))))), true)
5622
- ]), ns => [(0, typed_dom_1.html)(`h${ (0, array_1.shift)(ns)[0].length }`, (0, typed_dom_1.defrag)(ns))]))))));
5644
+ ]), ([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`, {
5645
+ class: 'invalid',
5646
+ 'data-invalid-syntax': 'heading',
5647
+ 'data-invalid-type': 'syntax',
5648
+ 'data-invalid-message': 'Heading level must be up to 6'
5649
+ }, (0, typed_dom_1.defrag)(ns))]))))));
5623
5650
  },
5624
5651
  {
5625
5652
  '../../combinator': 27,
5626
5653
  '../inline': 88,
5627
- '../inline/extension/indexee': 107,
5628
- '../inline/extension/indexer': 108,
5629
5654
  '../source': 128,
5630
5655
  '../util': 134,
5631
- 'spica/array': 6,
5632
5656
  'typed-dom': 26
5633
5657
  }
5634
5658
  ],
@@ -5711,7 +5735,7 @@ require = function () {
5711
5735
  class: 'invalid',
5712
5736
  translate: 'no',
5713
5737
  'data-invalid-syntax': 'mathblock',
5714
- 'data-invalid-type': delim.length > 2 ? 'syntax' : !closer ? 'closer' : 'argument',
5738
+ 'data-invalid-type': delim.length > 2 ? 'syntax' : !closer ? 'fence' : 'argument',
5715
5739
  'data-invalid-message': delim.length > 2 ? 'Invalid syntax' : !closer ? `Missing the closing delimiter "${ delim }"` : 'Invalid argument'
5716
5740
  }, `${ opener }${ body }${ closer }`)];
5717
5741
  })));
@@ -5748,17 +5772,20 @@ require = function () {
5748
5772
  (0, combinator_1.match)(new RegExp(`^(?=${ openers['.'].source.replace('?:', '') })`), (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => type(ms[1]))),
5749
5773
  (0, combinator_1.match)(new RegExp(`^(?=${ openers['('].source.replace('?:', '') })`), (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => type(ms[1])))
5750
5774
  ])));
5751
- 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)([
5775
+ 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)([
5752
5776
  (0, combinator_1.line)((0, combinator_1.open)(heads[delim], (0, combinator_1.trim)((0, combinator_1.subsequence)([
5753
5777
  ulist_1.checkbox,
5754
- (0, combinator_1.trimStart)((0, combinator_1.some)(inline_1.inline))
5778
+ (0, combinator_1.trimStart)((0, combinator_1.some)((0, combinator_1.union)([
5779
+ inline_1.indexer,
5780
+ inline_1.inline
5781
+ ])))
5755
5782
  ])), true)),
5756
5783
  (0, combinator_1.indent)((0, combinator_1.union)([
5757
5784
  ulist_1.ulist_,
5758
5785
  exports.olist_,
5759
5786
  ilist_1.ilist_
5760
5787
  ]))
5761
- ]), 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)]);
5788
+ ]), 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)]);
5762
5789
  const heads = {
5763
5790
  '.': (0, combinator_1.focus)(openers['.'], source => [
5764
5791
  [`${ source.split('.', 1)[0] }.`],
@@ -5769,7 +5796,7 @@ require = function () {
5769
5796
  ''
5770
5797
  ])
5771
5798
  };
5772
- const iitem = (0, combinator_1.rewrite)(source_1.contentline, source => [
5799
+ const invalid = (0, combinator_1.rewrite)(source_1.contentline, source => [
5773
5800
  [
5774
5801
  '',
5775
5802
  (0, typed_dom_1.html)('span', {
@@ -5932,6 +5959,10 @@ require = function () {
5932
5959
  (0, combinator_1.focus)(/^>>\.[^\S\n]*(?:$|\n)/, () => [
5933
5960
  [(0, typed_dom_1.html)('a', { class: 'anchor' }, '>>.')],
5934
5961
  ''
5962
+ ]),
5963
+ (0, combinator_1.focus)(/^>>#\S*[^\S\n]*(?:$|\n)/, source => [
5964
+ [(0, typed_dom_1.html)('a', { class: 'anchor' }, source)],
5965
+ ''
5935
5966
  ])
5936
5967
  ])
5937
5968
  ]))), ([el, quotes = '']) => [
@@ -6105,22 +6136,25 @@ require = function () {
6105
6136
  const array_1 = _dereq_('spica/array');
6106
6137
  const source_1 = _dereq_('../source');
6107
6138
  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_))));
6108
- 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)([
6139
+ 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)([
6109
6140
  (0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.trim)((0, combinator_1.subsequence)([
6110
6141
  exports.checkbox,
6111
- (0, combinator_1.trimStart)((0, combinator_1.some)(inline_1.inline))
6142
+ (0, combinator_1.trimStart)((0, combinator_1.some)((0, combinator_1.union)([
6143
+ inline_1.indexer,
6144
+ inline_1.inline
6145
+ ])))
6112
6146
  ])), true)),
6113
6147
  (0, combinator_1.indent)((0, combinator_1.union)([
6114
6148
  exports.ulist_,
6115
6149
  olist_1.olist_,
6116
6150
  ilist_1.ilist_
6117
6151
  ]))
6118
- ]), iitem), ns => [(0, typed_dom_1.html)('li', (0, typed_dom_1.defrag)(fillFirstLine(ns)))])])))), es => [format((0, typed_dom_1.html)('ul', es))])));
6152
+ ]), 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))])));
6119
6153
  exports.checkbox = (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, source => [
6120
6154
  [(0, typed_dom_1.html)('span', { class: 'checkbox' }, source[1].trimStart() ? '\u2611' : '\u2610')],
6121
6155
  ''
6122
6156
  ]);
6123
- const iitem = (0, combinator_1.rewrite)(source_1.contentline, source => [
6157
+ const invalid = (0, combinator_1.rewrite)(source_1.contentline, source => [
6124
6158
  [(0, typed_dom_1.html)('span', {
6125
6159
  class: 'invalid',
6126
6160
  'data-invalid-syntax': 'listitem',
@@ -6225,7 +6259,7 @@ require = function () {
6225
6259
  function (_dereq_, module, exports) {
6226
6260
  'use strict';
6227
6261
  Object.defineProperty(exports, '__esModule', { value: true });
6228
- exports.shortmedia = exports.media = exports.inline = void 0;
6262
+ exports.shortmedia = exports.media = exports.indexer = exports.indexee = exports.inline = void 0;
6229
6263
  const combinator_1 = _dereq_('../combinator');
6230
6264
  const escape_1 = _dereq_('./inline/escape');
6231
6265
  const annotation_1 = _dereq_('./inline/annotation');
@@ -6275,6 +6309,20 @@ require = function () {
6275
6309
  bracket_1.bracket,
6276
6310
  source_1.text
6277
6311
  ]);
6312
+ var indexee_1 = _dereq_('./inline/extension/indexee');
6313
+ Object.defineProperty(exports, 'indexee', {
6314
+ enumerable: true,
6315
+ get: function () {
6316
+ return indexee_1.indexee;
6317
+ }
6318
+ });
6319
+ var indexer_1 = _dereq_('./inline/extension/indexer');
6320
+ Object.defineProperty(exports, 'indexer', {
6321
+ enumerable: true,
6322
+ get: function () {
6323
+ return indexer_1.indexer;
6324
+ }
6325
+ });
6278
6326
  var media_2 = _dereq_('./inline/media');
6279
6327
  Object.defineProperty(exports, 'media', {
6280
6328
  enumerable: true,
@@ -6302,6 +6350,8 @@ require = function () {
6302
6350
  './inline/emstrong': 103,
6303
6351
  './inline/escape': 104,
6304
6352
  './inline/extension': 105,
6353
+ './inline/extension/indexee': 107,
6354
+ './inline/extension/indexer': 108,
6305
6355
  './inline/html': 111,
6306
6356
  './inline/htmlentity': 112,
6307
6357
  './inline/insertion': 113,
@@ -6696,7 +6746,7 @@ require = function () {
6696
6746
  ], ([as, bs = []], rest) => [
6697
6747
  (0, array_1.unshift)(as, bs),
6698
6748
  rest
6699
- ]), ([, fence]) => fence)))));
6749
+ ]), ([, fence]) => fence.length)))));
6700
6750
  },
6701
6751
  {
6702
6752
  '../../combinator': 27,
@@ -6989,8 +7039,8 @@ require = function () {
6989
7039
  const global_1 = _dereq_('spica/global');
6990
7040
  const combinator_1 = _dereq_('../../../combinator');
6991
7041
  const typed_dom_1 = _dereq_('typed-dom');
6992
- function indexee(parser) {
6993
- return (0, combinator_1.fmap)(parser, ([el], _, {id}) => [(0, typed_dom_1.define)(el, { id: id !== '' && identity(text(el)) || global_1.undefined })]);
7042
+ function indexee(parser, optional) {
7043
+ return (0, combinator_1.fmap)(parser, ([el], _, {id}) => [(0, typed_dom_1.define)(el, { id: id !== '' && identity(text(el, optional)) || global_1.undefined })]);
6994
7044
  }
6995
7045
  exports.indexee = indexee;
6996
7046
  function identity(text) {
@@ -6998,11 +7048,13 @@ require = function () {
6998
7048
  return text && `index:${ text.replace(/\s+/g, '_').slice(0, 101).replace(/^(.{97}).{4}$/, '$1...') }`;
6999
7049
  }
7000
7050
  exports.identity = identity;
7001
- function text(source) {
7051
+ function text(source, optional = false) {
7002
7052
  var _a;
7003
- const indexer = source.querySelector('.indexer');
7053
+ const indexer = source.querySelector(':scope > .indexer');
7004
7054
  if (indexer)
7005
7055
  return indexer.getAttribute('data-index');
7056
+ if (optional)
7057
+ return '';
7006
7058
  const target = source.cloneNode(true);
7007
7059
  for (let es = target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference'), i = 0, len = es.length; i < len; ++i) {
7008
7060
  const el = es[i];
@@ -8123,7 +8175,7 @@ require = function () {
8123
8175
  const multimap_1 = _dereq_('spica/multimap');
8124
8176
  const array_1 = _dereq_('spica/array');
8125
8177
  function* figure(target, footnotes, opts = {}) {
8126
- var _a, _b, _c;
8178
+ var _a, _b, _c, _d;
8127
8179
  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 => [
8128
8180
  el.getAttribute('data-label'),
8129
8181
  el
@@ -8133,40 +8185,71 @@ require = function () {
8133
8185
  let base = '0';
8134
8186
  let bases = base.split('.');
8135
8187
  let index = bases;
8136
- for (let defs = target.querySelectorAll('figure[data-label], h1, h2, h3'), i = 0, len = defs.length; i < len; ++i) {
8188
+ for (let defs = target.querySelectorAll('figure[data-label], h1, h2'), i = 0, len = defs.length; i < len; ++i) {
8137
8189
  yield;
8138
8190
  const def = defs[i];
8139
8191
  if (def.parentNode !== target)
8140
8192
  continue;
8141
- if (bases.length === 1 && def.tagName[0] === 'H')
8193
+ const {tagName, classList} = def;
8194
+ if (bases.length === 1 && tagName[0] === 'H')
8142
8195
  continue;
8143
- const label = def.tagName === 'FIGURE' ? def.getAttribute('data-label') : `$-${ increment(index, def) }`;
8196
+ const label = tagName === 'FIGURE' ? def.getAttribute('data-label') : `$-${ increment(index, def) }`;
8144
8197
  if (label.endsWith('-'))
8145
8198
  continue;
8146
- if (label.endsWith('-0'))
8199
+ if (label.endsWith('-0')) {
8200
+ (0, typed_dom_1.define)(def, {
8201
+ class: void classList.add('invalid'),
8202
+ 'data-invalid-syntax': 'figure',
8203
+ 'data-invalid-type': 'argument',
8204
+ 'data-invalid-message': 'Invalid base index',
8205
+ hidden: null
8206
+ });
8147
8207
  continue;
8148
- if (def.tagName === 'FIGURE' && label.endsWith('.0')) {
8149
- if (label.lastIndexOf('.', label.length - 3) < 0 && !(+((_c = def.previousElementSibling) === null || _c === void 0 ? void 0 : _c.tagName[1]) <= 2))
8208
+ }
8209
+ if (tagName === 'FIGURE' && label.endsWith('.0')) {
8210
+ if (label.lastIndexOf('.', label.length - 3) !== -1) {
8211
+ (0, typed_dom_1.define)(def, {
8212
+ class: void classList.add('invalid'),
8213
+ 'data-invalid-syntax': 'figure',
8214
+ 'data-invalid-type': 'argument',
8215
+ 'data-invalid-message': 'Base index must be $-x.0 format',
8216
+ hidden: null
8217
+ });
8150
8218
  continue;
8151
- if (label.lastIndexOf('.', label.length - 3) > 0)
8219
+ }
8220
+ if (!/^H[1-6]$/.test((_d = (_c = def.previousElementSibling) === null || _c === void 0 ? void 0 : _c.tagName) !== null && _d !== void 0 ? _d : '')) {
8221
+ (0, typed_dom_1.define)(def, {
8222
+ class: void classList.add('invalid'),
8223
+ 'data-invalid-syntax': 'figure',
8224
+ 'data-invalid-type': 'position',
8225
+ 'data-invalid-message': 'Base index declarations must be after level 1 to 6 headings',
8226
+ hidden: null
8227
+ });
8152
8228
  continue;
8229
+ } else {
8230
+ classList.contains('invalid') && (0, typed_dom_1.define)(def, {
8231
+ class: void classList.remove('invalid'),
8232
+ 'data-invalid-syntax': null,
8233
+ 'data-invalid-type': null,
8234
+ 'data-invalid-message': null,
8235
+ hidden: ''
8236
+ });
8237
+ }
8153
8238
  }
8154
8239
  const group = label.split('-', 1)[0];
8155
8240
  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);
8156
8241
  if (number.endsWith('.0')) {
8157
- if (number.split('.').length > 2)
8158
- continue;
8159
- if (group !== '$' || def.tagName === 'FIGURE' && def.firstChild)
8242
+ if (group !== '$' || tagName === 'FIGURE' && def.firstChild)
8160
8243
  continue;
8161
8244
  if (number.startsWith('0.')) {
8162
- number = (0, array_1.join)(index.slice(0).reduce((ns, _, i, bs) => {
8163
- i === ns.length ? bs.length = i : ns[i] = +ns[i] > +bs[i] ? ns[i] : +ns[i] === 0 ? bs[i] : `${ +bs[i] + 1 }`;
8245
+ number = (0, array_1.join)(index.slice(0).reduce((ns, _, i, xs) => {
8246
+ i === ns.length ? xs.length = i : ns[i] = +ns[i] > +xs[i] ? ns[i] : +ns[i] === 0 ? xs[i] : `${ +xs[i] + 1 }`;
8164
8247
  return ns;
8165
8248
  }, number.split('.')), '.');
8166
8249
  }
8167
8250
  base = number;
8168
8251
  bases = index = base.split('.');
8169
- numbers.clear();
8252
+ tagName !== 'FIGURE' && numbers.clear();
8170
8253
  continue;
8171
8254
  }
8172
8255
  !(0, label_1.isFixed)(label) && numbers.set(group, number);
@@ -8174,11 +8257,11 @@ require = function () {
8174
8257
  const figindex = group === '$' ? `(${ number })` : `${ capitalize(group) }${ group === 'fig' ? '.' : '' } ${ number }`;
8175
8258
  (0, typed_dom_1.define)(def.querySelector(':scope > figcaption > .figindex'), group === '$' ? figindex : `${ figindex }. `);
8176
8259
  if (labels.has(label)) {
8177
- if (def.classList.contains('invalid') && def.getAttribute('data-invalid-message') !== 'Duplicate label')
8260
+ if (classList.contains('invalid') && def.getAttribute('data-invalid-message') !== 'Duplicate label')
8178
8261
  continue;
8179
8262
  (0, typed_dom_1.define)(def, {
8180
8263
  id: null,
8181
- class: void def.classList.add('invalid'),
8264
+ class: void classList.add('invalid'),
8182
8265
  'data-invalid-syntax': 'figure',
8183
8266
  'data-invalid-type': 'argument',
8184
8267
  'data-invalid-message': 'Duplicate label'
@@ -8187,7 +8270,7 @@ require = function () {
8187
8270
  } else {
8188
8271
  labels.add(label);
8189
8272
  (0, typed_dom_1.define)(def, {
8190
- class: void def.classList.remove('invalid'),
8273
+ class: void classList.remove('invalid'),
8191
8274
  'data-invalid-syntax': null,
8192
8275
  'data-invalid-type': null,
8193
8276
  'data-invalid-message': null
@@ -8205,7 +8288,7 @@ require = function () {
8205
8288
  class: `${ ref.className } disabled invalid`,
8206
8289
  'data-invalid-syntax': 'label',
8207
8290
  'data-invalid-type': 'reference',
8208
- 'data-invalid-message': 'Missing the reference'
8291
+ 'data-invalid-message': 'Missing the target figure'
8209
8292
  });
8210
8293
  }
8211
8294
  yield ref;
@@ -8277,7 +8360,7 @@ require = function () {
8277
8360
  style !== null && style !== void 0 ? style : style = abbr ? 'abbr' : 'count';
8278
8361
  if (style === 'count' ? abbr : !abbr) {
8279
8362
  (0, typed_dom_1.define)(ref, {
8280
- class: `${ ref.className } invalid`,
8363
+ class: void ref.classList.add('invalid'),
8281
8364
  'data-invalid-syntax': syntax,
8282
8365
  'data-invalid-type': 'style',
8283
8366
  'data-invalid-message': `${ syntax[0].toUpperCase() + syntax.slice(1) } style must be consistent`
@@ -9434,6 +9517,7 @@ require = function () {
9434
9517
  'use strict';
9435
9518
  Object.defineProperty(exports, '__esModule', { value: true });
9436
9519
  exports.quote = void 0;
9520
+ const global_1 = _dereq_('spica/global');
9437
9521
  const parser_1 = _dereq_('../combinator/data/parser');
9438
9522
  const cite_1 = _dereq_('../parser/block/reply/cite');
9439
9523
  const typed_dom_1 = _dereq_('typed-dom');
@@ -9468,7 +9552,7 @@ require = function () {
9468
9552
  }
9469
9553
  for (let es = node.querySelectorAll('br'), i = 0, len = es.length; i < len; ++i) {
9470
9554
  const el = es[i];
9471
- if (anchor && el.nextSibling instanceof Element && el.nextSibling.matches('.cite, .quote')) {
9555
+ if (anchor && el.nextSibling instanceof global_1.Element && el.nextSibling.matches('.cite, .quote')) {
9472
9556
  el.replaceWith(`\n>${ el.nextSibling.matches('.quote.invalid') ? ' ' : '' }`);
9473
9557
  continue;
9474
9558
  }
@@ -9495,7 +9579,7 @@ require = function () {
9495
9579
  if ((_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.matches('.cite > .anchor')) {
9496
9580
  return void range.setStart(node.parentElement.previousSibling, 0);
9497
9581
  }
9498
- if (node.nodeName === 'BR' && node.nextSibling instanceof Element && node.nextSibling.matches('.cite, .quote')) {
9582
+ if (node.nodeName === 'BR' && node.nextSibling instanceof global_1.Element && node.nextSibling.matches('.cite, .quote')) {
9499
9583
  return void range.setStart(node.nextSibling.firstChild, 0);
9500
9584
  }
9501
9585
  const offset = range.startOffset;
@@ -9515,6 +9599,7 @@ require = function () {
9515
9599
  {
9516
9600
  '../combinator/data/parser': 47,
9517
9601
  '../parser/block/reply/cite': 83,
9602
+ 'spica/global': 15,
9518
9603
  'typed-dom': 26
9519
9604
  }
9520
9605
  ],