securemark 0.252.0 → 0.253.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 (36) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/design.md +17 -11
  3. package/dist/index.js +90 -85
  4. package/index.d.ts +1 -1
  5. package/package.json +1 -1
  6. package/src/combinator/data/parser.ts +1 -1
  7. package/src/parser/api/bind.test.ts +6 -6
  8. package/src/parser/api/parse.test.ts +2 -1
  9. package/src/parser/api/parse.ts +1 -1
  10. package/src/parser/block/blockquote.test.ts +31 -31
  11. package/src/parser/block/blockquote.ts +1 -3
  12. package/src/parser/block/extension/aside.test.ts +3 -3
  13. package/src/parser/block/extension/aside.ts +0 -3
  14. package/src/parser/block/extension/example.test.ts +11 -11
  15. package/src/parser/block/extension/example.ts +1 -3
  16. package/src/parser/block/extension/fig.test.ts +5 -5
  17. package/src/parser/block/extension/figure.test.ts +2 -2
  18. package/src/parser/block/ilist.ts +4 -5
  19. package/src/parser/block/olist.ts +24 -20
  20. package/src/parser/block/ulist.ts +3 -13
  21. package/src/parser/inline/annotation.test.ts +18 -18
  22. package/src/parser/inline/annotation.ts +1 -1
  23. package/src/parser/inline/autolink/hashnum.ts +1 -1
  24. package/src/parser/inline/autolink/hashtag.ts +5 -5
  25. package/src/parser/inline/autolink.ts +2 -2
  26. package/src/parser/inline/reference.test.ts +58 -58
  27. package/src/parser/inline/reference.ts +1 -1
  28. package/src/parser/inline.test.ts +20 -20
  29. package/src/parser/locale.test.ts +1 -1
  30. package/src/parser/processor/figure.test.ts +3 -3
  31. package/src/parser/processor/figure.ts +2 -2
  32. package/src/parser/processor/footnote.test.ts +60 -2
  33. package/src/parser/processor/footnote.ts +53 -24
  34. package/src/parser/util.ts +4 -4
  35. package/src/util/info.ts +4 -4
  36. package/src/util/toc.ts +12 -16
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.253.0
4
+
5
+ - Change annotation processing.
6
+
3
7
  ## 0.252.0
4
8
 
5
9
  - Remove indentblock syntax.
package/design.md CHANGED
@@ -29,15 +29,6 @@
29
29
 
30
30
  ゆえに構文はレンダリング後の操作により表示する内容および状態を変化させる構文を備えない。
31
31
 
32
- ### アクセント設定
33
-
34
- ドキュメントは漫然と読まれないよう緩急をつけられなければならない。
35
- よって構文は他の構文に続けて漫然と読み流せない異質な視覚表現を持ちアクセントとなる構文を備えなければならない。
36
- なおこのためアクセント構文は他の構文と完全に統一されたデザインであってはならず若干異質なデザインでなければならない。
37
-
38
- ゆえに構文は着色およびデザインにより視覚的刺激を与えるMessage構文を備える。
39
- またAside構文は関心の変化により認知的刺激を与える。
40
-
41
32
  ### モノクロプリント対応
42
33
 
43
34
  構文はモノクロ表示および印刷に対応していなければならない。
@@ -135,11 +126,17 @@
135
126
 
136
127
  ゆえに引用構文は引用文をパースしない。
137
128
 
129
+ ### 改行不変性
130
+
131
+ 改行は表示文字列とこれを入力とする再出力で不変でなければならない。
132
+
133
+ ゆえに改行は入力と出力で一貫することを標準とする。
134
+
138
135
  ### オートリンク不変性
139
136
 
140
- オートリンクは原則としてコピー&ペーストによる引用等を経た際にその解釈が変わってはならない。
137
+ オートリンクは表示文字列とこれを入力とする再出力において解釈が不変でなければならない。
141
138
 
142
- ゆえにハッシュタグ構文は構文が表示文字列と一致する構文であるオートリンク構文としてのみ構文化され、表示文字列からの構文の範囲の特定が不可能となる通常の構文を持たない。
139
+ ゆえにハッシュタグ構文は構文が表示文字列と一致する構文であるオートリンク構文(`#tag`)としてのみ構文化され、表示文字列から構文の範囲が特定不可能となる通常構文の形態(`#{tag}`)を持たない。
143
140
 
144
141
  ### 自動附番
145
142
 
@@ -148,6 +145,15 @@
148
145
  ゆえに参照箇所に実体を記述する注釈構文および識別に文字列を使用する図表構文を採用し、その表示方法は任意とする。
149
146
  脚注構文は附番が手作業となり参照と実体の対応の管理が困難であるため不採用とし注釈構文により生成可能とする。
150
147
 
148
+ ### アクセント設定
149
+
150
+ ドキュメントは漫然と読まれないよう緩急をつけられなければならない。
151
+ よって構文は他の構文に続けて漫然と読み流せない異質な視覚表現を持ちアクセントとなる構文を備えなければならない。
152
+ なおこのためアクセント構文は他の構文と完全に統一されたデザインであってはならず若干異質なデザインでなければならない。
153
+
154
+ ゆえに構文は着色およびデザインにより視覚的刺激を与えるMessage構文を備える。
155
+ またAside構文は関心の変化により認知的刺激を与える。
156
+
151
157
  ### 羅列的知識への非依存
152
158
 
153
159
  構文はその使用のために羅列的知識を求めてはならない。
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.252.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.253.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("DOMPurify"), require("Prism"));
@@ -3703,20 +3703,16 @@ const unindent = source => source.replace(/(^|\n)>(?:[^\S\n]|(?=>*(?:$|\s)))|\n$
3703
3703
 
3704
3704
  const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)((0, combinator_1.some)(autolink_1.autolink), ns => [(0, dom_1.html)('pre', (0, dom_1.defrag)(ns))])))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
3705
3705
  const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown)), (0, combinator_1.creator)(99, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (source, context) => {
3706
- const annotations = (0, dom_1.html)('ol', {
3707
- class: 'annotations'
3708
- });
3709
3706
  const references = (0, dom_1.html)('ol', {
3710
3707
  class: 'references'
3711
3708
  });
3712
3709
  const document = (0, parse_1.parse)(source, {
3713
3710
  id: '',
3714
3711
  footnotes: {
3715
- annotations,
3716
3712
  references
3717
3713
  }
3718
3714
  }, context);
3719
- return [[(0, dom_1.html)('section', [document, annotations, references])], ''];
3715
+ return [[(0, dom_1.html)('section', [document, references])], ''];
3720
3716
  })))]))), ns => [(0, dom_1.html)('blockquote', ns)]));
3721
3717
 
3722
3718
  /***/ }),
@@ -3901,16 +3897,12 @@ exports.aside = (0, combinator_1.creator)(100, (0, combinator_1.block)((0, combi
3901
3897
  'data-invalid-type': !closer || overflow ? 'fence' : 'argument',
3902
3898
  'data-invalid-message': !closer ? `Missing the closing delimiter "${delim}"` : overflow ? `Invalid trailing line after the closing delimiter "${delim}"` : 'Invalid argument'
3903
3899
  }, `${opener}${body}${overflow || closer}`)];
3904
- const annotations = (0, dom_1.html)('ol', {
3905
- class: 'annotations'
3906
- });
3907
3900
  const references = (0, dom_1.html)('ol', {
3908
3901
  class: 'references'
3909
3902
  });
3910
3903
  const document = (0, parse_1.parse)(body.slice(0, -1), {
3911
3904
  id: '',
3912
3905
  footnotes: {
3913
- annotations,
3914
3906
  references
3915
3907
  }
3916
3908
  }, context);
@@ -3927,7 +3919,7 @@ exports.aside = (0, combinator_1.creator)(100, (0, combinator_1.block)((0, combi
3927
3919
  return [(0, dom_1.html)('aside', {
3928
3920
  id: (0, indexee_1.identity)((0, indexee_1.text)(heading)),
3929
3921
  class: 'aside'
3930
- }, [document, annotations, references])];
3922
+ }, [document, references])];
3931
3923
  }))));
3932
3924
 
3933
3925
  /***/ }),
@@ -3967,16 +3959,12 @@ exports.example = (0, combinator_1.creator)(100, (0, combinator_1.block)((0, com
3967
3959
  switch (type) {
3968
3960
  case 'markdown':
3969
3961
  {
3970
- const annotations = (0, dom_1.html)('ol', {
3971
- class: 'annotations'
3972
- });
3973
3962
  const references = (0, dom_1.html)('ol', {
3974
3963
  class: 'references'
3975
3964
  });
3976
3965
  const document = (0, parse_1.parse)(body.slice(0, -1), {
3977
3966
  id: '',
3978
3967
  footnotes: {
3979
- annotations,
3980
3968
  references
3981
3969
  }
3982
3970
  }, context);
@@ -3985,7 +3973,7 @@ exports.example = (0, combinator_1.creator)(100, (0, combinator_1.block)((0, com
3985
3973
  'data-type': 'markdown'
3986
3974
  }, [(0, dom_1.html)('pre', {
3987
3975
  translate: 'no'
3988
- }, body.slice(0, -1)), (0, dom_1.html)('hr'), (0, dom_1.html)('section', [document, annotations, references])])];
3976
+ }, body.slice(0, -1)), (0, dom_1.html)('hr'), (0, dom_1.html)('section', [document, references])])];
3989
3977
  }
3990
3978
 
3991
3979
  case 'math':
@@ -4717,8 +4705,6 @@ const olist_1 = __webpack_require__(7471);
4717
4705
 
4718
4706
  const inline_1 = __webpack_require__(1160);
4719
4707
 
4720
- const source_1 = __webpack_require__(6743);
4721
-
4722
4708
  const dom_1 = __webpack_require__(3252);
4723
4709
 
4724
4710
  exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.context)({
@@ -4728,7 +4714,7 @@ exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combina
4728
4714
  }
4729
4715
  }
4730
4716
  }, exports.ilist_))));
4731
- exports.ilist_ = (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)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.trim)((0, combinator_1.some)(inline_1.inline)), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), (0, combinator_1.rewrite)(source_1.contentline, source => [[(0, dom_1.html)('span', source.replace('\n', ''))], ''])), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
4717
+ exports.ilist_ = (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)([(0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.some)(inline_1.inline), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, dom_1.html)('ul', {
4732
4718
  class: 'invalid',
4733
4719
  'data-invalid-syntax': 'list',
4734
4720
  'data-invalid-type': 'syntax',
@@ -4784,7 +4770,7 @@ exports.mathblock = (0, combinator_1.block)((0, combinator_1.validate)('$$', (0,
4784
4770
  Object.defineProperty(exports, "__esModule", ({
4785
4771
  value: true
4786
4772
  }));
4787
- exports.olist_ = exports.olist = void 0;
4773
+ exports.invalid = exports.olist_ = exports.olist = void 0;
4788
4774
 
4789
4775
  const global_1 = __webpack_require__(4128);
4790
4776
 
@@ -4806,11 +4792,13 @@ const memoize_1 = __webpack_require__(1808);
4806
4792
 
4807
4793
  const array_1 = __webpack_require__(8112);
4808
4794
 
4795
+ const tuple_1 = __webpack_require__(5341);
4796
+
4809
4797
  const openers = {
4810
- '.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?=$|\s)/,
4811
- '(': /^\(([0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?=$|\s)/
4798
+ '.': /^([0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?:$|\s)/,
4799
+ '(': /^\(([0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?:$|\s)/
4812
4800
  };
4813
- exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)([/^([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*\.(?=[^\S\n]|\n[^\S\n]*\S)/, /^\(([0-9]+|[a-z]+)\)(?:-[0-9]+)*(?=[^\S\n]|\n[^\S\n]*\S)/], (0, combinator_1.context)({
4801
+ exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(new RegExp([/^([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*\.(?=[^\S\n]|\n[^\S\n]*\S)/.source, /^\(([0-9]+|[a-z]+)\)(?:-[0-9]+)*(?=[^\S\n]|\n[^\S\n]*\S)/.source].join('|')), (0, combinator_1.context)({
4814
4802
  syntax: {
4815
4803
  inline: {
4816
4804
  media: false
@@ -4819,15 +4807,15 @@ exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combina
4819
4807
  }, exports.olist_))));
4820
4808
  exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.match)(openers['.'], (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => type(ms[1]).charCodeAt(0) || 0, [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => type(ms[1]).charCodeAt(0) || 0, []))])));
4821
4809
 
4822
- const list = (type, form) => (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)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.trim)((0, combinator_1.subsequence)([ulist_1.checkbox, (0, util_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))])), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), invalid), ns => [(0, dom_1.html)('li', {
4823
- 'data-marker': ns[0]
4810
+ const list = (type, form) => (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)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, util_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), exports.invalid), ns => [(0, dom_1.html)('li', {
4811
+ 'data-marker': ns[0] || global_1.undefined
4824
4812
  }, (0, dom_1.defrag)((0, ulist_1.fillFirstLine)((0, array_1.shift)(ns)[1])))]), true)]))), es => [format((0, dom_1.html)('ol', es), type, form)]);
4825
4813
 
4826
4814
  const heads = {
4827
- '.': (0, combinator_1.focus)(openers['.'], source => [[`${source.split('.', 1)[0]}.`], '']),
4828
- '(': (0, combinator_1.focus)(openers['('], source => [[source.replace(/^\($/, '(1)').replace(/^\((\w+)$/, '($1)')], ''])
4815
+ '.': (0, combinator_1.focus)(openers['.'], source => [[source.trimEnd().split('.', 1)[0] + '.'], '']),
4816
+ '(': (0, combinator_1.focus)(openers['('], source => [[source.trimEnd().replace(/^\($/, '(1)').replace(/^\((\w+)$/, '($1)')], ''])
4829
4817
  };
4830
- const invalid = (0, combinator_1.rewrite)(source_1.contentline, source => [['', (0, dom_1.html)('span', {
4818
+ exports.invalid = (0, combinator_1.rewrite)((0, combinator_1.inits)([source_1.contentline, (0, combinator_1.indent)(s => [(0, tuple_1.tuple)(s), ''])]), source => [['', (0, dom_1.html)('span', {
4831
4819
  class: 'invalid',
4832
4820
  'data-invalid-syntax': 'listitem',
4833
4821
  'data-invalid-type': 'syntax',
@@ -5199,8 +5187,6 @@ const ilist_1 = __webpack_require__(238);
5199
5187
 
5200
5188
  const inline_1 = __webpack_require__(1160);
5201
5189
 
5202
- const source_1 = __webpack_require__(6743);
5203
-
5204
5190
  const util_1 = __webpack_require__(9437);
5205
5191
 
5206
5192
  const dom_1 = __webpack_require__(3252);
@@ -5214,16 +5200,10 @@ exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combina
5214
5200
  }
5215
5201
  }
5216
5202
  }, exports.ulist_))));
5217
- 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)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.trim)((0, combinator_1.subsequence)([exports.checkbox, (0, util_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))])), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
5203
+ 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)([(0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.subsequence)([exports.checkbox, (0, util_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline])))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), olist_1.invalid), ns => [(0, dom_1.html)('li', (0, dom_1.defrag)(fillFirstLine(ns)))]), true)])))), es => [format((0, dom_1.html)('ul', es))])));
5218
5204
  exports.checkbox = (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, source => [[(0, dom_1.html)('span', {
5219
5205
  class: 'checkbox'
5220
5206
  }, source[1].trimStart() ? '☑' : '☐')], '']);
5221
- const invalid = (0, combinator_1.rewrite)(source_1.contentline, source => [[(0, dom_1.html)('span', {
5222
- class: 'invalid',
5223
- 'data-invalid-syntax': 'listitem',
5224
- 'data-invalid-type': 'syntax',
5225
- 'data-invalid-message': 'Fix the indent or the head of the list item'
5226
- }, source.replace('\n', ''))], '']);
5227
5207
 
5228
5208
  function fillFirstLine(ns) {
5229
5209
  return ns.length === 1 && typeof ns[0] === 'object' && ['UL', 'OL'].includes(ns[0].tagName) ? (0, array_1.unshift)([(0, dom_1.html)('br')], ns) : ns;
@@ -5426,7 +5406,7 @@ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0,
5426
5406
  delimiters: global_1.undefined
5427
5407
  }, (0, util_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', /^\\?\n/)))), '))'), ns => [(0, dom_1.html)('sup', {
5428
5408
  class: 'annotation'
5429
- }, (0, dom_1.defrag)(ns))]))));
5409
+ }, [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])]))));
5430
5410
 
5431
5411
  /***/ }),
5432
5412
 
@@ -5464,8 +5444,8 @@ const util_1 = __webpack_require__(9437);
5464
5444
  exports.autolink = (0, combinator_1.fmap)((0, combinator_1.validate)(/^(?:[@#>0-9A-Za-z]|\S#)/, (0, combinator_1.guard)(context => context.syntax?.inline?.autolink ?? true, (0, combinator_1.some)((0, combinator_1.union)([url_1.url, email_1.email, // Escape unmatched email-like strings.
5465
5445
  (0, source_1.str)(/^[0-9A-Za-z]+(?:[.+_-][0-9A-Za-z]+)*(?:@(?:[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?)+/), channel_1.channel, account_1.account, // Escape unmatched account-like strings.
5466
5446
  (0, source_1.str)(/^@+[0-9A-Za-z]*(?:-[0-9A-Za-z]+)*/), // Escape invalid leading characters.
5467
- (0, source_1.str)(new RegExp(String.raw`^(?:[^\p{C}\p{S}\p{P}\s]|${hashtag_1.emoji}|['_])(?=#)`, 'u')), hashtag_1.hashtag, hashnum_1.hashnum, // Escape unmatched hashtag-like strings.
5468
- (0, source_1.str)(new RegExp(String.raw`^#+(?:[^\p{C}\p{S}\p{P}\s]|${hashtag_1.emoji}|['_])*`, 'u')), anchor_1.anchor])))), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)]);
5447
+ (0, source_1.str)(new RegExp(/^(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])(?=#)/u.source.replace('emoji', hashtag_1.emoji), 'u')), hashtag_1.hashtag, hashnum_1.hashnum, // Escape unmatched hashtag-like strings.
5448
+ (0, source_1.str)(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])*/u.source.replace('emoji', hashtag_1.emoji), 'u')), anchor_1.anchor])))), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)]);
5469
5449
 
5470
5450
  /***/ }),
5471
5451
 
@@ -5619,7 +5599,7 @@ const source_1 = __webpack_require__(6743);
5619
5599
 
5620
5600
  const dom_1 = __webpack_require__(3252);
5621
5601
 
5622
- exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.open)('#', (0, source_1.str)(new RegExp(String.raw`^[0-9]{1,16}(?![^\p{C}\p{S}\p{P}\s]|${hashtag_1.emoji}|['_])`, 'u'))), (0, combinator_1.context)({
5602
+ exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.open)('#', (0, source_1.str)(new RegExp(/^[0-9]{1,16}(?![^\p{C}\p{S}\p{P}\s]|emoji|['_])/u.source.replace(/emoji/, hashtag_1.emoji), 'u'))), (0, combinator_1.context)({
5623
5603
  syntax: {
5624
5604
  inline: {
5625
5605
  link: true,
@@ -5655,7 +5635,7 @@ const dom_1 = __webpack_require__(3252); // https://example/hashtags/a must be a
5655
5635
 
5656
5636
 
5657
5637
  exports.emoji = String.raw`\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F`;
5658
- exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.open)('#', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-9A-Za-z](?:(?:[0-9A-Za-z]|-(?=\w)){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-(?=\w)){0,61}[0-9A-Za-z])?)*\//), ([source]) => source.length <= 253 + 1), (0, combinator_1.verify)((0, source_1.str)(new RegExp(['^', String.raw`(?=[0-9]{0,127}_?(?:[^\d\p{C}\p{S}\p{P}\s]|${exports.emoji}))`, String.raw`(?:[^\p{C}\p{S}\p{P}\s]|${exports.emoji}|_(?=[^\p{C}\p{S}\p{P}\s]|${exports.emoji})){1,128}`, String.raw`(?!_?(?:[^\p{C}\p{S}\p{P}\s]|${exports.emoji})|')`].join(''), 'u')), ([source]) => source.length <= 128)])), (0, combinator_1.context)({
5638
+ exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.open)('#', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-9A-Za-z](?:(?:[0-9A-Za-z]|-(?=\w)){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-(?=\w)){0,61}[0-9A-Za-z])?)*\//), ([source]) => source.length <= 253 + 1), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/^(?=[0-9]{0,127}_?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|_(?=[^\p{C}\p{S}\p{P}\s]|emoji)){1,128}/u.source, /(?!_?(?:[^\p{C}\p{S}\p{P}\s]|emoji)|')/u.source].join('').replace(/emoji/g, exports.emoji), 'u')), ([source]) => source.length <= 128)])), (0, combinator_1.context)({
5659
5639
  syntax: {
5660
5640
  inline: {
5661
5641
  link: true,
@@ -6690,7 +6670,7 @@ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, c
6690
6670
  }
6691
6671
  },
6692
6672
  delimiters: global_1.undefined
6693
- }, (0, combinator_1.subsequence)([abbr, (0, combinator_1.open)((0, source_1.stropt)(/^(?=\^)/), (0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/)), (0, util_1.trimBlank)((0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/))]))), ']]'), ns => [(0, dom_1.html)('sup', attributes(ns), (0, dom_1.defrag)(ns))]))));
6673
+ }, (0, combinator_1.subsequence)([abbr, (0, combinator_1.open)((0, source_1.stropt)(/^(?=\^)/), (0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/)), (0, util_1.trimBlank)((0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/))]))), ']]'), ns => [(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])]))));
6694
6674
  const abbr = (0, combinator_1.creator)((0, combinator_1.bind)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?![0-9]+\s?[|\]])[0-9A-Za-z]+(?:(?:-|(?=\W)(?!'\d)'?(?!\.\d)\.?(?!,\S),? ?)[0-9A-Za-z]+)*(?:-|'?\.?,? ?)?/)]), /^\|?(?=]])|^\|[^\S\n]*/), ([source], rest) => [[(0, dom_1.html)('abbr', source)], rest.replace(util_1.regBlankStart, '')]));
6695
6675
 
6696
6676
  function attributes(ns) {
@@ -7017,7 +6997,7 @@ const multimap_1 = __webpack_require__(940);
7017
6997
  const array_1 = __webpack_require__(8112);
7018
6998
 
7019
6999
  function* figure(target, footnotes, opts = {}) {
7020
- 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]')), footnotes?.annotations.querySelectorAll('a.label:not(.disabled)') ?? []), footnotes?.references.querySelectorAll('a.label:not(.disabled)') ?? []).map(el => [el.getAttribute('data-label'), el]));
7000
+ 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]')), footnotes?.annotations?.querySelectorAll('a.label:not(.disabled)') ?? []), footnotes?.references.querySelectorAll('a.label:not(.disabled)') ?? []).map(el => [el.getAttribute('data-label'), el]));
7021
7001
  const labels = new global_1.Set();
7022
7002
  const numbers = new global_1.Map();
7023
7003
  let base = '0';
@@ -7209,37 +7189,54 @@ const dom_1 = __webpack_require__(3252);
7209
7189
 
7210
7190
  const multimap_1 = __webpack_require__(940);
7211
7191
 
7212
- const memoize_1 = __webpack_require__(1808);
7192
+ const array_1 = __webpack_require__(8112);
7213
7193
 
7214
7194
  function* footnote(target, footnotes, opts = {}) {
7215
- yield* (0, exports.reference)(target, footnotes?.references, opts, footnotes?.annotations && [footnotes.annotations]);
7216
- yield* (0, exports.annotation)(target, footnotes?.annotations, opts, []);
7195
+ yield* (0, exports.reference)(target, footnotes?.references, opts);
7196
+ yield* (0, exports.annotation)(target, footnotes?.annotations, opts);
7217
7197
  return;
7218
7198
  }
7219
7199
 
7220
7200
  exports.footnote = footnote;
7221
- exports.annotation = build('annotation', n => `*${n}`);
7201
+ exports.annotation = build('annotation', n => `*${n}`, 'h1, h2, h3, h4, h5, h6, aside.aside, hr');
7222
7202
  exports.reference = build('reference', (n, abbr) => `[${abbr || n}]`);
7223
7203
 
7224
- function build(syntax, marker) {
7204
+ function build(syntax, marker, splitter) {
7225
7205
  // Referenceを含むAnnotationの重複排除は両構文が互いに処理済みであることを必要とするため
7226
7206
  // 構文ごとに各1回の処理では不可能
7227
- const identify = (0, memoize_1.memoize)(ref => `${+!ref.querySelector('.label')}:${ref.getAttribute('data-abbr') || '_' + ref.innerHTML}`, new global_1.WeakMap());
7228
- const contentify = (0, memoize_1.memoize)(ref => (0, dom_1.frag)(ref.cloneNode(true).childNodes), new global_1.WeakMap());
7229
- return function* (target, footnote, opts = {}, footnotes = []) {
7207
+ return function* (target, footnote, opts = {}) {
7208
+ //assert(syntax !== 'annotation' || !footnote);
7230
7209
  const defs = new global_1.Map();
7231
7210
  const buffer = new multimap_1.MultiMap();
7232
- const titles = new global_1.Map();
7233
- const check = footnotes.some(el => target.contains(el));
7211
+ const titles = new global_1.Map(); // Bug: Firefox
7212
+ //const splitters = push([], target.querySelectorAll(`:scope > :is(${splitter ?? '_'})`));
7213
+
7214
+ const splitters = (0, array_1.push)([], target.querySelectorAll(splitter ?? '_')).filter(el => el.parentNode === target); // Bug: Firefox
7215
+ //target.querySelectorAll(`:scope > .${syntax}s`).forEach(el => el.remove());
7216
+
7217
+ target.querySelectorAll(`.${syntax}s`).forEach(el => el.parentNode === target && el.remove());
7218
+ let offset = 0;
7234
7219
  let style;
7235
7220
 
7236
7221
  for (let refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`), i = 0, len = refs.length; i < len; ++i) {
7237
7222
  yield;
7238
7223
  const ref = refs[i];
7239
- if (check && footnotes.some(el => el.contains(ref))) continue;
7240
- const identifier = identify(ref);
7224
+
7225
+ while (+splitters[0]?.compareDocumentPosition(ref) & global_1.Node.DOCUMENT_POSITION_FOLLOWING) {
7226
+ if (defs.size > 0) {
7227
+ offset += defs.size;
7228
+ yield* proc(defs, target.insertBefore((0, dom_1.html)('ol', {
7229
+ class: `${syntax}s`
7230
+ }), splitters[0] ?? null));
7231
+ }
7232
+
7233
+ splitters.shift();
7234
+ }
7235
+
7236
+ if (syntax === 'annotation' && ref.closest('#annotations, .annotations, #references, .references')) continue;
7237
+ const identifier = `${+!ref.querySelector('.label')}:${ref.getAttribute('data-abbr') || '_' + ref.firstElementChild.innerHTML}`;
7241
7238
  const abbr = ref.getAttribute('data-abbr') || global_1.undefined;
7242
- const content = contentify(ref);
7239
+ const content = (0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes);
7243
7240
  style ??= abbr ? 'abbr' : 'count';
7244
7241
 
7245
7242
  if (style === 'count' ? abbr : !abbr) {
@@ -7249,12 +7246,17 @@ function build(syntax, marker) {
7249
7246
  'data-invalid-type': 'style',
7250
7247
  'data-invalid-message': `${syntax[0].toUpperCase() + syntax.slice(1)} style must be consistent`
7251
7248
  });
7249
+ } else if (ref.getAttribute('data-invalid-type') === 'style') {
7250
+ (0, dom_1.define)(ref, {
7251
+ class: void ref.classList.remove('invalid'),
7252
+ 'data-invalid-syntax': null,
7253
+ 'data-invalid-type': null,
7254
+ 'data-invalid-message': null
7255
+ });
7252
7256
  }
7253
7257
 
7254
- if (ref.firstElementChild?.getAttribute('hidden') !== '') {
7255
- ref.replaceChildren((0, dom_1.html)('span', {
7256
- hidden: ''
7257
- }, ref.childNodes));
7258
+ if (!ref.firstElementChild.hasAttribute('hidden')) {
7259
+ ref.firstElementChild.setAttribute('hidden', '');
7258
7260
  } else {
7259
7261
  ref.lastChild?.remove();
7260
7262
  }
@@ -7265,7 +7267,8 @@ function build(syntax, marker) {
7265
7267
  const refIndex = i + 1;
7266
7268
  const refId = opts.id !== '' ? ref.id || `${syntax}:${opts.id ? `${opts.id}:` : ''}ref:${refIndex}` : global_1.undefined;
7267
7269
  const def = global_1.undefined || defs.get(identifier) || defs.set(identifier, (0, dom_1.html)('li', {
7268
- id: opts.id !== '' ? `${syntax}:${opts.id ? `${opts.id}:` : ''}def:${defs.size + 1}` : global_1.undefined
7270
+ id: opts.id !== '' ? `${syntax}:${opts.id ? `${opts.id}:` : ''}def:${defs.size + offset + 1}` : global_1.undefined,
7271
+ 'data-marker': !footnote ? marker(defs.size + offset + 1, abbr) : global_1.undefined
7269
7272
  }, [content.cloneNode(true), (0, dom_1.html)('sup')])).get(identifier);
7270
7273
 
7271
7274
  if (title && !blank && def.childNodes.length === 1) {
@@ -7283,7 +7286,7 @@ function build(syntax, marker) {
7283
7286
  }
7284
7287
  }
7285
7288
 
7286
- const defIndex = +def.id.slice(def.id.lastIndexOf(':') + 1) || defs.size;
7289
+ const defIndex = +def.id.slice(def.id.lastIndexOf(':') + 1) || defs.size + offset;
7287
7290
  const defId = def.id || global_1.undefined;
7288
7291
  (0, dom_1.define)(ref, {
7289
7292
  id: refId,
@@ -7306,7 +7309,16 @@ function build(syntax, marker) {
7306
7309
  }, `^${refIndex}`));
7307
7310
  }
7308
7311
 
7309
- if (!footnote) return;
7312
+ if (defs.size > 0 || footnote) {
7313
+ yield* proc(defs, footnote ?? target.insertBefore((0, dom_1.html)('ol', {
7314
+ class: `${syntax}s`
7315
+ }), splitters[0] ?? target.querySelector(':scope > :is(#annotations, #references)')));
7316
+ }
7317
+
7318
+ return;
7319
+ };
7320
+
7321
+ function* proc(defs, footnote) {
7310
7322
  const {
7311
7323
  children
7312
7324
  } = footnote;
@@ -7314,7 +7326,8 @@ function build(syntax, marker) {
7314
7326
  let count = 0;
7315
7327
  let length = children.length;
7316
7328
 
7317
- I: for (const def of defs.values()) {
7329
+ I: for (const [key, def] of defs) {
7330
+ defs.delete(key);
7318
7331
  ++count;
7319
7332
 
7320
7333
  while (length > size) {
@@ -7336,7 +7349,7 @@ function build(syntax, marker) {
7336
7349
  }
7337
7350
 
7338
7351
  return;
7339
- };
7352
+ }
7340
7353
  }
7341
7354
 
7342
7355
  function equal(a, b) {
@@ -7768,7 +7781,7 @@ const memoize_1 = __webpack_require__(1808);
7768
7781
 
7769
7782
  const array_1 = __webpack_require__(8112);
7770
7783
 
7771
- exports.regBlankStart = new RegExp(String.raw`^(?:\\?[^\S\n]|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr>)+`);
7784
+ exports.regBlankStart = new RegExp(/^(?:\\?[^\S\n]|&IHN;|<wbr>)+/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`));
7772
7785
 
7773
7786
  function blankWith(starting, delimiter) {
7774
7787
  if (delimiter === global_1.undefined) return blankWith('', starting);
@@ -7778,7 +7791,7 @@ function blankWith(starting, delimiter) {
7778
7791
  exports.blankWith = blankWith;
7779
7792
 
7780
7793
  function visualize(parser) {
7781
- const blankline = new RegExp(String.raw`^(?:\\$|\\?[^\S\n]|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr>)+$`, 'gm');
7794
+ const blankline = new RegExp(/^(?:\\$|\\?[^\S\n]|&IHN;|<wbr>)+$/.source.replace('IHN', `(?:${normalize_1.invisibleHTMLEntityNames.join('|')})`), 'gm');
7782
7795
  return (0, combinator_1.union)([(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))), (0, combinator_1.some)((0, combinator_1.union)([source_1.linebreak, source_1.unescsource]))]);
7783
7796
  }
7784
7797
 
@@ -8477,13 +8490,13 @@ exports.info = void 0;
8477
8490
 
8478
8491
  const scope_1 = __webpack_require__(5202);
8479
8492
 
8480
- const query_1 = __webpack_require__(6120);
8493
+ const array_1 = __webpack_require__(8112);
8481
8494
 
8482
8495
  function info(source) {
8483
8496
  const match = (0, scope_1.scope)(source, '.invalid');
8484
8497
  return {
8485
- url: find('a:not(.email):not(.account):not(.channel):not(.hashtag):not(.hashnum):not(.anchor)').filter(el => ['http:', 'https:'].includes(el.protocol)),
8486
- tel: find('a:not(.email):not(.account):not(.channel):not(.hashtag):not(.hashnum):not(.anchor)').filter(el => ['tel:'].includes(el.protocol)),
8498
+ url: find('a:not(:is(.email, .account, .channel, .hashtag, .hashnum, .anchor))').filter(el => ['http:', 'https:'].includes(el.protocol)),
8499
+ tel: find('a:not(:is(.email, .account, .channel, .hashtag, .hashnum, .anchor))').filter(el => ['tel:'].includes(el.protocol)),
8487
8500
  email: find('a.email'),
8488
8501
  account: find('a.account'),
8489
8502
  channel: find('a.channel'),
@@ -8495,7 +8508,7 @@ function info(source) {
8495
8508
  };
8496
8509
 
8497
8510
  function find(selector) {
8498
- return (0, query_1.querySelectorAll)(source, selector).filter(match);
8511
+ return (0, array_1.push)([], source.querySelectorAll(selector)).filter(match);
8499
8512
  }
8500
8513
  }
8501
8514
 
@@ -8668,29 +8681,21 @@ const array_1 = __webpack_require__(8112); // Bug: Firefox
8668
8681
  //const selector = 'h1 h2 h3 h4 h5 h6 aside.aside'.split(' ').map(s => `:scope > ${s}[id]`).join();
8669
8682
 
8670
8683
 
8671
- const selector = 'h1 h2 h3 h4 h5 h6 aside.aside'.split(' ').map(s => `${s}[id]`).join();
8684
+ const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]';
8672
8685
 
8673
8686
  function toc(source) {
8674
- const es = source.querySelectorAll(selector);
8675
- const hs = (0, global_1.Array)(es.length);
8676
-
8677
- for (let i = 0; i < hs.length; ++i) {
8678
- const el = es[i];
8679
-
8687
+ const hs = (0, array_1.push)([], source.querySelectorAll(selector)).map(el => {
8680
8688
  switch (el.tagName) {
8681
8689
  case 'ASIDE':
8682
- hs[i] = (0, dom_1.html)(el.firstElementChild.tagName.toLowerCase(), {
8690
+ return (0, dom_1.html)(el.firstElementChild.tagName.toLowerCase(), {
8683
8691
  id: el.id,
8684
8692
  class: 'aside'
8685
8693
  }, el.firstElementChild.cloneNode(true).childNodes);
8686
- continue;
8687
8694
 
8688
8695
  default:
8689
- hs[i] = el;
8690
- continue;
8696
+ return el;
8691
8697
  }
8692
- }
8693
-
8698
+ });
8694
8699
  return parse(cons(hs));
8695
8700
  }
8696
8701
 
package/index.d.ts CHANGED
@@ -33,7 +33,7 @@ export interface ParserSettings {
33
33
  // For editing.
34
34
  readonly caches?: Partial<Caches>;
35
35
  readonly footnotes: {
36
- readonly annotations: HTMLOListElement;
36
+ readonly annotations?: HTMLOListElement;
37
37
  readonly references: HTMLOListElement;
38
38
  };
39
39
  readonly chunk?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.252.0",
3
+ "version": "0.253.0",
4
4
  "description": "Secure markdown renderer working on browsers for user input data.",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/falsandtru/securemark",
@@ -14,7 +14,7 @@ export interface Ctx {
14
14
  delimiters?: Delimiters;
15
15
  }
16
16
  export type Tree<P extends Parser<unknown>> = P extends Parser<infer T> ? T : never;
17
- export type SubParsers<P extends Parser<unknown>> = P extends Parser<unknown, any, infer D> ? D : never;
17
+ export type SubParsers<P extends Parser<unknown>> = P extends Parser<unknown, Ctx, infer D> ? D : never;
18
18
  export type Context<P extends Parser<unknown>> = P extends Parser<unknown, infer C> ? C : never;
19
19
  export type SubTree<P extends Parser<unknown>> = ExtractSubTree<SubParsers<P>>;
20
20
  export type IntermediateParser<P extends Parser<unknown>> = Parser<SubTree<P>, Context<P>, SubParsers<P>>;
@@ -175,17 +175,17 @@ describe('Unit: parser/api/bind', () => {
175
175
  assert.deepStrictEqual(
176
176
  [...el.children].map(el => el.outerHTML),
177
177
  [
178
- html('p', [html('sup', { class: "annotation" }, '1'),]).outerHTML,
179
- html('p', [html('sup', { class: "annotation" }, '2'),]).outerHTML,
178
+ html('p', [html('sup', { class: "annotation" }, [html('span', '1')]),]).outerHTML,
179
+ html('p', [html('sup', { class: "annotation" }, [html('span', '2')]),]).outerHTML,
180
180
  ]);
181
181
  inspect(iter, 1);
182
182
  el.appendChild(chunk);
183
183
  assert.deepStrictEqual(
184
184
  [...el.children].map(el => el.outerHTML),
185
185
  [
186
- html('p', [html('sup', { class: "annotation" }, '1'),]).outerHTML,
187
- html('p', [html('sup', { class: "annotation" }, '2'),]).outerHTML,
188
- html('p', [html('sup', { class: "annotation" }, '3'),]).outerHTML,
186
+ html('p', [html('sup', { class: "annotation" }, [html('span', '1')]),]).outerHTML,
187
+ html('p', [html('sup', { class: "annotation" }, [html('span', '2')]),]).outerHTML,
188
+ html('p', [html('sup', { class: "annotation" }, [html('span', '3')]),]).outerHTML,
189
189
  ]);
190
190
  inspect(iter);
191
191
  assert.deepStrictEqual(
@@ -211,7 +211,7 @@ describe('Unit: parser/api/bind', () => {
211
211
  ]).outerHTML,
212
212
  ]);
213
213
  assert.deepStrictEqual(
214
- cfgs.footnotes.annotations.outerHTML,
214
+ cfgs.footnotes.annotations?.outerHTML,
215
215
  html('ol', [
216
216
  html('li', { id: 'annotation:def:1' }, [
217
217
  '1',
@@ -137,6 +137,7 @@ describe('Unit: parser/api/parse', () => {
137
137
  '<p><a href="https://source/x/a" target="_blank"><img class="media" data-src="https://source/x/a" alt=""></a></p>',
138
138
  '<p><a href="/z/a" target="_blank"><img class="media" data-src="/z/a" alt=""></a></p>',
139
139
  '<p><a href="https://source/a" target="_blank"><img class="media" data-src="https://source/a" alt=""></a></p>',
140
+ '<ol class="annotations"><li id="annotation:def:1" data-marker="*1">a<sup><a href="#annotation:ref:1">^1</a></sup></li></ol>',
140
141
  ]);
141
142
  assert.deepStrictEqual(
142
143
  [...parse([
@@ -197,7 +198,7 @@ describe('Unit: parser/api/parse', () => {
197
198
  [
198
199
  `<aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="https://example/x"><span class="field-name">URL</span>: <span class="field-value">https://example/x</span>\n</span></details></aside>`,
199
200
  '<pre class="invalid" translate="no" data-invalid-syntax="header" data-invalid-type="syntax" data-invalid-message="Invalid syntax">---\nURL: https://example/y\n---\n</pre>',
200
- '<aside class="example" data-type="markdown"><pre translate="no">---\nURL: https://example/y\n---\n\n{#}</pre><hr><section><aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="https://example/y"><span class="field-name">URL</span>: <span class="field-value">https://example/y</span>\n</span></details></aside><p><a href="https://example/y#" target="_blank">#</a></p><ol class="annotations"></ol><ol class="references"></ol></section></aside>',
201
+ '<aside class="example" data-type="markdown"><pre translate="no">---\nURL: https://example/y\n---\n\n{#}</pre><hr><section><aside class="header"><details open=""><summary>Header</summary><span class="field" data-name="url" data-value="https://example/y"><span class="field-name">URL</span>: <span class="field-value">https://example/y</span>\n</span></details></aside><p><a href="https://example/y#" target="_blank">#</a></p><ol class="references"></ol></section></aside>',
201
202
  '<p><a href="https://example/x#" target="_blank">#</a></p>',
202
203
  ]);
203
204
  });
@@ -40,7 +40,7 @@ export function parse(source: string, opts: Options = {}, context?: MarkdownPars
40
40
  for (const _ of figure(node, opts.footnotes, context));
41
41
  for (const _ of footnote(node, opts.footnotes, context));
42
42
  assert(opts.id !== '' || !node.querySelector('[id], .index[href], .label[href], .annotation > a[href], .reference > a[href]'));
43
- assert(opts.id !== '' || !opts.footnotes?.annotations.querySelector('[id], .index[href], .label[href]'));
43
+ assert(opts.id !== '' || !opts.footnotes?.annotations?.querySelector('[id], .index[href], .label[href]'));
44
44
  assert(opts.id !== '' || !opts.footnotes?.references.querySelector('[id], .index[href], .label[href]'));
45
45
  return node;
46
46
  }