securemark 0.280.1 → 0.280.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.280.3
4
+
5
+ - Refactoring.
6
+
7
+ ## 0.280.2
8
+
9
+ - Refactoring.
10
+
3
11
  ## 0.280.1
4
12
 
5
13
  - Refactoring.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.280.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.280.3 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"));
@@ -2682,7 +2682,6 @@ Object.defineProperty(exports, "__esModule", ({
2682
2682
  }));
2683
2683
  exports.block = void 0;
2684
2684
  const parser_1 = __webpack_require__(6728);
2685
- const memo_1 = __webpack_require__(1090);
2686
2685
  const line_1 = __webpack_require__(9315);
2687
2686
  function block(parser, separation = true) {
2688
2687
  return ({
@@ -2690,7 +2689,6 @@ function block(parser, separation = true) {
2690
2689
  context
2691
2690
  }) => {
2692
2691
  if (source === '') return;
2693
- context.memo ??= new memo_1.Memo();
2694
2692
  const result = parser({
2695
2693
  source,
2696
2694
  context
@@ -2767,14 +2765,12 @@ Object.defineProperty(exports, "__esModule", ({
2767
2765
  }));
2768
2766
  exports.isBlank = exports.firstline = exports.line = void 0;
2769
2767
  const parser_1 = __webpack_require__(6728);
2770
- const memo_1 = __webpack_require__(1090);
2771
2768
  function line(parser) {
2772
2769
  return ({
2773
2770
  source,
2774
2771
  context
2775
2772
  }) => {
2776
2773
  if (source === '') return;
2777
- context.memo ??= new memo_1.Memo();
2778
2774
  const line = firstline(source);
2779
2775
  context.offset ??= 0;
2780
2776
  context.offset += source.length - line.length;
@@ -2927,7 +2923,7 @@ function fence(opener, limit, separation = true) {
2927
2923
  }
2928
2924
  rest = rest.slice(line.length);
2929
2925
  }
2930
- return [(0, array_1.unshift)([block, overflow, closer], matches), rest];
2926
+ return [(0, array_1.push)([block, overflow, closer], matches), rest];
2931
2927
  };
2932
2928
  }
2933
2929
  exports.fence = fence;
@@ -3325,9 +3321,6 @@ const alias_1 = __webpack_require__(5406);
3325
3321
  const parser_1 = __webpack_require__(6728);
3326
3322
  const memo_1 = __webpack_require__(1090);
3327
3323
  function reset(base, parser) {
3328
- if (!('memo' in base)) {
3329
- base.memo = undefined;
3330
- }
3331
3324
  const changes = Object.entries(base);
3332
3325
  const values = Array(changes.length);
3333
3326
  return ({
@@ -3346,44 +3339,33 @@ function context(base, parser) {
3346
3339
  }
3347
3340
  exports.context = context;
3348
3341
  function apply(parser, source, context, changes, values, reset = false) {
3349
- if (context) for (let i = 0; i < changes.length; ++i) {
3342
+ for (let i = 0; i < changes.length; ++i) {
3350
3343
  const change = changes[i];
3351
3344
  const prop = change[0];
3352
3345
  switch (prop) {
3353
3346
  case 'resources':
3354
- if (!reset) break;
3355
- if (prop in context && !(0, alias_1.hasOwnProperty)(context, prop)) break;
3356
- context[prop] = (0, alias_1.ObjectCreate)(change[1]);
3357
- break;
3358
- // @ts-expect-error
3359
- case 'memo':
3360
- if (!reset) break;
3361
- context.memo = new memo_1.Memo({
3362
- targets: context.memo?.targets
3363
- });
3364
- // fallthrough
3365
- default:
3366
- values[i] = context[prop];
3367
- context[prop] = change[1];
3347
+ context[prop] ??= (0, alias_1.ObjectCreate)(change[1]);
3348
+ continue;
3368
3349
  }
3350
+ values[i] = context[prop];
3351
+ context[prop] = change[1];
3369
3352
  }
3370
3353
  const result = parser({
3371
3354
  source,
3372
3355
  context
3373
3356
  });
3374
- if (context) for (let i = 0; i < changes.length; ++i) {
3357
+ for (let i = 0; i < changes.length; ++i) {
3375
3358
  const change = changes[i];
3376
3359
  const prop = change[0];
3377
3360
  switch (prop) {
3378
3361
  case 'resources':
3379
- // @ts-expect-error
3362
+ break;
3380
3363
  case 'memo':
3381
- if (!reset) break;
3382
- // fallthrough
3383
- default:
3384
- context[prop] = values[i];
3385
- values[i] = undefined;
3364
+ context.memo.clear();
3365
+ break;
3386
3366
  }
3367
+ context[prop] = values[i];
3368
+ values[i] = undefined;
3387
3369
  }
3388
3370
  return result;
3389
3371
  }
@@ -3398,16 +3380,15 @@ function syntax(syntax, prec, state, parser) {
3398
3380
  const position = source.length + context.offset;
3399
3381
  const stateOuter = context.state ?? 0;
3400
3382
  const stateInner = context.state = stateOuter | state;
3401
- const cache = syntax && stateInner & memo.targets && memo.get(position, syntax, stateInner);
3383
+ const cache = syntax & memo.targets && stateInner && memo.get(position, syntax, stateInner);
3402
3384
  const result = cache ? cache.length === 0 ? undefined : [cache[0], source.slice(cache[1])] : parser({
3403
3385
  source,
3404
3386
  context
3405
3387
  });
3406
- if (syntax && stateOuter & memo.targets) {
3407
- cache ?? memo.set(position, syntax, stateInner, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result, '').length);
3408
- }
3409
- if (result && !stateOuter && memo.length >= position + 2) {
3410
- memo.clear(position + 2);
3388
+ if (stateOuter && !cache && syntax & memo.targets) {
3389
+ memo.set(position, syntax, stateInner, (0, parser_1.eval)(result), source.length - (0, parser_1.exec)(result, '').length);
3390
+ } else if (!stateOuter && result && memo.length >= position + memo.margin) {
3391
+ memo.resize(position + memo.margin);
3411
3392
  }
3412
3393
  context.state = stateOuter;
3413
3394
  return result;
@@ -3557,7 +3538,7 @@ class Delimiters {
3557
3538
  const {
3558
3539
  signature,
3559
3540
  matcher,
3560
- precedence = 1
3541
+ precedence
3561
3542
  } = delims[i];
3562
3543
  const stack = registry(signature);
3563
3544
  const index = stack[0]?.index ?? delimiters.length;
@@ -3576,7 +3557,7 @@ class Delimiters {
3576
3557
  }
3577
3558
  }
3578
3559
  }
3579
- pop(count = 1) {
3560
+ pop(count) {
3580
3561
  const {
3581
3562
  registry,
3582
3563
  delimiters,
@@ -3640,35 +3621,41 @@ Object.defineProperty(exports, "__esModule", ({
3640
3621
  }));
3641
3622
  exports.Memo = void 0;
3642
3623
  class Memo {
3643
- constructor({
3644
- targets = ~0
3645
- } = {}) {
3646
- this.memory = [];
3624
+ constructor(targets = ~0, margin = 0) {
3647
3625
  this.targets = targets;
3626
+ this.margin = margin;
3627
+ this.memory = [];
3628
+ this.count = 0;
3648
3629
  }
3649
3630
  get length() {
3650
3631
  return this.memory.length;
3651
3632
  }
3652
3633
  get(position, syntax, state) {
3634
+ if (this.count === 0) return;
3653
3635
  //console.log('get', position, syntax, state, this.memory[position - 1]?.[syntax]?.[state]);
3654
3636
  const cache = this.memory[position - 1]?.[syntax]?.[state];
3655
3637
  return cache?.length === 2 ? [cache[0].slice(), cache[1]] : cache;
3656
3638
  }
3657
3639
  set(position, syntax, state, nodes, offset) {
3640
+ this.count += +!this.memory[position - 1];
3658
3641
  const record = this.memory[position - 1] ??= {};
3659
3642
  (record[syntax] ??= {})[state] = nodes ? [nodes.slice(), offset] : [];
3660
3643
  //console.log('set', position, syntax, state, record[syntax]?.[state]);
3661
3644
  }
3662
3645
 
3663
- clear(position) {
3646
+ resize(position) {
3664
3647
  const memory = this.memory;
3665
3648
  for (let len = memory.length, i = position; i < len; ++i) {
3666
- memory.pop();
3649
+ this.count -= +memory.pop();
3667
3650
  }
3668
- //console.log('clear', position + 1);
3651
+ //console.log('resize', position);
3669
3652
  }
3670
- }
3671
3653
 
3654
+ clear() {
3655
+ this.memory = [];
3656
+ this.count = 0;
3657
+ }
3658
+ }
3672
3659
  exports.Memo = Memo;
3673
3660
 
3674
3661
  /***/ }),
@@ -3792,7 +3779,7 @@ function some(parser, end, delimiters = [], limit = -1) {
3792
3779
  context
3793
3780
  });
3794
3781
  if (result === undefined) break;
3795
- nodes = nodes ? nodes.length < (0, parser_1.eval)(result).length ? (0, array_1.unshift)(nodes, (0, parser_1.eval)(result)) : (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
3782
+ nodes = nodes ? nodes.length < (0, parser_1.eval)(result).length / 8 ? (0, array_1.unshift)(nodes, (0, parser_1.eval)(result)) : (0, array_1.push)(nodes, (0, parser_1.eval)(result)) : (0, parser_1.eval)(result);
3796
3783
  rest = (0, parser_1.exec)(result);
3797
3784
  if (limit >= 0 && source.length - rest.length > limit) break;
3798
3785
  }
@@ -3972,7 +3959,6 @@ Object.defineProperty(exports, "__esModule", ({
3972
3959
  }));
3973
3960
  exports.bind = void 0;
3974
3961
  const parser_1 = __webpack_require__(6728);
3975
- const memo_1 = __webpack_require__(1090);
3976
3962
  const segment_1 = __webpack_require__(9002);
3977
3963
  const header_1 = __webpack_require__(5702);
3978
3964
  const block_1 = __webpack_require__(4032);
@@ -3985,12 +3971,8 @@ const array_1 = __webpack_require__(8112);
3985
3971
  function bind(target, settings) {
3986
3972
  let context = {
3987
3973
  ...settings,
3988
- host: settings.host ?? new url_1.ReadonlyURL(location.pathname, location.origin),
3989
- memo: new memo_1.Memo({
3990
- targets: 472 /* State.backtrackers */
3991
- })
3974
+ host: settings.host ?? new url_1.ReadonlyURL(location.pathname, location.origin)
3992
3975
  };
3993
-
3994
3976
  if (context.id?.match(/[^0-9a-z/-]/i)) throw new Error('Invalid ID: ID must be alphanumeric');
3995
3977
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
3996
3978
  const blocks = [];
@@ -4297,7 +4279,6 @@ Object.defineProperty(exports, "__esModule", ({
4297
4279
  }));
4298
4280
  exports.parse = void 0;
4299
4281
  const parser_1 = __webpack_require__(6728);
4300
- const memo_1 = __webpack_require__(1090);
4301
4282
  const segment_1 = __webpack_require__(9002);
4302
4283
  const header_1 = __webpack_require__(5702);
4303
4284
  const block_1 = __webpack_require__(4032);
@@ -4316,14 +4297,8 @@ function parse(source, opts = {}, context) {
4316
4297
  url: url ? new url_1.ReadonlyURL(url) : context?.url,
4317
4298
  id: opts.id ?? context?.id,
4318
4299
  caches: context?.caches,
4319
- ...(context?.resources && {
4320
- resources: context.resources
4321
- }),
4322
- memo: new memo_1.Memo({
4323
- targets: 472 /* State.backtrackers */
4324
- })
4300
+ resources: context?.resources
4325
4301
  };
4326
-
4327
4302
  if (context.id?.match(/[^0-9a-z/-]/i)) throw new Error('Invalid ID: ID must be alphanumeric');
4328
4303
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
4329
4304
  const node = (0, dom_1.frag)();
@@ -4376,6 +4351,7 @@ Object.defineProperty(exports, "__esModule", ({
4376
4351
  }));
4377
4352
  exports.block = void 0;
4378
4353
  const combinator_1 = __webpack_require__(2087);
4354
+ const memo_1 = __webpack_require__(1090);
4379
4355
  const source_1 = __webpack_require__(6743);
4380
4356
  const pagebreak_1 = __webpack_require__(4107);
4381
4357
  const heading_1 = __webpack_require__(4623);
@@ -4394,12 +4370,13 @@ const reply_1 = __webpack_require__(9978);
4394
4370
  const paragraph_1 = __webpack_require__(6457);
4395
4371
  const random_1 = __webpack_require__(7325);
4396
4372
  const dom_1 = __webpack_require__(3252);
4397
- exports.block = (0, combinator_1.creation)(0, false, error((0, combinator_1.reset)({
4373
+ exports.block = (0, combinator_1.creation)(0, false, (0, combinator_1.reset)({
4398
4374
  resources: {
4399
4375
  clock: 20000,
4400
4376
  recursion: 20 + 1
4401
- }
4402
- }, (0, combinator_1.union)([source_1.emptyline, pagebreak_1.pagebreak, heading_1.heading, ulist_1.ulist, olist_1.olist, ilist_1.ilist, dlist_1.dlist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, extension_1.extension, sidefence_1.sidefence, blockquote_1.blockquote, mediablock_1.mediablock, reply_1.reply, paragraph_1.paragraph]))));
4377
+ },
4378
+ memo: new memo_1.Memo(508 /* Syntax.targets */, 2)
4379
+ }, error((0, combinator_1.union)([source_1.emptyline, pagebreak_1.pagebreak, heading_1.heading, ulist_1.ulist, olist_1.olist, ilist_1.ilist, dlist_1.dlist, table_1.table, codeblock_1.codeblock, mathblock_1.mathblock, extension_1.extension, sidefence_1.sidefence, blockquote_1.blockquote, mediablock_1.mediablock, reply_1.reply, paragraph_1.paragraph]))));
4403
4380
  function error(parser) {
4404
4381
  return (0, combinator_1.recover)((0, combinator_1.fallback)((0, combinator_1.open)('\x07', ({
4405
4382
  source
@@ -5792,7 +5769,6 @@ const annotation_1 = __webpack_require__(2736);
5792
5769
  const reference_1 = __webpack_require__(3555);
5793
5770
  const template_1 = __webpack_require__(4695);
5794
5771
  const remark_1 = __webpack_require__(3217);
5795
- const math_1 = __webpack_require__(8946);
5796
5772
  const extension_1 = __webpack_require__(8053);
5797
5773
  const ruby_1 = __webpack_require__(6705);
5798
5774
  const link_1 = __webpack_require__(9628);
@@ -5801,14 +5777,15 @@ const insertion_1 = __webpack_require__(2945);
5801
5777
  const deletion_1 = __webpack_require__(7501);
5802
5778
  const mark_1 = __webpack_require__(2480);
5803
5779
  const emstrong_1 = __webpack_require__(6132);
5804
- const emphasis_1 = __webpack_require__(3867);
5805
5780
  const strong_1 = __webpack_require__(6578);
5781
+ const emphasis_1 = __webpack_require__(3867);
5782
+ const math_1 = __webpack_require__(8946);
5806
5783
  const code_1 = __webpack_require__(5771);
5807
5784
  const htmlentity_1 = __webpack_require__(1562);
5808
5785
  const autolink_1 = __webpack_require__(6051);
5809
5786
  const bracket_1 = __webpack_require__(5196);
5810
5787
  const source_1 = __webpack_require__(6743);
5811
- exports.inline = (0, combinator_1.lazy)(() => (0, combinator_1.union)([annotation_1.annotation, reference_1.reference, template_1.template, remark_1.remark, math_1.math, extension_1.extension, ruby_1.ruby, link_1.textlink, html_1.html, insertion_1.insertion, deletion_1.deletion, mark_1.mark, emstrong_1.emstrong, strong_1.strong, emphasis_1.emphasis, code_1.code, htmlentity_1.htmlentity, autolink_1.autolink, bracket_1.bracket, source_1.text]));
5788
+ exports.inline = (0, combinator_1.lazy)(() => (0, combinator_1.union)([annotation_1.annotation, reference_1.reference, template_1.template, remark_1.remark, extension_1.extension, ruby_1.ruby, link_1.textlink, html_1.html, insertion_1.insertion, deletion_1.deletion, mark_1.mark, emstrong_1.emstrong, strong_1.strong, emphasis_1.emphasis, math_1.math, code_1.code, htmlentity_1.htmlentity, autolink_1.autolink, bracket_1.bracket, source_1.text]));
5812
5789
  var indexee_1 = __webpack_require__(1269);
5813
5790
  Object.defineProperty(exports, "indexee", ({
5814
5791
  enumerable: true,
@@ -5861,7 +5838,7 @@ const combinator_1 = __webpack_require__(2087);
5861
5838
  const inline_1 = __webpack_require__(1160);
5862
5839
  const visibility_1 = __webpack_require__(7618);
5863
5840
  const dom_1 = __webpack_require__(3252);
5864
- exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.surround)('((', (0, combinator_1.constraint)(256 /* State.annotation */, false, (0, combinator_1.syntax)(0 /* Syntax.none */, 6, 256 /* State.annotation */ | 8 /* State.media */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
5841
+ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.surround)('((', (0, combinator_1.constraint)(256 /* State.annotation */, false, (0, combinator_1.syntax)(256 /* Syntax.annotation */, 6, 256 /* State.annotation */ | 8 /* State.media */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
5865
5842
  class: 'annotation'
5866
5843
  }, [(0, dom_1.html)('span', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))])], rest])));
5867
5844
 
@@ -6080,11 +6057,11 @@ const source_1 = __webpack_require__(6743);
6080
6057
  const array_1 = __webpack_require__(8112);
6081
6058
  const dom_1 = __webpack_require__(3252);
6082
6059
  const index = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*/;
6083
- exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 2, 0 /* State.none */, (0, source_1.str)(index))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(8 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ')', [[/^\\?\n/, 3], [')', 2]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
6060
+ exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(0 /* Syntax.none */, 2, 0 /* State.none */, (0, source_1.str)(index))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ')', [[/^\\?\n/, 3], [')', 2]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
6084
6061
  class: 'paren'
6085
- }, (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, combinator_1.syntax)(0 /* Syntax.none */, 2, 0 /* State.none */, (0, source_1.str)(new RegExp(index.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0)))))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(8 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ')', [[/^\\?\n/, 3], [')', 2]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
6062
+ }, (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, combinator_1.syntax)(0 /* Syntax.none */, 2, 0 /* State.none */, (0, source_1.str)(new RegExp(index.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0)))))), (0, source_1.str)(')')), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.creation)((0, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ')', [[/^\\?\n/, 3], [')', 2]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
6086
6063
  class: 'paren'
6087
- }, (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, combinator_1.syntax)(8 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 3], [']', 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, combinator_1.syntax)(8 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '}', [[/^\\?\n/, 3], ['}', 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, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '"', [[/^\\?\n/, 4], ['"', 3]]))), (0, source_1.str)('"'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])]));
6064
+ }, (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, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 3], [']', 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, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 3], [']', 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, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '}', [[/^\\?\n/, 3], ['}', 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, combinator_1.syntax)(4 /* Syntax.bracket */, 2, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '}', [[/^\\?\n/, 3], ['}', 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, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '"', [[/^\\?\n/, 4], ['"', 3]]))), (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, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '”', [[/^\\?\n/, 4], ['”', 3]]))), (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, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '’', [[/^\\?\n/, 4], ['’', 3]]))), (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, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '」', [[/^\\?\n/, 4], ['」', 3]]))), (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, combinator_1.syntax)(0 /* Syntax.none */, 3, 0 /* State.none */, (0, combinator_1.some)(inline_1.inline, '』', [[/^\\?\n/, 4], ['』', 3]]))), (0, source_1.str)('』'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])]));
6088
6065
 
6089
6066
  /***/ }),
6090
6067
 
@@ -6226,7 +6203,7 @@ const indexee_1 = __webpack_require__(1269);
6226
6203
  const source_1 = __webpack_require__(6743);
6227
6204
  const visibility_1 = __webpack_require__(7618);
6228
6205
  const dom_1 = __webpack_require__(3252);
6229
- exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.creation)((0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.constraint)(64 /* State.index */, false, (0, combinator_1.syntax)(128 /* Syntax.index */, 2, 502 /* State.linkers */ | 8 /* State.media */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.inits)([inline_1.inline, exports.signature]), ']', [[/^\\?\n/, 9], [']', 2]])))), ']', false, ([, ns], rest) => [[(0, dom_1.html)('a', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))], rest])), ([el]) => [(0, dom_1.define)(el, {
6206
+ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.creation)((0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.constraint)(64 /* State.index */, false, (0, combinator_1.syntax)(64 /* Syntax.index */, 2, 502 /* State.linkers */ | 8 /* State.media */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.inits)([inline_1.inline, exports.signature]), ']', [[/^\\?\n/, 9], [']', 2]])))), ']', false, ([, ns], rest) => [[(0, dom_1.html)('a', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))], rest])), ([el]) => [(0, dom_1.define)(el, {
6230
6207
  id: el.id ? null : undefined,
6231
6208
  class: 'index',
6232
6209
  href: el.id ? `#${el.id}` : undefined
@@ -6428,7 +6405,7 @@ const array_1 = __webpack_require__(8112);
6428
6405
  const dom_1 = __webpack_require__(3252);
6429
6406
  // Don't use the symbols already used: !#$%@&*+~=|
6430
6407
  // All syntax surrounded by square brackets shouldn't contain line breaks.
6431
- exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.creation)((0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.syntax)(64 /* Syntax.placeholder */, 2, 0 /* State.none */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 2]]))), (0, source_1.str)(']'), false, ([, bs], rest) => [[(0, dom_1.html)('span', {
6408
+ exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.creation)((0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.syntax)(32 /* Syntax.placeholder */, 2, 0 /* State.none */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 2]]))), (0, source_1.str)(']'), false, ([, bs], rest) => [[(0, dom_1.html)('span', {
6432
6409
  class: 'invalid',
6433
6410
  'data-invalid-syntax': 'extension',
6434
6411
  'data-invalid-type': 'syntax',
@@ -6539,7 +6516,7 @@ const parse = (0, memoize_1.reduce)((el => entity => {
6539
6516
  el.innerHTML = entity;
6540
6517
  const text = el.textContent;
6541
6518
  return entity === text ? undefined : text;
6542
- })((0, dom_1.html)('b')));
6519
+ })((0, dom_1.html)('span')));
6543
6520
 
6544
6521
  /***/ }),
6545
6522
 
@@ -6586,11 +6563,11 @@ const optspec = {
6586
6563
  };
6587
6564
  Object.setPrototypeOf(optspec, null);
6588
6565
  exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.union)([exports.medialink, exports.textlink])));
6589
- exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 502 /* State.linkers */ | 8 /* 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], [']', 2]])), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => {
6566
+ exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(8 /* Syntax.link */, 2, 502 /* State.linkers */ | 8 /* 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], [']', 2]])), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => {
6590
6567
  if (content.length !== 0 && (0, visibility_1.trimNodeEnd)(content = (0, dom_1.defrag)(content)).length === 0) return;
6591
6568
  return [[parse(content, params, context)], rest];
6592
6569
  })))));
6593
- exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 502 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => [[parse((0, dom_1.defrag)(content), params, context)], rest])))));
6570
+ exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(8 /* Syntax.link */, 2, 502 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => [[parse((0, dom_1.defrag)(content), params, context)], rest])))));
6594
6571
  exports.linemedialink = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.medialink]), /^(?=[^\S\n]*(?:$|\n))/);
6595
6572
  exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => [[parse((0, dom_1.defrag)(content), params, context)], rest]))));
6596
6573
  exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)), (0, source_1.str)(/^[^\s{}]+/)]);
@@ -6770,7 +6747,7 @@ const optspec = {
6770
6747
  rel: undefined
6771
6748
  };
6772
6749
  Object.setPrototypeOf(optspec, null);
6773
- exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.constraint)(8 /* State.media */, false, (0, combinator_1.syntax)(4 /* Syntax.media */, 2, ~16 /* State.link */, (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.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']', [[/^\\?\n/, 9]]), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
6750
+ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.constraint)(8 /* State.media */, false, (0, combinator_1.syntax)(0 /* Syntax.none */, 2, ~16 /* State.link */, (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.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']', [[/^\\?\n/, 9]]), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
6774
6751
  const INSECURE_URI = params.shift();
6775
6752
  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);
6776
6753
  let cache;
@@ -6842,7 +6819,7 @@ const inline_1 = __webpack_require__(1160);
6842
6819
  const source_1 = __webpack_require__(6743);
6843
6820
  const visibility_1 = __webpack_require__(7618);
6844
6821
  const dom_1 = __webpack_require__(3252);
6845
- exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.surround)('[[', (0, combinator_1.constraint)(128 /* State.reference */, false, (0, combinator_1.syntax)(256 /* Syntax.reference */, 6, 256 /* State.annotation */ | 128 /* State.reference */ | 8 /* State.media */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]]))]))), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))])], rest])));
6822
+ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.surround)('[[', (0, combinator_1.constraint)(128 /* State.reference */, false, (0, combinator_1.syntax)(128 /* Syntax.reference */, 6, 256 /* State.annotation */ | 128 /* State.reference */ | 8 /* State.media */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]]))]))), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))])], rest])));
6846
6823
  // Chicago-Style
6847
6824
  const abbr = (0, combinator_1.creation)((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}`]));
6848
6825
  function attributes(ns) {
@@ -6911,7 +6888,7 @@ const source_1 = __webpack_require__(6743);
6911
6888
  const visibility_1 = __webpack_require__(7618);
6912
6889
  const array_1 = __webpack_require__(8112);
6913
6890
  const dom_1 = __webpack_require__(3252);
6914
- exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.creation)((0, combinator_1.syntax)(32 /* Syntax.ruby */, 2, -1 /* State.all */, (0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.sequence)([(0, combinator_1.surround)('[', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ']'), (0, combinator_1.surround)('(', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ')')]), ([texts, rubies], _, context) => [(0, parser_1.eval)(text({
6891
+ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.creation)((0, combinator_1.syntax)(16 /* Syntax.ruby */, 2, -1 /* State.all */, (0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.sequence)([(0, combinator_1.surround)('[', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ']'), (0, combinator_1.surround)('(', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ')')]), ([texts, rubies], _, context) => [(0, parser_1.eval)(text({
6915
6892
  source: texts,
6916
6893
  context
6917
6894
  }), [])[0] ?? '', (0, parser_1.eval)(text({
@@ -7582,7 +7559,7 @@ exports.isAlphanumeric = exports.linebreak = exports.txt = exports.text = export
7582
7559
  const combinator_1 = __webpack_require__(2087);
7583
7560
  const str_1 = __webpack_require__(2790);
7584
7561
  const dom_1 = __webpack_require__(3252);
7585
- exports.delimiter = /[\s\x00-\x7F()]|\S[#>]/u;
7562
+ exports.delimiter = /[\s\x00-\x7F()[]{}“”‘’「」『』]|\S[#>]/u;
7586
7563
  exports.nonWhitespace = /[\S\n]|$/u;
7587
7564
  exports.nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/u;
7588
7565
  const repeat = (0, str_1.str)(/^(.)\1*/);
package/markdown.d.ts CHANGED
@@ -661,7 +661,6 @@ export namespace MarkdownParser {
661
661
  InlineParser.ReferenceParser,
662
662
  InlineParser.TemplateParser,
663
663
  InlineParser.RemarkParser,
664
- InlineParser.MathParser,
665
664
  InlineParser.ExtensionParser,
666
665
  InlineParser.RubyParser,
667
666
  InlineParser.LinkParser.TextLinkParser,
@@ -672,6 +671,7 @@ export namespace MarkdownParser {
672
671
  InlineParser.EmStrongParser,
673
672
  InlineParser.StrongParser,
674
673
  InlineParser.EmphasisParser,
674
+ InlineParser.MathParser,
675
675
  InlineParser.CodeParser,
676
676
  InlineParser.HTMLEntityParser,
677
677
  InlineParser.AutolinkParser,
@@ -743,27 +743,6 @@ export namespace MarkdownParser {
743
743
  InlineParser,
744
744
  ]> {
745
745
  }
746
- export interface MathParser extends
747
- // $expr$
748
- // ${expr}$
749
- Inline<'math'>,
750
- Parser<HTMLElement, Context, [
751
- MathParser.BracketParser,
752
- Parser<string, Context, [
753
- MathParser.BracketParser,
754
- SourceParser.UnescapableSourceParser,
755
- ]>,
756
- ]> {
757
- }
758
- export namespace MathParser {
759
- export interface BracketParser extends
760
- Inline<'math/bracket'>,
761
- Parser<HTMLElement, Context, [
762
- BracketParser,
763
- SourceParser.EscapableSourceParser,
764
- ]> {
765
- }
766
- }
767
746
  export interface ExtensionParser extends
768
747
  Inline<'extension'>,
769
748
  Parser<HTMLElement | string, Context, [
@@ -1097,6 +1076,27 @@ export namespace MarkdownParser {
1097
1076
  ]>,
1098
1077
  ]> {
1099
1078
  }
1079
+ export interface MathParser extends
1080
+ // $expr$
1081
+ // ${expr}$
1082
+ Inline<'math'>,
1083
+ Parser<HTMLElement, Context, [
1084
+ MathParser.BracketParser,
1085
+ Parser<string, Context, [
1086
+ MathParser.BracketParser,
1087
+ SourceParser.UnescapableSourceParser,
1088
+ ]>,
1089
+ ]> {
1090
+ }
1091
+ export namespace MathParser {
1092
+ export interface BracketParser extends
1093
+ Inline<'math/bracket'>,
1094
+ Parser<HTMLElement, Context, [
1095
+ BracketParser,
1096
+ SourceParser.EscapableSourceParser,
1097
+ ]> {
1098
+ }
1099
+ }
1100
1100
  export interface CodeParser extends
1101
1101
  // `abc`
1102
1102
  Inline<'code'>,
@@ -1246,6 +1246,12 @@ export namespace MarkdownParser {
1246
1246
  InlineParser,
1247
1247
  InlineParser,
1248
1248
  InlineParser,
1249
+ InlineParser,
1250
+ InlineParser,
1251
+ InlineParser,
1252
+ InlineParser,
1253
+ InlineParser,
1254
+ InlineParser,
1249
1255
  ]> {
1250
1256
  }
1251
1257
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.280.1",
3
+ "version": "0.280.3",
4
4
  "description": "Secure markdown renderer working on browsers for user input data.",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/falsandtru/securemark",
@@ -1,5 +1,4 @@
1
1
  import { Parser, exec } from '../../data/parser';
2
- import { Memo } from '../../data/parser/context/memo';
3
2
  import { firstline, isBlank } from './line';
4
3
 
5
4
  export function block<P extends Parser<unknown>>(parser: P, separation?: boolean): P;
@@ -7,7 +6,6 @@ export function block<T>(parser: Parser<T>, separation = true): Parser<T> {
7
6
  assert(parser);
8
7
  return ({ source, context }) => {
9
8
  if (source === '') return;
10
- context.memo ??= new Memo();
11
9
  const result = parser({ source, context });
12
10
  if (result === undefined) return;
13
11
  const rest = exec(result);
@@ -1,12 +1,10 @@
1
1
  import { Parser, eval, exec, check } from '../../data/parser';
2
- import { Memo } from '../../data/parser/context/memo';
3
2
 
4
3
  export function line<P extends Parser<unknown>>(parser: P): P;
5
4
  export function line<T>(parser: Parser<T>): Parser<T> {
6
5
  assert(parser);
7
6
  return ({ source, context }) => {
8
7
  if (source === '') return;
9
- context.memo ??= new Memo();
10
8
  const line = firstline(source);
11
9
  context.offset ??= 0;
12
10
  context.offset += source.length - line.length;
@@ -1,6 +1,6 @@
1
1
  import { Parser, Ctx } from '../../data/parser';
2
2
  import { firstline, isBlank } from '../constraint/line';
3
- import { unshift } from 'spica/array';
3
+ import { push } from 'spica/array';
4
4
 
5
5
  export function fence<C extends Ctx, D extends Parser<unknown, C>[]>(opener: RegExp, limit: number, separation = true): Parser<string, C, D> {
6
6
  return ({ source }) => {
@@ -42,6 +42,6 @@ export function fence<C extends Ctx, D extends Parser<unknown, C>[]>(opener: Reg
42
42
  }
43
43
  rest = rest.slice(line.length);
44
44
  }
45
- return [unshift([block, overflow, closer], matches), rest];
45
+ return [push([block, overflow, closer], matches), rest];
46
46
  };
47
47
  }
@@ -37,12 +37,12 @@ export class Delimiters {
37
37
  delims: readonly {
38
38
  readonly signature: string;
39
39
  readonly matcher: (source: string) => boolean | undefined;
40
- readonly precedence?: number;
40
+ readonly precedence: number;
41
41
  }[]
42
42
  ): void {
43
43
  const { registry, delimiters, order } = this;
44
44
  for (let i = 0; i < delims.length; ++i) {
45
- const { signature, matcher, precedence = 1 } = delims[i];
45
+ const { signature, matcher, precedence } = delims[i];
46
46
  const stack = registry(signature);
47
47
  const index = stack[0]?.index ?? delimiters.length;
48
48
  if (stack.length === 0 || precedence > delimiters[index].precedence) {
@@ -61,7 +61,7 @@ export class Delimiters {
61
61
  }
62
62
  }
63
63
  }
64
- public pop(count = 1): void {
64
+ public pop(count: number): void {
65
65
  assert(count > 0);
66
66
  const { registry, delimiters, order } = this;
67
67
  for (let i = 0; i < count; ++i) {
@@ -1,9 +1,11 @@
1
1
  export class Memo {
2
- constructor({ targets = ~0 } = {}) {
3
- this.targets = targets;
2
+ constructor(
3
+ public readonly targets = ~0,
4
+ public readonly margin = 0,
5
+ ) {
4
6
  }
5
- public readonly targets: number;
6
- private readonly memory: Record<number, Record<number, readonly [any[], number] | readonly []>>[/* pos */] = [];
7
+ private memory: Record<number, Record<number, readonly [any[], number] | readonly []>>[/* pos */] = [];
8
+ private count = 0;
7
9
  public get length(): number {
8
10
  return this.memory.length;
9
11
  }
@@ -12,6 +14,7 @@ export class Memo {
12
14
  syntax: number,
13
15
  state: number,
14
16
  ): readonly [any[], number] | readonly [] | undefined {
17
+ if (this.count === 0) return;
15
18
  //console.log('get', position, syntax, state, this.memory[position - 1]?.[syntax]?.[state]);
16
19
  const cache = this.memory[position - 1]?.[syntax]?.[state];
17
20
  return cache?.length === 2
@@ -25,6 +28,7 @@ export class Memo {
25
28
  nodes: any[] | undefined,
26
29
  offset: number,
27
30
  ): void {
31
+ this.count += +!this.memory[position - 1];
28
32
  const record = this.memory[position - 1] ??= {};
29
33
  assert(!record[syntax]?.[state]);
30
34
  (record[syntax] ??= {})[state] = nodes
@@ -32,11 +36,15 @@ export class Memo {
32
36
  : [];
33
37
  //console.log('set', position, syntax, state, record[syntax]?.[state]);
34
38
  }
35
- public clear(position: number): void {
39
+ public resize(position: number): void {
36
40
  const memory = this.memory;
37
41
  for (let len = memory.length, i = position; i < len; ++i) {
38
- memory.pop();
42
+ this.count -= +memory.pop()!;
39
43
  }
40
- //console.log('clear', position + 1);
44
+ //console.log('resize', position);
45
+ }
46
+ public clear(): void {
47
+ this.memory = [];
48
+ this.count = 0;
41
49
  }
42
50
  }
@@ -1,12 +1,9 @@
1
- import { hasOwnProperty, ObjectCreate } from 'spica/alias';
1
+ import { ObjectCreate } from 'spica/alias';
2
2
  import { Parser, Result, Ctx, Tree, Context, eval, exec } from '../../data/parser';
3
3
  import { Memo } from './context/memo';
4
4
 
5
5
  export function reset<P extends Parser<unknown>>(base: Context<P>, parser: P): P;
6
6
  export function reset<T>(base: Ctx, parser: Parser<T>): Parser<T> {
7
- if (!('memo' in base)) {
8
- base.memo = undefined;
9
- }
10
7
  assert(Object.getPrototypeOf(base) === Object.prototype);
11
8
  assert(Object.freeze(base));
12
9
  const changes = Object.entries(base);
@@ -27,41 +24,38 @@ export function context<T>(base: Ctx, parser: Parser<T>): Parser<T> {
27
24
 
28
25
  function apply<P extends Parser<unknown>>(parser: P, source: string, context: Context<P>, changes: readonly [string, unknown][], values: unknown[], reset?: boolean): Result<Tree<P>>;
29
26
  function apply<T>(parser: Parser<T>, source: string, context: Ctx, changes: readonly [string, unknown][], values: unknown[], reset = false): Result<T> {
30
- if (context) for (let i = 0; i < changes.length; ++i) {
27
+ for (let i = 0; i < changes.length; ++i) {
31
28
  const change = changes[i];
32
29
  const prop = change[0];
33
30
  switch (prop) {
34
31
  case 'resources':
35
- if (!reset) break;
36
- assert(typeof change[1] === 'object');
37
- assert(context[prop] || !(prop in context));
38
- if (prop in context && !hasOwnProperty(context, prop)) break;
39
- context[prop as string] = ObjectCreate(change[1] as object);
40
- break;
41
- // @ts-expect-error
42
- case 'memo':
43
- if (!reset) break;
44
- context.memo = new Memo({ targets: context.memo?.targets });
45
- // fallthrough
46
- default:
47
- values[i] = context[prop];
48
- context[prop] = change[1];
32
+ assert(reset);
33
+ assert(!context.offset);
34
+ assert(!context.precedence);
35
+ assert(!context.delimiters);
36
+ assert(!context.state);
37
+ assert(!context.memo);
38
+ context[prop as string] ??= ObjectCreate(change[1] as object);
39
+ continue;
49
40
  }
41
+ values[i] = context[prop];
42
+ context[prop] = change[1];
50
43
  }
51
44
  const result = parser({ source, context });
52
- if (context) for (let i = 0; i < changes.length; ++i) {
45
+ for (let i = 0; i < changes.length; ++i) {
53
46
  const change = changes[i];
54
47
  const prop = change[0];
55
48
  switch (prop) {
56
49
  case 'resources':
57
- // @ts-expect-error
50
+ assert(reset);
51
+ break;
58
52
  case 'memo':
59
- if (!reset) break;
60
- // fallthrough
61
- default:
62
- context[prop] = values[i];
63
- values[i] = undefined;
53
+ assert(reset);
54
+ context.memo!.clear();
55
+ break;
64
56
  }
57
+ context[prop] = values[i];
58
+ values[i] = undefined;
65
59
  }
66
60
  return result;
67
61
  }
@@ -75,19 +69,17 @@ export function syntax<T>(syntax: number, prec: number, state: number, parser?:
75
69
  const position = source.length + context.offset!;
76
70
  const stateOuter = context.state ?? 0;
77
71
  const stateInner = context.state = stateOuter | state;
78
- const cache = syntax && stateInner & memo.targets && memo.get(position, syntax, stateInner);
72
+ const cache = syntax & memo.targets && stateInner && memo.get(position, syntax, stateInner);
79
73
  const result: Result<T> = cache
80
74
  ? cache.length === 0
81
75
  ? undefined
82
76
  : [cache[0], source.slice(cache[1])]
83
77
  : parser!({ source, context });
84
- if (syntax && stateOuter & memo.targets) {
85
- cache ?? memo.set(position, syntax, stateInner, eval(result), source.length - exec(result, '').length);
86
- assert.deepStrictEqual(cache && cache, cache && memo.get(position, syntax, stateInner));
78
+ if (stateOuter && !cache && syntax & memo.targets) {
79
+ memo.set(position, syntax, stateInner, eval(result), source.length - exec(result, '').length);
87
80
  }
88
- if (result && !stateOuter && memo.length! >= position + 2) {
89
- assert(!(stateOuter & memo.targets));
90
- memo.clear(position + 2);
81
+ else if (!stateOuter && result && memo.length! >= position + memo.margin) {
82
+ memo.resize(position + memo.margin);
91
83
  }
92
84
  context.state = stateOuter;
93
85
  return result;
@@ -32,7 +32,7 @@ export function some<T>(parser: Parser<T>, end?: string | RegExp | number, delim
32
32
  assert.doesNotThrow(() => limit < 0 && check(rest, result));
33
33
  if (result === undefined) break;
34
34
  nodes = nodes
35
- ? nodes.length < eval(result).length
35
+ ? nodes.length < eval(result).length / 8
36
36
  ? unshift(nodes, eval(result))
37
37
  : push(nodes, eval(result))
38
38
  : eval(result);
@@ -1,11 +1,9 @@
1
1
  import { ParserSettings, Progress } from '../../..';
2
2
  import { MarkdownParser } from '../../../markdown';
3
3
  import { eval } from '../../combinator/data/parser';
4
- import { Memo } from '../../combinator/data/parser/context/memo';
5
4
  import { segment, validate, MAX_INPUT_SIZE } from '../segment';
6
5
  import { header } from '../header';
7
6
  import { block } from '../block';
8
- import { State } from '../context';
9
7
  import { normalize } from './normalize';
10
8
  import { headers } from './header';
11
9
  import { figure } from '../processor/figure';
@@ -24,12 +22,12 @@ export function bind(target: DocumentFragment | HTMLElement | ShadowRoot, settin
24
22
  let context: MarkdownParser.Context = {
25
23
  ...settings,
26
24
  host: settings.host ?? new ReadonlyURL(location.pathname, location.origin),
27
- memo: new Memo({ targets: State.backtrackers }),
28
25
  };
29
26
  assert(!context.offset);
30
27
  assert(!context.precedence);
31
28
  assert(!context.delimiters);
32
29
  assert(!context.state);
30
+ assert(!context.memo);
33
31
  if (context.id?.match(/[^0-9a-z/-]/i)) throw new Error('Invalid ID: ID must be alphanumeric');
34
32
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
35
33
  type Block = readonly [segment: string, blocks: readonly HTMLElement[], url: string];
@@ -333,7 +333,6 @@ describe('Unit: parser/api/parse', () => {
333
333
 
334
334
  it('creation', function () {
335
335
  this.timeout(5000);
336
- // 実測500ms程度
337
336
  assert.deepStrictEqual(
338
337
  [...parse('.'.repeat(20000)).children].map(el => el.outerHTML),
339
338
  [`<p>${'.'.repeat(20000)}</p>`]);
@@ -341,7 +340,6 @@ describe('Unit: parser/api/parse', () => {
341
340
 
342
341
  it('creation error', function () {
343
342
  this.timeout(5000);
344
- // 実測500ms程度
345
343
  assert.deepStrictEqual(
346
344
  [...parse('.'.repeat(20001)).children].map(el => el.outerHTML.replace(/:\w+/, ':rnd')),
347
345
  [
@@ -350,6 +348,16 @@ describe('Unit: parser/api/parse', () => {
350
348
  ]);
351
349
  });
352
350
 
351
+ it('recovery', function () {
352
+ this.timeout(5000);
353
+ assert.deepStrictEqual(
354
+ [...parse(`!>> ${'['.repeat(20)}${'{a}'.repeat(518)}\n> ${'{a}'.repeat(4)}\n\na`).children].map(el => el.outerHTML),
355
+ [
356
+ `<blockquote><blockquote><section><p>${'['.repeat(20)}${'<a class="url" href="a">a</a>'.repeat(518)}</p><h2>References</h2><ol class="references"></ol></section></blockquote><section><h1 class="error">Error: Too many creations</h1><pre class="error" translate="no">{a}{a}{a}{a}</pre><h2>References</h2><ol class="references"></ol></section></blockquote>`,
357
+ '<p>a</p>',
358
+ ]);
359
+ });
360
+
353
361
  });
354
362
 
355
363
  });
@@ -1,11 +1,9 @@
1
1
  import { ParserOptions } from '../../..';
2
2
  import { MarkdownParser } from '../../../markdown';
3
3
  import { eval } from '../../combinator/data/parser';
4
- import { Memo } from '../../combinator/data/parser/context/memo';
5
4
  import { segment, validate, MAX_SEGMENT_SIZE } from '../segment';
6
5
  import { header } from '../header';
7
6
  import { block } from '../block';
8
- import { State } from '../context';
9
7
  import { normalize } from './normalize';
10
8
  import { headers } from './header';
11
9
  import { figure } from '../processor/figure';
@@ -26,15 +24,13 @@ export function parse(source: string, opts: Options = {}, context?: MarkdownPars
26
24
  url: url ? new ReadonlyURL(url as ':') : context?.url,
27
25
  id: opts.id ?? context?.id,
28
26
  caches: context?.caches,
29
- ...context?.resources && {
30
- resources: context.resources,
31
- },
32
- memo: new Memo({ targets: State.backtrackers }),
27
+ resources: context?.resources,
33
28
  };
34
29
  assert(!context.offset);
35
30
  assert(!context.precedence);
36
31
  assert(!context.delimiters);
37
32
  assert(!context.state);
33
+ assert(!context.memo);
38
34
  if (context.id?.match(/[^0-9a-z/-]/i)) throw new Error('Invalid ID: ID must be alphanumeric');
39
35
  if (context.host?.origin === 'null') throw new Error(`Invalid host: ${context.host.href}`);
40
36
  const node = frag();
@@ -1,5 +1,6 @@
1
1
  import { MarkdownParser } from '../../markdown';
2
2
  import { union, reset, creation, open, fallback, recover } from '../combinator';
3
+ import { Memo } from '../combinator/data/parser/context/memo';
3
4
  import { emptyline } from './source';
4
5
  import { pagebreak } from './block/pagebreak';
5
6
  import { heading } from './block/heading';
@@ -16,6 +17,7 @@ import { blockquote } from './block/blockquote';
16
17
  import { mediablock } from './block/mediablock';
17
18
  import { reply } from './block/reply';
18
19
  import { paragraph } from './block/paragraph';
20
+ import { Syntax } from './context';
19
21
  import { rnd0Z } from 'spica/random';
20
22
  import { html } from 'typed-dom/dom';
21
23
 
@@ -36,9 +38,12 @@ export import MediaBlockParser = BlockParser.MediaBlockParser;
36
38
  export import ReplyParser = BlockParser.ReplyParser;
37
39
  export import ParagraphParser = BlockParser.ParagraphParser;
38
40
 
39
- export const block: BlockParser = creation(0, false, error(
40
- reset({ resources: { clock: 20000, recursion: 20 + 1 } },
41
- union([
41
+ export const block: BlockParser = creation(0, false,
42
+ reset({
43
+ resources: { clock: 20000, recursion: 20 + 1 },
44
+ memo: new Memo(Syntax.targets, 2),
45
+ },
46
+ error(union([
42
47
  emptyline,
43
48
  pagebreak,
44
49
  heading,
@@ -1,13 +1,21 @@
1
1
  export const enum Syntax {
2
- reference = 1 << 8,
3
- index = 1 << 7,
4
- placeholder = 1 << 6,
5
- ruby = 1 << 5,
6
- link = 1 << 4,
7
- bracket = 1 << 3,
8
- media = 1 << 2,
2
+ annotation = 1 << 8,
3
+ reference = 1 << 7,
4
+ index = 1 << 6,
5
+ placeholder = 1 << 5,
6
+ ruby = 1 << 4,
7
+ link = 1 << 3,
8
+ bracket = 1 << 2,
9
9
  autolink = 1 << 1,
10
10
  none = 0,
11
+ targets = 0
12
+ | Syntax.annotation
13
+ | Syntax.reference
14
+ | Syntax.index
15
+ | Syntax.placeholder
16
+ | Syntax.ruby
17
+ | Syntax.link
18
+ | Syntax.bracket,
11
19
  }
12
20
 
13
21
  export const enum State {
@@ -30,10 +38,4 @@ export const enum State {
30
38
  | State.link
31
39
  | State.mark
32
40
  | State.autolink,
33
- backtrackers = 0
34
- | State.annotation
35
- | State.reference
36
- | State.index
37
- | State.link
38
- | State.media,
39
41
  }
@@ -8,7 +8,7 @@ import { html, defrag } from 'typed-dom/dom';
8
8
  export const annotation: AnnotationParser = lazy(() => creation(surround(
9
9
  '((',
10
10
  constraint(State.annotation, false,
11
- syntax(Syntax.none, 6, State.annotation | State.media,
11
+ syntax(Syntax.annotation, 6, State.annotation | State.media,
12
12
  trimBlankStart(some(union([inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])))),
13
13
  '))',
14
14
  false,
@@ -20,10 +20,28 @@ export const bracket: BracketParser = lazy(() => union([
20
20
  surround(str('['), creation(syntax(Syntax.bracket, 2, State.none, some(inline, ']', [[/^\\?\n/, 3], [']', 2]]))), str(']'), true,
21
21
  undefined,
22
22
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
23
+ surround(str('['), creation(syntax(Syntax.bracket, 2, State.none, some(inline, ']', [[/^\\?\n/, 3], [']', 2]]))), str(']'), true,
24
+ undefined,
25
+ ([as, bs = []], rest) => [unshift(as, bs), rest]),
23
26
  surround(str('{'), creation(syntax(Syntax.bracket, 2, State.none, some(inline, '}', [[/^\\?\n/, 3], ['}', 2]]))), str('}'), true,
24
27
  undefined,
25
28
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
29
+ surround(str('{'), creation(syntax(Syntax.bracket, 2, State.none, some(inline, '}', [[/^\\?\n/, 3], ['}', 2]]))), str('}'), true,
30
+ undefined,
31
+ ([as, bs = []], rest) => [unshift(as, bs), rest]),
26
32
  surround(str('"'), creation(syntax(Syntax.none, 3, State.none, some(inline, '"', [[/^\\?\n/, 4], ['"', 3]]))), str('"'), true,
27
33
  undefined,
28
34
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
35
+ surround(str('“'), creation(syntax(Syntax.none, 3, State.none, some(inline, '”', [[/^\\?\n/, 4], ['”', 3]]))), str('”'), true,
36
+ undefined,
37
+ ([as, bs = []], rest) => [unshift(as, bs), rest]),
38
+ surround(str('‘'), creation(syntax(Syntax.none, 3, State.none, some(inline, '’', [[/^\\?\n/, 4], ['’', 3]]))), str('’'), true,
39
+ undefined,
40
+ ([as, bs = []], rest) => [unshift(as, bs), rest]),
41
+ surround(str('「'), creation(syntax(Syntax.none, 3, State.none, some(inline, '」', [[/^\\?\n/, 4], ['」', 3]]))), str('」'), true,
42
+ undefined,
43
+ ([as, bs = []], rest) => [unshift(as, bs), rest]),
44
+ surround(str('『'), creation(syntax(Syntax.none, 3, State.none, some(inline, '』', [[/^\\?\n/, 4], ['』', 3]]))), str('』'), true,
45
+ undefined,
46
+ ([as, bs = []], rest) => [unshift(as, bs), rest]),
29
47
  ]));
@@ -27,4 +27,4 @@ const parse = reduce((el => (entity: string): string | undefined => {
27
27
  return entity === text
28
28
  ? undefined
29
29
  : text;
30
- })(html('b')));
30
+ })(html('span')));
@@ -21,7 +21,7 @@ Object.setPrototypeOf(optspec, null);
21
21
  export const media: MediaParser = lazy(() => validate(['![', '!{'], creation(10, open(
22
22
  '!',
23
23
  constraint(State.media, false,
24
- syntax(Syntax.media, 2, ~State.link,
24
+ syntax(Syntax.none, 2, ~State.link,
25
25
  bind(verify(fmap(tails([
26
26
  dup(surround(
27
27
  '[',
@@ -68,9 +68,12 @@ export const linemedia: MediaParser.LineMediaParser = surround(
68
68
  /^(?=[^\S\n]*(?:$|\n))/);
69
69
 
70
70
  const bracket: MediaParser.TextParser.BracketParser = lazy(() => creation(union([
71
- surround(str('('), some(union([unsafehtmlentity, bracket, txt]), ')'), str(')'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
72
- surround(str('['), some(union([unsafehtmlentity, bracket, txt]), ']'), str(']'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
73
- surround(str('{'), some(union([unsafehtmlentity, bracket, txt]), '}'), str('}'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
71
+ surround(str('('), some(union([unsafehtmlentity, bracket, txt]), ')'), str(')'), true,
72
+ undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
73
+ surround(str('['), some(union([unsafehtmlentity, bracket, txt]), ']'), str(']'), true,
74
+ undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
75
+ surround(str('{'), some(union([unsafehtmlentity, bracket, txt]), '}'), str('}'), true,
76
+ undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
74
77
  surround(str('"'), precedence(3, some(union([unsafehtmlentity, txt]), '"')), str('"'), true),
75
78
  ])));
76
79
 
@@ -13,8 +13,11 @@ export const template: TemplateParser = lazy(() => creation(surround(
13
13
  ([, ns = []], rest) => [[html('span', { class: 'template' }, `{{${ns.join('').replace(/\x1B/g, '')}}}`)], rest])));
14
14
 
15
15
  const bracket: TemplateParser.BracketParser = lazy(() => creation(union([
16
- surround(str('('), some(union([bracket, escsource]), ')'), str(')'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
17
- surround(str('['), some(union([bracket, escsource]), ']'), str(']'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
18
- surround(str('{'), some(union([bracket, escsource]), '}'), str('}'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
16
+ surround(str('('), some(union([bracket, escsource]), ')'), str(')'), true,
17
+ undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
18
+ surround(str('['), some(union([bracket, escsource]), ']'), str(']'), true,
19
+ undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
20
+ surround(str('{'), some(union([bracket, escsource]), '}'), str('}'), true,
21
+ undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
19
22
  surround(str('"'), precedence(3, some(escsource, /^"|^\\?\n/)), str('"'), true),
20
23
  ])));
@@ -4,7 +4,6 @@ import { annotation } from './inline/annotation';
4
4
  import { reference } from './inline/reference';
5
5
  import { template } from './inline/template';
6
6
  import { remark } from './inline/remark';
7
- import { math } from './inline/math';
8
7
  import { extension } from './inline/extension';
9
8
  import { ruby } from './inline/ruby';
10
9
  import { textlink } from './inline/link';
@@ -13,8 +12,9 @@ import { insertion } from './inline/insertion';
13
12
  import { deletion } from './inline/deletion';
14
13
  import { mark } from './inline/mark';
15
14
  import { emstrong } from './inline/emstrong';
16
- import { emphasis } from './inline/emphasis';
17
15
  import { strong } from './inline/strong';
16
+ import { emphasis } from './inline/emphasis';
17
+ import { math } from './inline/math';
18
18
  import { code } from './inline/code';
19
19
  import { htmlentity } from './inline/htmlentity';
20
20
  import { autolink } from './inline/autolink';
@@ -26,7 +26,6 @@ export import AnnotationParser = InlineParser.AnnotationParser;
26
26
  export import ReferenceParser = InlineParser.ReferenceParser;
27
27
  export import TemplateParser = InlineParser.TemplateParser;
28
28
  export import RemarkParser = InlineParser.RemarkParser;
29
- export import MathParser = InlineParser.MathParser;
30
29
  export import ExtensionParser = InlineParser.ExtensionParser;
31
30
  export import RubyParser = InlineParser.RubyParser;
32
31
  export import LinkParser = InlineParser.LinkParser;
@@ -35,8 +34,9 @@ export import InsertionParser = InlineParser.InsertionParser;
35
34
  export import DeletionParser = InlineParser.DeletionParser;
36
35
  export import MarkParser = InlineParser.MarkParser;
37
36
  export import EmStrongParser = InlineParser.EmStrongParser;
38
- export import EmphasisParser = InlineParser.EmphasisParser;
39
37
  export import StrongParser = InlineParser.StrongParser;
38
+ export import EmphasisParser = InlineParser.EmphasisParser;
39
+ export import MathParser = InlineParser.MathParser;
40
40
  export import CodeParser = InlineParser.CodeParser;
41
41
  export import MediaParser = InlineParser.MediaParser;
42
42
  export import HTMLEntityParser = InlineParser.HTMLEntityParser;
@@ -50,7 +50,6 @@ export const inline: InlineParser = lazy(() => union([
50
50
  reference,
51
51
  template,
52
52
  remark,
53
- math,
54
53
  extension,
55
54
  ruby,
56
55
  textlink,
@@ -61,6 +60,7 @@ export const inline: InlineParser = lazy(() => union([
61
60
  emstrong,
62
61
  strong,
63
62
  emphasis,
63
+ math,
64
64
  code,
65
65
  htmlentity,
66
66
  autolink,
@@ -3,7 +3,7 @@ import { union, creation, focus } from '../../combinator';
3
3
  import { str } from './str';
4
4
  import { html } from 'typed-dom/dom';
5
5
 
6
- export const delimiter = /[\s\x00-\x7F()]|\S[#>]/u;
6
+ export const delimiter = /[\s\x00-\x7F()[]{}“”‘’「」『』]|\S[#>]/u;
7
7
  export const nonWhitespace = /[\S\n]|$/u;
8
8
  export const nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/u;
9
9
  const repeat = str(/^(.)\1*/);