securemark 0.296.4 → 0.297.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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.296.4 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.297.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("Prism"), require("DOMPurify"));
@@ -4894,7 +4894,7 @@ const indexee_1 = __webpack_require__(7610);
4894
4894
  const util_1 = __webpack_require__(4992);
4895
4895
  const parse_1 = __webpack_require__(3662);
4896
4896
  const dom_1 = __webpack_require__(394);
4897
- exports.aside = (0, combinator_1.recursion)(1 /* Recursion.block */, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.fence)(/(~{3,})aside(?!\S)([^\n]*)(?:$|\n)/y, 300),
4897
+ exports.aside = (0, combinator_1.block)((0, combinator_1.recursion)(1 /* Recursion.block */, (0, combinator_1.fmap)((0, combinator_1.fence)(/(~{3,})aside(?!\S)([^\n]*)(?:$|\n)/y, 300),
4898
4898
  // Bug: Type mismatch between outer and inner.
4899
4899
  (nodes, context) => {
4900
4900
  const [body, overflow, closer, opener, delim, param] = (0, util_1.unwrap)(nodes);
@@ -4942,7 +4942,7 @@ const mathblock_1 = __webpack_require__(4903);
4942
4942
  const util_1 = __webpack_require__(4992);
4943
4943
  const parse_1 = __webpack_require__(3662);
4944
4944
  const dom_1 = __webpack_require__(394);
4945
- exports.example = (0, combinator_1.recursion)(1 /* Recursion.block */, (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.fence)(/(~{3,})(?:example\/(\S+))?(?!\S)([^\n]*)(?:$|\n)/y, 300),
4945
+ exports.example = (0, combinator_1.block)((0, combinator_1.recursion)(1 /* Recursion.block */, (0, combinator_1.fmap)((0, combinator_1.fence)(/(~{3,})(?:example\/(\S+))?(?!\S)([^\n]*)(?:$|\n)/y, 300),
4946
4946
  // Bug: Type mismatch between outer and inner.
4947
4947
  (nodes, context) => {
4948
4948
  const [body, overflow, closer, opener, delim, type = 'markdown', param] = (0, util_1.unwrap)(nodes);
@@ -6319,24 +6319,75 @@ exports.annotation = void 0;
6319
6319
  const parser_1 = __webpack_require__(605);
6320
6320
  const combinator_1 = __webpack_require__(3484);
6321
6321
  const inline_1 = __webpack_require__(7973);
6322
+ const bracket_1 = __webpack_require__(4526);
6322
6323
  const visibility_1 = __webpack_require__(6364);
6323
6324
  const util_1 = __webpack_require__(4992);
6324
6325
  const dom_1 = __webpack_require__(394);
6325
- exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, (0, combinator_1.surround)((0, combinator_1.close)('((', visibility_1.beforeNonblank), (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[')', 1]]))), '))', false, [2, 1 | 4 /* Backtrack.common */, 3 | 128 /* Backtrack.doublebracket */], ([, ns], context) => context.linebreak === 0 ? new parser_1.List([new parser_1.Node((0, dom_1.html)('sup', {
6326
- class: 'annotation'
6327
- }, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns))))]))]) : undefined, (_, context) => {
6326
+ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, (0, combinator_1.surround)((0, combinator_1.close)('((', visibility_1.beforeNonblank), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[')', 1]]))))), '))', false, [], ([, ns], context) => {
6327
+ const {
6328
+ linebreak
6329
+ } = context;
6330
+ if (linebreak === 0) {
6331
+ return new parser_1.List([new parser_1.Node((0, dom_1.html)('sup', {
6332
+ class: 'annotation'
6333
+ }, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns))))]))]);
6334
+ }
6335
+ ns.unshift(new parser_1.Node('('));
6336
+ ns.push(new parser_1.Node(')'));
6337
+ return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6338
+ class: 'paren'
6339
+ }, ['(', (0, dom_1.html)('span', {
6340
+ class: 'paren'
6341
+ }, (0, dom_1.defrag)((0, util_1.unwrap)(ns))), ')']))]);
6342
+ }, ([, bs = new parser_1.List()], context) => {
6328
6343
  const {
6329
6344
  source,
6330
6345
  position,
6331
6346
  range,
6332
6347
  linebreak
6333
6348
  } = context;
6334
- const head = position - range;
6335
- if (source[position] !== ')') {
6336
- (0, combinator_1.setBacktrack)(context, 2 | 4 /* Backtrack.common */, head + 1);
6337
- } else if (linebreak !== 0) {
6338
- (0, combinator_1.setBacktrack)(context, 2 | 128 /* Backtrack.doublebracket */, head + 1);
6349
+ if (linebreak === 0 && bs.length === 1 && source[position] === ')' && typeof bs.head?.value === 'object' && bs.head.value.className === 'paren') {
6350
+ const {
6351
+ firstChild,
6352
+ lastChild
6353
+ } = bs.head.value;
6354
+ if (firstChild.nodeValue.length === 1) {
6355
+ firstChild.remove();
6356
+ } else {
6357
+ firstChild.nodeValue = firstChild.nodeValue.slice(1);
6358
+ }
6359
+ if (lastChild.nodeValue.length === 1) {
6360
+ lastChild.remove();
6361
+ } else {
6362
+ lastChild.nodeValue = lastChild.nodeValue.slice(0, -1);
6363
+ }
6364
+ context.position += 1;
6365
+ return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6366
+ class: 'paren'
6367
+ }, ['(', (0, dom_1.html)('sup', {
6368
+ class: 'annotation'
6369
+ }, [(0, dom_1.html)('span', bs.head.value.childNodes)])]))]);
6370
+ }
6371
+ if (linebreak === 0 && bs.length === 3 && source[position - range + 2] === '(' && source[position] === ')' && source[position - 1] === ')' && source[position - 2] !== '\\') {
6372
+ context.position += 1;
6373
+ return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6374
+ class: 'paren'
6375
+ }, ['(', (0, dom_1.html)('sup', {
6376
+ class: 'annotation'
6377
+ }, [(0, dom_1.html)('span', [bs.head.next.value])])]))]);
6339
6378
  }
6379
+ const str = linebreak === 0 ? source.slice(position - range + 2, position) : '';
6380
+ if (linebreak === 0 && bracket_1.indexA.test(str)) {
6381
+ return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6382
+ class: 'paren'
6383
+ }, ['((' + str]))]);
6384
+ }
6385
+ bs.unshift(new parser_1.Node('('));
6386
+ return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6387
+ class: 'paren'
6388
+ }, ['(', (0, dom_1.html)('span', {
6389
+ class: 'paren'
6390
+ }, (0, dom_1.defrag)((0, util_1.unwrap)(bs)))]))]);
6340
6391
  })));
6341
6392
 
6342
6393
  /***/ },
@@ -6418,7 +6469,7 @@ const source_1 = __webpack_require__(8745);
6418
6469
  const dom_1 = __webpack_require__(394);
6419
6470
  // https://example/@user must be a user page or a redirect page going there.
6420
6471
  // https://example/@user?ch=a+b must be a user channel page or a redirect page going there.
6421
- exports.account = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)((0, combinator_1.surround)(/(?<![0-9a-z])@/yi, (0, source_1.str)(/[0-9a-z](?:[.-](?=[0-9a-z])|[0-9a-z]){0,254}\/|/yi), (0, source_1.str)(/[a-z][0-9a-z]*(?:[.-][0-9a-z]+)*(?![_.-]?[0-9a-z@]|>>|:\S)/yi), false, [3 | 8 /* Backtrack.unescapable */]), (0, combinator_1.some)((0, combinator_1.surround)('#', (0, combinator_1.verify)((0, source_1.str)(new RegExp([/(?!['_])(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^\p{C}\p{S}\p{P}\s]|emoji))+/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu')), ([{
6472
+ exports.account = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)((0, combinator_1.surround)(/(?<![0-9a-z@#])@/yi, (0, source_1.str)(/[0-9a-z](?:[.-](?=[0-9a-z])|[0-9a-z]){0,254}\/|/yi), (0, source_1.str)(/[a-z][0-9a-z]*(?:[.-][0-9a-z]+)*(?![_.-]?[0-9a-z@]|>>|:\S)/yi), false, [3 | 8 /* Backtrack.unescapable */]), (0, combinator_1.some)((0, combinator_1.surround)('#', (0, combinator_1.verify)((0, source_1.str)(new RegExp([/(?!['_])(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^\p{C}\p{S}\p{P}\s]|emoji))+/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu')), ([{
6422
6473
  value
6423
6474
  }]) => /^[0-9]{0,4}[^0-9]/.test(value)), new RegExp([/(?![_.-]?[0-9a-z@]|>>|:\S|[^\p{C}\p{S}\p{P}\s]|emoji)/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu'), false, [3 | 8 /* Backtrack.unescapable */])), '', false, [], ([[{
6424
6475
  value: host
@@ -6471,7 +6522,7 @@ const dom_1 = __webpack_require__(394);
6471
6522
  // cid: YYYY-MMDD-HHMM-SSmmm
6472
6523
  // 内部表現はUnixTimeに統一する(時系列順)
6473
6524
  // 外部表現は投稿ごとに投稿者の投稿時のタイムゾーンに統一する(非時系列順)
6474
- exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(/(?<![0-9a-z])>>/yi, (0, source_1.str)(/[0-9a-z]+(?:-[0-9a-z]+)*(?![_.-]?[0-9a-z@#]|>>|:\S)/yi), '', false, [3 | 8 /* Backtrack.unescapable */], ([, [{
6525
+ exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(/(?<![0-9a-z@#])>>/yi, (0, source_1.str)(/[0-9a-z]+(?:-[0-9a-z]+)*(?![_.-]?[0-9a-z@#]|>>|:\S)/yi), '', false, [3 | 8 /* Backtrack.unescapable */], ([, [{
6475
6526
  value
6476
6527
  }]], context) => new parser_1.List([new parser_1.Node((0, dom_1.define)((0, link_1.parse)(new parser_1.List([new parser_1.Node(`>>${value}`)]), new parser_1.List([new parser_1.Node(`?at=${value}`)]), context), {
6477
6528
  class: 'anchor'
@@ -6521,7 +6572,7 @@ const link_1 = __webpack_require__(3628);
6521
6572
  const hashtag_1 = __webpack_require__(5764);
6522
6573
  const source_1 = __webpack_require__(8745);
6523
6574
  const dom_1 = __webpack_require__(394);
6524
- exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(new RegExp([/(?<![^\p{C}\p{S}\p{P}\s]|emoji)#/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu'), (0, source_1.str)(new RegExp([/[0-9]{1,9}(?![_.-]?[0-9a-z@#]|>>|:\S|[^\p{C}\p{S}\p{P}\s]|emoji)/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu')), '', false,
6575
+ exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(new RegExp([/(?<![^\p{C}\p{S}\p{P}\s]|emoji|[@#])#/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu'), (0, source_1.str)(new RegExp([/[0-9]{1,9}(?![_.-]?[0-9a-z@#]|>>|:\S|[^\p{C}\p{S}\p{P}\s]|emoji)/yu.source].join('|').replace(/emoji/g, hashtag_1.emoji.source), 'yu')), '', false,
6525
6576
  // unescapableを使用するべきだがhashtagとの重複を回避するためescapableを使用する。
6526
6577
  [3 | 16 /* Backtrack.escapable */], ([, [{
6527
6578
  value
@@ -6550,7 +6601,7 @@ const dom_1 = __webpack_require__(394);
6550
6601
  // https://example/hashtags/a must be a hashtag page or a redirect page going there.
6551
6602
  // https://github.com/tc39/proposal-regexp-unicode-property-escapes#matching-emoji
6552
6603
  exports.emoji = /\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F|\u200D/u;
6553
- exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(new RegExp([/(?<![^\p{C}\p{S}\p{P}\s]|emoji)#/yu.source].join('|').replace(/emoji/g, exports.emoji.source), 'yu'), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/(?!['_])(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^\p{C}\p{S}\p{P}\s]|emoji))+/yu.source].join('|').replace(/emoji/g, exports.emoji.source), 'yu')), ([{
6604
+ exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.surround)(new RegExp([/(?<![^\p{C}\p{S}\p{P}\s]|emoji|[@#])#/yu.source].join('|').replace(/emoji/g, exports.emoji.source), 'yu'), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/(?!['_])(?:[^\p{C}\p{S}\p{P}\s]|emoji|'(?=[0-9A-Za-z])|_(?=[^\p{C}\p{S}\p{P}\s]|emoji))+/yu.source].join('|').replace(/emoji/g, exports.emoji.source), 'yu')), ([{
6554
6605
  value
6555
6606
  }]) => /^[0-9]{0,4}[^0-9]/.test(value)), new RegExp([/(?![_.-]?[0-9a-z@#]|>>|:\S|[^\p{C}\p{S}\p{P}\s]|emoji)/yu.source].join('|').replace(/emoji/g, exports.emoji.source), 'yu'), false, [3 | 8 /* Backtrack.unescapable */], ([, [{
6556
6607
  value
@@ -6601,7 +6652,7 @@ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combin
6601
6652
  Object.defineProperty(exports, "__esModule", ({
6602
6653
  value: true
6603
6654
  }));
6604
- exports.bracket = void 0;
6655
+ exports.bracket = exports.indexA = void 0;
6605
6656
  const parser_1 = __webpack_require__(605);
6606
6657
  const combinator_1 = __webpack_require__(3484);
6607
6658
  const inline_1 = __webpack_require__(7973);
@@ -6609,8 +6660,8 @@ const link_1 = __webpack_require__(3628);
6609
6660
  const source_1 = __webpack_require__(8745);
6610
6661
  const util_1 = __webpack_require__(4992);
6611
6662
  const dom_1 = __webpack_require__(394);
6612
- const indexA = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*$/;
6613
- const indexF = new RegExp(indexA.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => String.fromCodePoint(c.codePointAt(0) + 0xFEE0)));
6663
+ exports.indexA = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*$/;
6664
+ const indexF = new RegExp(exports.indexA.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => String.fromCodePoint(c.codePointAt(0) + 0xFEE0)));
6614
6665
  exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([input => {
6615
6666
  const {
6616
6667
  context: {
@@ -6635,52 +6686,47 @@ exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([input =>
6635
6686
  return d1(input);
6636
6687
  }
6637
6688
  }]));
6638
- const p1 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'),
6639
- // 唯一の参照者であるAnnotation構文に対してのみバックトラックを記録しその他は記録しない。
6640
- // 二重括弧構文の内括弧のバックトラックは二重括弧構文自身が記録するため記録不要。
6641
- // Ruby構文の丸括弧は常にRuby構文が先に到達し記録するため記録不要。
6642
- true, [], ([as, bs = new parser_1.List(), cs], context) => {
6643
- const {
6644
- source,
6645
- position,
6646
- range
6647
- } = context;
6648
- const head = position - range;
6649
- if (source[head + 1] === '(' && (context.linebreak !== 0 || source[position - 2] !== ')')) {
6650
- (0, combinator_1.setBacktrack)(context, 2 | 128 /* Backtrack.doublebracket */, head);
6651
- }
6652
- const str = source.slice(position - range + 1, position - 1);
6653
- return indexA.test(str) ? new parser_1.List([new parser_1.Node(as.head.value), new parser_1.Node(str), new parser_1.Node(cs.head.value)]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6689
+ const p1 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, [], ([as, bs = [], cs], {
6690
+ source,
6691
+ position,
6692
+ range,
6693
+ linebreak
6694
+ }) => {
6695
+ const str = linebreak === 0 ? source.slice(position - range + 1, position - 1) : '';
6696
+ return linebreak === 0 && exports.indexA.test(str) ? new parser_1.List([new parser_1.Node(as.head.value), new parser_1.Node(str), new parser_1.Node(cs.head.value)]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6654
6697
  class: 'paren'
6655
6698
  }, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs).import(cs)))))]);
6656
6699
  }, ([as, bs = new parser_1.List()], context) => {
6657
6700
  const {
6658
6701
  source,
6659
6702
  position,
6660
- range
6703
+ range,
6704
+ linebreak
6661
6705
  } = context;
6662
- const str = source.slice(position - range + 1, position);
6663
- return indexA.test(str) ? new parser_1.List([new parser_1.Node(as.head.value), new parser_1.Node(str)]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6706
+ const str = linebreak === 0 ? source.slice(position - range + 1, position) : '';
6707
+ return linebreak === 0 && exports.indexA.test(str) ? new parser_1.List([new parser_1.Node(as.head.value), new parser_1.Node(str)]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6664
6708
  class: 'paren'
6665
6709
  }, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs)))))]);
6666
6710
  }));
6667
6711
  const p2 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, [], ([as, bs = [], cs], {
6668
6712
  source,
6669
6713
  position,
6670
- range
6714
+ range,
6715
+ linebreak
6671
6716
  }) => {
6672
- const str = source.slice(position - range + 1, position - 1);
6673
- return indexF.test(str) ? new parser_1.List([new parser_1.Node(as.head.value), new parser_1.Node(str), new parser_1.Node(cs.head.value)]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6717
+ const str = linebreak === 0 ? source.slice(position - range + 1, position - 1) : '';
6718
+ return linebreak === 0 && indexF.test(str) ? new parser_1.List([new parser_1.Node(as.head.value), new parser_1.Node(str), new parser_1.Node(cs.head.value)]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6674
6719
  class: 'paren'
6675
6720
  }, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs).import(cs)))))]);
6676
6721
  }, ([as, bs = new parser_1.List()], context) => {
6677
6722
  const {
6678
6723
  source,
6679
6724
  position,
6680
- range
6725
+ range,
6726
+ linebreak
6681
6727
  } = context;
6682
- const str = source.slice(position - range + 1, position);
6683
- return indexF.test(str) ? new parser_1.List([new parser_1.Node(as.head.value), new parser_1.Node(str)]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6728
+ const str = linebreak === 0 ? source.slice(position - range + 1, position) : '';
6729
+ return linebreak === 0 && indexF.test(str) ? new parser_1.List([new parser_1.Node(as.head.value), new parser_1.Node(str)]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6684
6730
  class: 'paren'
6685
6731
  }, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs)))))]);
6686
6732
  }));
@@ -6688,14 +6734,15 @@ const s1 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.
6688
6734
  const {
6689
6735
  source,
6690
6736
  position,
6691
- range
6737
+ range,
6738
+ linebreak
6692
6739
  } = context;
6693
6740
  const head = position - range;
6694
- if (source[head + 1] === '[' && (context.linebreak !== 0 || source[position - 2] !== ']')) {
6741
+ if (source[head + 1] === '[' && (linebreak !== 0 || source[position - 2] !== ']')) {
6695
6742
  (0, combinator_1.setBacktrack)(context, 2 | 128 /* Backtrack.doublebracket */, head);
6696
6743
  }
6697
6744
  if (context.state & 8 /* State.link */) {
6698
- if (context.linebreak !== 0) {
6745
+ if (linebreak !== 0) {
6699
6746
  (0, combinator_1.setBacktrack)(context, 2 | 64 /* Backtrack.link */ | 32 /* Backtrack.ruby */, head);
6700
6747
  } else if (source[position] !== '{') {
6701
6748
  (0, combinator_1.setBacktrack)(context, 2 | 64 /* Backtrack.link */, head);
@@ -6762,11 +6809,11 @@ const inline_1 = __webpack_require__(7973);
6762
6809
  const visibility_1 = __webpack_require__(6364);
6763
6810
  const util_1 = __webpack_require__(4992);
6764
6811
  const dom_1 = __webpack_require__(394);
6765
- exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('~~', '', (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '~~')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '~'), true)])), '~~', false, [], ([, bs], {
6812
+ exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('~~', '', (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '~~')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '~'), true)])), '~~', false, [], ([, bs], {
6766
6813
  buffer
6767
6814
  }) => buffer.import(bs), ([, bs], {
6768
6815
  buffer
6769
- }) => bs && buffer.import(bs).push(new parser_1.Node("\u0018" /* Command.Cancel */)) && buffer), nodes => new parser_1.List([new parser_1.Node((0, dom_1.html)('del', (0, dom_1.defrag)((0, util_1.unwrap)(nodes))))])))));
6816
+ }) => bs && buffer.import(bs).push(new parser_1.Node("\u0018" /* Command.Cancel */)) && buffer)), nodes => new parser_1.List([new parser_1.Node((0, dom_1.html)('del', (0, dom_1.defrag)((0, util_1.unwrap)(nodes))))]))));
6770
6817
 
6771
6818
  /***/ },
6772
6819
 
@@ -6816,7 +6863,7 @@ const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, comb
6816
6863
  // 開閉が明示的でない構文は開閉の不明確な記号による再帰的適用を行わず
6817
6864
  // 可能な限り早く閉じるよう解析しなければならない。
6818
6865
  // このため終端記号の後ろを見て終端を中止し同じ構文を再帰的に適用してはならない。
6819
- exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('***', visibility_1.beforeNonblank, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank)])), (0, source_1.strs)('*', 1, 3), false, [], ([, bs, cs], context) => {
6866
+ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('***', visibility_1.beforeNonblank, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank)])), (0, source_1.strs)('*', 1, 3), false, [], ([, bs, cs], context) => {
6820
6867
  const {
6821
6868
  buffer
6822
6869
  } = context;
@@ -6864,7 +6911,7 @@ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0,
6864
6911
  }
6865
6912
  }, ([, bs], {
6866
6913
  buffer
6867
- }) => bs && buffer.import(bs) && buffer.push(new parser_1.Node("\u0018" /* Command.Cancel */)) && buffer),
6914
+ }) => bs && buffer.import(bs) && buffer.push(new parser_1.Node("\u0018" /* Command.Cancel */)) && buffer)),
6868
6915
  // 3以上の`*`に対してemの適用を保証する
6869
6916
  nodes => new parser_1.List([new parser_1.Node((0, dom_1.html)('em', [(0, dom_1.html)('strong', (0, dom_1.defrag)((0, util_1.unwrap)(nodes)))]))]), (nodes, context, prefix, postfix, state) => {
6870
6917
  context.position += postfix;
@@ -6923,7 +6970,7 @@ nodes => new parser_1.List([new parser_1.Node((0, dom_1.html)('em', [(0, dom_1.h
6923
6970
  nodes = prepend('*'.repeat(prefix - postfix), nodes);
6924
6971
  }
6925
6972
  return nodes;
6926
- }))));
6973
+ })));
6927
6974
  function prepend(prefix, nodes) {
6928
6975
  if (typeof nodes.head?.value === 'string') {
6929
6976
  nodes.head.value = prefix + nodes.head.value;
@@ -7039,7 +7086,7 @@ function identity(type, id, text) {
7039
7086
  if (typeof text !== 'string') {
7040
7087
  const index = text.getAttribute('data-index') ?? undefined;
7041
7088
  if (index === '' && text.tagName === 'LI') return undefined;
7042
- return index ? `${type}:${id ?? ''}:${index}` : identity(type, id, signature(text));
7089
+ return index ? `${type}:${id ?? ''}:${index}` : identity(type, id, signature(text.cloneNode(true)));
7043
7090
  }
7044
7091
  text = text.trim();
7045
7092
  if (text === '') return undefined;
@@ -7075,9 +7122,8 @@ function baseR(n, r) {
7075
7122
  } while (n > 0);
7076
7123
  return acc;
7077
7124
  }
7078
- function signature(source) {
7079
- const target = source.cloneNode(true);
7080
- for (let es = target.querySelectorAll('code[data-src], .math[data-src], .label[data-label], .remark, rt, rp, br, .annotation, .reference, .checkbox, ul, ol'), len = es.length, i = 0; i < len; ++i) {
7125
+ function signature(target) {
7126
+ for (let es = target.querySelectorAll('code[data-src], .math[data-src], .remark, rt, rp, br, .annotation, .reference, .checkbox, ul, ol, .label[data-label]'), len = es.length, i = 0; i < len; ++i) {
7081
7127
  const el = es[i];
7082
7128
  switch (el.tagName) {
7083
7129
  case 'CODE':
@@ -7111,8 +7157,7 @@ function signature(source) {
7111
7157
  return target.textContent.trim();
7112
7158
  }
7113
7159
  exports.signature = signature;
7114
- function text(source) {
7115
- const target = source.cloneNode(true);
7160
+ function text(target) {
7116
7161
  for (let es = target.querySelectorAll('code[data-src], .math[data-src], .remark, rt, rp, br, .annotation, .reference, .checkbox, ul, ol'), len = es.length, i = 0; i < len; ++i) {
7117
7162
  const el = es[i];
7118
7163
  switch (el.tagName) {
@@ -7381,11 +7426,11 @@ const inline_1 = __webpack_require__(7973);
7381
7426
  const visibility_1 = __webpack_require__(6364);
7382
7427
  const util_1 = __webpack_require__(4992);
7383
7428
  const dom_1 = __webpack_require__(394);
7384
- exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('++', '', (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '++')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '+'), true)])), '++', false, [], ([, bs], {
7429
+ exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('++', '', (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '++')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '+'), true)])), '++', false, [], ([, bs], {
7385
7430
  buffer
7386
7431
  }) => buffer.import(bs), ([, bs], {
7387
7432
  buffer
7388
- }) => bs && buffer.import(bs).push(new parser_1.Node("\u0018" /* Command.Cancel */)) && buffer), nodes => new parser_1.List([new parser_1.Node((0, dom_1.html)('ins', (0, dom_1.defrag)((0, util_1.unwrap)(nodes))))])))));
7433
+ }) => bs && buffer.import(bs).push(new parser_1.Node("\u0018" /* Command.Cancel */)) && buffer)), nodes => new parser_1.List([new parser_1.Node((0, dom_1.html)('ins', (0, dom_1.defrag)((0, util_1.unwrap)(nodes))))]))));
7389
7434
 
7390
7435
  /***/ },
7391
7436
 
@@ -7408,11 +7453,11 @@ const dom_1 = __webpack_require__(394);
7408
7453
  // 可読性のため実際にはオブリーク体を指定する。
7409
7454
  // 斜体は単語に使うとかえって見づらく読み飛ばしやすくなるため使わないべきであり
7410
7455
  // ある程度の長さのある文に使うのが望ましい。
7411
- exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('///', visibility_1.beforeNonblank, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), '///', visibility_1.afterNonblank), '///', false, [], ([, bs], {
7456
+ exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('///', visibility_1.beforeNonblank, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), '///', visibility_1.afterNonblank), '///', false, [], ([, bs], {
7412
7457
  buffer
7413
7458
  }) => buffer.import(bs), ([, bs], {
7414
7459
  buffer
7415
- }) => bs && buffer.import(bs).push(new parser_1.Node("\u0018" /* Command.Cancel */)) && buffer), nodes => new parser_1.List([new parser_1.Node((0, dom_1.html)('i', (0, dom_1.defrag)((0, util_1.unwrap)(nodes))))])))));
7460
+ }) => bs && buffer.import(bs).push(new parser_1.Node("\u0018" /* Command.Cancel */)) && buffer)), nodes => new parser_1.List([new parser_1.Node((0, dom_1.html)('i', (0, dom_1.defrag)((0, util_1.unwrap)(nodes))))]))));
7416
7461
 
7417
7462
  /***/ },
7418
7463
 
@@ -7589,23 +7634,23 @@ const indexee_1 = __webpack_require__(7610);
7589
7634
  const visibility_1 = __webpack_require__(6364);
7590
7635
  const util_1 = __webpack_require__(4992);
7591
7636
  const dom_1 = __webpack_require__(394);
7592
- exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, util_1.repeat)('==', visibility_1.beforeNonblank, (0, combinator_1.surround)('', (0, combinator_1.state)(2 /* State.mark */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), '==', visibility_1.afterNonblank)), '==', false, [], ([, bs], {
7637
+ exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('==', visibility_1.beforeNonblank, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.surround)('', (0, combinator_1.state)(2 /* State.mark */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), '==', visibility_1.afterNonblank)), '==', false, [], ([, bs], {
7593
7638
  buffer
7594
7639
  }) => buffer.import(bs), ([, bs], {
7595
7640
  buffer
7596
- }) => bs && buffer.import(bs).push(new parser_1.Node("\u0018" /* Command.Cancel */)) && buffer), (nodes, {
7641
+ }) => bs && buffer.import(bs).push(new parser_1.Node("\u0018" /* Command.Cancel */)) && buffer)), (nodes, {
7597
7642
  id,
7598
7643
  state
7599
7644
  }, nest) => {
7600
7645
  const el = (0, dom_1.html)('mark', (0, dom_1.defrag)((0, util_1.unwrap)(nodes)));
7601
7646
  if (state & 251 /* State.linkers */ || nest) return new parser_1.List([new parser_1.Node(el)]);
7602
7647
  (0, dom_1.define)(el, {
7603
- id: (0, indexee_1.identity)('mark', id, (0, indexee_1.signature)(el))
7648
+ id: (0, indexee_1.identity)('mark', id, (0, indexee_1.signature)(el.cloneNode(true)))
7604
7649
  });
7605
7650
  return el.id ? new parser_1.List([new parser_1.Node(el), new parser_1.Node((0, dom_1.html)('a', {
7606
7651
  href: `#${el.id}`
7607
7652
  }))]) : new parser_1.List([new parser_1.Node(el)]);
7608
- }))));
7653
+ })));
7609
7654
 
7610
7655
  /***/ },
7611
7656
 
@@ -7728,7 +7773,7 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* S
7728
7773
  target: '_blank'
7729
7774
  }, [el]))]);
7730
7775
  }))));
7731
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, [3 | 16 /* Backtrack.escapable */], undefined, () => new parser_1.List()), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, [3 | 16 /* Backtrack.escapable */], undefined, () => new parser_1.List()), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, [3 | 16 /* Backtrack.escapable */], undefined, () => new parser_1.List()), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true, [3 | 16 /* Backtrack.escapable */], undefined, () => new parser_1.List())])));
7776
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')')), (0, source_1.str)(')'), true, [3 | 16 /* Backtrack.escapable */], undefined, () => new parser_1.List()), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']')), (0, source_1.str)(']'), true, [3 | 16 /* Backtrack.escapable */], undefined, () => new parser_1.List()), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}')), (0, source_1.str)('}'), true, [3 | 16 /* Backtrack.escapable */], undefined, () => new parser_1.List()), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"'))), (0, source_1.str)('"'), true, [3 | 16 /* Backtrack.escapable */], undefined, () => new parser_1.List())]));
7732
7777
  const option = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, combinator_1.open)(/ /y, (0, source_1.str)(/[1-9][0-9]*/y)), (0, source_1.str)(/[x:]/y), (0, source_1.str)(/[1-9][0-9]*(?=[ }])/y), false, [], ([[{
7733
7778
  value: a
7734
7779
  }], [{
@@ -8228,31 +8273,44 @@ function* note(target, notes, opts = {}, bottom = null) {
8228
8273
  yield* (0, exports.reference)(target, notes?.references, opts, bottom);
8229
8274
  }
8230
8275
  exports.note = note;
8231
- exports.annotation = build('annotation', n => `*${n}`, 'h1, h2, h3, h4, h5, h6, aside.aside, hr');
8232
- exports.reference = build('reference', (n, abbr) => `[${abbr || n}]`);
8233
- function build(syntax, marker, splitter = '') {
8276
+ exports.annotation = build('annotation', 'sup.annotation:not(.annotations .annotation)', n => `*${n}`, 'h1, h2, h3, h4, h5, h6, aside.aside, hr');
8277
+ exports.reference = build('reference', 'sup.reference:not(.references .reference)', (n, abbr) => `[${abbr || n}]`);
8278
+ // Referenceを含むAnnotationの重複排除は両構文が互いに処理済みであることを必要とするため
8279
+ // 構文ごとに各1回の処理では不可能
8280
+ function build(syntax, query, marker, splitter = '') {
8234
8281
  splitter &&= `${splitter}, .${syntax}s`;
8235
- // Referenceを含むAnnotationの重複排除は両構文が互いに処理済みであることを必要とするため
8236
- // 構文ごとに各1回の処理では不可能
8237
- const memory = (0, memoize_1.memoize)(ref => {
8238
- const content = ref.firstElementChild;
8239
- content.replaceWith(content.cloneNode());
8240
- const abbr = ref.getAttribute('data-abbr') ?? '';
8241
- const identifier = abbr ? (0, indexee_1.identity)('', undefined, abbr.match(/^(?:\S+ )+?(?:(?:January|February|March|April|May|June|August|September|October|November|December) \d{1,2}(?:-\d{0,2})?, \d{1,4}(?:-\d{0,4})?[a-z]?|n\.d\.)(?=,|$)/)?.[0] ?? abbr.match(/^[^,\s]+(?:,? [^,\s]+)*?(?: \d{1,4}(?:-\d{0,4})?[a-z]?(?=,|$)|(?=,(?: [a-z]+\.?)? [0-9]))/)?.[0] ?? abbr)?.slice(2) || '' : (0, indexee_1.identity)('mark', undefined, (0, indexee_1.signature)(content))?.slice(6) || '';
8242
- return {
8243
- content,
8244
- identifier,
8245
- abbr,
8246
- text: (0, indexee_1.text)(content).trim()
8247
- };
8248
- }, new WeakMap());
8282
+ const refMemoryCaller = (0, memoize_1.memoize)(target => new Map() ?? target, new WeakMap());
8249
8283
  return function* (target, note, opts = {}, bottom = null) {
8284
+ const refMemory = refMemoryCaller(target);
8285
+ const refInfoCaller = (0, memoize_1.memoize)(ref => {
8286
+ const content = ref.firstElementChild;
8287
+ const abbr = ref.getAttribute('data-abbr') ?? '';
8288
+ const clone = content.cloneNode(true);
8289
+ const txt = (0, indexee_1.text)(clone).trim();
8290
+ const identifier = abbr ? (0, indexee_1.identity)('', undefined, abbr.match(/^(?:\S+ )+?(?:(?:January|February|March|April|May|June|August|September|October|November|December) \d{1,2}(?:-\d{0,2})?, \d{1,4}(?:-\d{0,4})?[a-z]?|n\.d\.)(?=,|$)/)?.[0] ?? abbr.match(/^[^,\s]+(?:,? [^,\s]+)*?(?: \d{1,4}(?:-\d{0,4})?[a-z]?(?=,|$)|(?=,(?: [a-z]+\.?)? [0-9]))/)?.[0] ?? abbr)?.slice(2) || '' : (0, indexee_1.identity)('mark', undefined, (0, indexee_1.signature)(clone))?.slice(6) || '';
8291
+ return {
8292
+ content,
8293
+ identifier,
8294
+ abbr,
8295
+ text: txt
8296
+ };
8297
+ }, refMemory);
8298
+ for (const [ref, {
8299
+ content
8300
+ }] of refMemory) {
8301
+ content.replaceWith(content.cloneNode(true));
8302
+ ref.prepend(content);
8303
+ refMemory.delete(ref);
8304
+ }
8250
8305
  const defs = new Map();
8251
- const refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`);
8252
- const titles = new Map();
8253
- const defIndexes = new Map();
8254
- const refSubindexes = new Map();
8255
- const defSubindexes = new Map();
8306
+ const refs = target.querySelectorAll(`${query}:not(.disabled)`);
8307
+ const identifierInfoCaller = (0, memoize_1.memoize)(identifier => ({
8308
+ defIndex: 0,
8309
+ defSubindex: 0,
8310
+ refSubindex: 0,
8311
+ title: '' && 0,
8312
+ queue: []
8313
+ }));
8256
8314
  const scope = target instanceof Element ? ':scope > ' : '';
8257
8315
  const splitters = splitter ? target.querySelectorAll(`${scope}:is(${splitter})`) : [];
8258
8316
  let iSplitters = 0;
@@ -8261,10 +8319,6 @@ function build(syntax, marker, splitter = '') {
8261
8319
  let refIndex = 0;
8262
8320
  for (let len = refs.length, i = 0; i < len; ++i) {
8263
8321
  const ref = refs[i];
8264
- if (!target.contains(ref)) {
8265
- yield;
8266
- continue;
8267
- }
8268
8322
  if (splitter) for (let el; el = splitters[iSplitters], el?.compareDocumentPosition(ref) & Node.DOCUMENT_POSITION_FOLLOWING; ++iSplitters) {
8269
8323
  if (~iSplitters << 32 - 8 === 0) yield;
8270
8324
  if (!scope && el.parentNode !== target) continue;
@@ -8285,29 +8339,35 @@ function build(syntax, marker, splitter = '') {
8285
8339
  identifier,
8286
8340
  abbr,
8287
8341
  text
8288
- } = memory(ref);
8289
- const refSubindex = refSubindexes.get(identifier) + 1 || 1;
8290
- refSubindexes.set(identifier, refSubindex);
8342
+ } = refInfoCaller(ref);
8343
+ const info = identifierInfoCaller(identifier);
8344
+ const refSubindex = ++info.refSubindex;
8291
8345
  const refId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:ref:${identifier}:${refSubindex}` : undefined;
8292
8346
  const initial = splitter ? !defs.has(identifier) : refSubindex === 1;
8293
- const defSubindex = defSubindexes?.get(identifier) + +initial || 1;
8294
- initial && defSubindexes?.set(identifier, defSubindex);
8347
+ const defSubindex = initial ? ++info.defSubindex : info.defSubindex;
8295
8348
  const defId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:def:${identifier}${splitter && `:${defSubindex}`}` : undefined;
8296
8349
  const def = initial ? (0, dom_1.html)('li', {
8297
8350
  id: defId,
8298
8351
  'data-marker': note ? undefined : marker(total + defs.size + 1, abbr)
8299
- }, [content.cloneNode(true), (0, dom_1.html)('sup')]) : defs.get(identifier);
8352
+ }, [content, (0, dom_1.html)('sup')]) : defs.get(identifier);
8300
8353
  initial && defs.set(identifier, def);
8301
- const defIndex = initial ? total + defs.size : defIndexes.get(def);
8302
- initial && defIndexes.set(def, defIndex);
8303
- const title = initial ? text : titles.get(identifier);
8304
- initial && titles.set(identifier, title);
8305
- ref.childElementCount > 1 && ref.lastElementChild.remove();
8354
+ const defIndex = initial ? info.defIndex = total + defs.size : info.defIndex;
8355
+ const title = info.title ||= text;
8306
8356
  (0, dom_1.define)(ref, {
8307
8357
  id: refId,
8308
8358
  class: opts.id !== '' ? undefined : void ref.classList.add('disabled'),
8309
8359
  title
8310
- });
8360
+ }, []);
8361
+ if (title && info.queue.length > 0) {
8362
+ for (const ref of info.queue) {
8363
+ (0, dom_1.define)(ref, {
8364
+ title
8365
+ });
8366
+ (0, util_1.unmarkInvalid)(ref);
8367
+ }
8368
+ info.queue = [];
8369
+ def.firstElementChild.replaceWith(content);
8370
+ }
8311
8371
  switch (ref.getAttribute('data-invalid-syntax')) {
8312
8372
  case 'format':
8313
8373
  case 'content':
@@ -8315,11 +8375,12 @@ function build(syntax, marker, splitter = '') {
8315
8375
  }
8316
8376
  format ??= abbr ? 'abbr' : 'number';
8317
8377
  if (!ref.classList.contains('invalid')) switch (true) {
8318
- case format === 'number' ? !!abbr : !abbr:
8378
+ case format === 'number' ? abbr !== '' : abbr === '':
8319
8379
  (0, util_1.markInvalid)(ref, syntax, 'format', 'Notation format must be consistent with numbers or abbreviations');
8320
8380
  break;
8321
- case !title:
8381
+ case title === '':
8322
8382
  (0, util_1.markInvalid)(ref, syntax, 'content', 'Missing the content');
8383
+ info.queue.push(ref);
8323
8384
  break;
8324
8385
  }
8325
8386
  yield ref.appendChild((0, dom_1.html)('a', {
package/markdown.d.ts CHANGED
@@ -642,7 +642,7 @@ export namespace MarkdownParser {
642
642
  export interface AnnotationParser extends
643
643
  // ((abc))
644
644
  Inline<'annotation'>,
645
- Parser<HTMLElement, Context, [
645
+ Parser<string | HTMLElement, Context, [
646
646
  InlineParser,
647
647
  ]> {
648
648
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.296.4",
3
+ "version": "0.297.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",
@@ -192,19 +192,16 @@ describe('Unit: parser/api/bind', () => {
192
192
  [
193
193
  html('p', [
194
194
  html('sup', { class: "reference", id: "reference::ref:1:1", title: "1" }, [
195
- html('span'),
196
195
  html('a', { href: "#reference::def:1" }, '[1]'),
197
196
  ]),
198
197
  ]).outerHTML,
199
198
  html('p', [
200
199
  html('sup', { class: "reference", id: "reference::ref:2:1", title: "2" }, [
201
- html('span'),
202
200
  html('a', { href: "#reference::def:2" }, '[2]'),
203
201
  ]),
204
202
  ]).outerHTML,
205
203
  html('p', [
206
204
  html('sup', { class: "reference", id: "reference::ref:3:1", title: "3" }, [
207
- html('span'),
208
205
  html('a', { href: "#reference::def:3" }, '[3]'),
209
206
  ]),
210
207
  ]).outerHTML,