securemark 0.232.0 → 0.233.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 (40) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/design.md +4 -0
  3. package/dist/securemark.js +91 -117
  4. package/markdown.d.ts +13 -22
  5. package/package-lock.json +259 -245
  6. package/package.json +5 -5
  7. package/src/combinator/control/manipulation/indent.test.ts +12 -12
  8. package/src/combinator/control/manipulation/surround.ts +4 -3
  9. package/src/parser/api/parse.test.ts +6 -6
  10. package/src/parser/block/blockquote.test.ts +1 -1
  11. package/src/parser/block/extension/aside.test.ts +1 -1
  12. package/src/parser/block/extension/aside.ts +3 -3
  13. package/src/parser/block/extension/example.test.ts +2 -2
  14. package/src/parser/block/extension/table.ts +3 -3
  15. package/src/parser/block/paragraph.test.ts +7 -6
  16. package/src/parser/block/reply/cite.ts +3 -3
  17. package/src/parser/block/reply/quote.ts +5 -3
  18. package/src/parser/block/reply.ts +4 -4
  19. package/src/parser/inline/annotation.test.ts +0 -2
  20. package/src/parser/inline/autolink/anchor.ts +3 -1
  21. package/src/parser/inline/comment.test.ts +39 -38
  22. package/src/parser/inline/comment.ts +21 -28
  23. package/src/parser/inline/deletion.test.ts +0 -1
  24. package/src/parser/inline/emphasis.test.ts +0 -3
  25. package/src/parser/inline/extension/index.test.ts +4 -3
  26. package/src/parser/inline/extension/index.ts +2 -2
  27. package/src/parser/inline/extension/indexee.ts +21 -19
  28. package/src/parser/inline/extension/placeholder.test.ts +7 -7
  29. package/src/parser/inline/insertion.test.ts +0 -1
  30. package/src/parser/inline/link.test.ts +0 -1
  31. package/src/parser/inline/mark.test.ts +0 -3
  32. package/src/parser/inline/media.ts +9 -9
  33. package/src/parser/inline/reference.test.ts +17 -19
  34. package/src/parser/inline/reference.ts +1 -1
  35. package/src/parser/inline/strong.test.ts +0 -3
  36. package/src/parser/inline.ts +3 -3
  37. package/src/parser/processor/figure.test.ts +25 -25
  38. package/src/parser/processor/figure.ts +1 -1
  39. package/src/parser/util.ts +2 -17
  40. package/src/parser/util.test.ts +0 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.233.0
4
+
5
+ - Refine comment parser.
6
+
7
+ ## 0.232.2
8
+
9
+ - Refactoring.
10
+
11
+ ## 0.232.1
12
+
13
+ - Refactoring.
14
+
3
15
  ## 0.232.0
4
16
 
5
17
  - Refine paragraph syntax to separate mention syntax.
package/design.md CHANGED
@@ -293,3 +293,7 @@ MarkdownはGFMのように最初から高機能で完成度の高い拡張不要
293
293
  ### トランスクルージョン
294
294
 
295
295
  分散的に管理される情報のトランスクルージョンは権利関係の不明瞭さおよびリンク先の消失によりリンク元の情報に欠損が生じるなどの脆さから壊れやすいウェブ上の情報を扱う方法として既存の方法より劣っておりWikipediaのように中央集権的管理を実施できる場合にのみ有用となる。
296
+
297
+ ### Data URI
298
+
299
+ Data URIは保存および転送容量削減ならびに集約的管理のためサポートしない。
@@ -1,4 +1,4 @@
1
- /*! securemark v0.232.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.233.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) {
@@ -427,7 +427,7 @@ require = function () {
427
427
  this.indexes = {
428
428
  LRU: new invlist_1.List(),
429
429
  LFU: new invlist_1.List(),
430
- OVF: new invlist_1.List()
430
+ OVL: new invlist_1.List()
431
431
  };
432
432
  this.stats = {
433
433
  LRU: (0, tuple_1.tuple)(0, 0),
@@ -470,7 +470,7 @@ require = function () {
470
470
  callback && (callback = !!this.settings.disposer);
471
471
  record = callback ? record !== null && record !== void 0 ? record : this.memory.get(index.key) : record;
472
472
  node.delete();
473
- (_a = node.value.overflow) === null || _a === void 0 ? void 0 : _a.delete();
473
+ (_a = node.value.overlap) === null || _a === void 0 ? void 0 : _a.delete();
474
474
  this.memory.delete(index.key);
475
475
  this.SIZE -= index.size;
476
476
  callback && ((_c = (_b = this.settings).disposer) === null || _c === void 0 ? void 0 : _c.call(_b, record.value, index.key));
@@ -484,25 +484,30 @@ require = function () {
484
484
  let size = (_a = skip === null || skip === void 0 ? void 0 : skip.value.size) !== null && _a !== void 0 ? _a : 0;
485
485
  if (margin - size <= 0)
486
486
  return;
487
- const {LRU, LFU, OVF} = this.indexes;
487
+ const {LRU, LFU, OVL} = this.indexes;
488
488
  while (this.length === this.capacity || this.size + margin - size > this.space) {
489
- const lastNode = (_b = OVF.last) !== null && _b !== void 0 ? _b : LFU.last;
489
+ const lastNode = (_b = OVL.last) !== null && _b !== void 0 ? _b : LFU.last;
490
490
  const lastIndex = lastNode === null || lastNode === void 0 ? void 0 : lastNode.value;
491
491
  let target;
492
492
  switch (true) {
493
493
  case lastIndex && lastIndex.clock < this.clock - this.life:
494
494
  case lastIndex && lastIndex.expiry !== global_1.Infinity && lastIndex.expiry < (0, clock_1.now)():
495
- target = lastNode.list === OVF ? lastNode.value.parent : lastNode;
495
+ target = lastNode.list === OVL ? lastNode.value.node : lastNode;
496
496
  break;
497
497
  case LRU.length === 0:
498
498
  target = LFU.last !== skip ? LFU.last : LFU.last.prev;
499
499
  break;
500
500
  case LFU.length > this.capacity * this.ratio / 100:
501
- LRU.unshiftNode(LFU.last);
502
- LRU.head.value.parent = LRU.head;
503
- LRU.head.value.overflow = OVF.unshift(LRU.head.value);
501
+ target = LFU.last !== skip ? LFU.last : LFU.length >= 2 ? LFU.last.prev : skip;
502
+ if (target !== skip) {
503
+ if (this.ratio > 50)
504
+ break;
505
+ LRU.unshiftNode(target);
506
+ LRU.head.value.node = LRU.head;
507
+ LRU.head.value.overlap = OVL.unshift(LRU.head.value);
508
+ }
504
509
  default:
505
- target = LRU.last !== skip ? LRU.last : LRU.last.prev !== skip ? LRU.last.prev : LFU.last;
510
+ target = LRU.last !== skip ? LRU.last : LRU.length >= 2 ? LRU.last.prev : LFU.last;
506
511
  }
507
512
  this.evict(target, void 0, true);
508
513
  skip = (skip === null || skip === void 0 ? void 0 : skip.list) && skip;
@@ -593,7 +598,7 @@ require = function () {
593
598
  this.stats.clear();
594
599
  this.indexes.LRU.clear();
595
600
  this.indexes.LFU.clear();
596
- this.indexes.OVF.clear();
601
+ this.indexes.OVL.clear();
597
602
  if (!this.settings.disposer || !this.settings.capture.clear)
598
603
  return void this.memory.clear();
599
604
  const memory = this.memory;
@@ -620,7 +625,7 @@ require = function () {
620
625
  return;
621
626
  const lenR = indexes.LRU.length;
622
627
  const lenF = indexes.LFU.length;
623
- const lenV = indexes.OVF.length;
628
+ const lenV = indexes.OVL.length;
624
629
  const r = (lenF + lenV) * 1000 / (lenR + lenF) | 0;
625
630
  const rateR0 = rate(window, LRU[0], LRU[0] + LFU[0], LRU[1], LRU[1] + LFU[1], 0) * (1 + r);
626
631
  const rateF0 = rate(window, LFU[0], LRU[0] + LFU[0], LFU[1], LRU[1] + LFU[1], 0) * (1001 - r);
@@ -643,14 +648,14 @@ require = function () {
643
648
  const index = node.value;
644
649
  const {LRU, LFU} = this.indexes;
645
650
  ++this.stats[index.region][0];
646
- if (!index.overflow && index.clock >= this.clockR - LRU.length / 3 && this.capacity > 3) {
651
+ if (!index.overlap && index.clock >= this.clockR - LRU.length / 3 && this.capacity > 3) {
647
652
  index.clock = ++this.clockR;
648
653
  node.moveToHead();
649
654
  return true;
650
655
  }
651
656
  index.clock = ++this.clock;
652
657
  index.region = 'LFU';
653
- (_a = index.overflow) === null || _a === void 0 ? void 0 : _a.delete();
658
+ (_a = index.overlap) === null || _a === void 0 ? void 0 : _a.delete();
654
659
  LFU.unshiftNode(node);
655
660
  return true;
656
661
  }
@@ -3651,6 +3656,7 @@ require = function () {
3651
3656
  const global_1 = _dereq_('spica/global');
3652
3657
  const parser_1 = _dereq_('../../data/parser');
3653
3658
  const fmap_1 = _dereq_('../monad/fmap');
3659
+ const resource_1 = _dereq_('./resource');
3654
3660
  const array_1 = _dereq_('spica/array');
3655
3661
  function surround(opener, parser, closer, optional = false, f, g) {
3656
3662
  switch (typeof opener) {
@@ -3698,18 +3704,18 @@ require = function () {
3698
3704
  function match(pattern) {
3699
3705
  switch (typeof pattern) {
3700
3706
  case 'string':
3701
- return source => source.slice(0, pattern.length) === pattern ? [
3707
+ return (0, resource_1.creator)(source => source.slice(0, pattern.length) === pattern ? [
3702
3708
  [],
3703
3709
  source.slice(pattern.length)
3704
- ] : global_1.undefined;
3710
+ ] : global_1.undefined);
3705
3711
  case 'object':
3706
- return source => {
3712
+ return (0, resource_1.creator)(source => {
3707
3713
  const m = source.match(pattern);
3708
3714
  return m ? [
3709
3715
  [],
3710
3716
  source.slice(m[0].length)
3711
3717
  ] : global_1.undefined;
3712
- };
3718
+ });
3713
3719
  }
3714
3720
  }
3715
3721
  function open(opener, parser, optional = false) {
@@ -3728,6 +3734,7 @@ require = function () {
3728
3734
  {
3729
3735
  '../../data/parser': 47,
3730
3736
  '../monad/fmap': 46,
3737
+ './resource': 40,
3731
3738
  'spica/array': 6,
3732
3739
  'spica/global': 15
3733
3740
  }
@@ -4854,7 +4861,7 @@ require = function () {
4854
4861
  'data-invalid-description': 'Missing the title at the first line.'
4855
4862
  }, `${ opener }${ body }${ closer }`)];
4856
4863
  return [(0, typed_dom_1.html)('aside', {
4857
- id: (0, indexee_1.identity)(heading),
4864
+ id: (0, indexee_1.identity)((0, indexee_1.text)(heading)),
4858
4865
  class: 'aside'
4859
4866
  }, [
4860
4867
  document,
@@ -5300,9 +5307,9 @@ require = function () {
5300
5307
  let [, rowspan = global_1.undefined, colspan = global_1.undefined, highlight = global_1.undefined] = (_a = source.match(/^.(?:(\d+)?:(\d+)?)?(!+)?$/)) !== null && _a !== void 0 ? _a : [];
5301
5308
  rowspan === '1' ? rowspan = global_1.undefined : global_1.undefined;
5302
5309
  colspan === '1' ? colspan = global_1.undefined : global_1.undefined;
5303
- rowspan && (rowspan = (0, alias_1.max)(0, (0, alias_1.min)(+rowspan, 65534)) + '');
5304
- colspan && (colspan = (0, alias_1.max)(0, (0, alias_1.min)(+colspan, 1000)) + '');
5305
- highlight && (highlight = highlight.length > 0 ? highlight.length + '' : global_1.undefined);
5310
+ rowspan && (rowspan = `${ (0, alias_1.max)(0, (0, alias_1.min)(+rowspan, 65534)) }`);
5311
+ colspan && (colspan = `${ (0, alias_1.max)(0, (0, alias_1.min)(+colspan, 1000)) }`);
5312
+ highlight && (highlight = highlight.length > 0 ? `${ highlight.length }` : global_1.undefined);
5306
5313
  const valid = !highlight || source[0] === '#' && +highlight <= 1 || source[0] === ':' && +highlight <= 6;
5307
5314
  return {
5308
5315
  class: valid ? highlight && 'highlight' : 'invalid',
@@ -5807,16 +5814,16 @@ require = function () {
5807
5814
  const util_1 = _dereq_('../util');
5808
5815
  const typed_dom_1 = _dereq_('typed-dom');
5809
5816
  const array_1 = _dereq_('spica/array');
5810
- exports.reply = (0, combinator_1.block)((0, combinator_1.validate)('>', (0, locale_1.localize)((0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.inits)([
5817
+ exports.reply = (0, combinator_1.block)((0, combinator_1.validate)('>', (0, locale_1.localize)((0, combinator_1.fmap)((0, combinator_1.inits)([
5811
5818
  (0, combinator_1.some)((0, combinator_1.inits)([
5812
5819
  cite_1.cite,
5813
5820
  quote_1.quote
5814
5821
  ])),
5815
- (0, combinator_1.subsequence)([
5822
+ (0, combinator_1.some)((0, combinator_1.subsequence)([
5816
5823
  (0, combinator_1.some)(quote_1.quote),
5817
5824
  (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, quote_1.syntax), (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)(inline_1.inline)))), ns => (0, array_1.push)(ns, [(0, typed_dom_1.html)('br')]))
5818
- ])
5819
- ])), ns => [(0, typed_dom_1.html)('p', (0, typed_dom_1.defrag)((0, array_1.pop)(ns)[0]))]))));
5825
+ ]))
5826
+ ]), ns => [(0, typed_dom_1.html)('p', (0, typed_dom_1.defrag)((0, array_1.pop)(ns)[0]))]))));
5820
5827
  },
5821
5828
  {
5822
5829
  '../../combinator': 27,
@@ -5841,10 +5848,10 @@ require = function () {
5841
5848
  const typed_dom_1 = _dereq_('typed-dom');
5842
5849
  exports.cite = (0, combinator_1.creator)((0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.validate)('>>', (0, combinator_1.reverse)((0, combinator_1.tails)([
5843
5850
  (0, source_1.str)(/^>*(?=>>)/),
5844
- anchor_1.anchor
5851
+ (0, combinator_1.validate)(new RegExp(`${ anchor_1.syntax.source }[^\S\n]*(?:$|\n)`), anchor_1.anchor)
5845
5852
  ]))), ([el, quotes = '']) => [
5846
5853
  (0, typed_dom_1.html)('span', { class: 'cite' }, (0, typed_dom_1.defrag)([
5847
- quotes + '>',
5854
+ `${ quotes }>`,
5848
5855
  (0, typed_dom_1.define)(el, { 'data-depth': `${ quotes.length + 1 }` }, el.innerText.slice(1))
5849
5856
  ])),
5850
5857
  (0, typed_dom_1.html)('br')
@@ -5873,12 +5880,12 @@ require = function () {
5873
5880
  (0, combinator_1.rewrite)((0, combinator_1.some)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|')[0]), source_1.anyline)), qblock),
5874
5881
  (0, combinator_1.rewrite)((0, combinator_1.validate)(new RegExp(exports.syntax.source.split('|').slice(1).join('|')), source_1.anyline), (0, combinator_1.line)((0, combinator_1.union)([(0, source_1.str)(/^.+/)])))
5875
5882
  ])), ns => [
5876
- (0, typed_dom_1.html)('span', ns.length > 1 || /^>+(?=[^\S\n])/.test(ns[0]) ? { class: 'quote' } : {
5883
+ (0, typed_dom_1.html)('span', ns.length > 1 ? { class: 'quote' } : {
5877
5884
  class: 'quote invalid',
5878
5885
  'data-invalid-syntax': 'quote',
5879
5886
  'data-invalid-type': 'syntax',
5880
5887
  'data-invalid-description': `Missing the whitespace after "${ ns[0].split(/[^>]/, 1)[0] }".`
5881
- }, ns),
5888
+ }, (0, typed_dom_1.defrag)(ns)),
5882
5889
  (0, typed_dom_1.html)('br')
5883
5890
  ]), false)));
5884
5891
  const qblock = (source, context) => {
@@ -5908,8 +5915,9 @@ require = function () {
5908
5915
  continue;
5909
5916
  }
5910
5917
  }
5918
+ nodes.unshift('');
5911
5919
  return [
5912
- (0, typed_dom_1.defrag)(nodes),
5920
+ nodes,
5913
5921
  ''
5914
5922
  ];
5915
5923
  };
@@ -6138,11 +6146,11 @@ require = function () {
6138
6146
  const annotation_1 = _dereq_('./inline/annotation');
6139
6147
  const reference_1 = _dereq_('./inline/reference');
6140
6148
  const template_1 = _dereq_('./inline/template');
6149
+ const comment_1 = _dereq_('./inline/comment');
6141
6150
  const extension_1 = _dereq_('./inline/extension');
6142
6151
  const ruby_1 = _dereq_('./inline/ruby');
6143
6152
  const link_1 = _dereq_('./inline/link');
6144
6153
  const html_1 = _dereq_('./inline/html');
6145
- const comment_1 = _dereq_('./inline/comment');
6146
6154
  const insertion_1 = _dereq_('./inline/insertion');
6147
6155
  const deletion_1 = _dereq_('./inline/deletion');
6148
6156
  const mark_1 = _dereq_('./inline/mark');
@@ -6162,12 +6170,12 @@ require = function () {
6162
6170
  annotation_1.annotation,
6163
6171
  reference_1.reference,
6164
6172
  template_1.template,
6173
+ comment_1.comment,
6165
6174
  extension_1.extension,
6166
6175
  ruby_1.ruby,
6167
6176
  link_1.link,
6168
6177
  media_1.media,
6169
6178
  html_1.html,
6170
- comment_1.comment,
6171
6179
  insertion_1.insertion,
6172
6180
  deletion_1.deletion,
6173
6181
  mark_1.mark,
@@ -6332,12 +6340,13 @@ require = function () {
6332
6340
  function (_dereq_, module, exports) {
6333
6341
  'use strict';
6334
6342
  Object.defineProperty(exports, '__esModule', { value: true });
6335
- exports.anchor = void 0;
6343
+ exports.anchor = exports.syntax = void 0;
6336
6344
  const combinator_1 = _dereq_('../../../combinator');
6337
6345
  const link_1 = _dereq_('../link');
6338
6346
  const source_1 = _dereq_('../../source');
6339
6347
  const typed_dom_1 = _dereq_('typed-dom');
6340
- exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('>>', (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, source_1.str)(/^>>[0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:])/), (0, combinator_1.context)({
6348
+ exports.syntax = /^>>[0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:])/;
6349
+ exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('>>', (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, source_1.str)(exports.syntax), (0, combinator_1.context)({
6341
6350
  syntax: {
6342
6351
  inline: {
6343
6352
  link: true,
@@ -6597,52 +6606,28 @@ require = function () {
6597
6606
  'use strict';
6598
6607
  Object.defineProperty(exports, '__esModule', { value: true });
6599
6608
  exports.comment = void 0;
6600
- const combinator_1 = _dereq_('../../combinator');
6601
6609
  const parser_1 = _dereq_('../../combinator/data/parser');
6602
- const htmlentity_1 = _dereq_('./htmlentity');
6610
+ const combinator_1 = _dereq_('../../combinator');
6611
+ const inline_1 = _dereq_('../inline');
6603
6612
  const source_1 = _dereq_('../source');
6604
6613
  const typed_dom_1 = _dereq_('typed-dom');
6605
- exports.comment = (0, combinator_1.creator)((0, combinator_1.validate)('[#', (0, combinator_1.match)(/^\[(#+)(?!\S|\s+\1\]|\s*\[\1(?:$|\s))((?:\s+\S+)+?)(?:\s+(\1\])|\s*(?=\[\1(?:$|\s)))/, ([whole, , body, closer]) => (rest, context) => {
6606
- [whole, body] = `${ whole }\0${ body.trimStart() }`.replace(/\x1B/g, '').split('\0', 2);
6607
- if (!closer)
6608
- return [
6609
- [(0, typed_dom_1.html)('sup', {
6610
- class: 'comment invalid',
6611
- 'data-invalid-syntax': 'comment',
6612
- 'data-invalid-type': 'content',
6613
- 'data-invalid-description': 'Comment syntax using the same level cannot start in another comment syntax.'
6614
- }, whole)],
6615
- rest
6616
- ];
6617
- const title = (0, parser_1.eval)((0, combinator_1.some)(text)(body, context), []).join('').trim();
6618
- if (title.includes('\0'))
6619
- return [
6620
- [(0, typed_dom_1.html)('sup', {
6621
- class: 'comment invalid',
6622
- 'data-invalid-syntax': 'comment',
6623
- 'data-invalid-type': 'content',
6624
- 'data-invalid-description': `Invalid HTML entitiy "${ title.match(/\0&[0-9A-Za-z]+;/)[0].slice(1) }".`
6625
- }, whole)],
6626
- rest
6627
- ];
6628
- return [
6629
- [(0, typed_dom_1.html)('sup', {
6630
- class: 'comment',
6631
- title
6632
- })],
6633
- rest
6634
- ];
6635
- })));
6636
- const text = (0, combinator_1.union)([
6637
- htmlentity_1.unsafehtmlentity,
6638
- source_1.unescsource
6639
- ]);
6614
+ const memoize_1 = _dereq_('spica/memoize');
6615
+ const array_1 = _dereq_('spica/array');
6616
+ exports.comment = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('[#', (0, combinator_1.match)(/^(?=\[(#+)\s)/, (0, memoize_1.memoize)(([, fence], closer = new RegExp(String.raw`^\s+${ fence }\]`)) => (0, combinator_1.surround)((0, source_1.str)(/^\[(\S+)\s+(?!\1\])/), (0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, closer)]), (0, source_1.str)(closer), true, ([, bs = []], rest) => [
6617
+ [(0, typed_dom_1.html)('span', { class: 'comment' }, (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)([`[${ fence } `], bs), [` ${ fence }]`])))],
6618
+ rest
6619
+ ], ([as, bs = []], rest, context) => [
6620
+ (0, array_1.unshift)((0, array_1.pop)((0, parser_1.eval)((0, combinator_1.some)(source_1.text)(`${ as[0] }!`, context)))[0], bs),
6621
+ rest
6622
+ ]), ([, fence]) => fence)))));
6640
6623
  },
6641
6624
  {
6642
6625
  '../../combinator': 27,
6643
6626
  '../../combinator/data/parser': 47,
6627
+ '../inline': 88,
6644
6628
  '../source': 128,
6645
- './htmlentity': 112,
6629
+ 'spica/array': 6,
6630
+ 'spica/memoize': 18,
6646
6631
  'typed-dom': 26
6647
6632
  }
6648
6633
  ],
@@ -6881,7 +6866,7 @@ require = function () {
6881
6866
  source_1.txt
6882
6867
  ]), ']', /^\\?\n/))), ns => [(0, typed_dom_1.html)('span', {
6883
6868
  class: 'indexer',
6884
- 'data-index': (0, indexee_1.identify)((0, array_1.join)(ns).trim()).slice(6)
6869
+ 'data-index': (0, indexee_1.identity)((0, array_1.join)(ns)).slice(6)
6885
6870
  })])));
6886
6871
  const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.union)([
6887
6872
  (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([
@@ -6914,45 +6899,50 @@ require = function () {
6914
6899
  function (_dereq_, module, exports) {
6915
6900
  'use strict';
6916
6901
  Object.defineProperty(exports, '__esModule', { value: true });
6917
- exports.identify = exports.text = exports.identity = exports.indexee = void 0;
6902
+ exports.text = exports.identity = exports.indexee = void 0;
6918
6903
  const global_1 = _dereq_('spica/global');
6919
6904
  const combinator_1 = _dereq_('../../../combinator');
6920
6905
  const typed_dom_1 = _dereq_('typed-dom');
6921
6906
  function indexee(parser) {
6922
- return (0, combinator_1.fmap)(parser, ([el], _, {id}) => [(0, typed_dom_1.define)(el, { id: id !== '' && identity(el) || global_1.undefined })]);
6907
+ return (0, combinator_1.fmap)(parser, ([el], _, {id}) => [(0, typed_dom_1.define)(el, { id: id !== '' && identity(text(el)) || global_1.undefined })]);
6923
6908
  }
6924
6909
  exports.indexee = indexee;
6925
- function identity(source) {
6926
- return identify(text(source).trim());
6910
+ function identity(index) {
6911
+ return `index:${ index.trim().replace(/\s+/g, '_').slice(0, 101).replace(/^(.{97}).{4}$/, '$1...') }`;
6927
6912
  }
6928
6913
  exports.identity = identity;
6929
6914
  function text(source) {
6915
+ var _a;
6930
6916
  const indexer = source.querySelector('.indexer');
6931
6917
  if (indexer)
6932
6918
  return indexer.getAttribute('data-index');
6933
6919
  const target = source.cloneNode(true);
6934
- for (let es = target.querySelectorAll('code[data-src], .math[data-src], rt, rp, .reference'), i = 0, len = es.length; i < len; ++i) {
6920
+ for (let es = target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference'), i = 0, len = es.length; i < len; ++i) {
6935
6921
  const el = es[i];
6936
6922
  switch (el.tagName) {
6923
+ case 'CODE':
6924
+ (0, typed_dom_1.define)(el, el.getAttribute('data-src'));
6925
+ continue;
6937
6926
  case 'RT':
6938
6927
  case 'RP':
6939
6928
  el.remove();
6940
6929
  continue;
6941
- case 'SUP':
6942
- el.firstChild.remove();
6943
- continue;
6944
- default:
6930
+ }
6931
+ switch (el.className) {
6932
+ case 'math':
6945
6933
  (0, typed_dom_1.define)(el, el.getAttribute('data-src'));
6946
6934
  continue;
6935
+ case 'comment':
6936
+ el.remove();
6937
+ continue;
6938
+ case 'reference':
6939
+ el.firstChild.remove();
6940
+ continue;
6947
6941
  }
6948
6942
  }
6949
6943
  return target.textContent;
6950
6944
  }
6951
6945
  exports.text = text;
6952
- function identify(index) {
6953
- return index ? `index:${ index.replace(/\s+/g, '_').slice(0, 101).replace(/^(.{97}).{4}$/, '$1...') }` : '';
6954
- }
6955
- exports.identify = identify;
6956
6946
  },
6957
6947
  {
6958
6948
  '../../../combinator': 27,
@@ -7605,6 +7595,15 @@ require = function () {
7605
7595
  switch (uri.protocol) {
7606
7596
  case 'http:':
7607
7597
  case 'https:':
7598
+ if (/\/\.\.?(?:\/|$)/.test('/' + uri.source.slice(0, uri.source.search(/[?#]|$/)))) {
7599
+ (0, typed_dom_1.define)(target, {
7600
+ class: void target.classList.add('invalid'),
7601
+ 'data-invalid-syntax': 'media',
7602
+ 'data-invalid-type': 'argument',
7603
+ 'data-invalid-description': 'Dot-segments cannot be used in media paths; use subresource paths instead.'
7604
+ });
7605
+ return false;
7606
+ }
7608
7607
  break;
7609
7608
  default:
7610
7609
  (0, typed_dom_1.define)(target, {
@@ -7615,15 +7614,6 @@ require = function () {
7615
7614
  });
7616
7615
  return false;
7617
7616
  }
7618
- if (/\/\.\.?(?:\/|$)/.test('/' + uri.source.slice(0, uri.source.search(/[?#]|$/)))) {
7619
- (0, typed_dom_1.define)(target, {
7620
- class: void target.classList.add('invalid'),
7621
- 'data-invalid-syntax': 'media',
7622
- 'data-invalid-type': 'argument',
7623
- 'data-invalid-description': 'Dot-segments cannot be used in media paths; use subresource paths instead.'
7624
- });
7625
- return false;
7626
- }
7627
7617
  if (alt.includes('\0')) {
7628
7618
  (0, typed_dom_1.define)(target, {
7629
7619
  class: void target.classList.add('invalid'),
@@ -7690,7 +7680,7 @@ require = function () {
7690
7680
  class: 'reference',
7691
7681
  'data-abbr': (0, util_1.stringify)([ns.shift()]).trimEnd()
7692
7682
  } : ns[0] === '' ? {
7693
- class: 'reference invalid',
7683
+ class: 'invalid',
7694
7684
  'data-invalid-syntax': 'reference',
7695
7685
  'data-invalid-type': 'syntax',
7696
7686
  'data-invalid-description': 'Invalid abbr.'
@@ -8073,7 +8063,7 @@ require = function () {
8073
8063
  !(0, label_1.isFixed)(label) && numbers.set(group, number);
8074
8064
  opts.id !== '' && def.setAttribute('id', `label:${ opts.id ? `${ opts.id }:` : '' }${ label }`);
8075
8065
  const figindex = group === '$' ? `(${ number })` : `${ capitalize(group) }${ group === 'fig' ? '.' : '' } ${ number }`;
8076
- (0, typed_dom_1.define)(def.querySelector(':scope > .figindex'), group === '$' ? figindex : `${ figindex }: `);
8066
+ (0, typed_dom_1.define)(def.querySelector(':scope > .figindex'), group === '$' ? figindex : `${ figindex }. `);
8077
8067
  for (const ref of refs.take(label, global_1.Infinity)) {
8078
8068
  if (ref.hash.slice(1) === def.id && ref.innerText === figindex)
8079
8069
  continue;
@@ -8649,7 +8639,6 @@ require = function () {
8649
8639
  const global_1 = _dereq_('spica/global');
8650
8640
  const parser_1 = _dereq_('../combinator/data/parser');
8651
8641
  const combinator_1 = _dereq_('../combinator');
8652
- const comment_1 = _dereq_('./inline/comment');
8653
8642
  const htmlentity_1 = _dereq_('./inline/htmlentity');
8654
8643
  const source_1 = _dereq_('./source');
8655
8644
  const array_1 = _dereq_('spica/array');
@@ -8687,10 +8676,10 @@ require = function () {
8687
8676
  'InvisibleComma',
8688
8677
  'ic'
8689
8678
  ];
8690
- const blankline = new RegExp(String.raw`^(?!$)(?:\\$|\\?[^\S\n]|&(?:${ invisibleHTMLEntityNames.join('|') });|<wbr>|\[(#+)(?!\S|\s+\1\]|\s*\[\1(?:$|\s))((?:\s+\S+)+?)(?:\s+(\1\])|\s*(?=\[\1(?:$|\s))))+(?=$|(\S))`, 'gm');
8679
+ const blankline = new RegExp(String.raw`^(?!$)(?:\\$|\\?[^\S\n]|&(?:${ invisibleHTMLEntityNames.join('|') });|<wbr>)+$`, 'gm');
8691
8680
  function visualize(parser) {
8692
8681
  return (0, combinator_1.union)([
8693
- (0, combinator_1.convert)(source => source.replace(blankline, (line, ...$) => !$[3] ? line.replace(/[\\&<\[]/g, '\x1B$&') : line), (0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context))),
8682
+ (0, combinator_1.convert)(source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context))),
8694
8683
  (0, combinator_1.some)((0, combinator_1.union)([
8695
8684
  source_1.linebreak,
8696
8685
  source_1.unescsource
@@ -8736,7 +8725,7 @@ require = function () {
8736
8725
  }
8737
8726
  exports.startTight = startTight;
8738
8727
  function isStartTight(source, context) {
8739
- var _a, _b, _c, _d, _e;
8728
+ var _a, _b, _c;
8740
8729
  if (source === '')
8741
8730
  return true;
8742
8731
  switch (source[0]) {
@@ -8760,12 +8749,6 @@ require = function () {
8760
8749
  return false;
8761
8750
  }
8762
8751
  return true;
8763
- case '[':
8764
- switch (true) {
8765
- case source.length >= 7 && source[1] === '#' && ((_d = (0, parser_1.eval)((0, comment_1.comment)(source, context))) === null || _d === void 0 ? void 0 : _d[0].className) === 'comment':
8766
- return false;
8767
- }
8768
- return true;
8769
8752
  default:
8770
8753
  return source[0].trimStart() !== '';
8771
8754
  }
@@ -8781,8 +8764,6 @@ require = function () {
8781
8764
  return true;
8782
8765
  for (let i = nodes.length; i--;) {
8783
8766
  const node = nodes[i];
8784
- if (typeof node === 'object' && node.className === 'comment')
8785
- continue;
8786
8767
  return isVisible(node, -1);
8787
8768
  }
8788
8769
  return false;
@@ -8808,8 +8789,6 @@ require = function () {
8808
8789
  return false;
8809
8790
  case 'SPAN':
8810
8791
  return node.className !== 'linebreak';
8811
- case 'SUP':
8812
- return node.className !== 'comment';
8813
8792
  default:
8814
8793
  return true;
8815
8794
  }
@@ -8823,8 +8802,6 @@ require = function () {
8823
8802
  for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
8824
8803
  if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer')
8825
8804
  break;
8826
- if (typeof node === 'object' && node.className === 'comment')
8827
- break;
8828
8805
  if (typeof node === 'string') {
8829
8806
  const pos = node.length - node.trimStart().length;
8830
8807
  if (pos > 0) {
@@ -8839,8 +8816,6 @@ require = function () {
8839
8816
  function trimNodeEnd(nodes) {
8840
8817
  const skip = nodes.length > 0 && typeof nodes[nodes.length - 1] === 'object' && nodes[nodes.length - 1]['className'] === 'indexer' ? [nodes.pop()] : [];
8841
8818
  for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
8842
- if (typeof node === 'object' && node.className === 'comment')
8843
- break;
8844
8819
  if (typeof node === 'string') {
8845
8820
  const pos = node.trimEnd().length;
8846
8821
  if (pos > 0) {
@@ -8877,7 +8852,6 @@ require = function () {
8877
8852
  {
8878
8853
  '../combinator': 27,
8879
8854
  '../combinator/data/parser': 47,
8880
- './inline/comment': 100,
8881
8855
  './inline/htmlentity': 112,
8882
8856
  './source': 128,
8883
8857
  'spica/array': 6,
package/markdown.d.ts CHANGED
@@ -557,11 +557,11 @@ export namespace MarkdownParser {
557
557
  // abc
558
558
  Block<'reply'>,
559
559
  Parser<HTMLParagraphElement, Context, [
560
- Parser<string | HTMLElement, Context, [
560
+ Parser<HTMLElement, Context, [
561
561
  ReplyParser.CiteParser,
562
562
  ReplyParser.QuoteParser,
563
563
  ]>,
564
- Parser<string | HTMLElement, Context, [
564
+ Parser<HTMLElement | string, Context, [
565
565
  ReplyParser.QuoteParser,
566
566
  InlineParser,
567
567
  ]>,
@@ -619,12 +619,12 @@ export namespace MarkdownParser {
619
619
  InlineParser.AnnotationParser,
620
620
  InlineParser.ReferenceParser,
621
621
  InlineParser.TemplateParser,
622
+ InlineParser.CommentParser,
622
623
  InlineParser.ExtensionParser,
623
624
  InlineParser.RubyParser,
624
625
  InlineParser.LinkParser,
625
626
  InlineParser.MediaParser,
626
627
  InlineParser.HTMLParser,
627
- InlineParser.CommentParser,
628
628
  InlineParser.InsertionParser,
629
629
  InlineParser.DeletionParser,
630
630
  InlineParser.MarkParser,
@@ -709,6 +709,13 @@ export namespace MarkdownParser {
709
709
  ]> {
710
710
  }
711
711
  }
712
+ export interface CommentParser extends
713
+ // [# comment #]
714
+ Inline<'comment'>,
715
+ Parser<HTMLElement | string, Context, [
716
+ InlineParser,
717
+ ]> {
718
+ }
712
719
  export interface ExtensionParser extends
713
720
  // [#abc]
714
721
  Inline<'extension'>,
@@ -941,22 +948,6 @@ export namespace MarkdownParser {
941
948
  }
942
949
  }
943
950
  }
944
- export interface CommentParser extends
945
- // [# comment #]
946
- Inline<'comment'>,
947
- Parser<HTMLElement, Context, [
948
- CommentParser.TextParser,
949
- ]> {
950
- }
951
- export namespace CommentParser {
952
- export interface TextParser extends
953
- Inline<'comment/text'>,
954
- Parser<string, Context, [
955
- UnsafeHTMLEntityParser,
956
- SourceParser.UnescapableSourceParser,
957
- ]> {
958
- }
959
- }
960
951
  export interface InsertionParser extends
961
952
  // ++abc++
962
953
  Inline<'insertion'>,
@@ -1030,7 +1021,7 @@ export namespace MarkdownParser {
1030
1021
  export interface HTMLEntityParser extends
1031
1022
  // &copy;
1032
1023
  Inline<'htmlentity'>,
1033
- Parser<HTMLSpanElement | string, Context, [
1024
+ Parser<string | HTMLSpanElement, Context, [
1034
1025
  UnsafeHTMLEntityParser,
1035
1026
  ]> {
1036
1027
  }
@@ -1153,7 +1144,7 @@ export namespace MarkdownParser {
1153
1144
  }
1154
1145
  export interface AutolinkParser extends
1155
1146
  Markdown<'autolink'>,
1156
- Parser<HTMLElement | string, Context, [
1147
+ Parser<string | HTMLElement, Context, [
1157
1148
  InlineParser.AutolinkParser,
1158
1149
  SourceParser.LinebreakParser,
1159
1150
  SourceParser.UnescapableSourceParser,
@@ -1164,7 +1155,7 @@ export namespace MarkdownParser {
1164
1155
  export interface TextParser extends
1165
1156
  // abc
1166
1157
  Source<'text'>,
1167
- Parser<HTMLBRElement | HTMLSpanElement | string, Context, []> {
1158
+ Parser<string | HTMLBRElement | HTMLSpanElement, Context, []> {
1168
1159
  }
1169
1160
  export interface TxtParser extends
1170
1161
  // abc