securemark 0.300.4 → 0.300.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +215 -151
  3. package/markdown.d.ts +36 -36
  4. package/package.json +1 -1
  5. package/src/api/bind.ts +5 -2
  6. package/src/api/header.ts +1 -1
  7. package/src/api/parse.test.ts +0 -27
  8. package/src/api/parse.ts +8 -2
  9. package/src/combinator/effect/backtrack.ts +19 -7
  10. package/src/combinator/parser/list.ts +13 -15
  11. package/src/combinator/parser.ts +3 -5
  12. package/src/debug.test.ts +3 -0
  13. package/src/parser/autolink.ts +2 -2
  14. package/src/parser/block/blockquote.test.ts +4 -4
  15. package/src/parser/block/blockquote.ts +2 -1
  16. package/src/parser/block/extension/aside.test.ts +3 -3
  17. package/src/parser/block/extension/aside.ts +2 -1
  18. package/src/parser/block/extension/example.test.ts +3 -3
  19. package/src/parser/block/extension/example.ts +3 -1
  20. package/src/parser/{header.test.ts → block/header.test.ts} +3 -3
  21. package/src/parser/{header.ts → block/header.ts} +7 -7
  22. package/src/parser/block/reply/cite.ts +2 -3
  23. package/src/parser/block/reply/quote.ts +1 -2
  24. package/src/parser/block/reply.ts +1 -2
  25. package/src/parser/block.ts +6 -5
  26. package/src/parser/context.ts +6 -4
  27. package/src/parser/document.ts +22 -11
  28. package/src/parser/inline/annotation.test.ts +24 -0
  29. package/src/parser/inline/annotation.ts +20 -7
  30. package/src/parser/inline/extension/index.ts +1 -2
  31. package/src/parser/inline/extension/indexee.ts +1 -2
  32. package/src/parser/inline/extension/label.ts +10 -6
  33. package/src/parser/inline/html.ts +1 -2
  34. package/src/parser/inline/htmlentity.ts +5 -4
  35. package/src/parser/inline/media.ts +2 -3
  36. package/src/parser/inline/reference.ts +3 -3
  37. package/src/parser/inline.ts +2 -2
  38. package/src/parser/node.ts +0 -5
  39. package/src/parser/segment.ts +2 -2
  40. package/src/parser/source/escapable.ts +5 -6
  41. package/src/parser/source/str.ts +3 -2
  42. package/src/parser/source/text.ts +3 -4
  43. package/src/parser/source/unescapable.ts +3 -4
  44. package/src/parser/source.ts +2 -2
  45. package/src/parser/util.ts +9 -0
  46. package/src/parser/visibility.ts +4 -5
  47. package/src/processor/figure.test.ts +35 -24
  48. package/src/processor/figure.ts +8 -23
  49. package/src/processor/note.test.ts +71 -25
  50. package/src/processor/note.ts +28 -24
  51. package/src/util/toc.ts +2 -3
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.300.4 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.300.6 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"));
@@ -2526,7 +2526,7 @@ function bind(target, settings) {
2526
2526
  if (rev !== revision) return yield {
2527
2527
  type: 'cancel'
2528
2528
  };
2529
- for (const el of (0, figure_1.figure)(next(0)?.parentNode ?? target, settings.notes, options)) {
2529
+ for (const el of (0, figure_1.figure)(next(0)?.parentNode ?? target, output.labels.pop(), settings.notes, options)) {
2530
2530
  el ? yield {
2531
2531
  type: 'figure'
2532
2532
  } : yield {
@@ -2537,7 +2537,10 @@ function bind(target, settings) {
2537
2537
  type: 'cancel'
2538
2538
  };
2539
2539
  }
2540
- for (const el of (0, note_1.note)(next(0)?.parentNode ?? target, settings.notes, options, bottom)) {
2540
+ for (const el of (0, note_1.note)(next(0)?.parentNode ?? target, {
2541
+ annotations: output.annotations.pop(),
2542
+ references: output.references.pop()
2543
+ }, settings.notes, options, bottom)) {
2541
2544
  el ? yield {
2542
2545
  type: 'note',
2543
2546
  value: el
@@ -2647,7 +2650,7 @@ Object.defineProperty(exports, "__esModule", ({
2647
2650
  exports.headers = exports.header = void 0;
2648
2651
  const context_1 = __webpack_require__(8669);
2649
2652
  const parser_1 = __webpack_require__(3360);
2650
- const header_1 = __webpack_require__(3009);
2653
+ const header_1 = __webpack_require__(2855);
2651
2654
  function header(source) {
2652
2655
  const [, pos = 0] = parse(source);
2653
2656
  return source.slice(0, pos);
@@ -3353,6 +3356,7 @@ Object.defineProperty(exports, "__esModule", ({
3353
3356
  }));
3354
3357
  exports.backtrack = exports.Backtrack = void 0;
3355
3358
  const state_1 = __webpack_require__(9440);
3359
+ const parser_1 = __webpack_require__(3360);
3356
3360
  class Backtrack {
3357
3361
  constructor(scope) {
3358
3362
  this.scope = scope;
@@ -3377,8 +3381,8 @@ class Backtrack {
3377
3381
  input.range = range;
3378
3382
  input.linebreak = linebreak;
3379
3383
  }
3380
- handle(state) {
3381
- state ? this.unmemory() : this.backtrack();
3384
+ handle(output) {
3385
+ output.state ? this.unmemory() : this.backtrack();
3382
3386
  }
3383
3387
  }
3384
3388
  exports.Backtrack = Backtrack;
@@ -3398,12 +3402,25 @@ function backtrack(parser) {
3398
3402
  linebreak
3399
3403
  });
3400
3404
  output.push();
3405
+ output.labels.push(new parser_1.List());
3406
+ output.annotations.push(new parser_1.List());
3407
+ output.references.push(new parser_1.List());
3401
3408
  return output.context;
3402
3409
  }, parser, ({
3403
3410
  backtrack
3404
3411
  }, output) => {
3405
- output.state ? output.flat() : output.pop();
3406
- backtrack.handle(output.state);
3412
+ backtrack.handle(output);
3413
+ if (output.state) {
3414
+ output.import(output.pop());
3415
+ output.labels.at(-2).import(output.labels.pop());
3416
+ output.annotations.at(-2).import(output.annotations.pop());
3417
+ output.references.at(-2).import(output.references.pop());
3418
+ } else {
3419
+ output.pop();
3420
+ output.labels.pop();
3421
+ output.annotations.pop();
3422
+ output.references.pop();
3423
+ }
3407
3424
  return output.context;
3408
3425
  }]);
3409
3426
  }
@@ -3765,6 +3782,9 @@ class Output {
3765
3782
  this.state = true;
3766
3783
  this.context = Result.succ;
3767
3784
  this.error = undefined;
3785
+ this.labels = [new list_1.List()];
3786
+ this.annotations = [new list_1.List()];
3787
+ this.references = [new list_1.List()];
3768
3788
  }
3769
3789
  peek() {
3770
3790
  return this.data.at(-1);
@@ -3785,10 +3805,6 @@ class Output {
3785
3805
  this.data[this.data.length - 1] = list;
3786
3806
  return Result.succ;
3787
3807
  }
3788
- flat() {
3789
- this.import(this.data.pop());
3790
- return Result.succ;
3791
- }
3792
3808
  push(list = new list_1.List()) {
3793
3809
  this.data.push(list);
3794
3810
  }
@@ -3935,6 +3951,9 @@ class List {
3935
3951
  this.push(nodes[i]);
3936
3952
  }
3937
3953
  }
3954
+ isEmpty() {
3955
+ return this.head === undefined;
3956
+ }
3938
3957
  get tail() {
3939
3958
  return this.head?.next;
3940
3959
  }
@@ -4007,16 +4026,6 @@ class List {
4007
4026
  list.clear();
4008
4027
  return this;
4009
4028
  }
4010
- truncateBefore(node) {
4011
- if (node.prev === undefined) return;
4012
- this.delete(node.prev);
4013
- this.head = node;
4014
- }
4015
- truncateAfter(node) {
4016
- if (node.next === undefined) return;
4017
- this.delete(node.next);
4018
- this.last = node;
4019
- }
4020
4029
  clear() {
4021
4030
  this.length = 0;
4022
4031
  this.head = this.last = undefined;
@@ -4063,8 +4072,9 @@ class List {
4063
4072
  }
4064
4073
  exports.List = List;
4065
4074
  class Node {
4066
- constructor(value, flags = 0) {
4075
+ constructor(value, position = 0, flags = 0) {
4067
4076
  this.value = value;
4077
+ this.position = position;
4068
4078
  this.flags = flags;
4069
4079
  this.next = undefined;
4070
4080
  this.prev = undefined;
@@ -4809,15 +4819,15 @@ Object.defineProperty(exports, "__esModule", ({
4809
4819
  exports.block = void 0;
4810
4820
  const parser_1 = __webpack_require__(3360);
4811
4821
  const combinator_1 = __webpack_require__(3484);
4812
- const header_1 = __webpack_require__(3009);
4822
+ const header_1 = __webpack_require__(2855);
4813
4823
  const source_1 = __webpack_require__(8745);
4814
- const pagebreak_1 = __webpack_require__(2946);
4815
4824
  const heading_1 = __webpack_require__(2778);
4816
4825
  const ulist_1 = __webpack_require__(7595);
4817
4826
  const olist_1 = __webpack_require__(7697);
4818
4827
  const ilist_1 = __webpack_require__(4223);
4819
4828
  const dlist_1 = __webpack_require__(636);
4820
4829
  const table_1 = __webpack_require__(2752);
4830
+ const pagebreak_1 = __webpack_require__(2946);
4821
4831
  const codeblock_1 = __webpack_require__(9194);
4822
4832
  const mathblock_1 = __webpack_require__(4903);
4823
4833
  const extension_1 = __webpack_require__(6193);
@@ -4957,7 +4967,9 @@ const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combina
4957
4967
  }, output) => {
4958
4968
  const doc = output.pop().head.value;
4959
4969
  if (!doc.firstChild) return output.context;
4960
- return output.append(new parser_1.Node((0, dom_1.html)('section', [doc, (0, dom_1.html)('h2', 'References'), notes.references])));
4970
+ return output.append(new parser_1.Node((0, dom_1.html)('section', [
4971
+ // DocumentFragmentを追加すると異常に重くなるので避ける
4972
+ ...doc.children, (0, dom_1.html)('h2', 'References'), notes.references])));
4961
4973
  }]), true))]))), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('blockquote', (0, util_1.unwrap)(ns)))])));
4962
4974
 
4963
4975
  /***/ },
@@ -5152,7 +5164,9 @@ exports.aside = (0, combinator_1.block)((0, combinator_1.recursion)(1 /* Recursi
5152
5164
  return output.append(new parser_1.Node((0, dom_1.html)('aside', {
5153
5165
  id: (0, indexee_1.identity)('index', input.id, heading),
5154
5166
  class: 'aside'
5155
- }, [doc, (0, dom_1.html)('h2', 'References'), notes.references])));
5167
+ }, [
5168
+ // DocumentFragmentを追加すると異常に重くなるので避ける
5169
+ ...doc.children, (0, dom_1.html)('h2', 'References'), notes.references])));
5156
5170
  }])));
5157
5171
 
5158
5172
  /***/ },
@@ -5217,12 +5231,15 @@ const contMD = [(input, output) => {
5217
5231
  notes
5218
5232
  } = input;
5219
5233
  input = input.scope.pop();
5234
+ const doc = output.pop().head.value;
5220
5235
  return output.append(new parser_1.Node((0, dom_1.html)('aside', {
5221
5236
  class: 'example',
5222
5237
  'data-type': 'markdown'
5223
5238
  }, [(0, dom_1.html)('pre', {
5224
5239
  translate: 'no'
5225
- }, input.memory.body.slice(0, input.memory.body.at(-2) === '\r' ? -2 : -1)), (0, dom_1.html)('hr'), (0, dom_1.html)('section', [output.pop().head.value, (0, dom_1.html)('h2', 'References'), notes.references])])));
5240
+ }, input.memory.body.slice(0, input.memory.body.at(-2) === '\r' ? -2 : -1)), (0, dom_1.html)('hr'), (0, dom_1.html)('section', [
5241
+ // DocumentFragmentを追加すると異常に重くなるので避ける
5242
+ ...doc.children, (0, dom_1.html)('h2', 'References'), notes.references])])));
5226
5243
  }];
5227
5244
  const contMath = [(input, output) => {
5228
5245
  input.scope.push(`$$\n${input.memory.body}$$`);
@@ -5766,6 +5783,64 @@ function format(rows) {
5766
5783
 
5767
5784
  /***/ },
5768
5785
 
5786
+ /***/ 2855
5787
+ (__unused_webpack_module, exports, __webpack_require__) {
5788
+
5789
+ "use strict";
5790
+
5791
+
5792
+ Object.defineProperty(exports, "__esModule", ({
5793
+ value: true
5794
+ }));
5795
+ exports.header = void 0;
5796
+ const parser_1 = __webpack_require__(3360);
5797
+ const combinator_1 = __webpack_require__(3484);
5798
+ const source_1 = __webpack_require__(8745);
5799
+ const util_1 = __webpack_require__(4992);
5800
+ const url_1 = __webpack_require__(1904);
5801
+ const dom_1 = __webpack_require__(394);
5802
+ exports.header = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/---+[^\S\r\n]*\r?\n(?=\S)/y, (0, combinator_1.inits)([(0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.validate)(input => input.header, (0, combinator_1.focus)(/(---+)[^\S\r\n]*\r?\n(?:[a-z][0-9a-z]*(?:-[0-9a-z]+)*:[ \t]+\S[^\r\n]*\r?\n){1,32}\1[^\S\r\n]*(?:$|\r?\n)/yi, (0, combinator_1.scope)(({
5803
+ source
5804
+ }) => source.slice(source.indexOf('\n') + 1, source.trimEnd().lastIndexOf('\n')), (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([field])), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('aside', {
5805
+ class: 'header'
5806
+ }, [(0, dom_1.html)('details', {
5807
+ open: ''
5808
+ }, (0, dom_1.defrag)((0, util_1.unwrap)(ns.unshift(new parser_1.Node((0, dom_1.html)('summary', 'Header'))))))]))])), false))), (input, output) => {
5809
+ const {
5810
+ source,
5811
+ position
5812
+ } = input;
5813
+ input.position += source.length;
5814
+ return output.append(new parser_1.Node((0, dom_1.html)('pre', {
5815
+ class: 'invalid',
5816
+ translate: 'no',
5817
+ ...(0, util_1.invalid)('header', 'syntax', 'Invalid syntax')
5818
+ }, source.slice(position))));
5819
+ }])), (0, combinator_1.clear)((0, source_1.str)(/[^\S\r\n]*\r?\n/y))])));
5820
+ const field = (0, combinator_1.line)((input, output) => {
5821
+ const {
5822
+ source,
5823
+ position
5824
+ } = input;
5825
+ const name = source.slice(position, source.indexOf(':', position));
5826
+ const value = source.slice(position + name.length + 1).trim();
5827
+ if (name.toLowerCase() === 'url') {
5828
+ // @ts-expect-error
5829
+ input.url = new url_1.ReadonlyURL(value);
5830
+ }
5831
+ return output.append(new parser_1.Node((0, dom_1.html)('div', {
5832
+ class: 'field',
5833
+ 'data-name': name.toLowerCase(),
5834
+ 'data-value': value
5835
+ }, [(0, dom_1.html)('span', {
5836
+ class: 'field-name'
5837
+ }, name), ': ', (0, dom_1.html)('span', {
5838
+ class: 'field-value'
5839
+ }, value)])));
5840
+ });
5841
+
5842
+ /***/ },
5843
+
5769
5844
  /***/ 2778
5770
5845
  (__unused_webpack_module, exports, __webpack_require__) {
5771
5846
 
@@ -6096,7 +6171,7 @@ const delimiter = new RegExp(`${cite_1.syntax.source}|${quote_1.syntax.source}`,
6096
6171
  exports.reply = (0, combinator_1.block)((0, combinator_1.validate)(cite_1.syntax, (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([cite_1.cite, quote_1.quote, (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.anyline, delimiter), (0, visibility_1.visualize)((0, combinator_1.fmap)((0, combinator_1.some)(inline_1.inline), (ns, {
6097
6172
  source,
6098
6173
  position
6099
- }) => source[position - 1] === '\n' ? ns : ns.push(new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.blank */)))))])), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('p', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns)))))]))));
6174
+ }) => source[position - 1] === '\n' ? ns : ns.push(new parser_1.Node((0, dom_1.html)('br'), position, 1 /* Node.Flag.blank */)))))])), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('p', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns)))))]))));
6100
6175
 
6101
6176
  /***/ },
6102
6177
 
@@ -6132,7 +6207,9 @@ exports.cite = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.op
6132
6207
  target: '_blank'
6133
6208
  }, source)))), (0, combinator_1.focus)(/>>\S+(?=\s*$)/y, ({
6134
6209
  source
6135
- }, output) => output.append(new parser_1.Node(source)))])), nodes => {
6210
+ }, output) => output.append(new parser_1.Node(source)))])), (nodes, {
6211
+ position
6212
+ }) => {
6136
6213
  const quotes = nodes.head.value;
6137
6214
  const node = nodes.last.value;
6138
6215
  return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', typeof node === 'object' ? {
@@ -6142,7 +6219,7 @@ exports.cite = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.op
6142
6219
  ...(0, util_1.invalid)('cite', 'syntax', 'Invalid syntax')
6143
6220
  }, (0, dom_1.defrag)([`${quotes}>`, typeof node === 'object' ? (0, dom_1.define)(node, {
6144
6221
  'data-depth': `${quotes.length + 1}`
6145
- }, node.innerText.slice(1)) : node.slice(1)]))), new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.blank */)]);
6222
+ }, node.innerText.slice(1)) : node.slice(1)]))), new parser_1.Node((0, dom_1.html)('br'), position, 1 /* Node.Flag.blank */)]);
6146
6223
  }));
6147
6224
 
6148
6225
  /***/ },
@@ -6172,7 +6249,7 @@ exports.quote = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.
6172
6249
  math_1.math, autolink_1.autolink, source_1.unescsource])), true)), (ns, {
6173
6250
  source,
6174
6251
  position
6175
- }) => new parser_1.List([new parser_1.Node(source[position - 1] === '\n' ? ns.pop().value : (0, dom_1.html)('br'), 1 /* Flag.blank */), new parser_1.Node((0, dom_1.html)('span', {
6252
+ }) => new parser_1.List([new parser_1.Node(source[position - 1] === '\n' ? ns.pop().value : (0, dom_1.html)('br'), position, 1 /* Node.Flag.blank */), new parser_1.Node((0, dom_1.html)('span', {
6176
6253
  class: 'quote'
6177
6254
  }, (0, dom_1.defrag)((0, util_1.unwrap)(ns))))].reverse())), false);
6178
6255
 
@@ -6354,7 +6431,10 @@ class Input extends parser_1.Input {
6354
6431
  this.resources ??= {
6355
6432
  clock: -1,
6356
6433
  interval: 200,
6357
- recursions: [20 || 0 /* Recursion.document */, 100 || 0 /* Recursion.block */, 100 || 0 /* Recursion.inline */, 100 || 0 /* Recursion.bracket */]
6434
+ recursions: [
6435
+ // DOMの垂直的追加の繰り返しが加速的に異常に重くなる。
6436
+ // ブラウザの問題でありアルゴリズムの計算量は問題ない。
6437
+ 10 || 0 /* Recursion.document */, 100 || 0 /* Recursion.block */, 100 || 0 /* Recursion.inline */, 100 || 0 /* Recursion.bracket */]
6358
6438
  };
6359
6439
  this.segment = segment ?? 0 /* Segment.unknown */;
6360
6440
  this.header = header ?? true;
@@ -6380,10 +6460,10 @@ class RecursionCounter {
6380
6460
  stack
6381
6461
  } = this;
6382
6462
  for (; this.index > 0 && stack[this.index - 1] >= depth; --this.index);
6383
- // 内側から数えるので無効化処理できずエラーを投げるしかない。
6384
- if (this.index === this.limit) return new Error(`Too much recursion`);
6385
6463
  stack[this.index] = depth;
6386
6464
  ++this.index;
6465
+ // 内側から数えるので無効化処理できない。
6466
+ return this.index <= this.limit;
6387
6467
  }
6388
6468
  }
6389
6469
 
@@ -6409,7 +6489,7 @@ const figure_1 = __webpack_require__(5815);
6409
6489
  const note_1 = __webpack_require__(8119);
6410
6490
  const dom_1 = __webpack_require__(394);
6411
6491
  exports.document = (() => {
6412
- const loop = (0, parser_2.build)(segment_1.parser, block_1.block);
6492
+ const document = (0, parser_2.build)(segment_1.parser, block_1.block);
6413
6493
  return (0, combinator_1.always)([(input, output) => {
6414
6494
  input.id = input.id === '' ? '' : input.local ? (0, util_1.randomID)() : input.id;
6415
6495
  input.memory = {
@@ -6419,18 +6499,29 @@ exports.document = (() => {
6419
6499
  })
6420
6500
  };
6421
6501
  output.push();
6502
+ output.labels.push(new parser_1.List());
6503
+ output.annotations.push(new parser_1.List());
6504
+ output.references.push(new parser_1.List());
6422
6505
  return output.context;
6423
- }, (0, combinator_1.recursion)(0 /* Recursion.document */, (0, combinator_1.force)(() => loop)), (input, output) => {
6506
+ }, (0, combinator_1.recursion)(0 /* Recursion.document */, (0, combinator_1.force)(() => document)), (input, output) => {
6424
6507
  const {
6425
6508
  memory
6426
6509
  } = input;
6427
6510
  const doc = memory.doc = (0, dom_1.frag)((0, util_1.unwrap)(output.pop()));
6428
6511
  output.append(new parser_1.Node(doc));
6429
- if (input.test && !input.local) return parser_1.Result.skip;
6512
+ if (input.test && !input.local) {
6513
+ output.labels.at(-2).import(output.labels.pop());
6514
+ output.annotations.at(-2).import(output.annotations.pop());
6515
+ output.references.at(-2).import(output.references.pop());
6516
+ return parser_1.Result.skip;
6517
+ }
6430
6518
  memory.orphan = !memory.references.parentNode;
6431
6519
  memory.orphan && doc.appendChild(memory.references);
6432
6520
  return output.context;
6433
- }, input => conv((0, figure_1.figure)(input.memory.doc, input.memory, input)), input => conv((0, note_1.note)(input.memory.doc, input.memory, input)), (input, output) => {
6521
+ }, (input, output) => conv((0, figure_1.figure)(input.memory.doc, output.labels.pop(), input.memory, input)), (input, output) => conv((0, note_1.note)(input.memory.doc, {
6522
+ annotations: output.annotations.pop(),
6523
+ references: output.references.pop()
6524
+ }, input.memory, input)), (input, output) => {
6434
6525
  const {
6435
6526
  memory
6436
6527
  } = input;
@@ -6446,64 +6537,6 @@ function conv(iterable) {
6446
6537
 
6447
6538
  /***/ },
6448
6539
 
6449
- /***/ 3009
6450
- (__unused_webpack_module, exports, __webpack_require__) {
6451
-
6452
- "use strict";
6453
-
6454
-
6455
- Object.defineProperty(exports, "__esModule", ({
6456
- value: true
6457
- }));
6458
- exports.header = void 0;
6459
- const parser_1 = __webpack_require__(3360);
6460
- const combinator_1 = __webpack_require__(3484);
6461
- const source_1 = __webpack_require__(8745);
6462
- const util_1 = __webpack_require__(4992);
6463
- const url_1 = __webpack_require__(1904);
6464
- const dom_1 = __webpack_require__(394);
6465
- exports.header = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/---+[^\S\r\n]*\r?\n(?=\S)/y, (0, combinator_1.inits)([(0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.validate)(input => input.header, (0, combinator_1.focus)(/(---+)[^\S\r\n]*\r?\n(?:[a-z][0-9a-z]*(?:-[0-9a-z]+)*:[ \t]+\S[^\r\n]*\r?\n){1,32}\1[^\S\r\n]*(?:$|\r?\n)/yi, (0, combinator_1.scope)(({
6466
- source
6467
- }) => source.slice(source.indexOf('\n') + 1, source.trimEnd().lastIndexOf('\n')), (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([field])), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('aside', {
6468
- class: 'header'
6469
- }, [(0, dom_1.html)('details', {
6470
- open: ''
6471
- }, (0, dom_1.defrag)((0, util_1.unwrap)(ns.unshift(new parser_1.Node((0, dom_1.html)('summary', 'Header'))))))]))])), false))), (input, output) => {
6472
- const {
6473
- source,
6474
- position
6475
- } = input;
6476
- input.position += source.length;
6477
- return output.append(new parser_1.Node((0, dom_1.html)('pre', {
6478
- class: 'invalid',
6479
- translate: 'no',
6480
- ...(0, util_1.invalid)('header', 'syntax', 'Invalid syntax')
6481
- }, source.slice(position))));
6482
- }])), (0, combinator_1.clear)((0, source_1.str)(/[^\S\r\n]*\r?\n/y))])));
6483
- const field = (0, combinator_1.line)((input, output) => {
6484
- const {
6485
- source,
6486
- position
6487
- } = input;
6488
- const name = source.slice(position, source.indexOf(':', position));
6489
- const value = source.slice(position + name.length + 1).trim();
6490
- if (name.toLowerCase() === 'url') {
6491
- // @ts-expect-error
6492
- input.url = new url_1.ReadonlyURL(value);
6493
- }
6494
- return output.append(new parser_1.Node((0, dom_1.html)('div', {
6495
- class: 'field',
6496
- 'data-name': name.toLowerCase(),
6497
- 'data-value': value
6498
- }, [(0, dom_1.html)('span', {
6499
- class: 'field-name'
6500
- }, name), ': ', (0, dom_1.html)('span', {
6501
- class: 'field-value'
6502
- }, value)])));
6503
- });
6504
-
6505
- /***/ },
6506
-
6507
6540
  /***/ 7973
6508
6541
  (__unused_webpack_module, exports, __webpack_require__) {
6509
6542
 
@@ -6694,7 +6727,9 @@ const dom_1 = __webpack_require__(394);
6694
6727
  // 常に非常に非効率な処理を行い常時低速化するより三重以上の注釈を禁止して効率性を維持するのが妥当である。
6695
6728
  exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, (0, repeat_1.repeat)('(', visibility_1.beforeNonblank, ')', 2 /* Recursion.inline */, (0, combinator_1.precedence)(1, (0, combinator_1.backtrack)((0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[')', 1]]), ')', false, [], ([, bs], _, output) => output.import(bs), ([, bs], _, output) => bs && output.import(bs.push(new parser_1.Node("\u0018" /* Command.Cancel */)))))), (nodes, input, output, lead, follow) => {
6696
6729
  const {
6730
+ position,
6697
6731
  linebreak,
6732
+ range,
6698
6733
  recursion,
6699
6734
  resources
6700
6735
  } = input;
@@ -6705,11 +6740,22 @@ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1
6705
6740
  class: (0, bracket_1.bracketname)(input, 1, 1)
6706
6741
  }, (0, dom_1.defrag)((0, util_1.unwrap)(nodes))))]);
6707
6742
  }
6708
- output.error ??= recursion.add(resources?.recursions[2 /* Recursion.inline */] ?? resources?.recursions.at(-1));
6709
6743
  input.position += 1;
6710
- return new parser_1.List([new parser_1.Node((0, dom_1.html)('sup', {
6744
+ if (!recursion.add(resources?.recursions[2 /* Recursion.inline */] ?? resources?.recursions.at(-1))) {
6745
+ return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
6746
+ class: 'invalid',
6747
+ ...(0, util_1.invalid)('annotation', 'syntax', 'Recursions must be two or fewer')
6748
+ }, (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(nodes)))))]);
6749
+ }
6750
+ const el = (0, dom_1.html)('sup', {
6711
6751
  class: 'annotation'
6712
- }, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(nodes))))]))]);
6752
+ }, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(nodes))))]);
6753
+ for (let list = output.annotations.at(-1), node = list.last, pos = position - range, i = 0;; node = node.prev, ++i) {
6754
+ if (node && node.position > pos) continue;
6755
+ i === list.length ? list.unshift(new parser_1.Node(el, pos)) : list.insert(new parser_1.Node(el, pos), node?.next);
6756
+ break;
6757
+ }
6758
+ return new parser_1.List([new parser_1.Node(el)]);
6713
6759
  }, (nodes, input, output, prefix, postfix) => {
6714
6760
  for (let i = 0; i < prefix; ++i) {
6715
6761
  nodes.unshift(new parser_1.Node('('));
@@ -7352,7 +7398,7 @@ exports.signature = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('|',
7352
7398
  const index = (0, indexee_1.identity)('index', undefined, ns.foldl((acc, {
7353
7399
  value
7354
7400
  }) => acc + value, ''))?.slice(7);
7355
- if (linebreak !== 0 || ns.head.flags & 1 /* Flag.blank */ || !index) {
7401
+ if (linebreak !== 0 || ns.head.flags & 1 /* Node.Flag.blank */ || !index) {
7356
7402
  return void (0, combinator_1.setBacktrack)(input, 2 | 16 /* Backtrack.escapable */, head);
7357
7403
  }
7358
7404
  return output.append(new parser_1.Node((0, dom_1.html)('span', {
@@ -7391,11 +7437,9 @@ const combinator_1 = __webpack_require__(3484);
7391
7437
  const dom_1 = __webpack_require__(394);
7392
7438
  function indexee(parser) {
7393
7439
  return (0, combinator_1.fmap)(parser, (ns, {
7394
- id,
7395
- local
7440
+ id
7396
7441
  }) => ns.length === 1 ? new parser_1.List([new parser_1.Node((0, dom_1.define)(ns.head.value, {
7397
7442
  id: identity('index', id, ns.head.value),
7398
- class: local ? `${ns.head.value.className} local`.trimStart() : undefined,
7399
7443
  'data-index': null
7400
7444
  }))]) : ns);
7401
7445
  }
@@ -7581,10 +7625,14 @@ exports.test = test;
7581
7625
  exports.segment = (0, combinator_1.clear)((0, combinator_1.union)([(0, combinator_1.backtrack)((0, combinator_1.surround)('[', body, ']')), body]));
7582
7626
  exports.label = (0, combinator_1.constraint)(16 /* State.label */, (0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.backtrack)((0, combinator_1.surround)('[', body, ']', false, [1 | 4 /* Backtrack.common */])), body]), ([{
7583
7627
  value
7584
- }]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('a', {
7585
- class: 'label',
7586
- 'data-label': value.slice(value[1] === '-' ? 0 : 1).toLowerCase()
7587
- }, value))])));
7628
+ }], _, output) => {
7629
+ const label = (0, dom_1.html)('a', {
7630
+ class: 'label',
7631
+ 'data-label': value.slice(value[1] === '-' ? 0 : 1).toLowerCase()
7632
+ }, value);
7633
+ output.labels.at(-1).push(new parser_1.Node(label));
7634
+ return new parser_1.List([new parser_1.Node(label)]);
7635
+ }));
7588
7636
  function number(label, base) {
7589
7637
  return isFixed(label) ? label.slice(label.lastIndexOf('-') + 1) : increment(base, base.split('.').length);
7590
7638
  }
@@ -7662,7 +7710,7 @@ Object.setPrototypeOf(attrspecs, null);
7662
7710
  Object.values(attrspecs).forEach(o => Object.setPrototypeOf(o, null));
7663
7711
  exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)(
7664
7712
  // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
7665
- (0, source_1.str)(/<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[ >])/y), (0, combinator_1.precedence)(9, (0, combinator_1.some)((0, combinator_1.union)([exports.attribute]))), (0, combinator_1.open)((0, source_1.str)(/ ?/y), (0, source_1.str)('>'), true), true, [], ([as, bs = new parser_1.List(), cs], input, output) => output.append(new parser_1.Node(elem(as.head.value.slice(1), false, [...(0, util_1.unwrap)(as.import(bs).import(cs))], new parser_1.List(), new parser_1.List(), input), as.head.value === '<wbr' ? 1 /* Flag.blank */ : 0 /* Flag.none */)), ([as, bs = new parser_1.List()], input, output) => output.append(new parser_1.Node(elem(as.head.value.slice(1), false, [...(0, util_1.unwrap)(as.import(bs))], new parser_1.List(), new parser_1.List(), input)))), (0, combinator_1.match)(new RegExp(String.raw`<(${exports.TAGS.join('|')})(?=[ >])`, 'y'), (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.precedence)(9, (0, combinator_1.some)(exports.attribute)), (0, combinator_1.open)((0, source_1.str)(/ ?/y), (0, source_1.str)('>'), true), true, [], ([as, bs = new parser_1.List(), cs], _, output) => output.import(as.import(bs).import(cs)), ([as, bs = new parser_1.List()], _, output) => output.import(as.import(bs))),
7713
+ (0, source_1.str)(/<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[ >])/y), (0, combinator_1.precedence)(9, (0, combinator_1.some)((0, combinator_1.union)([exports.attribute]))), (0, combinator_1.open)((0, source_1.str)(/ ?/y), (0, source_1.str)('>'), true), true, [], ([as, bs = new parser_1.List(), cs], input, output) => output.append(new parser_1.Node(elem(as.head.value.slice(1), false, [...(0, util_1.unwrap)(as.import(bs).import(cs))], new parser_1.List(), new parser_1.List(), input), as.head.position, as.head.value === '<wbr' ? 1 /* Node.Flag.blank */ : 0 /* Node.Flag.none */)), ([as, bs = new parser_1.List()], input, output) => output.append(new parser_1.Node(elem(as.head.value.slice(1), false, [...(0, util_1.unwrap)(as.import(bs))], new parser_1.List(), new parser_1.List(), input)))), (0, combinator_1.match)(new RegExp(String.raw`<(${exports.TAGS.join('|')})(?=[ >])`, 'y'), (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.precedence)(9, (0, combinator_1.some)(exports.attribute)), (0, combinator_1.open)((0, source_1.str)(/ ?/y), (0, source_1.str)('>'), true), true, [], ([as, bs = new parser_1.List(), cs], _, output) => output.import(as.import(bs).import(cs)), ([as, bs = new parser_1.List()], _, output) => output.import(as.import(bs))),
7666
7714
  // 不可視のHTML構造が可視構造を変化させるべきでない。
7667
7715
  // 可視のHTMLは優先度変更を検討する。
7668
7716
  // このため`<>`記号は将来的に共通構造を変化させる可能性があり
@@ -7742,11 +7790,12 @@ const combinator_1 = __webpack_require__(3484);
7742
7790
  const source_1 = __webpack_require__(8745);
7743
7791
  const util_1 = __webpack_require__(4992);
7744
7792
  const dom_1 = __webpack_require__(394);
7745
- exports.unsafehtmlentity = (0, combinator_1.surround)((0, source_1.str)('&'), (0, source_1.str)(/[0-9A-Za-z]+/y), (0, source_1.str)(';'), false, [3 | 8 /* Backtrack.unescapable */], ([as, bs, cs], _, output) => output.append(new parser_1.Node(parser(as.head.value + bs.head.value + cs.head.value), (0, node_1.isBlankHTMLEntityName)(bs.head.value) ? 1 /* Flag.blank */ : 0 /* Flag.none */)), ([as, bs], _, output) => output.append(new parser_1.Node(as.head.value + (bs?.head?.value ?? ''))));
7793
+ exports.unsafehtmlentity = (0, combinator_1.surround)((0, source_1.str)('&'), (0, source_1.str)(/[0-9A-Za-z]+/y), (0, source_1.str)(';'), false, [3 | 8 /* Backtrack.unescapable */], ([as, bs, cs], _, output) => output.append(new parser_1.Node(parser(as.head.value + bs.head.value + cs.head.value), as.head.position, (0, node_1.isBlankHTMLEntityName)(bs.head.value) ? 1 /* Node.Flag.blank */ : 0 /* Node.Flag.none */)), ([as, bs], _, output) => output.append(new parser_1.Node(as.head.value + (bs?.head?.value ?? ''))));
7746
7794
  exports.htmlentity = (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([{
7747
7795
  value,
7796
+ position,
7748
7797
  flags
7749
- }]) => new parser_1.List([value.length === 1 || value.at(-1) !== ';' ? new parser_1.Node(value, flags) : new parser_1.Node((0, dom_1.html)('span', {
7798
+ }]) => new parser_1.List([value.length === 1 || value.at(-1) !== ';' ? new parser_1.Node(value, position, flags) : new parser_1.Node((0, dom_1.html)('span', {
7750
7799
  class: 'invalid',
7751
7800
  ...(0, util_1.invalid)('htmlentity', 'syntax', 'Invalid HTML entity')
7752
7801
  }, value))]));
@@ -8053,14 +8102,14 @@ const optspec = {
8053
8102
  };
8054
8103
  Object.setPrototypeOf(optspec, null);
8055
8104
  exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* State.media */, (0, combinator_1.backtrack)((0, combinator_1.open)('!', (0, combinator_1.bind)((0, combinator_1.fmap)((0, combinator_1.tails)([(0, combinator_1.backtrack)((0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']')), ']', true, [3 | 16 /* Backtrack.escapable */, 2 | 32 /* Backtrack.ruby */], ([, ns = new parser_1.List()], input, output) => {
8056
- if (input.linebreak !== 0 || ns.head?.flags & 1 /* Flag.blank */ || ns.head?.value?.[0].trimStart() === '') {
8105
+ if (input.linebreak !== 0 || ns.head?.flags & 1 /* Node.Flag.blank */ || ns.head?.value?.[0].trimStart() === '') {
8057
8106
  const head = input.position - input.range;
8058
8107
  return void (0, combinator_1.setBacktrack)(input, 2 | 16 /* Backtrack.escapable */ | 32 /* Backtrack.ruby */, head);
8059
8108
  }
8060
8109
  return output.import(ns);
8061
8110
  }))), (0, combinator_1.backtrack)((0, combinator_1.dup)((0, combinator_1.surround)(/{(?![{}])/y, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), / ?}/y, false, [], undefined, ([as, bs], _, output) => bs && output.import(as.import(bs).push(new parser_1.Node("\u0018" /* Command.Cancel */))))))]), nodes => nodes.length === 1 ? new parser_1.List([new parser_1.Node(new parser_1.List([new parser_1.Node('')])), nodes.delete(nodes.head)]) : new parser_1.List([new parser_1.Node(new parser_1.List([new parser_1.Node(nodes.head.value.foldl((acc, {
8062
8111
  value
8063
- }) => acc + value, '').trimEnd(), nodes.head.value.head?.flags)])), nodes.delete(nodes.last)])), ([{
8112
+ }) => acc + value, '').trimEnd(), nodes.head.position, nodes.head.value.head?.flags)])), nodes.delete(nodes.last)])), ([{
8064
8113
  value: [{
8065
8114
  value: text
8066
8115
  }]
@@ -8166,7 +8215,9 @@ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64
8166
8215
  (0, combinator_1.setBacktrack)(input, 2 | 64 /* Backtrack.link */, head, 2);
8167
8216
  return;
8168
8217
  }
8169
- return output.import(new parser_1.List([new parser_1.Node((0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns))))]))]));
8218
+ const el = (0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns))))]);
8219
+ output.references.at(-1).push(new parser_1.Node(el));
8220
+ return output.import(new parser_1.List([new parser_1.Node(el)]));
8170
8221
  }, (_, input) => {
8171
8222
  const {
8172
8223
  source,
@@ -8883,29 +8934,29 @@ const escsource = (input, output) => {
8883
8934
  case "\u001B" /* Command.Escape */:
8884
8935
  (0, combinator_1.spend)(input, output, 1);
8885
8936
  input.position += 1;
8886
- return output.append(new parser_1.Node(source.slice(position + 1, position + 2)));
8937
+ return output.append(new parser_1.Node(source.slice(position + 1, position + 2), position));
8887
8938
  case '\\':
8888
8939
  switch (source[position + 1]) {
8889
8940
  case undefined:
8890
8941
  case '\r':
8891
8942
  case '\n':
8892
- return output.append(new parser_1.Node(char));
8943
+ return output.append(new parser_1.Node(char, position));
8893
8944
  default:
8894
8945
  (0, combinator_1.spend)(input, output, 1);
8895
8946
  input.position += 1;
8896
- return output.append(new parser_1.Node(source.slice(position, position + 2)));
8947
+ return output.append(new parser_1.Node(source.slice(position, position + 2), position));
8897
8948
  }
8898
8949
  case '\r':
8899
8950
  return parser_1.Result.succ;
8900
8951
  case '\n':
8901
8952
  input.linebreak ||= source.length - position;
8902
- return output.append(new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.blank */));
8953
+ return output.append(new parser_1.Node((0, dom_1.html)('br'), position, 1 /* Node.Flag.blank */));
8903
8954
  default:
8904
8955
  let i = seek(source, position);
8905
8956
  i -= position;
8906
8957
  (0, combinator_1.spend)(input, output, i - 1);
8907
8958
  input.position += i - 1;
8908
- return output.append(new parser_1.Node(source.slice(position, input.position)));
8959
+ return output.append(new parser_1.Node(source.slice(position, input.position), position));
8909
8960
  }
8910
8961
  };
8911
8962
  exports.escsource = escsource;
@@ -9030,9 +9081,12 @@ const delimiter_1 = __webpack_require__(5486);
9030
9081
  function str(pattern, after) {
9031
9082
  const match = (0, delimiter_1.matcher)(pattern, true, after ? (0, delimiter_1.tester)(after, false) : undefined);
9032
9083
  return (input, output) => {
9084
+ const {
9085
+ position
9086
+ } = input;
9033
9087
  const src = match(input, output);
9034
9088
  if (src === undefined) return;
9035
- return output.append(new parser_1.Node(src));
9089
+ return output.append(new parser_1.Node(src, position));
9036
9090
  };
9037
9091
  }
9038
9092
  exports.str = str;
@@ -9050,7 +9104,7 @@ function strs(char, min = 1, max = -1) {
9050
9104
  }
9051
9105
  if (cnt < min) return;
9052
9106
  input.position = pos;
9053
- return output.append(new parser_1.Node(source.slice(position, input.position)));
9107
+ return output.append(new parser_1.Node(source.slice(position, input.position), position));
9054
9108
  };
9055
9109
  }
9056
9110
  exports.strs = strs;
@@ -9094,13 +9148,13 @@ const text = (input, output) => {
9094
9148
  default:
9095
9149
  (0, combinator_1.spend)(input, output, 1);
9096
9150
  input.position += 1;
9097
- return output.append(new parser_1.Node(source.slice(position + 1, input.position)));
9151
+ return output.append(new parser_1.Node(source.slice(position + 1, input.position), position));
9098
9152
  }
9099
9153
  case '\r':
9100
9154
  return parser_1.Result.succ;
9101
9155
  case '\n':
9102
9156
  input.linebreak ||= source.length - position;
9103
- return output.append(new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.blank */));
9157
+ return output.append(new parser_1.Node((0, dom_1.html)('br'), position, 1 /* Node.Flag.blank */));
9104
9158
  default:
9105
9159
  exports.nonWhitespace.lastIndex = position + 1;
9106
9160
  const s = canSkip(source, position);
@@ -9112,7 +9166,7 @@ const text = (input, output) => {
9112
9166
  input.position += i - 1;
9113
9167
  const linestart = position === 0 || source[position - 1] === '\n';
9114
9168
  if (position === input.position || s && !linestart || lineend) return parser_1.Result.succ;
9115
- return output.append(new parser_1.Node(source.slice(position, input.position)));
9169
+ return output.append(new parser_1.Node(source.slice(position, input.position), position));
9116
9170
  }
9117
9171
  };
9118
9172
  exports.text = text;
@@ -9287,19 +9341,19 @@ const unescsource = (input, output) => {
9287
9341
  case "\u001B" /* Command.Escape */:
9288
9342
  (0, combinator_1.spend)(input, output, 1);
9289
9343
  input.position += 1;
9290
- return output.append(new parser_1.Node(source.slice(position + 1, position + 2)));
9344
+ return output.append(new parser_1.Node(source.slice(position + 1, position + 2), position));
9291
9345
  case '\r':
9292
9346
  return parser_1.Result.succ;
9293
9347
  case '\n':
9294
9348
  input.linebreak ||= source.length - position;
9295
- return output.append(new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.blank */));
9349
+ return output.append(new parser_1.Node((0, dom_1.html)('br'), position, 1 /* Node.Flag.blank */));
9296
9350
  default:
9297
9351
  text_1.nonWhitespace.lastIndex = position + 1;
9298
9352
  let i = (0, text_1.canSkip)(source, position) ? text_1.nonWhitespace.test(source) ? text_1.nonWhitespace.lastIndex - 1 : source.length : next(source, position, state);
9299
9353
  i -= position;
9300
9354
  (0, combinator_1.spend)(input, output, i - 1);
9301
9355
  input.position += i - 1;
9302
- return output.append(new parser_1.Node(source.slice(position, input.position)));
9356
+ return output.append(new parser_1.Node(source.slice(position, input.position), position));
9303
9357
  }
9304
9358
  };
9305
9359
  exports.unescsource = unescsource;
@@ -9438,7 +9492,7 @@ exports.isWhitespace = isWhitespace;
9438
9492
  Object.defineProperty(exports, "__esModule", ({
9439
9493
  value: true
9440
9494
  }));
9441
- exports.randomID = exports.stringify = exports.unmarkInvalid = exports.markInvalid = exports.invalid = exports.unwrap = void 0;
9495
+ exports.collect = exports.randomID = exports.stringify = exports.unmarkInvalid = exports.markInvalid = exports.invalid = exports.unwrap = void 0;
9442
9496
  const random_1 = __webpack_require__(3158);
9443
9497
  const dom_1 = __webpack_require__(394);
9444
9498
  function* unwrap(nodes) {
@@ -9491,6 +9545,15 @@ function randomID() {
9491
9545
  return `random-${(0, random_1.rnd0Z)(6)}`;
9492
9546
  }
9493
9547
  exports.randomID = randomID;
9548
+ function collect(target, selector) {
9549
+ const acc = [];
9550
+ for (let el = target.firstElementChild; el; el = el?.nextElementSibling) {
9551
+ if (!el.matches(selector)) continue;
9552
+ acc.push(el);
9553
+ }
9554
+ return acc;
9555
+ }
9556
+ exports.collect = collect;
9494
9557
 
9495
9558
  /***/ },
9496
9559
 
@@ -9556,7 +9619,7 @@ function isNonblankFirstLine(nodes) {
9556
9619
  if (nodes.length === 0) return true;
9557
9620
  for (const node of nodes) {
9558
9621
  if (isNonblank(node)) return true;
9559
- if (node.flags & 1 /* Flag.blank */ && typeof node.value === 'object' && node.value.tagName === 'BR') break;
9622
+ if (node.flags & 1 /* Node.Flag.blank */ && typeof node.value === 'object' && node.value.tagName === 'BR') break;
9560
9623
  }
9561
9624
  return false;
9562
9625
  }
@@ -9570,7 +9633,7 @@ function isNonblank({
9570
9633
  value: node,
9571
9634
  flags
9572
9635
  }, strpos) {
9573
- if (flags & 1 /* Flag.blank */) return false;
9636
+ if (flags & 1 /* Node.Flag.blank */) return false;
9574
9637
  if (typeof node !== 'string') return true;
9575
9638
  const str = node && strpos !== undefined ? node[strpos >= 0 ? strpos : node.length + strpos] : node;
9576
9639
  switch (str) {
@@ -9607,9 +9670,9 @@ function trimBlankEnd(parser) {
9607
9670
  }
9608
9671
  exports.trimBlankEnd = trimBlankEnd;
9609
9672
  function trimBlankNodeEnd(nodes) {
9610
- const skip = nodes.last && ~nodes.last.flags & 1 /* Flag.blank */ && typeof nodes.last.value === 'object' ? nodes.last.value.className === 'indexer' : false;
9673
+ const skip = nodes.last && ~nodes.last.flags & 1 /* Node.Flag.blank */ && typeof nodes.last.value === 'object' ? nodes.last.value.className === 'indexer' : false;
9611
9674
  for (let node = skip ? nodes.last?.prev : nodes.last; node;) {
9612
- if (~node.flags & 1 /* Flag.blank */) {
9675
+ if (~node.flags & 1 /* Node.Flag.blank */) {
9613
9676
  if (typeof node.value === 'string') {
9614
9677
  const str = node.value.trimEnd();
9615
9678
  if (str.length > 0) {
@@ -9643,16 +9706,16 @@ exports.figure = void 0;
9643
9706
  const label_1 = __webpack_require__(2178);
9644
9707
  const util_1 = __webpack_require__(4992);
9645
9708
  const queue_1 = __webpack_require__(4110);
9646
- const array_1 = __webpack_require__(6876);
9647
9709
  const dom_1 = __webpack_require__(394);
9648
- function* figure(target, notes, opts = {}) {
9649
- const selector = ':is(figure[data-label], h1, h2)';
9650
- const refs = new queue_1.MultiQueue(!notes || notes.references.parentNode === target ? Array.from(target.querySelectorAll('a.label:not(.local)[data-label]'), el => [el.getAttribute('data-label'), el]) : (0, array_1.push)(Array.from(target.querySelectorAll('a.label:not(.local)[data-label]'), el => [el.getAttribute('data-label'), el]), Array.from(notes.references.querySelectorAll('a.label:not(.local)'), el => [el.getAttribute('data-label'), el])));
9710
+ function* figure(target, list, notes, opts = {}) {
9711
+ const refs = new queue_1.MultiQueue(list.foldl((acc, {
9712
+ value: el
9713
+ }) => (acc.push([el.getAttribute('data-label'), el]), acc), []));
9651
9714
  const labels = new Set();
9652
9715
  const numbers = new Map();
9653
9716
  let base = '0';
9654
9717
  let bases = base.split('.');
9655
- for (let defs = target instanceof Element ? target.querySelectorAll(`:scope > ${selector}`) : target.querySelectorAll(`:not(* > *)${selector}`), len = defs.length, i = 0; i < len; ++i) {
9718
+ for (let defs = (0, util_1.collect)(target, 'figure[data-label], h1, h2'), len = defs.length, i = 0; i < len; ++i) {
9656
9719
  if (~i << 32 - 8 === 0) yield;
9657
9720
  const def = defs[i];
9658
9721
  const {
@@ -9727,7 +9790,6 @@ function* figure(target, notes, opts = {}) {
9727
9790
  }
9728
9791
  if (ref.hash.slice(1) === def.id && ref.innerText === figindex) continue;
9729
9792
  (0, dom_1.define)(ref, {
9730
- class: opts.local ? `${ref.className} local` : undefined,
9731
9793
  href: opts.id !== '' ? `#${def.id}` : undefined
9732
9794
  }, figindex);
9733
9795
  }
@@ -9777,7 +9839,7 @@ const indexee_1 = __webpack_require__(7610);
9777
9839
  const util_1 = __webpack_require__(4992);
9778
9840
  const memoize_1 = __webpack_require__(6925);
9779
9841
  const dom_1 = __webpack_require__(394);
9780
- function* note(target, notes, opts = {}, bottom = null) {
9842
+ function* note(target, lists, notes, opts = {}, bottom = null) {
9781
9843
  const referenceRefMemory = referenceRefsMemoryCaller(target);
9782
9844
  const annotationRefMemory = annotationRefsMemoryCaller(target);
9783
9845
  for (const memory of [referenceRefMemory, annotationRefMemory]) {
@@ -9788,17 +9850,21 @@ function* note(target, notes, opts = {}, bottom = null) {
9788
9850
  }
9789
9851
  memory.clear();
9790
9852
  }
9791
- yield* reference(referenceRefMemory, target, notes?.references, opts, bottom);
9792
- yield* annotation(annotationRefMemory, target, notes?.annotations, opts, bottom);
9853
+ yield* reference(referenceRefMemory, target, lists.references.foldl((acc, {
9854
+ value: el
9855
+ }) => (acc.push(el), acc), []), notes?.references, opts, bottom);
9856
+ yield* annotation(annotationRefMemory, target, lists.annotations.foldl((acc, {
9857
+ value: el
9858
+ }) => (acc.push(el), acc), []), notes?.annotations, opts, bottom);
9793
9859
  }
9794
9860
  exports.note = note;
9795
9861
  const annotationRefsMemoryCaller = (0, memoize_1.memoize)(target => new Map() ?? target, new WeakMap());
9796
9862
  const referenceRefsMemoryCaller = (0, memoize_1.memoize)(target => new Map() ?? target, new WeakMap());
9797
- const annotation = build('annotation', 'annotations', '.annotation:not(:is(.annotations, .references) &, .local)', n => `*${n}`, 'h1, h2, h3, h4, h5, h6, aside.aside, hr, .references');
9798
- const reference = build('reference', 'references', '.reference:not(:is(.annotations, .references) &, .local)', (n, abbr) => `[${abbr || n}]`);
9799
- function build(syntax, list, selector, marker, splitter = '') {
9863
+ const annotation = build('annotation', 'annotations', n => `*${n}`, 'h1, h2, h3, h4, h5, h6, aside.aside, hr, .references');
9864
+ const reference = build('reference', 'references', (n, abbr) => `[${abbr || n}]`);
9865
+ function build(syntax, list, marker, splitter = '') {
9800
9866
  splitter &&= `${splitter}, .${list}`;
9801
- return function* (memory, target, note, opts = {}, bottom = null) {
9867
+ return function* (memory, target, refs, note, opts = {}, bottom = null) {
9802
9868
  const refInfoCaller = (0, memoize_1.memoize)(ref => {
9803
9869
  const content = ref.firstElementChild;
9804
9870
  const abbr = ref.getAttribute('data-abbr') ?? '';
@@ -9813,7 +9879,6 @@ function build(syntax, list, selector, marker, splitter = '') {
9813
9879
  };
9814
9880
  }, memory);
9815
9881
  const defs = new Map();
9816
- const refs = target.querySelectorAll(selector);
9817
9882
  const identifierInfoCaller = (0, memoize_1.memoize)(identifier => ({
9818
9883
  defIndex: 0,
9819
9884
  defSubindex: 0,
@@ -9821,7 +9886,7 @@ function build(syntax, list, selector, marker, splitter = '') {
9821
9886
  title: '' && 0,
9822
9887
  queue: []
9823
9888
  }));
9824
- const splitters = splitter ? target instanceof Element ? target.querySelectorAll(`:scope > :is(${splitter}, .${list})`) : target.querySelectorAll(`:not(* > *):is(${splitter}, .${list})`) : [];
9889
+ const splitters = splitter ? (0, util_1.collect)(target, `${splitter}, .${list}`) : [];
9825
9890
  let iSplitters = 0;
9826
9891
  let total = 0;
9827
9892
  let format;
@@ -9831,7 +9896,7 @@ function build(syntax, list, selector, marker, splitter = '') {
9831
9896
  const ref = refs[i];
9832
9897
  if (splitter) for (let splitter; splitter = splitters[iSplitters]; ++iSplitters) {
9833
9898
  const pos = splitter?.compareDocumentPosition(ref) ?? 0;
9834
- if (pos & (Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_POSITION_DISCONNECTED)) break;
9899
+ if (pos & (__webpack_require__.g.Node.DOCUMENT_POSITION_PRECEDING | __webpack_require__.g.Node.DOCUMENT_POSITION_DISCONNECTED)) break;
9835
9900
  if (~iSplitters << 32 - 8 === 0) yield;
9836
9901
  if (splitter.classList.contains(list) && splitter.nextElementSibling !== splitters[iSplitters + 1]) {
9837
9902
  const note = splitter;
@@ -9873,7 +9938,6 @@ function build(syntax, list, selector, marker, splitter = '') {
9873
9938
  const title = info.title ||= text;
9874
9939
  (0, dom_1.define)(ref, {
9875
9940
  id: refId,
9876
- class: opts.local ? `${ref.className} local` : undefined,
9877
9941
  title
9878
9942
  }, []);
9879
9943
  if (title && info.queue.length > 0) {
@@ -10523,12 +10587,12 @@ Object.defineProperty(exports, "__esModule", ({
10523
10587
  value: true
10524
10588
  }));
10525
10589
  exports.toc = void 0;
10590
+ const util_1 = __webpack_require__(4992);
10526
10591
  const array_1 = __webpack_require__(6876);
10527
10592
  const dom_1 = __webpack_require__(394);
10528
- const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]:not(.local)';
10529
10593
  function toc(source) {
10530
10594
  const hs = [];
10531
- for (let es = source.querySelectorAll(selector), len = es.length, i = 0; i < len; ++i) {
10595
+ for (let es = (0, util_1.collect)(source, ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]'), len = es.length, i = 0; i < len; ++i) {
10532
10596
  const el = es[i];
10533
10597
  switch (el.tagName) {
10534
10598
  case 'ASIDE':