securemark 0.297.4 → 0.297.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.js +176 -67
- package/package.json +1 -1
- package/src/combinator/data/parser/context.ts +26 -4
- package/src/parser/api/parse.test.ts +37 -1
- package/src/parser/block/blockquote.ts +1 -1
- package/src/parser/block/heading.test.ts +2 -2
- package/src/parser/block/sidefence.ts +4 -3
- package/src/parser/block/table.test.ts +2 -2
- package/src/parser/block/table.ts +1 -1
- package/src/parser/block.ts +2 -1
- package/src/parser/context.ts +21 -2
- package/src/parser/inline/annotation.test.ts +20 -16
- package/src/parser/inline/annotation.ts +78 -28
- package/src/parser/inline/bracket.test.ts +48 -48
- package/src/parser/inline/bracket.ts +8 -8
- package/src/parser/inline/emphasis.test.ts +2 -2
- package/src/parser/inline/emstrong.test.ts +3 -3
- package/src/parser/inline/extension/index.test.ts +1 -1
- package/src/parser/inline/italic.test.ts +1 -1
- package/src/parser/inline/link.test.ts +1 -1
- package/src/parser/inline/reference.test.ts +1 -1
- package/src/parser/inline/strong.test.ts +2 -2
- package/src/parser/inline.test.ts +23 -23
- package/src/parser/processor/note.test.ts +15 -37
- package/src/parser/processor/note.ts +2 -1
- package/src/renderer/render.ts +0 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.297.
|
|
1
|
+
/*! securemark v0.297.6 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("Prism"), require("DOMPurify"));
|
|
@@ -3726,7 +3726,7 @@ exports.failsafe = failsafe;
|
|
|
3726
3726
|
Object.defineProperty(exports, "__esModule", ({
|
|
3727
3727
|
value: true
|
|
3728
3728
|
}));
|
|
3729
|
-
exports.constraint = exports.state = exports.precedence = exports.recursion = exports.consume = exports.creation = exports.context = exports.reset = void 0;
|
|
3729
|
+
exports.constraint = exports.state = exports.precedence = exports.recursions = exports.recursion = exports.consume = exports.creation = exports.context = exports.reset = void 0;
|
|
3730
3730
|
const alias_1 = __webpack_require__(5413);
|
|
3731
3731
|
const assign_1 = __webpack_require__(9888);
|
|
3732
3732
|
function reset(base, parser) {
|
|
@@ -3833,15 +3833,41 @@ function recursion(recursion, parser) {
|
|
|
3833
3833
|
const {
|
|
3834
3834
|
recursions
|
|
3835
3835
|
} = resources;
|
|
3836
|
-
const rec = (0, alias_1.min)(recursion, recursions.length);
|
|
3837
|
-
if (rec
|
|
3838
|
-
rec
|
|
3836
|
+
const rec = (0, alias_1.min)(recursion, recursions.length - 1);
|
|
3837
|
+
if (rec >= 0 && recursions[rec] < 1) throw new Error('Too much recursion');
|
|
3838
|
+
rec >= 0 && --recursions[rec];
|
|
3839
3839
|
const result = parser(input);
|
|
3840
|
-
rec
|
|
3840
|
+
rec >= 0 && ++recursions[rec];
|
|
3841
3841
|
return result;
|
|
3842
3842
|
};
|
|
3843
3843
|
}
|
|
3844
3844
|
exports.recursion = recursion;
|
|
3845
|
+
function recursions(rs, parser) {
|
|
3846
|
+
return input => {
|
|
3847
|
+
const {
|
|
3848
|
+
context
|
|
3849
|
+
} = input;
|
|
3850
|
+
const resources = context.resources ?? {
|
|
3851
|
+
clock: 1,
|
|
3852
|
+
recursions: [4]
|
|
3853
|
+
};
|
|
3854
|
+
const {
|
|
3855
|
+
recursions
|
|
3856
|
+
} = resources;
|
|
3857
|
+
for (const recursion of rs) {
|
|
3858
|
+
const rec = (0, alias_1.min)(recursion, recursions.length - 1);
|
|
3859
|
+
if (rec >= 0 && recursions[rec] < 1) throw new Error('Too much recursion');
|
|
3860
|
+
rec >= 0 && --recursions[rec];
|
|
3861
|
+
}
|
|
3862
|
+
const result = parser(input);
|
|
3863
|
+
for (const recursion of rs) {
|
|
3864
|
+
const rec = (0, alias_1.min)(recursion, recursions.length - 1);
|
|
3865
|
+
rec >= 0 && ++recursions[rec];
|
|
3866
|
+
}
|
|
3867
|
+
return result;
|
|
3868
|
+
};
|
|
3869
|
+
}
|
|
3870
|
+
exports.recursions = recursions;
|
|
3845
3871
|
function precedence(precedence, parser) {
|
|
3846
3872
|
return input => {
|
|
3847
3873
|
const {
|
|
@@ -4639,7 +4665,7 @@ exports.block = (0, combinator_1.reset)({
|
|
|
4639
4665
|
resources: {
|
|
4640
4666
|
// バックトラックのせいで文字数制限を受けないようにする。
|
|
4641
4667
|
clock: segment_1.MAX_SEGMENT_SIZE * 6 + 1,
|
|
4642
|
-
recursions: [
|
|
4668
|
+
recursions: [5 || 0 /* Recursion.block */, 20 || 0 /* Recursion.blockquote */, 40 || 0 /* Recursion.listitem */, 20 || 0 /* Recursion.inline */, 20 || 0 /* Recursion.annotation */, 20 || 0 /* Recursion.bracket */, 20 || 0 /* Recursion.terminal */]
|
|
4643
4669
|
},
|
|
4644
4670
|
backtracks: {}
|
|
4645
4671
|
}, error((0, combinator_1.union)([source_1.emptysegment, input => {
|
|
@@ -4745,10 +4771,10 @@ const dom_1 = __webpack_require__(394);
|
|
|
4745
4771
|
exports.segment = (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.validate)(/!?>+ /y, (0, combinator_1.some)(source_1.contentline))]));
|
|
4746
4772
|
exports.blockquote = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.rewrite)(exports.segment, (0, combinator_1.union)([(0, combinator_1.open)(/(?=>)/y, source), (0, combinator_1.open)(/!(?=>)/y, markdown)]))));
|
|
4747
4773
|
const opener = /(?=>>+(?:$|[ \n]))/y;
|
|
4748
|
-
const indent = (0, combinator_1.
|
|
4774
|
+
const indent = (0, combinator_1.open)(opener, (0, combinator_1.some)(source_1.contentline, />(?:$|[ \n])/y));
|
|
4749
4775
|
const unindent = source => source.replace(/(?<=^|\n)>(?: |(?=>*(?:$|[ \n])))|\n$/g, '');
|
|
4750
|
-
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.recursion)(
|
|
4751
|
-
const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.recursion)(
|
|
4776
|
+
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.recursion)(1 /* Recursion.blockquote */, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source, true)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('pre', (0, dom_1.defrag)((0, util_1.unwrap)(ns))))])), true))]))), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('blockquote', (0, util_1.unwrap)(ns)))])));
|
|
4777
|
+
const markdown = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.recursion)(1 /* Recursion.blockquote */, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, markdown, true)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, ({
|
|
4752
4778
|
context
|
|
4753
4779
|
}) => {
|
|
4754
4780
|
(0, combinator_1.consume)(10, context);
|
|
@@ -4900,7 +4926,7 @@ const indexee_1 = __webpack_require__(7610);
|
|
|
4900
4926
|
const util_1 = __webpack_require__(4992);
|
|
4901
4927
|
const parse_1 = __webpack_require__(3662);
|
|
4902
4928
|
const dom_1 = __webpack_require__(394);
|
|
4903
|
-
exports.aside = (0, combinator_1.block)((0, combinator_1.recursion)(
|
|
4929
|
+
exports.aside = (0, combinator_1.block)((0, combinator_1.recursion)(0 /* Recursion.block */, (0, combinator_1.fmap)((0, combinator_1.fence)(/(~{3,})aside(?!\S)([^\n]*)(?:$|\n)/y, 300),
|
|
4904
4930
|
// Bug: Type mismatch between outer and inner.
|
|
4905
4931
|
(nodes, context) => {
|
|
4906
4932
|
const [body, overflow, closer, opener, delim, param] = (0, util_1.unwrap)(nodes);
|
|
@@ -4948,7 +4974,7 @@ const mathblock_1 = __webpack_require__(4903);
|
|
|
4948
4974
|
const util_1 = __webpack_require__(4992);
|
|
4949
4975
|
const parse_1 = __webpack_require__(3662);
|
|
4950
4976
|
const dom_1 = __webpack_require__(394);
|
|
4951
|
-
exports.example = (0, combinator_1.block)((0, combinator_1.recursion)(
|
|
4977
|
+
exports.example = (0, combinator_1.block)((0, combinator_1.recursion)(0 /* Recursion.block */, (0, combinator_1.fmap)((0, combinator_1.fence)(/(~{3,})(?:example\/(\S+))?(?!\S)([^\n]*)(?:$|\n)/y, 300),
|
|
4952
4978
|
// Bug: Type mismatch between outer and inner.
|
|
4953
4979
|
(nodes, context) => {
|
|
4954
4980
|
const [body, overflow, closer, opener, delim, type = 'markdown', param] = (0, util_1.unwrap)(nodes);
|
|
@@ -5571,7 +5597,7 @@ const visibility_1 = __webpack_require__(6364);
|
|
|
5571
5597
|
const util_1 = __webpack_require__(4992);
|
|
5572
5598
|
const dom_1 = __webpack_require__(394);
|
|
5573
5599
|
exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/[-+*] /y, exports.ilist_)));
|
|
5574
|
-
exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/[-+*](?:$|[ \n])/y, (0, combinator_1.recursion)(
|
|
5600
|
+
exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/[-+*](?:$|[ \n])/y, (0, combinator_1.recursion)(2 /* Recursion.listitem */, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/[-+*](?:$|[ \n])/y, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)(inline_1.inline))), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, olist_1.olist_, exports.ilist_]))]), exports.ilistitem), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('li', (0, dom_1.defrag)((0, util_1.unwrap)((0, ulist_1.fillFirstLine)(ns)))))]))])))), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('ul', {
|
|
5575
5601
|
class: 'invalid',
|
|
5576
5602
|
...(0, util_1.invalid)('list', 'syntax', 'Use "-" instead of "+" or "*"')
|
|
5577
5603
|
}, (0, util_1.unwrap)(ns)))]))));
|
|
@@ -5678,7 +5704,7 @@ const openers = {
|
|
|
5678
5704
|
};
|
|
5679
5705
|
exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(new RegExp([/(?:[0-9]+)(?:-[0-9]+)*\. /y.source, /\((?:[0-9]+)\)(?:-[0-9]+)* /y.source].join('|'), 'y'), exports.olist_)));
|
|
5680
5706
|
exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([(0, combinator_1.match)(openers['.'], (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => idx(ms[1]), [])), (0, combinator_1.match)(openers['('], (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => idx(ms[1]), []))])));
|
|
5681
|
-
const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.recursion)(
|
|
5707
|
+
const list = (type, form) => (0, combinator_1.fmap)((0, combinator_1.recursion)(2 /* Recursion.listitem */, (0, combinator_1.some)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(heads[form], (0, combinator_1.subsequence)([ulist_1.checkbox, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([ulist_1.ulist_, exports.olist_, ilist_1.ilist_]))]), ilist_1.ilistitem), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('li', {
|
|
5682
5708
|
'data-index': (0, inline_1.dataindex)(ns),
|
|
5683
5709
|
'data-marker': ns.shift()?.value || undefined
|
|
5684
5710
|
}, (0, dom_1.defrag)((0, util_1.unwrap)((0, ulist_1.fillFirstLine)(ns)))))])))]))), ns => new parser_1.List([new parser_1.Node(format((0, dom_1.html)('ol', (0, util_1.unwrap)(ns)), type, form))]));
|
|
@@ -5953,8 +5979,9 @@ exports.sidefence = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, com
|
|
|
5953
5979
|
...(0, util_1.invalid)('sidefence', 'syntax', 'Reserved syntax')
|
|
5954
5980
|
}))]))));
|
|
5955
5981
|
const opener = /(?=\|\|+(?:$|[ \n]))/y;
|
|
5982
|
+
const indent = (0, combinator_1.open)(opener, (0, combinator_1.some)(source_1.contentline, /\|(?:$|[ \n])/y));
|
|
5956
5983
|
const unindent = source => source.replace(/(?<=^|\n)\|(?: |(?=\|*(?:$|[ \n])))|\n$/g, '');
|
|
5957
|
-
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.recursion)(
|
|
5984
|
+
const source = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.recursion)(0 /* Recursion.block */, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.rewrite)(indent, (0, combinator_1.convert)(unindent, source, true)), (0, combinator_1.rewrite)((0, combinator_1.some)(source_1.contentline, opener), (0, combinator_1.convert)(unindent, (0, combinator_1.fmap)(autolink_1.autolink, ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('pre', (0, dom_1.defrag)((0, util_1.unwrap)(ns))))])), true))]))), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('blockquote', (0, util_1.unwrap)(ns)))])));
|
|
5958
5985
|
|
|
5959
5986
|
/***/ },
|
|
5960
5987
|
|
|
@@ -5977,7 +6004,7 @@ const util_1 = __webpack_require__(4992);
|
|
|
5977
6004
|
const duff_1 = __webpack_require__(9202);
|
|
5978
6005
|
const array_1 = __webpack_require__(6876);
|
|
5979
6006
|
const dom_1 = __webpack_require__(394);
|
|
5980
|
-
exports.table = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/\|[^\n]
|
|
6007
|
+
exports.table = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/\|[^\n]*\n\|[-:][^\n]*\n\|/y, (0, combinator_1.sequence)([row((0, combinator_1.some)(head), true), row((0, combinator_1.some)(align), false), (0, combinator_1.some)(row((0, combinator_1.some)(data), true))])), rows => new parser_1.List([new parser_1.Node((0, dom_1.html)('table', [(0, dom_1.html)('thead', [rows.shift().value]), (0, dom_1.html)('tbody', (0, util_1.unwrap)(format(rows)))]))]))));
|
|
5981
6008
|
const row = (parser, optional) => (0, combinator_1.fallback)((0, combinator_1.fmap)((0, combinator_1.line)((0, combinator_1.surround)(/(?=\|)/y, (0, combinator_1.some)((0, combinator_1.union)([parser])), /\|?\s*$/y, optional)), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('tr', (0, util_1.unwrap)(ns)))])), (0, combinator_1.rewrite)(source_1.contentline, ({
|
|
5982
6009
|
context: {
|
|
5983
6010
|
source
|
|
@@ -6039,7 +6066,7 @@ const visibility_1 = __webpack_require__(6364);
|
|
|
6039
6066
|
const util_1 = __webpack_require__(4992);
|
|
6040
6067
|
const dom_1 = __webpack_require__(394);
|
|
6041
6068
|
exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)('- ', exports.ulist_)));
|
|
6042
|
-
exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/-(?=$|[ \n])/y, (0, combinator_1.recursion)(
|
|
6069
|
+
exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/-(?=$|[ \n])/y, (0, combinator_1.recursion)(2 /* Recursion.listitem */, (0, combinator_1.some)((0, combinator_1.union)([(0, inline_1.indexee)((0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([(0, combinator_1.line)((0, combinator_1.open)(/-(?:$|[ \n])/y, (0, combinator_1.subsequence)([exports.checkbox, (0, visibility_1.visualize)((0, visibility_1.trimBlank)((0, combinator_1.some)((0, combinator_1.union)([inline_1.indexer, inline_1.inline]))))]), true)), (0, combinator_1.indent)((0, combinator_1.union)([exports.ulist_, olist_1.olist_, ilist_1.ilist_]))]), ilist_1.ilistitem), ns => new parser_1.List([new parser_1.Node((0, dom_1.html)('li', {
|
|
6043
6070
|
'data-index': (0, inline_1.dataindex)(ns)
|
|
6044
6071
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(fillFirstLine(ns)))))])))])))), ns => new parser_1.List([new parser_1.Node(format((0, dom_1.html)('ul', (0, util_1.unwrap)(ns))))]))));
|
|
6045
6072
|
exports.checkbox = (0, combinator_1.focus)(/\[[xX ]\](?=$|[ \n])/y, ({
|
|
@@ -6084,6 +6111,7 @@ const parser_1 = __webpack_require__(605);
|
|
|
6084
6111
|
class Context extends parser_1.Context {
|
|
6085
6112
|
constructor(options = {}) {
|
|
6086
6113
|
super(options);
|
|
6114
|
+
this.recursion = new RecursionCounter('annotation', 2);
|
|
6087
6115
|
const {
|
|
6088
6116
|
segment,
|
|
6089
6117
|
buffer,
|
|
@@ -6105,6 +6133,24 @@ class Context extends parser_1.Context {
|
|
|
6105
6133
|
}
|
|
6106
6134
|
}
|
|
6107
6135
|
exports.Context = Context;
|
|
6136
|
+
class RecursionCounter {
|
|
6137
|
+
constructor(syntax, limit) {
|
|
6138
|
+
this.syntax = syntax;
|
|
6139
|
+
this.limit = limit;
|
|
6140
|
+
this.stack = [];
|
|
6141
|
+
this.index = 0;
|
|
6142
|
+
}
|
|
6143
|
+
add(depth) {
|
|
6144
|
+
const {
|
|
6145
|
+
stack
|
|
6146
|
+
} = this;
|
|
6147
|
+
for (; this.index > 0 && stack[this.index - 1] <= depth; --this.index);
|
|
6148
|
+
// 内側から数えるので無効化処理できずエラーを投げるしかない。
|
|
6149
|
+
if (this.index === this.limit) throw new Error(`Too much ${this.syntax} recursion`);
|
|
6150
|
+
stack[this.index] = depth;
|
|
6151
|
+
++this.index;
|
|
6152
|
+
}
|
|
6153
|
+
}
|
|
6108
6154
|
exports.CmdRegExp = {
|
|
6109
6155
|
Error: /\x07/g
|
|
6110
6156
|
};
|
|
@@ -6329,11 +6375,30 @@ const bracket_1 = __webpack_require__(4526);
|
|
|
6329
6375
|
const visibility_1 = __webpack_require__(6364);
|
|
6330
6376
|
const util_1 = __webpack_require__(4992);
|
|
6331
6377
|
const dom_1 = __webpack_require__(394);
|
|
6332
|
-
|
|
6378
|
+
// シグネチャ等生成のために構文木のツリーウォークを再帰的に行い指数計算量にならないよう
|
|
6379
|
+
// 動的計画法を適用するか再帰数を制限する必要がある。
|
|
6380
|
+
// 動的計画法においては再帰的記録により指数空間計算量にならないよう下位の記録を消しながら記録しなければならない。
|
|
6381
|
+
// トリムも再帰的に行わないよう前後のトリムサイズの記録を要する。
|
|
6382
|
+
// しかし理論的には無制限の再帰が可能だがホバーテキストの記録やハッシュの計算を行う言語仕様から指数計算量を
|
|
6383
|
+
// 避けられないためAnnotation構文に限り再帰数の制限が必要となる。
|
|
6384
|
+
// シグネチャやハッシュは分割計算可能にすれば解決するがホバーテキストは記録せず動的に再計算して
|
|
6385
|
+
// 表示しなければ指数空間計算量を避けられない。
|
|
6386
|
+
// 注釈を除外すると重複排除により参照元が消滅し欠番が生じるため少なくとも直接注釈は残す必要があるが間接注釈は
|
|
6387
|
+
// 除外できる。しかしこれを効率的に行うことは難しいため最大再帰数を1回に制限することで間接注釈を行えない
|
|
6388
|
+
// ようにするのが合理的だろう。
|
|
6389
|
+
// 原理的には逆順処理により圧縮後正順で再附番すればすべて解決するはずだがテキストとシグネチャとハッシュも
|
|
6390
|
+
// 修正する必要があるためほぼ完全な二重処理が必要になり三重以上の注釈という不適切な使用のために
|
|
6391
|
+
// 常に非常に非効率な処理を行い常時低速化するより三重以上の注釈を禁止して効率性を維持するのが妥当である。
|
|
6392
|
+
const MAX_DEPTH = 20;
|
|
6393
|
+
exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, (0, combinator_1.surround)((0, combinator_1.open)('((', visibility_1.beforeNonblank), (0, combinator_1.precedence)(1, (0, combinator_1.recursions)([4 /* Recursion.annotation */, 3 /* Recursion.inline */, 5 /* Recursion.bracket */, 5 /* Recursion.bracket */], (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[')', 1]]))), '))', false, [], ([, ns], context) => {
|
|
6333
6394
|
const {
|
|
6334
|
-
linebreak
|
|
6395
|
+
linebreak,
|
|
6396
|
+
recursion,
|
|
6397
|
+
resources
|
|
6335
6398
|
} = context;
|
|
6399
|
+
const depth = MAX_DEPTH - (resources?.recursions[4 /* Recursion.annotation */] ?? resources?.recursions.at(-1) ?? MAX_DEPTH);
|
|
6336
6400
|
if (linebreak === 0) {
|
|
6401
|
+
recursion.add(depth);
|
|
6337
6402
|
return new parser_1.List([new parser_1.Node((0, dom_1.html)('sup', {
|
|
6338
6403
|
class: 'annotation'
|
|
6339
6404
|
}, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns))))]))]);
|
|
@@ -6341,60 +6406,96 @@ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1
|
|
|
6341
6406
|
ns.unshift(new parser_1.Node('('));
|
|
6342
6407
|
ns.push(new parser_1.Node(')'));
|
|
6343
6408
|
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6344
|
-
class: '
|
|
6409
|
+
class: 'bracket'
|
|
6345
6410
|
}, ['(', (0, dom_1.html)('span', {
|
|
6346
|
-
class: '
|
|
6411
|
+
class: 'bracket'
|
|
6347
6412
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(ns))), ')']))]);
|
|
6348
6413
|
}, ([, bs = new parser_1.List()], context) => {
|
|
6349
6414
|
const {
|
|
6350
6415
|
source,
|
|
6351
6416
|
position,
|
|
6352
6417
|
range,
|
|
6353
|
-
linebreak
|
|
6418
|
+
linebreak,
|
|
6419
|
+
recursion,
|
|
6420
|
+
resources
|
|
6354
6421
|
} = context;
|
|
6355
|
-
|
|
6422
|
+
const depth = MAX_DEPTH - (resources?.recursions[4 /* Recursion.annotation */] ?? resources?.recursions.at(-1) ?? MAX_DEPTH);
|
|
6423
|
+
if (linebreak === 0 && bs.length === 1 && source[position] === ')' && typeof bs.head?.value === 'object') {
|
|
6356
6424
|
const {
|
|
6357
|
-
|
|
6358
|
-
lastChild
|
|
6425
|
+
className
|
|
6359
6426
|
} = bs.head.value;
|
|
6360
|
-
if (
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6427
|
+
if (className === 'paren' || className === 'bracket') {
|
|
6428
|
+
const {
|
|
6429
|
+
firstChild,
|
|
6430
|
+
lastChild
|
|
6431
|
+
} = bs.head.value;
|
|
6432
|
+
if (firstChild.nodeValue.length === 1) {
|
|
6433
|
+
firstChild.remove();
|
|
6434
|
+
} else {
|
|
6435
|
+
firstChild.nodeValue = firstChild.nodeValue.slice(1);
|
|
6436
|
+
}
|
|
6437
|
+
if (lastChild.nodeValue.length === 1) {
|
|
6438
|
+
lastChild.remove();
|
|
6439
|
+
} else {
|
|
6440
|
+
lastChild.nodeValue = lastChild.nodeValue.slice(0, -1);
|
|
6441
|
+
}
|
|
6442
|
+
context.position += 1;
|
|
6443
|
+
recursion.add(depth);
|
|
6444
|
+
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6445
|
+
class: 'bracket'
|
|
6446
|
+
}, ['(', (0, dom_1.html)('sup', {
|
|
6447
|
+
class: 'annotation'
|
|
6448
|
+
}, [(0, dom_1.html)('span', bs.head.value.childNodes)])]))]);
|
|
6449
|
+
}
|
|
6450
|
+
if (className === 'annotation' && deepunwrap(bs)) {
|
|
6451
|
+
context.position += 1;
|
|
6452
|
+
recursion.add(depth);
|
|
6453
|
+
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6454
|
+
class: 'bracket'
|
|
6455
|
+
}, ['(', (0, dom_1.html)('sup', {
|
|
6456
|
+
class: 'annotation'
|
|
6457
|
+
}, [(0, dom_1.html)('span', [bs.head.value])])]))]);
|
|
6369
6458
|
}
|
|
6370
|
-
context.position += 1;
|
|
6371
|
-
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6372
|
-
class: 'paren'
|
|
6373
|
-
}, ['(', (0, dom_1.html)('sup', {
|
|
6374
|
-
class: 'annotation'
|
|
6375
|
-
}, [(0, dom_1.html)('span', bs.head.value.childNodes)])]))]);
|
|
6376
|
-
}
|
|
6377
|
-
if (linebreak === 0 && bs.length === 3 && source[position - range + 2] === '(' && source[position] === ')' && source[position - 1] === ')' && source[position - 2] !== '\\') {
|
|
6378
|
-
context.position += 1;
|
|
6379
|
-
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6380
|
-
class: 'paren'
|
|
6381
|
-
}, ['(', (0, dom_1.html)('sup', {
|
|
6382
|
-
class: 'annotation'
|
|
6383
|
-
}, [(0, dom_1.html)('span', [bs.head.next.value])])]))]);
|
|
6384
6459
|
}
|
|
6385
6460
|
const str = linebreak === 0 ? source.slice(position - range + 2, position) : '';
|
|
6386
6461
|
if (linebreak === 0 && bracket_1.indexA.test(str)) {
|
|
6387
6462
|
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6388
|
-
class: '
|
|
6463
|
+
class: 'bracket'
|
|
6389
6464
|
}, ['((' + str]))]);
|
|
6390
6465
|
}
|
|
6391
6466
|
bs.unshift(new parser_1.Node('('));
|
|
6392
6467
|
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6393
|
-
class: '
|
|
6468
|
+
class: 'bracket'
|
|
6394
6469
|
}, ['(', (0, dom_1.html)('span', {
|
|
6395
|
-
class: '
|
|
6470
|
+
class: 'bracket'
|
|
6396
6471
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(bs)))]))]);
|
|
6397
6472
|
})));
|
|
6473
|
+
function deepunwrap(list) {
|
|
6474
|
+
let bottom = list.head.value;
|
|
6475
|
+
for (; bottom;) {
|
|
6476
|
+
const el = bottom.firstChild.firstChild;
|
|
6477
|
+
if (el !== el?.parentNode?.lastChild) break;
|
|
6478
|
+
if (el instanceof HTMLElement === false) break;
|
|
6479
|
+
if (el?.className !== 'annotation') break;
|
|
6480
|
+
bottom = el;
|
|
6481
|
+
}
|
|
6482
|
+
const el = bottom.firstChild.firstChild;
|
|
6483
|
+
if (el instanceof Element === false) return false;
|
|
6484
|
+
if (el === el?.parentNode?.lastChild) {
|
|
6485
|
+
const {
|
|
6486
|
+
className,
|
|
6487
|
+
firstChild,
|
|
6488
|
+
lastChild
|
|
6489
|
+
} = el;
|
|
6490
|
+
if (className === 'paren' || className === 'bracket') {
|
|
6491
|
+
firstChild.nodeValue.length === 1 ? firstChild.remove() : firstChild.nodeValue = firstChild.nodeValue.slice(1);
|
|
6492
|
+
lastChild.nodeValue.length === 1 ? lastChild.remove() : lastChild.nodeValue = lastChild.nodeValue.slice(0, -1);
|
|
6493
|
+
el.replaceWith(...el.childNodes);
|
|
6494
|
+
return true;
|
|
6495
|
+
}
|
|
6496
|
+
}
|
|
6497
|
+
return false;
|
|
6498
|
+
}
|
|
6398
6499
|
|
|
6399
6500
|
/***/ },
|
|
6400
6501
|
|
|
@@ -6699,8 +6800,10 @@ const p1 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.
|
|
|
6699
6800
|
linebreak
|
|
6700
6801
|
}) => {
|
|
6701
6802
|
const str = linebreak === 0 ? source.slice(position - range + 1, position - 1) : '';
|
|
6702
|
-
return linebreak === 0 && exports.indexA.test(str) ? new parser_1.List([new parser_1.Node(
|
|
6803
|
+
return linebreak === 0 && exports.indexA.test(str) ? new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6703
6804
|
class: 'paren'
|
|
6805
|
+
}, `(${str})`))]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6806
|
+
class: 'bracket'
|
|
6704
6807
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs).import(cs)))))]);
|
|
6705
6808
|
}, ([as, bs = new parser_1.List()], context) => {
|
|
6706
6809
|
const {
|
|
@@ -6710,8 +6813,10 @@ const p1 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.
|
|
|
6710
6813
|
linebreak
|
|
6711
6814
|
} = context;
|
|
6712
6815
|
const str = linebreak === 0 ? source.slice(position - range + 1, position) : '';
|
|
6713
|
-
return linebreak === 0 && exports.indexA.test(str) ? new parser_1.List([new parser_1.Node(
|
|
6816
|
+
return linebreak === 0 && exports.indexA.test(str) ? new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6714
6817
|
class: 'paren'
|
|
6818
|
+
}, `(${str}`))]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6819
|
+
class: 'bracket'
|
|
6715
6820
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs)))))]);
|
|
6716
6821
|
}));
|
|
6717
6822
|
const p2 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, [], ([as, bs = [], cs], {
|
|
@@ -6721,8 +6826,10 @@ const p2 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.
|
|
|
6721
6826
|
linebreak
|
|
6722
6827
|
}) => {
|
|
6723
6828
|
const str = linebreak === 0 ? source.slice(position - range + 1, position - 1) : '';
|
|
6724
|
-
return linebreak === 0 && indexF.test(str) ? new parser_1.List([new parser_1.Node(
|
|
6829
|
+
return linebreak === 0 && indexF.test(str) ? new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6725
6830
|
class: 'paren'
|
|
6831
|
+
}, `(${str})`))]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6832
|
+
class: 'bracket'
|
|
6726
6833
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs).import(cs)))))]);
|
|
6727
6834
|
}, ([as, bs = new parser_1.List()], context) => {
|
|
6728
6835
|
const {
|
|
@@ -6732,8 +6839,10 @@ const p2 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.
|
|
|
6732
6839
|
linebreak
|
|
6733
6840
|
} = context;
|
|
6734
6841
|
const str = linebreak === 0 ? source.slice(position - range + 1, position) : '';
|
|
6735
|
-
return linebreak === 0 && indexF.test(str) ? new parser_1.List([new parser_1.Node(
|
|
6842
|
+
return linebreak === 0 && indexF.test(str) ? new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6736
6843
|
class: 'paren'
|
|
6844
|
+
}, `(${str}`))]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6845
|
+
class: 'bracket'
|
|
6737
6846
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs)))))]);
|
|
6738
6847
|
}));
|
|
6739
6848
|
const s1 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, [2 | 4 /* Backtrack.common */], ([as, bs = new parser_1.List(), cs], context) => {
|
|
@@ -6815,7 +6924,7 @@ const inline_1 = __webpack_require__(7973);
|
|
|
6815
6924
|
const visibility_1 = __webpack_require__(6364);
|
|
6816
6925
|
const util_1 = __webpack_require__(4992);
|
|
6817
6926
|
const dom_1 = __webpack_require__(394);
|
|
6818
|
-
exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('~~', '', (0, combinator_1.recursion)(
|
|
6927
|
+
exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('~~', '', (0, combinator_1.recursion)(3 /* Recursion.inline */, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '~~')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '~'), true)])), '~~', false, [], ([, bs], {
|
|
6819
6928
|
buffer
|
|
6820
6929
|
}) => buffer.import(bs), ([, bs], {
|
|
6821
6930
|
buffer
|
|
@@ -6841,7 +6950,7 @@ const source_1 = __webpack_require__(8745);
|
|
|
6841
6950
|
const visibility_1 = __webpack_require__(6364);
|
|
6842
6951
|
const util_1 = __webpack_require__(4992);
|
|
6843
6952
|
const dom_1 = __webpack_require__(394);
|
|
6844
|
-
exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*', (0, visibility_1.beforeNonblankWith)(/(?!\*)/)), (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(
|
|
6953
|
+
exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*', (0, visibility_1.beforeNonblankWith)(/(?!\*)/)), (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(3 /* Recursion.inline */, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank), strong_1.strong])))), (0, source_1.str)('*'), false, [], ([, bs]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('em', (0, dom_1.defrag)((0, util_1.unwrap)(bs))))]), ([as, bs]) => bs && as.import(bs)));
|
|
6845
6954
|
|
|
6846
6955
|
/***/ },
|
|
6847
6956
|
|
|
@@ -6869,7 +6978,7 @@ const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, comb
|
|
|
6869
6978
|
// 開閉が明示的でない構文は開閉の不明確な記号による再帰的適用を行わず
|
|
6870
6979
|
// 可能な限り早く閉じるよう解析しなければならない。
|
|
6871
6980
|
// このため終端記号の後ろを見て終端を中止し同じ構文を再帰的に適用してはならない。
|
|
6872
|
-
exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('***', visibility_1.beforeNonblank, (0, combinator_1.recursion)(
|
|
6981
|
+
exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('***', visibility_1.beforeNonblank, (0, combinator_1.recursion)(3 /* Recursion.inline */, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank)])), (0, source_1.strs)('*', 1, 3), false, [], ([, bs, cs], context) => {
|
|
6873
6982
|
const {
|
|
6874
6983
|
buffer
|
|
6875
6984
|
} = context;
|
|
@@ -7297,7 +7406,7 @@ const dom_1 = __webpack_require__(394);
|
|
|
7297
7406
|
// All syntax surrounded by square brackets shouldn't contain line breaks.
|
|
7298
7407
|
exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.surround)(
|
|
7299
7408
|
// ^はabbrで使用済みだが^:などのようにして分離使用可能
|
|
7300
|
-
(0, source_1.str)(/\[[:^|]/y, visibility_1.beforeNonblank), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(
|
|
7409
|
+
(0, source_1.str)(/\[[:^|]/y, visibility_1.beforeNonblank), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(3 /* Recursion.inline */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 1]]))), (0, source_1.str)(']'), false, [3 | 4 /* Backtrack.common */], (_, context) => new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
7301
7410
|
class: 'invalid',
|
|
7302
7411
|
...(0, util_1.invalid)('extension', 'syntax', `Invalid start symbol or linebreak`)
|
|
7303
7412
|
}, context.source.slice(context.position - context.range, context.position)))]), ([as, bs]) => bs && as.import(bs)));
|
|
@@ -7338,7 +7447,7 @@ exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/<[a-z]+(
|
|
|
7338
7447
|
// 可視のHTMLは優先度変更を検討する。
|
|
7339
7448
|
// このため`<>`記号は将来的に共通構造を変化させる可能性があり
|
|
7340
7449
|
// 共通構造を変化させない非構造文字列としては依然としてエスケープを要する。
|
|
7341
|
-
(0, combinator_1.precedence)(0, (0, combinator_1.recursion)(
|
|
7450
|
+
(0, combinator_1.precedence)(0, (0, combinator_1.recursion)(3 /* Recursion.inline */, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', `</${tag}>`)), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, `</${tag}>`), true)])))), (0, source_1.str)(`</${tag}>`), true, [], ([as, bs = new parser_1.List(), cs], context) => new parser_1.List([new parser_1.Node(elem(tag, true, [...(0, util_1.unwrap)(as)], bs, cs, context))]), ([as, bs = new parser_1.List()], context) => new parser_1.List([new parser_1.Node(elem(tag, true, [...(0, util_1.unwrap)(as)], bs, new parser_1.List(), context))])), ([, tag]) => tag, new Map())), (0, combinator_1.surround)(
|
|
7342
7451
|
// https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
7343
7452
|
(0, source_1.str)(/<[a-z]+(?=[ >])/yi), (0, combinator_1.precedence)(9, (0, combinator_1.some)((0, combinator_1.union)([exports.attribute]))), (0, combinator_1.open)((0, source_1.str)(/ ?/y), (0, source_1.str)('>'), true), true, [], ([as, bs = new parser_1.List(), cs], context) => new parser_1.List([new parser_1.Node(elem(as.head.value.slice(1), false, [...(0, util_1.unwrap)(as.import(bs).import(cs))], new parser_1.List(), new parser_1.List(), context))]), ([as, bs = new parser_1.List()], context) => new parser_1.List([new parser_1.Node(elem(as.head.value.slice(1), false, [...(0, util_1.unwrap)(as.import(bs))], new parser_1.List(), new parser_1.List(), context))]))])));
|
|
7344
7453
|
exports.attribute = (0, combinator_1.union)([(0, source_1.str)(/ [a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[ >])/yi), (0, source_1.str)(/ [^\s<>]+/y)]);
|
|
@@ -7444,7 +7553,7 @@ const inline_1 = __webpack_require__(7973);
|
|
|
7444
7553
|
const visibility_1 = __webpack_require__(6364);
|
|
7445
7554
|
const util_1 = __webpack_require__(4992);
|
|
7446
7555
|
const dom_1 = __webpack_require__(394);
|
|
7447
|
-
exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('++', '', (0, combinator_1.recursion)(
|
|
7556
|
+
exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('++', '', (0, combinator_1.recursion)(3 /* Recursion.inline */, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', '++')), (0, combinator_1.open)('\n', (0, combinator_1.some)(inline_1.inline, '+'), true)])), '++', false, [], ([, bs], {
|
|
7448
7557
|
buffer
|
|
7449
7558
|
}) => buffer.import(bs), ([, bs], {
|
|
7450
7559
|
buffer
|
|
@@ -7471,7 +7580,7 @@ const dom_1 = __webpack_require__(394);
|
|
|
7471
7580
|
// 可読性のため実際にはオブリーク体を指定する。
|
|
7472
7581
|
// 斜体は単語に使うとかえって見づらく読み飛ばしやすくなるため使わないべきであり
|
|
7473
7582
|
// ある程度の長さのある文に使うのが望ましい。
|
|
7474
|
-
exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('///', visibility_1.beforeNonblank, (0, combinator_1.recursion)(
|
|
7583
|
+
exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('///', visibility_1.beforeNonblank, (0, combinator_1.recursion)(3 /* Recursion.inline */, (0, combinator_1.surround)('', (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), '///', visibility_1.afterNonblank), '///', false, [], ([, bs], {
|
|
7475
7584
|
buffer
|
|
7476
7585
|
}) => buffer.import(bs), ([, bs], {
|
|
7477
7586
|
buffer
|
|
@@ -7652,7 +7761,7 @@ const indexee_1 = __webpack_require__(7610);
|
|
|
7652
7761
|
const visibility_1 = __webpack_require__(6364);
|
|
7653
7762
|
const util_1 = __webpack_require__(4992);
|
|
7654
7763
|
const dom_1 = __webpack_require__(394);
|
|
7655
|
-
exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('==', visibility_1.beforeNonblank, (0, combinator_1.recursion)(
|
|
7764
|
+
exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('==', visibility_1.beforeNonblank, (0, combinator_1.recursion)(3 /* Recursion.inline */, (0, combinator_1.surround)('', (0, combinator_1.state)(2 /* State.mark */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), '==', visibility_1.afterNonblank)), '==', false, [], ([, bs], {
|
|
7656
7765
|
buffer
|
|
7657
7766
|
}) => buffer.import(bs), ([, bs], {
|
|
7658
7767
|
buffer
|
|
@@ -7935,7 +8044,7 @@ const inline_1 = __webpack_require__(7973);
|
|
|
7935
8044
|
const source_1 = __webpack_require__(8745);
|
|
7936
8045
|
const util_1 = __webpack_require__(4992);
|
|
7937
8046
|
const dom_1 = __webpack_require__(394);
|
|
7938
|
-
exports.remark = (0, combinator_1.lazy)(() => (0, combinator_1.fallback)((0, combinator_1.surround)((0, source_1.str)(/\[%(?=[ \n])/y), (0, combinator_1.precedence)(3, (0, combinator_1.recursion)(
|
|
8047
|
+
exports.remark = (0, combinator_1.lazy)(() => (0, combinator_1.fallback)((0, combinator_1.surround)((0, source_1.str)(/\[%(?=[ \n])/y), (0, combinator_1.precedence)(3, (0, combinator_1.recursion)(3 /* Recursion.inline */, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), /[ \n]%\]/y, [[/[ \n]%\]/y, 3]]))), (0, combinator_1.close)(source_1.text, (0, source_1.str)('%]')), true, [], ([as, bs = new parser_1.List(), cs]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
7939
8048
|
class: 'remark'
|
|
7940
8049
|
}, [(0, dom_1.html)('input', {
|
|
7941
8050
|
type: 'checkbox'
|
|
@@ -8090,7 +8199,7 @@ const source_1 = __webpack_require__(8745);
|
|
|
8090
8199
|
const visibility_1 = __webpack_require__(6364);
|
|
8091
8200
|
const util_1 = __webpack_require__(4992);
|
|
8092
8201
|
const dom_1 = __webpack_require__(394);
|
|
8093
|
-
exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('**', (0, visibility_1.beforeNonblankWith)(/(?!\*)/)), (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(
|
|
8202
|
+
exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('**', (0, visibility_1.beforeNonblankWith)(/(?!\*)/)), (0, combinator_1.precedence)(0, (0, combinator_1.recursion)(3 /* Recursion.inline */, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*', visibility_1.afterNonblank), emphasis_1.emphasis])))), (0, source_1.str)('**'), false, [], ([, bs]) => new parser_1.List([new parser_1.Node((0, dom_1.html)('strong', (0, dom_1.defrag)((0, util_1.unwrap)(bs))))]), ([as, bs]) => bs && as.import(bs)));
|
|
8094
8203
|
|
|
8095
8204
|
/***/ },
|
|
8096
8205
|
|
|
@@ -8403,13 +8512,14 @@ function build(syntax, list, query, marker, splitter = '') {
|
|
|
8403
8512
|
info.queue.push(ref);
|
|
8404
8513
|
break;
|
|
8405
8514
|
}
|
|
8406
|
-
|
|
8515
|
+
ref.appendChild((0, dom_1.html)('a', {
|
|
8407
8516
|
href: refId && defId && `#${defId}`
|
|
8408
8517
|
}, marker(defIndex, abbr)));
|
|
8409
8518
|
def.lastElementChild.appendChild((0, dom_1.html)('a', {
|
|
8410
8519
|
href: refId && `#${refId}`,
|
|
8411
8520
|
title: abbr && text || undefined
|
|
8412
8521
|
}, `^${++refIndex}`));
|
|
8522
|
+
yield;
|
|
8413
8523
|
}
|
|
8414
8524
|
if (note || defs.size > 0) {
|
|
8415
8525
|
const splitter = splitters[iSplitters++];
|
|
@@ -9372,7 +9482,6 @@ function render(source, opts = {}) {
|
|
|
9372
9482
|
}
|
|
9373
9483
|
exports.render = render;
|
|
9374
9484
|
function render_(base, source, opts) {
|
|
9375
|
-
if (source.classList.contains('invalid')) return;
|
|
9376
9485
|
try {
|
|
9377
9486
|
switch (true) {
|
|
9378
9487
|
case !!opts.code && !source.firstElementChild && source.matches('pre.code'):
|
package/package.json
CHANGED
|
@@ -101,11 +101,33 @@ export function recursion(recursion: number, parser: Parser): Parser {
|
|
|
101
101
|
const resources = context.resources ?? { clock: 1, recursions: [1] };
|
|
102
102
|
const { recursions } = resources;
|
|
103
103
|
assert(recursions.length > 0);
|
|
104
|
-
const rec = min(recursion, recursions.length);
|
|
105
|
-
if (rec
|
|
106
|
-
rec
|
|
104
|
+
const rec = min(recursion, recursions.length - 1);
|
|
105
|
+
if (rec >= 0 && recursions[rec] < 1) throw new Error('Too much recursion');
|
|
106
|
+
rec >= 0 && --recursions[rec];
|
|
107
107
|
const result = parser(input);
|
|
108
|
-
rec
|
|
108
|
+
rec >= 0 && ++recursions[rec];
|
|
109
|
+
return result;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function recursions<P extends Parser>(recursions: readonly number[], parser: P): P;
|
|
114
|
+
export function recursions(rs: readonly number[], parser: Parser): Parser {
|
|
115
|
+
assert(rs.every(r => r >= 0));
|
|
116
|
+
return input => {
|
|
117
|
+
const { context } = input;
|
|
118
|
+
const resources = context.resources ?? { clock: 1, recursions: [4] };
|
|
119
|
+
const { recursions } = resources;
|
|
120
|
+
assert(recursions.length > 0);
|
|
121
|
+
for (const recursion of rs) {
|
|
122
|
+
const rec = min(recursion, recursions.length - 1);
|
|
123
|
+
if (rec >= 0 && recursions[rec] < 1) throw new Error('Too much recursion');
|
|
124
|
+
rec >= 0 && --recursions[rec];
|
|
125
|
+
}
|
|
126
|
+
const result = parser(input);
|
|
127
|
+
for (const recursion of rs) {
|
|
128
|
+
const rec = min(recursion, recursions.length - 1);
|
|
129
|
+
rec >= 0 && ++recursions[rec];
|
|
130
|
+
}
|
|
109
131
|
return result;
|
|
110
132
|
};
|
|
111
133
|
}
|