securemark 0.300.3 → 0.300.5

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 (53) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +230 -180
  3. package/index.d.ts +2 -2
  4. package/markdown.d.ts +36 -36
  5. package/package.json +1 -1
  6. package/src/api/bind.test.ts +3 -1
  7. package/src/api/bind.ts +6 -3
  8. package/src/api/header.ts +1 -1
  9. package/src/api/parse.ts +8 -2
  10. package/src/combinator/effect/backtrack.ts +19 -7
  11. package/src/combinator/parser/list.ts +13 -15
  12. package/src/combinator/parser.ts +3 -5
  13. package/src/debug.test.ts +3 -0
  14. package/src/parser/autolink.ts +2 -2
  15. package/src/parser/block/blockquote.test.ts +4 -4
  16. package/src/parser/block/blockquote.ts +2 -1
  17. package/src/parser/block/extension/aside.test.ts +3 -3
  18. package/src/parser/block/extension/aside.ts +2 -1
  19. package/src/parser/block/extension/example.test.ts +3 -3
  20. package/src/parser/block/extension/example.ts +3 -1
  21. package/src/parser/{header.test.ts → block/header.test.ts} +3 -3
  22. package/src/parser/{header.ts → block/header.ts} +7 -7
  23. package/src/parser/block/reply/cite.ts +2 -3
  24. package/src/parser/block/reply/quote.ts +1 -2
  25. package/src/parser/block/reply.ts +1 -2
  26. package/src/parser/block.ts +6 -5
  27. package/src/parser/context.ts +3 -1
  28. package/src/parser/document.ts +25 -22
  29. package/src/parser/inline/annotation.ts +11 -5
  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.test.ts +1 -0
  38. package/src/parser/inline.ts +2 -2
  39. package/src/parser/node.ts +0 -5
  40. package/src/parser/repeat.ts +5 -1
  41. package/src/parser/segment.ts +2 -2
  42. package/src/parser/source/escapable.ts +5 -6
  43. package/src/parser/source/str.ts +3 -2
  44. package/src/parser/source/text.ts +3 -4
  45. package/src/parser/source/unescapable.ts +3 -4
  46. package/src/parser/source.ts +2 -2
  47. package/src/parser/util.ts +9 -0
  48. package/src/parser/visibility.ts +4 -5
  49. package/src/processor/figure.test.ts +35 -24
  50. package/src/processor/figure.ts +11 -27
  51. package/src/processor/note.test.ts +71 -25
  52. package/src/processor/note.ts +45 -35
  53. package/src/util/toc.ts +2 -3
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.300.3 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.300.5 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,10 +2526,9 @@ 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
- type: 'figure',
2532
- value: el
2531
+ type: 'figure'
2533
2532
  } : yield {
2534
2533
  type: 'break',
2535
2534
  value: 'figure'
@@ -2538,7 +2537,10 @@ function bind(target, settings) {
2538
2537
  type: 'cancel'
2539
2538
  };
2540
2539
  }
2541
- 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)) {
2542
2544
  el ? yield {
2543
2545
  type: 'note',
2544
2546
  value: el
@@ -2648,7 +2650,7 @@ Object.defineProperty(exports, "__esModule", ({
2648
2650
  exports.headers = exports.header = void 0;
2649
2651
  const context_1 = __webpack_require__(8669);
2650
2652
  const parser_1 = __webpack_require__(3360);
2651
- const header_1 = __webpack_require__(3009);
2653
+ const header_1 = __webpack_require__(2855);
2652
2654
  function header(source) {
2653
2655
  const [, pos = 0] = parse(source);
2654
2656
  return source.slice(0, pos);
@@ -3354,6 +3356,7 @@ Object.defineProperty(exports, "__esModule", ({
3354
3356
  }));
3355
3357
  exports.backtrack = exports.Backtrack = void 0;
3356
3358
  const state_1 = __webpack_require__(9440);
3359
+ const parser_1 = __webpack_require__(3360);
3357
3360
  class Backtrack {
3358
3361
  constructor(scope) {
3359
3362
  this.scope = scope;
@@ -3378,8 +3381,8 @@ class Backtrack {
3378
3381
  input.range = range;
3379
3382
  input.linebreak = linebreak;
3380
3383
  }
3381
- handle(state) {
3382
- state ? this.unmemory() : this.backtrack();
3384
+ handle(output) {
3385
+ output.state ? this.unmemory() : this.backtrack();
3383
3386
  }
3384
3387
  }
3385
3388
  exports.Backtrack = Backtrack;
@@ -3399,12 +3402,25 @@ function backtrack(parser) {
3399
3402
  linebreak
3400
3403
  });
3401
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());
3402
3408
  return output.context;
3403
3409
  }, parser, ({
3404
3410
  backtrack
3405
3411
  }, output) => {
3406
- output.state ? output.flat() : output.pop();
3407
- 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
+ }
3408
3424
  return output.context;
3409
3425
  }]);
3410
3426
  }
@@ -3766,6 +3782,9 @@ class Output {
3766
3782
  this.state = true;
3767
3783
  this.context = Result.succ;
3768
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()];
3769
3788
  }
3770
3789
  peek() {
3771
3790
  return this.data.at(-1);
@@ -3786,10 +3805,6 @@ class Output {
3786
3805
  this.data[this.data.length - 1] = list;
3787
3806
  return Result.succ;
3788
3807
  }
3789
- flat() {
3790
- this.import(this.data.pop());
3791
- return Result.succ;
3792
- }
3793
3808
  push(list = new list_1.List()) {
3794
3809
  this.data.push(list);
3795
3810
  }
@@ -3936,6 +3951,9 @@ class List {
3936
3951
  this.push(nodes[i]);
3937
3952
  }
3938
3953
  }
3954
+ isEmpty() {
3955
+ return this.head === undefined;
3956
+ }
3939
3957
  get tail() {
3940
3958
  return this.head?.next;
3941
3959
  }
@@ -4008,16 +4026,6 @@ class List {
4008
4026
  list.clear();
4009
4027
  return this;
4010
4028
  }
4011
- truncateBefore(node) {
4012
- if (node.prev === undefined) return;
4013
- this.delete(node.prev);
4014
- this.head = node;
4015
- }
4016
- truncateAfter(node) {
4017
- if (node.next === undefined) return;
4018
- this.delete(node.next);
4019
- this.last = node;
4020
- }
4021
4029
  clear() {
4022
4030
  this.length = 0;
4023
4031
  this.head = this.last = undefined;
@@ -4064,8 +4072,9 @@ class List {
4064
4072
  }
4065
4073
  exports.List = List;
4066
4074
  class Node {
4067
- constructor(value, flags = 0) {
4075
+ constructor(value, position = 0, flags = 0) {
4068
4076
  this.value = value;
4077
+ this.position = position;
4069
4078
  this.flags = flags;
4070
4079
  this.next = undefined;
4071
4080
  this.prev = undefined;
@@ -4810,15 +4819,15 @@ Object.defineProperty(exports, "__esModule", ({
4810
4819
  exports.block = void 0;
4811
4820
  const parser_1 = __webpack_require__(3360);
4812
4821
  const combinator_1 = __webpack_require__(3484);
4813
- const header_1 = __webpack_require__(3009);
4822
+ const header_1 = __webpack_require__(2855);
4814
4823
  const source_1 = __webpack_require__(8745);
4815
- const pagebreak_1 = __webpack_require__(2946);
4816
4824
  const heading_1 = __webpack_require__(2778);
4817
4825
  const ulist_1 = __webpack_require__(7595);
4818
4826
  const olist_1 = __webpack_require__(7697);
4819
4827
  const ilist_1 = __webpack_require__(4223);
4820
4828
  const dlist_1 = __webpack_require__(636);
4821
4829
  const table_1 = __webpack_require__(2752);
4830
+ const pagebreak_1 = __webpack_require__(2946);
4822
4831
  const codeblock_1 = __webpack_require__(9194);
4823
4832
  const mathblock_1 = __webpack_require__(4903);
4824
4833
  const extension_1 = __webpack_require__(6193);
@@ -4958,7 +4967,9 @@ const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combina
4958
4967
  }, output) => {
4959
4968
  const doc = output.pop().head.value;
4960
4969
  if (!doc.firstChild) return output.context;
4961
- 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])));
4962
4973
  }]), true))]))), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('blockquote', (0, util_1.unwrap)(ns)))])));
4963
4974
 
4964
4975
  /***/ },
@@ -5153,7 +5164,9 @@ exports.aside = (0, combinator_1.block)((0, combinator_1.recursion)(1 /* Recursi
5153
5164
  return output.append(new parser_1.Node((0, dom_1.html)('aside', {
5154
5165
  id: (0, indexee_1.identity)('index', input.id, heading),
5155
5166
  class: 'aside'
5156
- }, [doc, (0, dom_1.html)('h2', 'References'), notes.references])));
5167
+ }, [
5168
+ // DocumentFragmentを追加すると異常に重くなるので避ける
5169
+ ...doc.children, (0, dom_1.html)('h2', 'References'), notes.references])));
5157
5170
  }])));
5158
5171
 
5159
5172
  /***/ },
@@ -5218,12 +5231,15 @@ const contMD = [(input, output) => {
5218
5231
  notes
5219
5232
  } = input;
5220
5233
  input = input.scope.pop();
5234
+ const doc = output.pop().head.value;
5221
5235
  return output.append(new parser_1.Node((0, dom_1.html)('aside', {
5222
5236
  class: 'example',
5223
5237
  'data-type': 'markdown'
5224
5238
  }, [(0, dom_1.html)('pre', {
5225
5239
  translate: 'no'
5226
- }, 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])])));
5227
5243
  }];
5228
5244
  const contMath = [(input, output) => {
5229
5245
  input.scope.push(`$$\n${input.memory.body}$$`);
@@ -5767,6 +5783,64 @@ function format(rows) {
5767
5783
 
5768
5784
  /***/ },
5769
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
+
5770
5844
  /***/ 2778
5771
5845
  (__unused_webpack_module, exports, __webpack_require__) {
5772
5846
 
@@ -6097,7 +6171,7 @@ const delimiter = new RegExp(`${cite_1.syntax.source}|${quote_1.syntax.source}`,
6097
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, {
6098
6172
  source,
6099
6173
  position
6100
- }) => 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)))))]))));
6101
6175
 
6102
6176
  /***/ },
6103
6177
 
@@ -6133,7 +6207,9 @@ exports.cite = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.op
6133
6207
  target: '_blank'
6134
6208
  }, source)))), (0, combinator_1.focus)(/>>\S+(?=\s*$)/y, ({
6135
6209
  source
6136
- }, output) => output.append(new parser_1.Node(source)))])), nodes => {
6210
+ }, output) => output.append(new parser_1.Node(source)))])), (nodes, {
6211
+ position
6212
+ }) => {
6137
6213
  const quotes = nodes.head.value;
6138
6214
  const node = nodes.last.value;
6139
6215
  return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', typeof node === 'object' ? {
@@ -6143,7 +6219,7 @@ exports.cite = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.op
6143
6219
  ...(0, util_1.invalid)('cite', 'syntax', 'Invalid syntax')
6144
6220
  }, (0, dom_1.defrag)([`${quotes}>`, typeof node === 'object' ? (0, dom_1.define)(node, {
6145
6221
  'data-depth': `${quotes.length + 1}`
6146
- }, 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 */)]);
6147
6223
  }));
6148
6224
 
6149
6225
  /***/ },
@@ -6173,7 +6249,7 @@ exports.quote = (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.
6173
6249
  math_1.math, autolink_1.autolink, source_1.unescsource])), true)), (ns, {
6174
6250
  source,
6175
6251
  position
6176
- }) => 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', {
6177
6253
  class: 'quote'
6178
6254
  }, (0, dom_1.defrag)((0, util_1.unwrap)(ns))))].reverse())), false);
6179
6255
 
@@ -6355,7 +6431,10 @@ class Input extends parser_1.Input {
6355
6431
  this.resources ??= {
6356
6432
  clock: -1,
6357
6433
  interval: 200,
6358
- 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 */]
6359
6438
  };
6360
6439
  this.segment = segment ?? 0 /* Segment.unknown */;
6361
6440
  this.header = header ?? true;
@@ -6410,7 +6489,7 @@ const figure_1 = __webpack_require__(5815);
6410
6489
  const note_1 = __webpack_require__(8119);
6411
6490
  const dom_1 = __webpack_require__(394);
6412
6491
  exports.document = (() => {
6413
- 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);
6414
6493
  return (0, combinator_1.always)([(input, output) => {
6415
6494
  input.id = input.id === '' ? '' : input.local ? (0, util_1.randomID)() : input.id;
6416
6495
  input.memory = {
@@ -6420,30 +6499,29 @@ exports.document = (() => {
6420
6499
  })
6421
6500
  };
6422
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());
6423
6505
  return output.context;
6424
- }, (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) => {
6425
6507
  const {
6426
6508
  memory
6427
6509
  } = input;
6428
6510
  const doc = memory.doc = (0, dom_1.frag)((0, util_1.unwrap)(output.pop()));
6429
6511
  output.append(new parser_1.Node(doc));
6430
- if (input.test && !input.local) return output.context;
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
+ }
6431
6518
  memory.orphan = !memory.references.parentNode;
6432
6519
  memory.orphan && doc.appendChild(memory.references);
6433
6520
  return output.context;
6434
- }, (input, output) => {
6435
- if (input.test && !input.local) return output.context;
6436
- const {
6437
- memory
6438
- } = input;
6439
- return conv((0, figure_1.figure)(memory.doc, memory, input));
6440
- }, (input, output) => {
6441
- if (input.test && !input.local) return output.context;
6442
- const {
6443
- memory
6444
- } = input;
6445
- return conv((0, note_1.note)(memory.doc, memory, input));
6446
- }, (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) => {
6447
6525
  const {
6448
6526
  memory
6449
6527
  } = input;
@@ -6453,75 +6531,12 @@ exports.document = (() => {
6453
6531
  })();
6454
6532
  function conv(iterable) {
6455
6533
  const iter = iterable[Symbol.iterator]();
6456
- const cont = [(_, output) => {
6457
- const {
6458
- done
6459
- } = iter.next();
6460
- return done ? output.context : cont;
6461
- }];
6534
+ const cont = [(_, output) => iter.next().done ? output.context : cont];
6462
6535
  return cont;
6463
6536
  }
6464
6537
 
6465
6538
  /***/ },
6466
6539
 
6467
- /***/ 3009
6468
- (__unused_webpack_module, exports, __webpack_require__) {
6469
-
6470
- "use strict";
6471
-
6472
-
6473
- Object.defineProperty(exports, "__esModule", ({
6474
- value: true
6475
- }));
6476
- exports.header = void 0;
6477
- const parser_1 = __webpack_require__(3360);
6478
- const combinator_1 = __webpack_require__(3484);
6479
- const source_1 = __webpack_require__(8745);
6480
- const util_1 = __webpack_require__(4992);
6481
- const url_1 = __webpack_require__(1904);
6482
- const dom_1 = __webpack_require__(394);
6483
- 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)(({
6484
- source
6485
- }) => 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', {
6486
- class: 'header'
6487
- }, [(0, dom_1.html)('details', {
6488
- open: ''
6489
- }, (0, dom_1.defrag)((0, util_1.unwrap)(ns.unshift(new parser_1.Node((0, dom_1.html)('summary', 'Header'))))))]))])), false))), (input, output) => {
6490
- const {
6491
- source,
6492
- position
6493
- } = input;
6494
- input.position += source.length;
6495
- return output.append(new parser_1.Node((0, dom_1.html)('pre', {
6496
- class: 'invalid',
6497
- translate: 'no',
6498
- ...(0, util_1.invalid)('header', 'syntax', 'Invalid syntax')
6499
- }, source.slice(position))));
6500
- }])), (0, combinator_1.clear)((0, source_1.str)(/[^\S\r\n]*\r?\n/y))])));
6501
- const field = (0, combinator_1.line)((input, output) => {
6502
- const {
6503
- source,
6504
- position
6505
- } = input;
6506
- const name = source.slice(position, source.indexOf(':', position));
6507
- const value = source.slice(position + name.length + 1).trim();
6508
- if (name.toLowerCase() === 'url') {
6509
- // @ts-expect-error
6510
- input.url = new url_1.ReadonlyURL(value);
6511
- }
6512
- return output.append(new parser_1.Node((0, dom_1.html)('div', {
6513
- class: 'field',
6514
- 'data-name': name.toLowerCase(),
6515
- 'data-value': value
6516
- }, [(0, dom_1.html)('span', {
6517
- class: 'field-name'
6518
- }, name), ': ', (0, dom_1.html)('span', {
6519
- class: 'field-value'
6520
- }, value)])));
6521
- });
6522
-
6523
- /***/ },
6524
-
6525
6540
  /***/ 7973
6526
6541
  (__unused_webpack_module, exports, __webpack_require__) {
6527
6542
 
@@ -6712,7 +6727,9 @@ const dom_1 = __webpack_require__(394);
6712
6727
  // 常に非常に非効率な処理を行い常時低速化するより三重以上の注釈を禁止して効率性を維持するのが妥当である。
6713
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) => {
6714
6729
  const {
6730
+ position,
6715
6731
  linebreak,
6732
+ range,
6716
6733
  recursion,
6717
6734
  resources
6718
6735
  } = input;
@@ -6725,9 +6742,15 @@ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1
6725
6742
  }
6726
6743
  output.error ??= recursion.add(resources?.recursions[2 /* Recursion.inline */] ?? resources?.recursions.at(-1));
6727
6744
  input.position += 1;
6728
- return new parser_1.List([new parser_1.Node((0, dom_1.html)('sup', {
6745
+ const el = (0, dom_1.html)('sup', {
6729
6746
  class: 'annotation'
6730
- }, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(nodes))))]))]);
6747
+ }, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(nodes))))]);
6748
+ for (let list = output.annotations.at(-1), node = list.last, pos = position - range, i = 0;; node = node.prev, ++i) {
6749
+ if (node && node.position > pos) continue;
6750
+ i === list.length ? list.unshift(new parser_1.Node(el, pos)) : list.insert(new parser_1.Node(el, pos), node?.next);
6751
+ break;
6752
+ }
6753
+ return new parser_1.List([new parser_1.Node(el)]);
6731
6754
  }, (nodes, input, output, prefix, postfix) => {
6732
6755
  for (let i = 0; i < prefix; ++i) {
6733
6756
  nodes.unshift(new parser_1.Node('('));
@@ -7370,7 +7393,7 @@ exports.signature = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('|',
7370
7393
  const index = (0, indexee_1.identity)('index', undefined, ns.foldl((acc, {
7371
7394
  value
7372
7395
  }) => acc + value, ''))?.slice(7);
7373
- if (linebreak !== 0 || ns.head.flags & 1 /* Flag.blank */ || !index) {
7396
+ if (linebreak !== 0 || ns.head.flags & 1 /* Node.Flag.blank */ || !index) {
7374
7397
  return void (0, combinator_1.setBacktrack)(input, 2 | 16 /* Backtrack.escapable */, head);
7375
7398
  }
7376
7399
  return output.append(new parser_1.Node((0, dom_1.html)('span', {
@@ -7409,11 +7432,9 @@ const combinator_1 = __webpack_require__(3484);
7409
7432
  const dom_1 = __webpack_require__(394);
7410
7433
  function indexee(parser) {
7411
7434
  return (0, combinator_1.fmap)(parser, (ns, {
7412
- id,
7413
- local
7435
+ id
7414
7436
  }) => ns.length === 1 ? new parser_1.List([new parser_1.Node((0, dom_1.define)(ns.head.value, {
7415
7437
  id: identity('index', id, ns.head.value),
7416
- class: local ? `${ns.head.value.className} local`.trimStart() : undefined,
7417
7438
  'data-index': null
7418
7439
  }))]) : ns);
7419
7440
  }
@@ -7599,10 +7620,14 @@ exports.test = test;
7599
7620
  exports.segment = (0, combinator_1.clear)((0, combinator_1.union)([(0, combinator_1.backtrack)((0, combinator_1.surround)('[', body, ']')), body]));
7600
7621
  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]), ([{
7601
7622
  value
7602
- }]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('a', {
7603
- class: 'label',
7604
- 'data-label': value.slice(value[1] === '-' ? 0 : 1).toLowerCase()
7605
- }, value))])));
7623
+ }], _, output) => {
7624
+ const label = (0, dom_1.html)('a', {
7625
+ class: 'label',
7626
+ 'data-label': value.slice(value[1] === '-' ? 0 : 1).toLowerCase()
7627
+ }, value);
7628
+ output.labels.at(-1).push(new parser_1.Node(label));
7629
+ return new parser_1.List([new parser_1.Node(label)]);
7630
+ }));
7606
7631
  function number(label, base) {
7607
7632
  return isFixed(label) ? label.slice(label.lastIndexOf('-') + 1) : increment(base, base.split('.').length);
7608
7633
  }
@@ -7680,7 +7705,7 @@ Object.setPrototypeOf(attrspecs, null);
7680
7705
  Object.values(attrspecs).forEach(o => Object.setPrototypeOf(o, null));
7681
7706
  exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)(
7682
7707
  // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
7683
- (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))),
7708
+ (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))),
7684
7709
  // 不可視のHTML構造が可視構造を変化させるべきでない。
7685
7710
  // 可視のHTMLは優先度変更を検討する。
7686
7711
  // このため`<>`記号は将来的に共通構造を変化させる可能性があり
@@ -7760,11 +7785,12 @@ const combinator_1 = __webpack_require__(3484);
7760
7785
  const source_1 = __webpack_require__(8745);
7761
7786
  const util_1 = __webpack_require__(4992);
7762
7787
  const dom_1 = __webpack_require__(394);
7763
- 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 ?? ''))));
7788
+ 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 ?? ''))));
7764
7789
  exports.htmlentity = (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([{
7765
7790
  value,
7791
+ position,
7766
7792
  flags
7767
- }]) => 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', {
7793
+ }]) => 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', {
7768
7794
  class: 'invalid',
7769
7795
  ...(0, util_1.invalid)('htmlentity', 'syntax', 'Invalid HTML entity')
7770
7796
  }, value))]));
@@ -8071,14 +8097,14 @@ const optspec = {
8071
8097
  };
8072
8098
  Object.setPrototypeOf(optspec, null);
8073
8099
  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) => {
8074
- if (input.linebreak !== 0 || ns.head?.flags & 1 /* Flag.blank */ || ns.head?.value?.[0].trimStart() === '') {
8100
+ if (input.linebreak !== 0 || ns.head?.flags & 1 /* Node.Flag.blank */ || ns.head?.value?.[0].trimStart() === '') {
8075
8101
  const head = input.position - input.range;
8076
8102
  return void (0, combinator_1.setBacktrack)(input, 2 | 16 /* Backtrack.escapable */ | 32 /* Backtrack.ruby */, head);
8077
8103
  }
8078
8104
  return output.import(ns);
8079
8105
  }))), (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, {
8080
8106
  value
8081
- }) => acc + value, '').trimEnd(), nodes.head.value.head?.flags)])), nodes.delete(nodes.last)])), ([{
8107
+ }) => acc + value, '').trimEnd(), nodes.head.position, nodes.head.value.head?.flags)])), nodes.delete(nodes.last)])), ([{
8082
8108
  value: [{
8083
8109
  value: text
8084
8110
  }]
@@ -8184,7 +8210,9 @@ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64
8184
8210
  (0, combinator_1.setBacktrack)(input, 2 | 64 /* Backtrack.link */, head, 2);
8185
8211
  return;
8186
8212
  }
8187
- 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))))]))]));
8213
+ 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))))]);
8214
+ output.references.at(-1).push(new parser_1.Node(el));
8215
+ return output.import(new parser_1.List([new parser_1.Node(el)]));
8188
8216
  }, (_, input) => {
8189
8217
  const {
8190
8218
  source,
@@ -8594,6 +8622,7 @@ function repeat(opener, after, closer, recursion, parser, cons, termination = (n
8594
8622
  const {
8595
8623
  source,
8596
8624
  position,
8625
+ linebreak,
8597
8626
  resources: {
8598
8627
  recursions
8599
8628
  }
@@ -8610,12 +8639,14 @@ function repeat(opener, after, closer, recursion, parser, cons, termination = (n
8610
8639
  (0, combinator_1.recur)(output, recursions, recursion, depth, true);
8611
8640
  input.memory = {
8612
8641
  position,
8642
+ linebreak,
8613
8643
  i,
8614
8644
  lead: 0,
8615
8645
  follow: 0,
8616
8646
  state: false,
8617
8647
  depth
8618
8648
  };
8649
+ input.linebreak = 0;
8619
8650
  output.push();
8620
8651
  return loop;
8621
8652
  }, (input, output) => {
@@ -8628,6 +8659,7 @@ function repeat(opener, after, closer, recursion, parser, cons, termination = (n
8628
8659
  } = input;
8629
8660
  (0, combinator_1.recur)(output, recursions, recursion, -m.depth);
8630
8661
  m.depth = 0;
8662
+ input.linebreak ||= m.linebreak;
8631
8663
  const prefix = m.i;
8632
8664
  m.i = 0;
8633
8665
  for (let len = (0, alias_1.min)(prefix, source.length - input.position); m.i < len && source[input.position + m.i] === closer[0];) {
@@ -8897,29 +8929,29 @@ const escsource = (input, output) => {
8897
8929
  case "\u001B" /* Command.Escape */:
8898
8930
  (0, combinator_1.spend)(input, output, 1);
8899
8931
  input.position += 1;
8900
- return output.append(new parser_1.Node(source.slice(position + 1, position + 2)));
8932
+ return output.append(new parser_1.Node(source.slice(position + 1, position + 2), position));
8901
8933
  case '\\':
8902
8934
  switch (source[position + 1]) {
8903
8935
  case undefined:
8904
8936
  case '\r':
8905
8937
  case '\n':
8906
- return output.append(new parser_1.Node(char));
8938
+ return output.append(new parser_1.Node(char, position));
8907
8939
  default:
8908
8940
  (0, combinator_1.spend)(input, output, 1);
8909
8941
  input.position += 1;
8910
- return output.append(new parser_1.Node(source.slice(position, position + 2)));
8942
+ return output.append(new parser_1.Node(source.slice(position, position + 2), position));
8911
8943
  }
8912
8944
  case '\r':
8913
8945
  return parser_1.Result.succ;
8914
8946
  case '\n':
8915
8947
  input.linebreak ||= source.length - position;
8916
- return output.append(new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.blank */));
8948
+ return output.append(new parser_1.Node((0, dom_1.html)('br'), position, 1 /* Node.Flag.blank */));
8917
8949
  default:
8918
8950
  let i = seek(source, position);
8919
8951
  i -= position;
8920
8952
  (0, combinator_1.spend)(input, output, i - 1);
8921
8953
  input.position += i - 1;
8922
- return output.append(new parser_1.Node(source.slice(position, input.position)));
8954
+ return output.append(new parser_1.Node(source.slice(position, input.position), position));
8923
8955
  }
8924
8956
  };
8925
8957
  exports.escsource = escsource;
@@ -9044,9 +9076,12 @@ const delimiter_1 = __webpack_require__(5486);
9044
9076
  function str(pattern, after) {
9045
9077
  const match = (0, delimiter_1.matcher)(pattern, true, after ? (0, delimiter_1.tester)(after, false) : undefined);
9046
9078
  return (input, output) => {
9079
+ const {
9080
+ position
9081
+ } = input;
9047
9082
  const src = match(input, output);
9048
9083
  if (src === undefined) return;
9049
- return output.append(new parser_1.Node(src));
9084
+ return output.append(new parser_1.Node(src, position));
9050
9085
  };
9051
9086
  }
9052
9087
  exports.str = str;
@@ -9064,7 +9099,7 @@ function strs(char, min = 1, max = -1) {
9064
9099
  }
9065
9100
  if (cnt < min) return;
9066
9101
  input.position = pos;
9067
- return output.append(new parser_1.Node(source.slice(position, input.position)));
9102
+ return output.append(new parser_1.Node(source.slice(position, input.position), position));
9068
9103
  };
9069
9104
  }
9070
9105
  exports.strs = strs;
@@ -9108,13 +9143,13 @@ const text = (input, output) => {
9108
9143
  default:
9109
9144
  (0, combinator_1.spend)(input, output, 1);
9110
9145
  input.position += 1;
9111
- return output.append(new parser_1.Node(source.slice(position + 1, input.position)));
9146
+ return output.append(new parser_1.Node(source.slice(position + 1, input.position), position));
9112
9147
  }
9113
9148
  case '\r':
9114
9149
  return parser_1.Result.succ;
9115
9150
  case '\n':
9116
9151
  input.linebreak ||= source.length - position;
9117
- return output.append(new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.blank */));
9152
+ return output.append(new parser_1.Node((0, dom_1.html)('br'), position, 1 /* Node.Flag.blank */));
9118
9153
  default:
9119
9154
  exports.nonWhitespace.lastIndex = position + 1;
9120
9155
  const s = canSkip(source, position);
@@ -9126,7 +9161,7 @@ const text = (input, output) => {
9126
9161
  input.position += i - 1;
9127
9162
  const linestart = position === 0 || source[position - 1] === '\n';
9128
9163
  if (position === input.position || s && !linestart || lineend) return parser_1.Result.succ;
9129
- return output.append(new parser_1.Node(source.slice(position, input.position)));
9164
+ return output.append(new parser_1.Node(source.slice(position, input.position), position));
9130
9165
  }
9131
9166
  };
9132
9167
  exports.text = text;
@@ -9301,19 +9336,19 @@ const unescsource = (input, output) => {
9301
9336
  case "\u001B" /* Command.Escape */:
9302
9337
  (0, combinator_1.spend)(input, output, 1);
9303
9338
  input.position += 1;
9304
- return output.append(new parser_1.Node(source.slice(position + 1, position + 2)));
9339
+ return output.append(new parser_1.Node(source.slice(position + 1, position + 2), position));
9305
9340
  case '\r':
9306
9341
  return parser_1.Result.succ;
9307
9342
  case '\n':
9308
9343
  input.linebreak ||= source.length - position;
9309
- return output.append(new parser_1.Node((0, dom_1.html)('br'), 1 /* Flag.blank */));
9344
+ return output.append(new parser_1.Node((0, dom_1.html)('br'), position, 1 /* Node.Flag.blank */));
9310
9345
  default:
9311
9346
  text_1.nonWhitespace.lastIndex = position + 1;
9312
9347
  let i = (0, text_1.canSkip)(source, position) ? text_1.nonWhitespace.test(source) ? text_1.nonWhitespace.lastIndex - 1 : source.length : next(source, position, state);
9313
9348
  i -= position;
9314
9349
  (0, combinator_1.spend)(input, output, i - 1);
9315
9350
  input.position += i - 1;
9316
- return output.append(new parser_1.Node(source.slice(position, input.position)));
9351
+ return output.append(new parser_1.Node(source.slice(position, input.position), position));
9317
9352
  }
9318
9353
  };
9319
9354
  exports.unescsource = unescsource;
@@ -9452,7 +9487,7 @@ exports.isWhitespace = isWhitespace;
9452
9487
  Object.defineProperty(exports, "__esModule", ({
9453
9488
  value: true
9454
9489
  }));
9455
- exports.randomID = exports.stringify = exports.unmarkInvalid = exports.markInvalid = exports.invalid = exports.unwrap = void 0;
9490
+ exports.collect = exports.randomID = exports.stringify = exports.unmarkInvalid = exports.markInvalid = exports.invalid = exports.unwrap = void 0;
9456
9491
  const random_1 = __webpack_require__(3158);
9457
9492
  const dom_1 = __webpack_require__(394);
9458
9493
  function* unwrap(nodes) {
@@ -9505,6 +9540,15 @@ function randomID() {
9505
9540
  return `random-${(0, random_1.rnd0Z)(6)}`;
9506
9541
  }
9507
9542
  exports.randomID = randomID;
9543
+ function collect(target, selector) {
9544
+ const acc = [];
9545
+ for (let el = target.firstElementChild; el; el = el?.nextElementSibling) {
9546
+ if (!el.matches(selector)) continue;
9547
+ acc.push(el);
9548
+ }
9549
+ return acc;
9550
+ }
9551
+ exports.collect = collect;
9508
9552
 
9509
9553
  /***/ },
9510
9554
 
@@ -9570,7 +9614,7 @@ function isNonblankFirstLine(nodes) {
9570
9614
  if (nodes.length === 0) return true;
9571
9615
  for (const node of nodes) {
9572
9616
  if (isNonblank(node)) return true;
9573
- if (node.flags & 1 /* Flag.blank */ && typeof node.value === 'object' && node.value.tagName === 'BR') break;
9617
+ if (node.flags & 1 /* Node.Flag.blank */ && typeof node.value === 'object' && node.value.tagName === 'BR') break;
9574
9618
  }
9575
9619
  return false;
9576
9620
  }
@@ -9584,7 +9628,7 @@ function isNonblank({
9584
9628
  value: node,
9585
9629
  flags
9586
9630
  }, strpos) {
9587
- if (flags & 1 /* Flag.blank */) return false;
9631
+ if (flags & 1 /* Node.Flag.blank */) return false;
9588
9632
  if (typeof node !== 'string') return true;
9589
9633
  const str = node && strpos !== undefined ? node[strpos >= 0 ? strpos : node.length + strpos] : node;
9590
9634
  switch (str) {
@@ -9621,9 +9665,9 @@ function trimBlankEnd(parser) {
9621
9665
  }
9622
9666
  exports.trimBlankEnd = trimBlankEnd;
9623
9667
  function trimBlankNodeEnd(nodes) {
9624
- const skip = nodes.last && ~nodes.last.flags & 1 /* Flag.blank */ && typeof nodes.last.value === 'object' ? nodes.last.value.className === 'indexer' : false;
9668
+ const skip = nodes.last && ~nodes.last.flags & 1 /* Node.Flag.blank */ && typeof nodes.last.value === 'object' ? nodes.last.value.className === 'indexer' : false;
9625
9669
  for (let node = skip ? nodes.last?.prev : nodes.last; node;) {
9626
- if (~node.flags & 1 /* Flag.blank */) {
9670
+ if (~node.flags & 1 /* Node.Flag.blank */) {
9627
9671
  if (typeof node.value === 'string') {
9628
9672
  const str = node.value.trimEnd();
9629
9673
  if (str.length > 0) {
@@ -9657,17 +9701,17 @@ exports.figure = void 0;
9657
9701
  const label_1 = __webpack_require__(2178);
9658
9702
  const util_1 = __webpack_require__(4992);
9659
9703
  const queue_1 = __webpack_require__(4110);
9660
- const array_1 = __webpack_require__(6876);
9661
9704
  const dom_1 = __webpack_require__(394);
9662
- function* figure(target, notes, opts = {}) {
9663
- const selector = ':is(figure[data-label], h1, h2)';
9664
- 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])));
9705
+ function* figure(target, list, notes, opts = {}) {
9706
+ const refs = new queue_1.MultiQueue(list.foldl((acc, {
9707
+ value: el
9708
+ }) => (acc.push([el.getAttribute('data-label'), el]), acc), []));
9665
9709
  const labels = new Set();
9666
9710
  const numbers = new Map();
9667
9711
  let base = '0';
9668
9712
  let bases = base.split('.');
9669
- for (let defs = target instanceof Element ? target.querySelectorAll(`:scope > ${selector}`) : target.querySelectorAll(`:not(* > *)${selector}`), len = defs.length, i = 0; i < len; ++i) {
9670
- yield;
9713
+ for (let defs = (0, util_1.collect)(target, 'figure[data-label], h1, h2'), len = defs.length, i = 0; i < len; ++i) {
9714
+ if (~i << 32 - 8 === 0) yield;
9671
9715
  const def = defs[i];
9672
9716
  const {
9673
9717
  tagName
@@ -9740,8 +9784,7 @@ function* figure(target, notes, opts = {}) {
9740
9784
  (0, util_1.unmarkInvalid)(ref);
9741
9785
  }
9742
9786
  if (ref.hash.slice(1) === def.id && ref.innerText === figindex) continue;
9743
- yield (0, dom_1.define)(ref, {
9744
- class: opts.local ? `${ref.className} local` : undefined,
9787
+ (0, dom_1.define)(ref, {
9745
9788
  href: opts.id !== '' ? `#${def.id}` : undefined
9746
9789
  }, figindex);
9747
9790
  }
@@ -9750,7 +9793,6 @@ function* figure(target, notes, opts = {}) {
9750
9793
  if (opts.id !== '' && !ref.classList.contains('invalid')) {
9751
9794
  (0, util_1.markInvalid)(ref, 'label', 'reference', messages.reference);
9752
9795
  }
9753
- yield ref;
9754
9796
  }
9755
9797
  }
9756
9798
  exports.figure = figure;
@@ -9792,7 +9834,7 @@ const indexee_1 = __webpack_require__(7610);
9792
9834
  const util_1 = __webpack_require__(4992);
9793
9835
  const memoize_1 = __webpack_require__(6925);
9794
9836
  const dom_1 = __webpack_require__(394);
9795
- function* note(target, notes, opts = {}, bottom = null) {
9837
+ function* note(target, lists, notes, opts = {}, bottom = null) {
9796
9838
  const referenceRefMemory = referenceRefsMemoryCaller(target);
9797
9839
  const annotationRefMemory = annotationRefsMemoryCaller(target);
9798
9840
  for (const memory of [referenceRefMemory, annotationRefMemory]) {
@@ -9803,17 +9845,21 @@ function* note(target, notes, opts = {}, bottom = null) {
9803
9845
  }
9804
9846
  memory.clear();
9805
9847
  }
9806
- yield* reference(referenceRefMemory, target, notes?.references, opts, bottom);
9807
- yield* annotation(annotationRefMemory, target, notes?.annotations, opts, bottom);
9848
+ yield* reference(referenceRefMemory, target, lists.references.foldl((acc, {
9849
+ value: el
9850
+ }) => (acc.push(el), acc), []), notes?.references, opts, bottom);
9851
+ yield* annotation(annotationRefMemory, target, lists.annotations.foldl((acc, {
9852
+ value: el
9853
+ }) => (acc.push(el), acc), []), notes?.annotations, opts, bottom);
9808
9854
  }
9809
9855
  exports.note = note;
9810
9856
  const annotationRefsMemoryCaller = (0, memoize_1.memoize)(target => new Map() ?? target, new WeakMap());
9811
9857
  const referenceRefsMemoryCaller = (0, memoize_1.memoize)(target => new Map() ?? target, new WeakMap());
9812
- const annotation = build('annotation', 'annotations', '.annotation:not(:is(.annotations, .references) &, .local)', n => `*${n}`, 'h1, h2, h3, h4, h5, h6, aside.aside, hr, .references');
9813
- const reference = build('reference', 'references', '.reference:not(:is(.annotations, .references) &, .local)', (n, abbr) => `[${abbr || n}]`);
9814
- function build(syntax, list, selector, marker, splitter = '') {
9858
+ const annotation = build('annotation', 'annotations', n => `*${n}`, 'h1, h2, h3, h4, h5, h6, aside.aside, hr, .references');
9859
+ const reference = build('reference', 'references', (n, abbr) => `[${abbr || n}]`);
9860
+ function build(syntax, list, marker, splitter = '') {
9815
9861
  splitter &&= `${splitter}, .${list}`;
9816
- return function* (memory, target, note, opts = {}, bottom = null) {
9862
+ return function* (memory, target, refs, note, opts = {}, bottom = null) {
9817
9863
  const refInfoCaller = (0, memoize_1.memoize)(ref => {
9818
9864
  const content = ref.firstElementChild;
9819
9865
  const abbr = ref.getAttribute('data-abbr') ?? '';
@@ -9828,7 +9874,6 @@ function build(syntax, list, selector, marker, splitter = '') {
9828
9874
  };
9829
9875
  }, memory);
9830
9876
  const defs = new Map();
9831
- const refs = target.querySelectorAll(selector);
9832
9877
  const identifierInfoCaller = (0, memoize_1.memoize)(identifier => ({
9833
9878
  defIndex: 0,
9834
9879
  defSubindex: 0,
@@ -9836,20 +9881,23 @@ function build(syntax, list, selector, marker, splitter = '') {
9836
9881
  title: '' && 0,
9837
9882
  queue: []
9838
9883
  }));
9839
- const splitters = splitter ? target instanceof Element ? target.querySelectorAll(`:scope > :is(${splitter}, .${list})`) : target.querySelectorAll(`:not(* > *):is(${splitter}, .${list})`) : [];
9884
+ const splitters = splitter ? (0, util_1.collect)(target, `${splitter}, .${list}`) : [];
9840
9885
  let iSplitters = 0;
9841
9886
  let total = 0;
9842
9887
  let format;
9843
9888
  let refIndex = 0;
9844
9889
  for (let len = refs.length, i = 0; i < len; ++i) {
9890
+ if (~i << 32 - 8 === 0) yield;
9845
9891
  const ref = refs[i];
9846
9892
  if (splitter) for (let splitter; splitter = splitters[iSplitters]; ++iSplitters) {
9847
9893
  const pos = splitter?.compareDocumentPosition(ref) ?? 0;
9848
- if (pos & (Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_POSITION_DISCONNECTED)) break;
9894
+ if (pos & (__webpack_require__.g.Node.DOCUMENT_POSITION_PRECEDING | __webpack_require__.g.Node.DOCUMENT_POSITION_DISCONNECTED)) break;
9849
9895
  if (~iSplitters << 32 - 8 === 0) yield;
9850
9896
  if (splitter.classList.contains(list) && splitter.nextElementSibling !== splitters[iSplitters + 1]) {
9851
- yield* proc(splitter);
9852
- splitter.remove();
9897
+ const note = splitter;
9898
+ proc(note);
9899
+ note.remove();
9900
+ yield note;
9853
9901
  continue;
9854
9902
  }
9855
9903
  if (defs.size > 0) {
@@ -9857,7 +9905,8 @@ function build(syntax, list, selector, marker, splitter = '') {
9857
9905
  const note = splitter.classList.contains(list) ? splitter : target.insertBefore((0, dom_1.html)('ol', {
9858
9906
  class: list
9859
9907
  }), splitter);
9860
- yield* proc(note, defs);
9908
+ proc(note, defs);
9909
+ yield note;
9861
9910
  }
9862
9911
  }
9863
9912
  const {
@@ -9884,7 +9933,6 @@ function build(syntax, list, selector, marker, splitter = '') {
9884
9933
  const title = info.title ||= text;
9885
9934
  (0, dom_1.define)(ref, {
9886
9935
  id: refId,
9887
- class: opts.local ? `${ref.className} local` : undefined,
9888
9936
  title
9889
9937
  }, []);
9890
9938
  if (title && info.queue.length > 0) {
@@ -9919,31 +9967,33 @@ function build(syntax, list, selector, marker, splitter = '') {
9919
9967
  href: refId && `#${refId}`,
9920
9968
  title: abbr && text || undefined
9921
9969
  }, `^${++refIndex}`));
9922
- yield;
9923
9970
  }
9924
9971
  if (note || defs.size > 0) {
9925
9972
  const splitter = splitters[iSplitters++];
9926
9973
  note ??= splitter?.classList.contains(list) ? splitter : target.insertBefore((0, dom_1.html)('ol', {
9927
9974
  class: list
9928
9975
  }), splitter ?? bottom);
9929
- yield* proc(note, defs);
9976
+ proc(note, defs);
9977
+ yield note;
9930
9978
  }
9931
9979
  if (splitter) for (let splitter; splitter = splitters[iSplitters]; ++iSplitters) {
9932
9980
  if (~iSplitters << 32 - 8 === 0) yield;
9933
9981
  if (splitter.classList.contains(list)) {
9934
- yield* proc(splitter);
9982
+ const note = splitter;
9983
+ proc(note);
9935
9984
  splitter.remove();
9985
+ yield note;
9936
9986
  }
9937
9987
  }
9938
9988
  };
9939
9989
  }
9940
- function* proc(note, defs) {
9990
+ function proc(note, defs) {
9941
9991
  for (let defs = note.children, i = defs.length; i--;) {
9942
- yield note.removeChild(defs[i]);
9992
+ note.removeChild(defs[i]);
9943
9993
  }
9944
9994
  if (!defs) return;
9945
9995
  for (const [, def] of defs) {
9946
- yield note.appendChild(def);
9996
+ note.appendChild(def);
9947
9997
  }
9948
9998
  defs.clear();
9949
9999
  }
@@ -10532,12 +10582,12 @@ Object.defineProperty(exports, "__esModule", ({
10532
10582
  value: true
10533
10583
  }));
10534
10584
  exports.toc = void 0;
10585
+ const util_1 = __webpack_require__(4992);
10535
10586
  const array_1 = __webpack_require__(6876);
10536
10587
  const dom_1 = __webpack_require__(394);
10537
- const selector = ':is(h1, h2, h3, h4, h5, h6, aside.aside)[id]:not(.local)';
10538
10588
  function toc(source) {
10539
10589
  const hs = [];
10540
- for (let es = source.querySelectorAll(selector), len = es.length, i = 0; i < len; ++i) {
10590
+ 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) {
10541
10591
  const el = es[i];
10542
10592
  switch (el.tagName) {
10543
10593
  case 'ASIDE':