securemark 0.284.0 → 0.285.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +191 -82
  3. package/markdown.d.ts +20 -19
  4. package/package.json +1 -1
  5. package/src/combinator/control/constraint/contract.ts +4 -4
  6. package/src/combinator/control/manipulation/convert.ts +3 -3
  7. package/src/combinator/control/manipulation/indent.ts +3 -3
  8. package/src/combinator/control/manipulation/scope.ts +3 -3
  9. package/src/combinator/control/manipulation/surround.ts +25 -13
  10. package/src/combinator/data/parser/context.ts +1 -1
  11. package/src/combinator/data/parser/some.ts +1 -0
  12. package/src/combinator/data/parser.ts +2 -1
  13. package/src/parser/api/parse.test.ts +14 -14
  14. package/src/parser/context.ts +11 -6
  15. package/src/parser/inline/annotation.ts +2 -2
  16. package/src/parser/inline/autolink/url.ts +14 -7
  17. package/src/parser/inline/bracket.test.ts +2 -2
  18. package/src/parser/inline/deletion.ts +15 -14
  19. package/src/parser/inline/emphasis.ts +2 -2
  20. package/src/parser/inline/emstrong.test.ts +115 -0
  21. package/src/parser/inline/emstrong.ts +71 -37
  22. package/src/parser/inline/extension/index.ts +14 -10
  23. package/src/parser/inline/extension/label.ts +1 -1
  24. package/src/parser/inline/extension/placeholder.ts +2 -2
  25. package/src/parser/inline/html.ts +2 -2
  26. package/src/parser/inline/insertion.ts +15 -14
  27. package/src/parser/inline/italic.test.ts +23 -4
  28. package/src/parser/inline/italic.ts +16 -15
  29. package/src/parser/inline/link.ts +3 -3
  30. package/src/parser/inline/mark.ts +22 -21
  31. package/src/parser/inline/media.ts +10 -6
  32. package/src/parser/inline/reference.ts +2 -2
  33. package/src/parser/inline/ruby.ts +6 -4
  34. package/src/parser/inline/strong.ts +2 -2
  35. package/src/parser/inline/template.ts +7 -8
  36. package/src/parser/inline.test.ts +18 -42
  37. package/src/parser/inline.ts +4 -4
  38. package/src/parser/source/text.ts +0 -4
  39. package/src/parser/util.ts +66 -1
  40. package/src/parser/visibility.ts +22 -19
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.284.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.285.1 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"));
@@ -500,26 +500,59 @@ const strong_1 = __webpack_require__(6591);
500
500
  const emphasis_1 = __webpack_require__(1354);
501
501
  const source_1 = __webpack_require__(8745);
502
502
  const visibility_1 = __webpack_require__(6364);
503
+ const util_1 = __webpack_require__(4992);
503
504
  const dom_1 = __webpack_require__(394);
504
505
  const array_1 = __webpack_require__(6876);
505
506
  const substrong = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('**')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([exports.emstrong, strong_1.strong]))])));
506
507
  const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([strong_1.strong, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([exports.emstrong, strong_1.strong, emphasis_1.emphasis]))])));
507
- exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)('***'), (0, combinator_1.precedence)(0, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)])))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], rest, context) => {
508
+ // 開閉が明示的でない構文は開閉の不明確な記号による再帰的適用を行わず早く閉じるよう解析しなければならない。
509
+ // このため終端記号の後ろを見て終端を中止し同じ構文を再帰的に適用してはならない。
510
+ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.validate)('***', (0, combinator_1.precedence)(0, (0, util_1.repeat)('***', (0, combinator_1.surround)('', (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)]))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], rest, context) => {
508
511
  switch (cs[0]) {
509
512
  case '***':
510
- return [[(0, dom_1.html)('em', [(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))])], rest];
513
+ return [bs, rest];
511
514
  case '**':
512
- return (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' ? [[(0, dom_1.html)('em', (0, array_1.unshift)([(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds)))], rest.slice(1)] : [(0, array_1.unshift)(['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], ds), rest])({
515
+ return (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' ? [[(0, dom_1.html)('em', (0, array_1.unshift)([(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds))), "\u001F" /* Command.Separator */], rest.slice(1)] : [(0, array_1.push)((0, array_1.unshift)(['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], ds), ["\u001F" /* Command.Separator */]), rest])({
513
516
  source: rest,
514
517
  context
515
- }) ?? [['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest];
518
+ }) ?? [['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs)), "\u001F" /* Command.Separator */], rest];
516
519
  case '*':
517
- return (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' ? [[(0, dom_1.html)('strong', (0, array_1.unshift)([(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds)))], rest.slice(2)] : [(0, array_1.unshift)(['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], ds), rest])({
520
+ return (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' ? [[(0, dom_1.html)('strong', (0, array_1.unshift)([(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds))), "\u001F" /* Command.Separator */], rest.slice(2)] : [(0, array_1.push)((0, array_1.unshift)(['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], ds), ["\u001F" /* Command.Separator */]), rest])({
518
521
  source: rest,
519
522
  context
520
- }) ?? [['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest];
523
+ }) ?? [['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs)), "\u001F" /* Command.Separator */], rest];
524
+ }
525
+ }, ([as, bs], rest) => [(0, array_1.push)((0, array_1.unshift)(as, bs), ["\u001B" /* Command.Escape */]), rest]),
526
+ // 3以上の`*`に対してemの適用を保証する
527
+ nodes => [(0, dom_1.html)('em', [(0, dom_1.html)('strong', (0, dom_1.defrag)(nodes))])], (acc, rest, prefix, postfix, state) => {
528
+ const nodes = [];
529
+ let i = postfix;
530
+ if (state) while (i > 0) {
531
+ switch (i) {
532
+ case 1:
533
+ acc = [[(0, dom_1.html)('em', acc.flat())]];
534
+ i -= 1;
535
+ break;
536
+ case 2:
537
+ acc = [[(0, dom_1.html)('strong', acc.flat())]];
538
+ i -= 2;
539
+ break;
540
+ default:
541
+ acc = [[(0, dom_1.html)('em', [(0, dom_1.html)('strong', acc.flat())])]];
542
+ i -= 3;
543
+ }
544
+ }
545
+ if (prefix > postfix) {
546
+ nodes.push('*'.repeat(prefix - postfix));
547
+ }
548
+ for (let i = 0; i < acc.length; ++i) {
549
+ nodes.push(...acc[i]);
521
550
  }
522
- }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
551
+ if (postfix > 0) {
552
+ rest = rest.slice(postfix);
553
+ }
554
+ return [nodes, rest];
555
+ })))));
523
556
 
524
557
  /***/ },
525
558
 
@@ -963,14 +996,14 @@ function indent(opener, parser, separation = false) {
963
996
  source
964
997
  }) => [[source], '']))), ([indent]) => indent.length * 2 + +(indent[0] === ' '), {})), separation), (lines, rest, context) => {
965
998
  const {
966
- logger
999
+ backtracks
967
1000
  } = context;
968
- context.logger = {};
1001
+ context.backtracks = {};
969
1002
  const result = parser({
970
1003
  source: trimBlockEnd(lines.join('')),
971
1004
  context
972
1005
  });
973
- context.logger = logger;
1006
+ context.backtracks = backtracks;
974
1007
  return result && (0, parser_1.exec)(result) === '' ? [(0, parser_1.eval)(result), rest] : undefined;
975
1008
  });
976
1009
  }
@@ -1488,7 +1521,7 @@ const source_1 = __webpack_require__(8745);
1488
1521
  const visibility_1 = __webpack_require__(6364);
1489
1522
  const array_1 = __webpack_require__(6876);
1490
1523
  const dom_1 = __webpack_require__(394);
1491
- exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)('*', '*'), (0, combinator_1.precedence)(0, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([strong_1.strong, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, strong_1.strong, exports.emphasis]))])))), (0, source_1.str)('*'), false, ([, bs], rest) => [[(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
1524
+ exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)('*', '*'), (0, combinator_1.precedence)(0, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([strong_1.strong, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, strong_1.strong, exports.emphasis]))])))), (0, source_1.str)('*'), false, ([, bs], rest) => [[(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
1492
1525
 
1493
1526
  /***/ },
1494
1527
 
@@ -1960,13 +1993,13 @@ const combinator_1 = __webpack_require__(3484);
1960
1993
  const link_1 = __webpack_require__(3628);
1961
1994
  const source_1 = __webpack_require__(8745);
1962
1995
  const closer = /^[-+*=~^_,.;:!?]*(?=[\\"`|\[\](){}<>]|$)/;
1963
- exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['http://', 'https://'], (0, combinator_1.rewrite)((0, combinator_1.open)(/^https?:\/\/(?=[\x21-\x7E])/, (0, combinator_1.focus)(/^[\x21-\x7E]+/, (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([bracket, (0, combinator_1.some)(source_1.unescsource, closer)]))))), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink))), ({
1996
+ exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['http://', 'https://'], (0, combinator_1.rewrite)((0, combinator_1.open)(/^https?:\/\/(?=[\x21-\x7E])/, (0, combinator_1.focus)(/^[\x21-\x7E]+/, (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.verify)((0, combinator_1.union)([bracket, (0, combinator_1.some)(source_1.unescsource, closer)]), ns => ns[0] !== "\u001B" /* Command.Escape */))))), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink))), ({
1964
1997
  source
1965
1998
  }) => [[source], '']]))));
1966
1999
  exports.lineurl = (0, combinator_1.lazy)(() => (0, combinator_1.open)(source_1.linebreak, (0, combinator_1.focus)(/^!?https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, combinator_1.tails)([(0, source_1.str)('!'), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink))), ({
1967
2000
  source
1968
2001
  }) => [[source], '']])]))));
1969
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(0, 6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')'), (0, source_1.str)(')'), true, undefined, undefined, 3 | 8 /* Backtrack.url */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']'), (0, source_1.str)(']'), true, undefined, undefined, 3 | 8 /* Backtrack.url */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}'), (0, source_1.str)('}'), true, undefined, undefined, 3 | 8 /* Backtrack.url */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)(source_1.unescsource, '"')), (0, source_1.str)('"'), true, undefined, undefined, 3 | 8 /* Backtrack.url */)])));
2002
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(0, 6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')'), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 4 /* Backtrack.url */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']'), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 4 /* Backtrack.url */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}'), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 4 /* Backtrack.url */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)(source_1.unescsource, '"')), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 4 /* Backtrack.url */)])));
1970
2003
 
1971
2004
  /***/ },
1972
2005
 
@@ -3234,7 +3267,7 @@ const optspec = {
3234
3267
  rel: ['nofollow']
3235
3268
  };
3236
3269
  Object.setPrototypeOf(optspec, null);
3237
- exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8 /* State.link */, false, (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */ | 4 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [['\n', 9], [']', 1]])), ']', true, undefined, undefined, 1 | 4 /* Backtrack.bracket */)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/, false, undefined, undefined, 3 | 16 /* Backtrack.link */))])), ([params, content = []], rest, context) => {
3270
+ exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8 /* State.link */, false, (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */ | 4 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [['\n', 9], [']', 1]])), ']', true, undefined, undefined, 1 | 12 /* Backtrack.linebracket */, 8 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/, false, undefined, undefined, 3 | 24 /* Backtrack.link */))])), ([params, content = []], rest, context) => {
3238
3271
  if (content.length !== 0 && (0, visibility_1.trimBlankNodeEnd)(content).length === 0) return;
3239
3272
  return [[parse((0, dom_1.defrag)(content), params, context)], rest];
3240
3273
  }))))));
@@ -3929,13 +3962,13 @@ Object.defineProperty(exports, "__esModule", ({
3929
3962
  exports.italic = void 0;
3930
3963
  const combinator_1 = __webpack_require__(3484);
3931
3964
  const inline_1 = __webpack_require__(7973);
3932
- const source_1 = __webpack_require__(8745);
3933
3965
  const visibility_1 = __webpack_require__(6364);
3966
+ const util_1 = __webpack_require__(4992);
3934
3967
  const array_1 = __webpack_require__(6876);
3935
3968
  const dom_1 = __webpack_require__(394);
3936
3969
  // 斜体は単語に使うとかえって見づらく読み飛ばしやすくなるため使わないべきであり
3937
3970
  // ある程度の長さのある文に使うのが望ましい。
3938
- exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)('///', '/'), (0, combinator_1.precedence)(0, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('///')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '/'), exports.italic)])))), (0, source_1.str)('///'), false, ([, bs], rest) => [[(0, dom_1.html)('i', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
3971
+ exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.validate)('///', (0, combinator_1.precedence)(0, (0, util_1.repeat)('///', (0, combinator_1.surround)('', (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('///')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '/'), exports.italic)]))), '///', false, ([, bs], rest) => [bs, rest], ([, bs], rest) => [(0, array_1.push)(bs, ["\u001B" /* Command.Escape */]), rest]), nodes => [(0, dom_1.html)('i', (0, dom_1.defrag)(nodes))])))));
3939
3972
 
3940
3973
  /***/ },
3941
3974
 
@@ -4310,7 +4343,7 @@ const visibility_1 = __webpack_require__(6364);
4310
4343
  const dom_1 = __webpack_require__(394);
4311
4344
  exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, false, (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.surround)('((', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 4 /* State.media */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [['\n', 9], [')', 1]])))), '))', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('sup', {
4312
4345
  class: 'annotation'
4313
- }, [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])], rest] : undefined, undefined, 1 | 4 /* Backtrack.bracket */))));
4346
+ }, [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])], rest] : undefined, undefined, 1 | 12 /* Backtrack.linebracket */, 8 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */))));
4314
4347
 
4315
4348
  /***/ },
4316
4349
 
@@ -4976,12 +5009,11 @@ Object.defineProperty(exports, "__esModule", ({
4976
5009
  exports.template = void 0;
4977
5010
  const combinator_1 = __webpack_require__(3484);
4978
5011
  const source_1 = __webpack_require__(8745);
4979
- const array_1 = __webpack_require__(6876);
4980
5012
  const dom_1 = __webpack_require__(394);
4981
- exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.surround)('{{', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), '}}', true, ([, ns = []], rest) => [[(0, dom_1.html)('span', {
5013
+ exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.surround)('{{', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.verify)((0, combinator_1.union)([bracket, source_1.escsource]), ns => ns[0] !== "\u001B" /* Command.Escape */), '}')), '}}', true, ([, ns = []], rest) => [[(0, dom_1.html)('span', {
4982
5014
  class: 'template'
4983
- }, `{{${ns.join('')}}}`)], rest], undefined, 3 | 28 /* Backtrack.template */)));
4984
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(0, 6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')'), (0, source_1.str)(')'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 28 /* Backtrack.template */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']'), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 28 /* Backtrack.template */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}'), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 28 /* Backtrack.template */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)(source_1.escsource, /^["\n]/)), (0, source_1.str)('"'), true, undefined, undefined, 3 | 28 /* Backtrack.template */)])));
5015
+ }, `{{${ns.join('')}}}`)], rest], undefined, 3 | 32 /* Backtrack.template */)));
5016
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(0, 6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')'), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 32 /* Backtrack.template */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']'), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 32 /* Backtrack.template */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}'), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 32 /* Backtrack.template */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)(source_1.escsource, /^["\n]/)), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 32 /* Backtrack.template */)])));
4985
5017
 
4986
5018
  /***/ },
4987
5019
 
@@ -4997,11 +5029,11 @@ Object.defineProperty(exports, "__esModule", ({
4997
5029
  exports.insertion = void 0;
4998
5030
  const combinator_1 = __webpack_require__(3484);
4999
5031
  const inline_1 = __webpack_require__(7973);
5000
- const source_1 = __webpack_require__(8745);
5001
5032
  const visibility_1 = __webpack_require__(6364);
5033
+ const util_1 = __webpack_require__(4992);
5002
5034
  const array_1 = __webpack_require__(6876);
5003
5035
  const dom_1 = __webpack_require__(394);
5004
- exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)('++', '+'), (0, combinator_1.precedence)(0, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '++')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '+'), true)]))), (0, source_1.str)('++'), false, ([, bs], rest) => [[(0, dom_1.html)('ins', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
5036
+ exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.validate)('++', (0, combinator_1.precedence)(0, (0, util_1.repeat)('++', (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '++')), (0, combinator_1.open)('\n', (0, combinator_1.some)(exports.insertion, '+'), true)])), '++', false, ([, bs], rest) => [bs, rest], ([, bs], rest) => [(0, array_1.push)(bs, ["\u001B" /* Command.Escape */]), rest]), nodes => [(0, dom_1.html)('ins', (0, dom_1.defrag)(nodes))])))));
5005
5037
 
5006
5038
  /***/ },
5007
5039
 
@@ -5024,9 +5056,9 @@ const indexA = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*/;
5024
5056
  const indexF = new RegExp(indexA.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => String.fromCodePoint(c.codePointAt(0) + 0xFEE0)));
5025
5057
  exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, source_1.str)(indexA))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
5026
5058
  class: 'paren'
5027
- }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 4 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, source_1.str)(indexF))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
5059
+ }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 8 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, source_1.str)(indexF))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
5028
5060
  class: 'paren'
5029
- }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 4 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 4 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]),
5061
+ }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 8 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 8 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]),
5030
5062
  // 改行禁止はバックトラックなしでは内側の構文を破壊するため安易に行えない。
5031
5063
  (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '"', [['\n', 9], ['"', 2]]))), (0, source_1.str)('"'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('“'), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '”', [['\n', 9], ['”', 2]]))), (0, source_1.str)('”'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('‘'), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '’', [['\n', 9], ['’', 2]]))), (0, source_1.str)('’'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('「'), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '」', [['\n', 9], ['」', 2]]))), (0, source_1.str)('」'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('『'), (0, combinator_1.creation)(0, 5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '』', [['\n', 9], ['』', 2]]))), (0, source_1.str)('』'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])]));
5032
5064
 
@@ -5108,18 +5140,18 @@ const indexee_1 = __webpack_require__(7610);
5108
5140
  const source_1 = __webpack_require__(8745);
5109
5141
  const visibility_1 = __webpack_require__(6364);
5110
5142
  const dom_1 = __webpack_require__(394);
5111
- exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(32 /* State.index */, false, (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */ | 4 /* State.media */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.inits)([inline_1.inline, exports.signature]), ']', [['\n', 9], [']', 1]])))), ']', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('a', {
5143
+ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(32 /* State.index */, false, (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */ | 4 /* State.media */, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.inits)([inline_1.inline, exports.signature]), ']', [['\n', 9], [']', 1]])))), ']', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('a', {
5112
5144
  'data-index': dataindex(ns)
5113
- }, (0, dom_1.defrag)(ns))], rest] : undefined, undefined, 1 | 4 /* Backtrack.bracket */)), ([el]) => [(0, dom_1.define)(el, {
5145
+ }, (0, dom_1.defrag)(ns))], rest] : undefined, undefined, 1 | 12 /* Backtrack.linebracket */, 8 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */)), ([el]) => [(0, dom_1.define)(el, {
5114
5146
  id: el.id ? null : undefined,
5115
5147
  class: 'index',
5116
5148
  href: el.id ? `#${el.id}` : undefined
5117
5149
  })]))));
5118
- exports.signature = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('|', (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.fmap)((0, combinator_1.open)(/^\|(?!\\?\s)/, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ']')), ns => [(0, dom_1.html)('span', {
5150
+ exports.signature = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('|', (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.fmap)((0, combinator_1.open)(/^\|(?!\\?\s)/, (0, combinator_1.some)((0, combinator_1.verify)((0, combinator_1.union)([bracket, source_1.txt]), ns => ns[0] !== "\u001B" /* Command.Escape */), ']')), ns => [(0, dom_1.html)('span', {
5119
5151
  class: 'indexer',
5120
5152
  'data-index': (0, indexee_1.identity)('index', undefined, ns.join('')).slice(7)
5121
5153
  })]))));
5122
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(0, 6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, undefined, undefined, 3 | 24 /* Backtrack.index */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, undefined, undefined, 3 | 24 /* Backtrack.index */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, undefined, undefined, 3 | 24 /* Backtrack.index */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)(source_1.txt, '"')), (0, source_1.str)('"'), true, undefined, undefined, 3 | 24 /* Backtrack.index */)])));
5154
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(0, 6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 28 /* Backtrack.index */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 28 /* Backtrack.index */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 28 /* Backtrack.index */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)(source_1.txt, '"')), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 28 /* Backtrack.index */)])));
5123
5155
  function dataindex(ns) {
5124
5156
  if (ns.length === 0) return;
5125
5157
  for (let i = ns.length - 1; i >= 0; --i) {
@@ -5225,13 +5257,80 @@ exports.mathblock = (0, combinator_1.block)((0, combinator_1.validate)('$$', (0,
5225
5257
  Object.defineProperty(exports, "__esModule", ({
5226
5258
  value: true
5227
5259
  }));
5228
- exports.stringify = exports.unmarkInvalid = exports.markInvalid = exports.lineable = void 0;
5260
+ exports.stringify = exports.unmarkInvalid = exports.markInvalid = exports.repeat = exports.lineable = void 0;
5261
+ const alias_1 = __webpack_require__(5413);
5262
+ const parser_1 = __webpack_require__(605);
5229
5263
  const combinator_1 = __webpack_require__(3484);
5230
5264
  const dom_1 = __webpack_require__(394);
5231
5265
  function lineable(parser) {
5232
5266
  return (0, combinator_1.convert)(source => `\r${source}`, parser);
5233
5267
  }
5234
5268
  exports.lineable = lineable;
5269
+ function repeat(symbol, parser, cons, termination = (acc, rest, prefix, postfix) => {
5270
+ const nodes = [];
5271
+ if (prefix > 0) {
5272
+ nodes.push(symbol[0].repeat(prefix));
5273
+ }
5274
+ for (let i = 0; i < acc.length; ++i) {
5275
+ nodes.push(...acc[i]);
5276
+ }
5277
+ if (postfix > 0) {
5278
+ nodes.push(rest.slice(0, postfix));
5279
+ rest = rest.slice(postfix);
5280
+ }
5281
+ return [nodes, rest];
5282
+ }) {
5283
+ return input => {
5284
+ const {
5285
+ source,
5286
+ context
5287
+ } = input;
5288
+ let acc = [];
5289
+ let i = symbol.length;
5290
+ while (source[i] === source[0]) ++i;
5291
+ let rest = source.slice(i);
5292
+ let state = false;
5293
+ for (; i >= symbol.length; i -= symbol.length) {
5294
+ if (acc.length > 0 && rest.startsWith(symbol)) {
5295
+ acc = [cons(acc.flat(), context)];
5296
+ rest = rest.slice(symbol.length);
5297
+ continue;
5298
+ }
5299
+ const result = parser({
5300
+ source: rest,
5301
+ context
5302
+ });
5303
+ if (result === undefined) break;
5304
+ const nodes = (0, parser_1.eval)(result);
5305
+ rest = (0, parser_1.exec)(result);
5306
+ acc.push(nodes);
5307
+ switch (nodes.at(-1)) {
5308
+ case "\u001B" /* Command.Escape */:
5309
+ nodes.pop();
5310
+ state = false;
5311
+ break;
5312
+ case "\u001F" /* Command.Separator */:
5313
+ nodes.pop();
5314
+ state = true;
5315
+ continue;
5316
+ default:
5317
+ acc = [cons(acc.flat(), context)];
5318
+ state = true;
5319
+ continue;
5320
+ }
5321
+ break;
5322
+ }
5323
+ if (acc.length === 0) return;
5324
+ const prefix = i;
5325
+ i = 0;
5326
+ for (let len = (0, alias_1.min)(prefix, rest.length); i < len && rest[i] === symbol[0];) {
5327
+ ++i;
5328
+ }
5329
+ const postfix = i;
5330
+ return termination(acc, rest, prefix, postfix, state);
5331
+ };
5332
+ }
5333
+ exports.repeat = repeat;
5235
5334
  function markInvalid(el, syntax, type, message) {
5236
5335
  return (0, dom_1.define)(el, {
5237
5336
  class: void el.classList.add('invalid'),
@@ -5304,7 +5403,7 @@ function elem(tag, as, bs, cs) {
5304
5403
  if (!tags.includes(tag)) return invalid('tag', `Invalid HTML tag name "${tag}"`, as, bs, cs);
5305
5404
  if (cs.length === 0) return invalid('tag', `Missing the closing HTML tag "</${tag}>"`, as, bs, cs);
5306
5405
  if (bs.length === 0) return invalid('content', `Missing the content`, as, bs, cs);
5307
- if (!(0, visibility_1.isStartLooseNodes)(bs)) return invalid('content', `Missing the visible content in the same line`, as, bs, cs);
5406
+ if (!(0, visibility_1.isLooseNodeStart)(bs)) return invalid('content', `Missing the visible content in the same line`, as, bs, cs);
5308
5407
  const attrs = attributes('html', [], attrspecs[tag], as.slice(1, -1));
5309
5408
  return 'data-invalid-syntax' in attrs ? invalid('attribute', 'Invalid HTML attribute', as, bs, cs) : (0, dom_1.html)(tag, attrs, (0, dom_1.defrag)(bs));
5310
5409
  }
@@ -5373,20 +5472,21 @@ exports.mark = void 0;
5373
5472
  const combinator_1 = __webpack_require__(3484);
5374
5473
  const inline_1 = __webpack_require__(7973);
5375
5474
  const indexee_1 = __webpack_require__(7610);
5376
- const source_1 = __webpack_require__(8745);
5377
5475
  const visibility_1 = __webpack_require__(6364);
5476
+ const util_1 = __webpack_require__(4992);
5378
5477
  const array_1 = __webpack_require__(6876);
5379
5478
  const dom_1 = __webpack_require__(394);
5380
- exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(2 /* State.mark */, false, (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)('==', '='), (0, combinator_1.precedence)(0, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('==')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '='), exports.mark)])))), (0, source_1.str)('=='), false, ([, bs], rest, {
5479
+ exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(2 /* State.mark */, false, (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.validate)('==', (0, combinator_1.precedence)(0, (0, util_1.repeat)('==', (0, combinator_1.surround)('', (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('==')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '='), exports.mark)]))), '==', false, ([, bs], rest) => [bs, rest], ([, bs], rest) => [(0, array_1.push)(bs, ["\u001B" /* Command.Escape */]), rest]), (nodes, {
5381
5480
  id
5382
5481
  }) => {
5383
- const el = (0, dom_1.html)('mark', (0, dom_1.defrag)(bs));
5384
- return [[(0, dom_1.define)(el, {
5482
+ const el = (0, dom_1.html)('mark', (0, dom_1.defrag)(nodes));
5483
+ (0, dom_1.define)(el, {
5385
5484
  id: (0, indexee_1.identity)('mark', id, (0, indexee_1.signature)(el))
5386
- }), el.id && (0, dom_1.html)('a', {
5485
+ });
5486
+ return el.id ? [el, el.id && (0, dom_1.html)('a', {
5387
5487
  href: `#${el.id}`
5388
- })], rest];
5389
- }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]))));
5488
+ })] : [el];
5489
+ }))))));
5390
5490
 
5391
5491
  /***/ },
5392
5492
 
@@ -5457,10 +5557,6 @@ exports.text = (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, ({
5457
5557
  case '\n':
5458
5558
  return [[(0, dom_1.html)('br')], source.slice(1)];
5459
5559
  case '*':
5460
- case '/':
5461
- case '+':
5462
- case '~':
5463
- case '=':
5464
5560
  case '`':
5465
5561
  return source[1] === source[0] ? repeat({
5466
5562
  source,
@@ -5654,7 +5750,7 @@ function context(base, parser) {
5654
5750
  exports.context = context;
5655
5751
  function apply(parser, source, context, changes, values, reset = false) {
5656
5752
  if (reset) {
5657
- context.logger = {};
5753
+ context.backtracks = {};
5658
5754
  }
5659
5755
  for (let i = 0; i < changes.length; ++i) {
5660
5756
  const change = changes[i];
@@ -5799,7 +5895,7 @@ exports.clear = exports.close = exports.open = exports.surround = void 0;
5799
5895
  const parser_1 = __webpack_require__(605);
5800
5896
  const fmap_1 = __webpack_require__(2705);
5801
5897
  const array_1 = __webpack_require__(6876);
5802
- function surround(opener, parser, closer, optional = false, f, g, log = 0) {
5898
+ function surround(opener, parser, closer, optional = false, f, g, backtrack = 0, bstate = 0) {
5803
5899
  switch (typeof opener) {
5804
5900
  case 'string':
5805
5901
  case 'object':
@@ -5823,22 +5919,30 @@ function surround(opener, parser, closer, optional = false, f, g, log = 0) {
5823
5919
  if (res1 === undefined) return;
5824
5920
  const rl = (0, parser_1.eval)(res1);
5825
5921
  const mr_ = (0, parser_1.exec)(res1);
5826
- if (log & 1) {
5922
+ if (backtrack & 1) {
5827
5923
  const {
5828
- logger = {},
5924
+ backtracks = {},
5925
+ backtrack: state = 0,
5829
5926
  offset = 0
5830
5927
  } = context;
5831
5928
  for (let i = 0; i < source.length - mr_.length; ++i) {
5832
5929
  if (source[i] !== source[0]) break;
5833
5930
  const pos = source.length + offset - i - 1;
5834
- if (!(pos in logger)) continue;
5835
- if (logger[pos] & 1 << (log >>> 2)) return;
5931
+ if (!(pos in backtracks)) continue;
5932
+ // bracket only
5933
+ const shift = backtrack >>> 2 === state >>> 2 ? state & 3 : 0;
5934
+ if (backtracks[pos] & 1 << (backtrack >>> 2) + shift) return;
5836
5935
  }
5837
5936
  }
5937
+ const {
5938
+ backtrack: state = 0
5939
+ } = context;
5940
+ context.backtrack = state | bstate;
5838
5941
  const res2 = mr_ !== '' ? parser({
5839
5942
  source: mr_,
5840
5943
  context
5841
5944
  }) : undefined;
5945
+ context.backtrack = state;
5842
5946
  const rm = (0, parser_1.eval)(res2);
5843
5947
  const r_ = (0, parser_1.exec)(res2, mr_);
5844
5948
  if (!rm && !optional) return;
@@ -5849,12 +5953,15 @@ function surround(opener, parser, closer, optional = false, f, g, log = 0) {
5849
5953
  const rr = (0, parser_1.eval)(res3);
5850
5954
  const rest = (0, parser_1.exec)(res3, r_);
5851
5955
  if (rest.length === lmr_.length) return;
5852
- if (log & 2 && rr === undefined) {
5956
+ if (backtrack & 2 && rr === undefined) {
5853
5957
  const {
5854
- logger = {},
5958
+ backtracks = {},
5959
+ backtrack: state = 0,
5855
5960
  offset = 0
5856
5961
  } = context;
5857
- logger[source.length + offset - 1] |= 1 << (log >>> 2);
5962
+ // bracket only
5963
+ const shift = backtrack >>> 2 === state >>> 2 ? state & 3 : 0;
5964
+ backtracks[source.length + offset - 1] |= 1 << (backtrack >>> 2) + shift;
5858
5965
  }
5859
5966
  return rr ? f ? f([rl, rm, rr], rest, context) : [(0, array_1.push)((0, array_1.unshift)(rl, rm ?? []), rr), rest] : g ? g([rl, rm, mr_], rest, context) : undefined;
5860
5967
  };
@@ -6052,12 +6159,12 @@ const array_1 = __webpack_require__(6876);
6052
6159
  const dom_1 = __webpack_require__(394);
6053
6160
  // Don't use the symbols already used: !#$%@&*+~=|
6054
6161
  // All syntax surrounded by square brackets shouldn't contain line breaks.
6055
- exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.precedence)(1, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]]))), (0, source_1.str)(']'), false, ([, bs], rest) => [[(0, dom_1.html)('span', {
6162
+ exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.precedence)(1, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]]))), (0, source_1.str)(']'), false, ([, bs], rest) => [[(0, dom_1.html)('span', {
6056
6163
  class: 'invalid',
6057
6164
  'data-invalid-syntax': 'extension',
6058
6165
  'data-invalid-type': 'syntax',
6059
6166
  'data-invalid-message': `Invalid start symbol or linebreak`
6060
- }, (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 4 /* Backtrack.bracket */)));
6167
+ }, (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 8 /* Backtrack.bracket */)));
6061
6168
 
6062
6169
  /***/ },
6063
6170
 
@@ -6175,7 +6282,7 @@ __exportStar(__webpack_require__(1311), exports);
6175
6282
  Object.defineProperty(exports, "__esModule", ({
6176
6283
  value: true
6177
6284
  }));
6178
- exports.trimBlankNodeEnd = exports.trimBlankEnd = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.blankWith = exports.visualize = exports.blank = void 0;
6285
+ exports.trimBlankNodeEnd = exports.trimBlankEnd = exports.trimBlankStart = exports.trimBlank = exports.isTightNodeStart = exports.isLooseNodeStart = exports.tightStart = exports.blankWith = exports.visualize = exports.blank = void 0;
6179
6286
  const parser_1 = __webpack_require__(605);
6180
6287
  const combinator_1 = __webpack_require__(3484);
6181
6288
  const htmlentity_1 = __webpack_require__(470);
@@ -6205,16 +6312,18 @@ function hasVisible(nodes) {
6205
6312
  }
6206
6313
  return false;
6207
6314
  }
6208
- function blankWith(starting, delimiter) {
6209
- if (delimiter === undefined) return blankWith('', starting);
6210
- return new RegExp(String.raw`^(?:(?=${starting})(?:\\?\s|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr[^\S\n]*>)${starting && '+'})?${typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source}`);
6315
+ function blankWith(starts, delimiter) {
6316
+ if (delimiter === undefined) return blankWith('', starts);
6317
+ return new RegExp(String.raw`^(?:(?=${starts})(?:\\?\s|&(?:${normalize_1.invisibleHTMLEntityNames.join('|')});|<wbr[^\S\n]*>)${
6318
+ // 空行除去
6319
+ starts && '+'})?${typeof delimiter === 'string' ? delimiter.replace(/[*+()\[\]]/g, '\\$&') : delimiter.source}`);
6211
6320
  }
6212
6321
  exports.blankWith = blankWith;
6213
- function startTight(parser, except) {
6214
- return input => isStartTight(input, except) ? parser(input) : undefined;
6322
+ function tightStart(parser, except) {
6323
+ return input => isTightStart(input, except) ? parser(input) : undefined;
6215
6324
  }
6216
- exports.startTight = startTight;
6217
- const isStartTight = (0, memoize_1.reduce)((input, except) => {
6325
+ exports.tightStart = tightStart;
6326
+ const isTightStart = (0, memoize_1.reduce)((input, except) => {
6218
6327
  const {
6219
6328
  source
6220
6329
  } = input;
@@ -6246,7 +6355,7 @@ const isStartTight = (0, memoize_1.reduce)((input, except) => {
6246
6355
  }, ({
6247
6356
  source
6248
6357
  }, except = '') => `${source}${"\u001F" /* Command.Separator */}${except}`);
6249
- function isStartLooseNodes(nodes) {
6358
+ function isLooseNodeStart(nodes) {
6250
6359
  if (nodes.length === 0) return true;
6251
6360
  for (let i = 0; i < nodes.length; ++i) {
6252
6361
  const node = nodes[i];
@@ -6255,13 +6364,13 @@ function isStartLooseNodes(nodes) {
6255
6364
  }
6256
6365
  return false;
6257
6366
  }
6258
- exports.isStartLooseNodes = isStartLooseNodes;
6259
- function isStartTightNodes(nodes) {
6367
+ exports.isLooseNodeStart = isLooseNodeStart;
6368
+ function isTightNodeStart(nodes) {
6260
6369
  if (nodes.length === 0) return true;
6261
6370
  return isVisible(nodes[0], 0);
6262
6371
  }
6263
- exports.isStartTightNodes = isStartTightNodes;
6264
- //export function isEndTightNodes(nodes: readonly (HTMLElement | string)[]): boolean {
6372
+ exports.isTightNodeStart = isTightNodeStart;
6373
+ //export function isTightNodeEnd(nodes: readonly (HTMLElement | string)[]): boolean {
6265
6374
  // if (nodes.length === 0) return true;
6266
6375
  // return isVisible(nodes.at(-1)!, -1);
6267
6376
  //}
@@ -6384,14 +6493,14 @@ function convert(conv, parser, empty = false) {
6384
6493
  if (src === '') return empty ? [[], ''] : undefined;
6385
6494
  const sub = source.endsWith(src);
6386
6495
  const {
6387
- logger
6496
+ backtracks
6388
6497
  } = context;
6389
- context.logger = sub ? logger : {};
6498
+ context.backtracks = sub ? backtracks : {};
6390
6499
  const result = parser({
6391
6500
  source: src,
6392
6501
  context
6393
6502
  });
6394
- context.logger = logger;
6503
+ context.backtracks = backtracks;
6395
6504
  return result;
6396
6505
  };
6397
6506
  }
@@ -6416,7 +6525,7 @@ const source_1 = __webpack_require__(8745);
6416
6525
  const visibility_1 = __webpack_require__(6364);
6417
6526
  const array_1 = __webpack_require__(6876);
6418
6527
  const dom_1 = __webpack_require__(394);
6419
- exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)('**', '*'), (0, combinator_1.precedence)(0, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('**')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, exports.strong]))])))), (0, source_1.str)('**'), false, ([, bs], rest) => [[(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
6528
+ exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)('**', '*'), (0, combinator_1.precedence)(0, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('**')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, exports.strong]))])))), (0, source_1.str)('**'), false, ([, bs], rest) => [[(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
6420
6529
 
6421
6530
  /***/ },
6422
6531
 
@@ -6794,11 +6903,11 @@ Object.defineProperty(exports, "__esModule", ({
6794
6903
  exports.deletion = void 0;
6795
6904
  const combinator_1 = __webpack_require__(3484);
6796
6905
  const inline_1 = __webpack_require__(7973);
6797
- const source_1 = __webpack_require__(8745);
6798
6906
  const visibility_1 = __webpack_require__(6364);
6907
+ const util_1 = __webpack_require__(4992);
6799
6908
  const array_1 = __webpack_require__(6876);
6800
6909
  const dom_1 = __webpack_require__(394);
6801
- exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.surround)((0, source_1.str)('~~', '~'), (0, combinator_1.precedence)(0, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '~~')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '~'), true)]))), (0, source_1.str)('~~'), false, ([, bs], rest) => [[(0, dom_1.html)('del', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
6910
+ exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 4 /* Recursion.inline */, (0, combinator_1.validate)('~~', (0, combinator_1.precedence)(0, (0, util_1.repeat)('~~', (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '~~')), (0, combinator_1.open)('\n', (0, combinator_1.some)(exports.deletion, '~'), true)])), '~~', false, ([, bs], rest) => [bs, rest], ([, bs], rest) => [(0, array_1.push)(bs, ["\u001B" /* Command.Escape */]), rest]), nodes => [(0, dom_1.html)('del', (0, dom_1.defrag)(nodes))])))));
6802
6911
 
6803
6912
  /***/ },
6804
6913
 
@@ -6998,7 +7107,7 @@ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(1, 0 /* R
6998
7107
  context
6999
7108
  }), [undefined])[0];
7000
7109
  ns && ns.at(-1) === '' && ns.pop();
7001
- return ns && (0, visibility_1.isStartTightNodes)(ns) ? [[ns], rest] : undefined;
7110
+ return ns && (0, visibility_1.isTightNodeStart)(ns) ? [[ns], rest] : undefined;
7002
7111
  }), (0, combinator_1.bind)((0, combinator_1.surround)('(', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ')', false, undefined, undefined, 3 | 20 /* Backtrack.ruby */), ([source], rest, context) => {
7003
7112
  const ns = (0, parser_1.eval)(text({
7004
7113
  source,
@@ -7153,7 +7262,7 @@ const optspec = {
7153
7262
  rel: undefined
7154
7263
  };
7155
7264
  Object.setPrototypeOf(optspec, null);
7156
- exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* State.media */, false, (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.open)('!', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.tails)([(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]), ']', [['\n', 9]])), ']', true, undefined, undefined, 1 | 12 /* Backtrack.media */)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/, false, undefined, undefined, 3 | 16 /* Backtrack.link */))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
7265
+ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* State.media */, false, (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.open)('!', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.verify)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ns => ns[0] !== "\u001B" /* Command.Escape */), ']', [['\n', 9]])), ']', true, undefined, undefined, 1 | 16 /* Backtrack.media */)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/, false, undefined, undefined, 3 | 24 /* Backtrack.link */))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
7157
7266
  const INSECURE_URI = params.shift();
7158
7267
  const url = new url_1.ReadonlyURL((0, link_1.resolve)(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
7159
7268
  let cache;
@@ -7180,7 +7289,7 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* S
7180
7289
  });
7181
7290
  }))))));
7182
7291
  exports.linemedia = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.media]), /^(?=[^\S\n]*(?:$|\n))/);
7183
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(0, 6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 12 /* Backtrack.media */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 12 /* Backtrack.media */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 12 /* Backtrack.media */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true, undefined, undefined, 3 | 12 /* Backtrack.media */)])));
7292
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(0, 6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 16 /* Backtrack.media */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 16 /* Backtrack.media */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 16 /* Backtrack.media */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 16 /* Backtrack.media */)])));
7184
7293
  const option = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*x[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` width="${opt.slice(1).split('x')[0]}"`, ` height="${opt.slice(1).split('x')[1]}"`]), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*:[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` aspect-ratio="${opt.slice(1).split(':').join('/')}"`]), link_1.option]));
7185
7294
  function sanitize(target, uri, alt) {
7186
7295
  switch (uri.protocol) {
@@ -7646,14 +7755,14 @@ function rewrite(scope, parser) {
7646
7755
  } = input;
7647
7756
  if (source === '') return;
7648
7757
  const {
7649
- logger
7758
+ backtracks
7650
7759
  } = context;
7651
- context.logger = {};
7760
+ context.backtracks = {};
7652
7761
  //const { resources = { clock: 0 } } = context;
7653
7762
  //const clock = resources.clock;
7654
7763
  const res1 = scope(input);
7655
7764
  //resources.clock = clock;
7656
- context.logger = logger;
7765
+ context.backtracks = backtracks;
7657
7766
  if (res1 === undefined || (0, parser_1.exec)(res1).length >= source.length) return;
7658
7767
  const src = source.slice(0, source.length - (0, parser_1.exec)(res1).length);
7659
7768
  const offset = source.length - src.length;
@@ -7688,8 +7797,8 @@ const reference_1 = __webpack_require__(9047);
7688
7797
  const template_1 = __webpack_require__(4510);
7689
7798
  const remark_1 = __webpack_require__(8948);
7690
7799
  const extension_1 = __webpack_require__(2743);
7691
- const ruby_1 = __webpack_require__(7304);
7692
7800
  const link_1 = __webpack_require__(3628);
7801
+ const ruby_1 = __webpack_require__(7304);
7693
7802
  const html_1 = __webpack_require__(5013);
7694
7803
  const insertion_1 = __webpack_require__(4515);
7695
7804
  const deletion_1 = __webpack_require__(7066);
@@ -7737,7 +7846,7 @@ exports.inline = (0, combinator_1.lazy)(() => (0, combinator_1.union)([input =>
7737
7846
  }
7738
7847
  switch (source[0]) {
7739
7848
  case '[':
7740
- return (0, ruby_1.ruby)(input) || (0, link_1.textlink)(input);
7849
+ return (0, link_1.textlink)(input) || (0, ruby_1.ruby)(input);
7741
7850
  case '{':
7742
7851
  return (0, link_1.textlink)(input);
7743
7852
  case '<':
@@ -8742,7 +8851,7 @@ const inline_1 = __webpack_require__(7973);
8742
8851
  const source_1 = __webpack_require__(8745);
8743
8852
  const visibility_1 = __webpack_require__(6364);
8744
8853
  const dom_1 = __webpack_require__(394);
8745
- exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64 /* State.reference */, false, (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.surround)('[[', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */ | 4 /* State.media */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [['\n', 9], [']', 1]]))]))), ']]', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])], rest] : undefined, undefined, 1 | 4 /* Backtrack.bracket */))));
8854
+ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64 /* State.reference */, false, (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.surround)('[[', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */ | 4 /* State.media */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [['\n', 9], [']', 1]]))]))), ']]', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])], rest] : undefined, undefined, 1 | 12 /* Backtrack.linebracket */, 8 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */))));
8746
8855
  // Chicago-Style
8747
8856
  const abbr = (0, combinator_1.creation)(1, 0 /* Recursion.ignore */, (0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/, true, ([, ns], rest) => ns ? [['\n', ns[0].trimEnd()], rest.replace(visibility_1.blank.start, '')] : [[''], `^${rest}`], ([,, rest]) => [[''], `^${rest}`]));
8748
8857
  function attributes(ns) {