securemark 0.297.3 → 0.297.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.js +162 -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 +17 -2
- package/src/parser/inline/annotation.test.ts +20 -16
- package/src/parser/inline/annotation.ts +68 -26
- package/src/parser/inline/autolink/url.ts +6 -6
- 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/media.ts +4 -4
- package/src/parser/inline/reference.test.ts +1 -1
- package/src/parser/inline/strong.test.ts +2 -2
- package/src/parser/inline/template.ts +5 -6
- package/src/parser/inline.test.ts +23 -23
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.297.
|
|
1
|
+
/*! securemark v0.297.5 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("Prism"), require("DOMPurify"));
|
|
@@ -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(5);
|
|
6087
6115
|
const {
|
|
6088
6116
|
segment,
|
|
6089
6117
|
buffer,
|
|
@@ -6105,6 +6133,22 @@ class Context extends parser_1.Context {
|
|
|
6105
6133
|
}
|
|
6106
6134
|
}
|
|
6107
6135
|
exports.Context = Context;
|
|
6136
|
+
class RecursionCounter {
|
|
6137
|
+
constructor(limit) {
|
|
6138
|
+
this.limit = limit;
|
|
6139
|
+
this.stack = [];
|
|
6140
|
+
this.index = 0;
|
|
6141
|
+
}
|
|
6142
|
+
add(depth) {
|
|
6143
|
+
const {
|
|
6144
|
+
stack
|
|
6145
|
+
} = this;
|
|
6146
|
+
for (; this.index > 0 && stack[this.index - 1] <= depth; --this.index);
|
|
6147
|
+
if (this.index === this.limit) throw new Error('Too much recursion');
|
|
6148
|
+
stack[this.index] = depth;
|
|
6149
|
+
++this.index;
|
|
6150
|
+
}
|
|
6151
|
+
}
|
|
6108
6152
|
exports.CmdRegExp = {
|
|
6109
6153
|
Error: /\x07/g
|
|
6110
6154
|
};
|
|
@@ -6329,11 +6373,21 @@ const bracket_1 = __webpack_require__(4526);
|
|
|
6329
6373
|
const visibility_1 = __webpack_require__(6364);
|
|
6330
6374
|
const util_1 = __webpack_require__(4992);
|
|
6331
6375
|
const dom_1 = __webpack_require__(394);
|
|
6332
|
-
|
|
6376
|
+
// シグネチャ等生成のために構文木のツリーウォークを再帰的に行い指数計算量にならないよう
|
|
6377
|
+
// 動的計画法を適用するか再帰数を制限する必要がある。
|
|
6378
|
+
// 動的計画法においては再帰的記録により指数空間計算量にならないよう下位の記録を消しながら記録しなければならない。
|
|
6379
|
+
// トリムも再帰的に行わないよう前後のトリムサイズの記録を要する。
|
|
6380
|
+
// しかし理論的には再帰数の制限はないがポップアップテキストの記録やハッシュの計算を行う言語仕様から指数計算量を
|
|
6381
|
+
// 避けられないためAnnotation構文に限り再帰数の制限が必要となる。
|
|
6382
|
+
// シグネチャやハッシュは分割計算可能にすれば解決するがポップアップテキストは記録せず動的に再計算して
|
|
6383
|
+
// 表示しなければ指数空間計算量を避けられない。
|
|
6384
|
+
// 注釈は本来再帰的に行うものではないため再帰数を制限して機能を優先するのが合理的となる。
|
|
6385
|
+
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
6386
|
const {
|
|
6334
6387
|
linebreak
|
|
6335
6388
|
} = context;
|
|
6336
6389
|
if (linebreak === 0) {
|
|
6390
|
+
context.recursion.add(20 - (context.resources?.recursions[4 /* Recursion.annotation */] ?? context.resources?.recursions.at(-1) ?? 20));
|
|
6337
6391
|
return new parser_1.List([new parser_1.Node((0, dom_1.html)('sup', {
|
|
6338
6392
|
class: 'annotation'
|
|
6339
6393
|
}, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(ns))))]))]);
|
|
@@ -6341,9 +6395,9 @@ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1
|
|
|
6341
6395
|
ns.unshift(new parser_1.Node('('));
|
|
6342
6396
|
ns.push(new parser_1.Node(')'));
|
|
6343
6397
|
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6344
|
-
class: '
|
|
6398
|
+
class: 'bracket'
|
|
6345
6399
|
}, ['(', (0, dom_1.html)('span', {
|
|
6346
|
-
class: '
|
|
6400
|
+
class: 'bracket'
|
|
6347
6401
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(ns))), ')']))]);
|
|
6348
6402
|
}, ([, bs = new parser_1.List()], context) => {
|
|
6349
6403
|
const {
|
|
@@ -6352,49 +6406,82 @@ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1
|
|
|
6352
6406
|
range,
|
|
6353
6407
|
linebreak
|
|
6354
6408
|
} = context;
|
|
6355
|
-
if (linebreak === 0 && bs.length === 1 && source[position] === ')' && typeof bs.head?.value === 'object'
|
|
6409
|
+
if (linebreak === 0 && bs.length === 1 && source[position] === ')' && typeof bs.head?.value === 'object') {
|
|
6356
6410
|
const {
|
|
6357
|
-
|
|
6358
|
-
lastChild
|
|
6411
|
+
className
|
|
6359
6412
|
} = bs.head.value;
|
|
6360
|
-
if (
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6413
|
+
if (className === 'paren' || className === 'bracket') {
|
|
6414
|
+
const {
|
|
6415
|
+
firstChild,
|
|
6416
|
+
lastChild
|
|
6417
|
+
} = bs.head.value;
|
|
6418
|
+
if (firstChild.nodeValue.length === 1) {
|
|
6419
|
+
firstChild.remove();
|
|
6420
|
+
} else {
|
|
6421
|
+
firstChild.nodeValue = firstChild.nodeValue.slice(1);
|
|
6422
|
+
}
|
|
6423
|
+
if (lastChild.nodeValue.length === 1) {
|
|
6424
|
+
lastChild.remove();
|
|
6425
|
+
} else {
|
|
6426
|
+
lastChild.nodeValue = lastChild.nodeValue.slice(0, -1);
|
|
6427
|
+
}
|
|
6428
|
+
context.position += 1;
|
|
6429
|
+
context.recursion.add(20 - (context.resources?.recursions[4 /* Recursion.annotation */] ?? context.resources?.recursions.at(-1) ?? 20));
|
|
6430
|
+
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6431
|
+
class: 'bracket'
|
|
6432
|
+
}, ['(', (0, dom_1.html)('sup', {
|
|
6433
|
+
class: 'annotation'
|
|
6434
|
+
}, [(0, dom_1.html)('span', bs.head.value.childNodes)])]))]);
|
|
6435
|
+
}
|
|
6436
|
+
if (className === 'annotation' && deepunwrap(bs)) {
|
|
6437
|
+
context.position += 1;
|
|
6438
|
+
context.recursion.add(20 - (context.resources?.recursions[4 /* Recursion.annotation */] ?? context.resources?.recursions.at(-1) ?? 20));
|
|
6439
|
+
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6440
|
+
class: 'bracket'
|
|
6441
|
+
}, ['(', (0, dom_1.html)('sup', {
|
|
6442
|
+
class: 'annotation'
|
|
6443
|
+
}, [(0, dom_1.html)('span', [bs.head.value])])]))]);
|
|
6369
6444
|
}
|
|
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
6445
|
}
|
|
6385
6446
|
const str = linebreak === 0 ? source.slice(position - range + 2, position) : '';
|
|
6386
6447
|
if (linebreak === 0 && bracket_1.indexA.test(str)) {
|
|
6387
6448
|
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6388
|
-
class: '
|
|
6449
|
+
class: 'bracket'
|
|
6389
6450
|
}, ['((' + str]))]);
|
|
6390
6451
|
}
|
|
6391
6452
|
bs.unshift(new parser_1.Node('('));
|
|
6392
6453
|
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6393
|
-
class: '
|
|
6454
|
+
class: 'bracket'
|
|
6394
6455
|
}, ['(', (0, dom_1.html)('span', {
|
|
6395
|
-
class: '
|
|
6456
|
+
class: 'bracket'
|
|
6396
6457
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(bs)))]))]);
|
|
6397
6458
|
})));
|
|
6459
|
+
function deepunwrap(list) {
|
|
6460
|
+
let bottom = list.head.value;
|
|
6461
|
+
for (; bottom;) {
|
|
6462
|
+
const el = bottom.firstChild.firstChild;
|
|
6463
|
+
if (el !== el?.parentNode?.lastChild) break;
|
|
6464
|
+
if (el instanceof HTMLElement === false) break;
|
|
6465
|
+
if (el?.className !== 'annotation') break;
|
|
6466
|
+
bottom = el;
|
|
6467
|
+
}
|
|
6468
|
+
const el = bottom.firstChild.firstChild;
|
|
6469
|
+
if (el instanceof Element === false) return false;
|
|
6470
|
+
if (el === el?.parentNode?.lastChild) {
|
|
6471
|
+
const {
|
|
6472
|
+
className,
|
|
6473
|
+
firstChild,
|
|
6474
|
+
lastChild
|
|
6475
|
+
} = el;
|
|
6476
|
+
if (className === 'paren' || className === 'bracket') {
|
|
6477
|
+
firstChild.nodeValue.length === 1 ? firstChild.remove() : firstChild.nodeValue = firstChild.nodeValue.slice(1);
|
|
6478
|
+
lastChild.nodeValue.length === 1 ? lastChild.remove() : lastChild.nodeValue = lastChild.nodeValue.slice(0, -1);
|
|
6479
|
+
el.replaceWith(...el.childNodes);
|
|
6480
|
+
return true;
|
|
6481
|
+
}
|
|
6482
|
+
}
|
|
6483
|
+
return false;
|
|
6484
|
+
}
|
|
6398
6485
|
|
|
6399
6486
|
/***/ },
|
|
6400
6487
|
|
|
@@ -6632,7 +6719,7 @@ const combinator_1 = __webpack_require__(3484);
|
|
|
6632
6719
|
const inline_1 = __webpack_require__(7973);
|
|
6633
6720
|
const link_1 = __webpack_require__(3628);
|
|
6634
6721
|
const source_1 = __webpack_require__(8745);
|
|
6635
|
-
exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.open)(/(?<![0-9A-Za-z][.+-]?|[@#])https?:\/\/(?=[\x21-\x7E])/y, (0, combinator_1.precedence)(0, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(source_1.unescsource, /(?<![-+*=~^_,.;:!?]|\/{3})(?:[-+*=~^_,.;:!?]|\/{3,}(?!\/))*(?=[\\$"`\[\](){}<>()[]{}|]|[^\x21-\x7E]|$)/y), (0, combinator_1.precedence)(1,
|
|
6722
|
+
exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.rewrite)((0, combinator_1.open)(/(?<![0-9A-Za-z][.+-]?|[@#])https?:\/\/(?=[\x21-\x7E])/y, (0, combinator_1.precedence)(0, (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(source_1.unescsource, /(?<![-+*=~^_,.;:!?]|\/{3})(?:[-+*=~^_,.;:!?]|\/{3,}(?!\/))*(?=[\\$"`\[\](){}<>()[]{}|]|[^\x21-\x7E]|$)/y), (0, combinator_1.precedence)(1, bracket)]), [[/[^\x21-\x7E]|\$/y, 9]])), false, [3 | 8 /* Backtrack.unescapable */]), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, ({
|
|
6636
6723
|
context
|
|
6637
6724
|
}) => new parser_1.List([new parser_1.Node((0, link_1.parse)(new parser_1.List(), new parser_1.List([new parser_1.Node(context.source)]), context))]))), (0, combinator_1.open)((0, source_1.str)(/[^:]+/y), (0, combinator_1.some)(inline_1.inline))])));
|
|
6638
6725
|
exports.lineurl = (0, combinator_1.lazy)(() => (0, combinator_1.focus)(/(?<=^|[\r\n])!?https?:\/\/\S+(?=[^\S\n]*(?=$|\n))/y, (0, combinator_1.tails)([(0, source_1.str)('!'), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, (0, combinator_1.state)(1 /* State.autolink */, ({
|
|
@@ -6645,7 +6732,7 @@ exports.lineurl = (0, combinator_1.lazy)(() => (0, combinator_1.focus)(/(?<=^|[\
|
|
|
6645
6732
|
context.position -= source[0] === '!' ? 1 : 0;
|
|
6646
6733
|
return new parser_1.List([new parser_1.Node((0, link_1.parse)(new parser_1.List(), new parser_1.List([new parser_1.Node(source.slice(position))]), context))]);
|
|
6647
6734
|
})), (0, source_1.str)(/[^:]+/y)])])));
|
|
6648
|
-
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')')), (0, source_1.str)(')'), true, [3 | 8 /* Backtrack.unescapable */]
|
|
6735
|
+
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')')), (0, source_1.str)(')'), true, [3 | 8 /* Backtrack.unescapable */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']')), (0, source_1.str)(']'), true, [3 | 8 /* Backtrack.unescapable */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}')), (0, source_1.str)('}'), true, [3 | 8 /* Backtrack.unescapable */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.unescsource, '"'))), (0, source_1.str)('"'), true, [3 | 8 /* Backtrack.unescapable */])]));
|
|
6649
6736
|
|
|
6650
6737
|
/***/ },
|
|
6651
6738
|
|
|
@@ -6699,8 +6786,10 @@ const p1 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.
|
|
|
6699
6786
|
linebreak
|
|
6700
6787
|
}) => {
|
|
6701
6788
|
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(
|
|
6789
|
+
return linebreak === 0 && exports.indexA.test(str) ? new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6703
6790
|
class: 'paren'
|
|
6791
|
+
}, `(${str})`))]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6792
|
+
class: 'bracket'
|
|
6704
6793
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs).import(cs)))))]);
|
|
6705
6794
|
}, ([as, bs = new parser_1.List()], context) => {
|
|
6706
6795
|
const {
|
|
@@ -6710,8 +6799,10 @@ const p1 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.
|
|
|
6710
6799
|
linebreak
|
|
6711
6800
|
} = context;
|
|
6712
6801
|
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(
|
|
6802
|
+
return linebreak === 0 && exports.indexA.test(str) ? new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6714
6803
|
class: 'paren'
|
|
6804
|
+
}, `(${str}`))]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6805
|
+
class: 'bracket'
|
|
6715
6806
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs)))))]);
|
|
6716
6807
|
}));
|
|
6717
6808
|
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 +6812,10 @@ const p2 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.
|
|
|
6721
6812
|
linebreak
|
|
6722
6813
|
}) => {
|
|
6723
6814
|
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(
|
|
6815
|
+
return linebreak === 0 && indexF.test(str) ? new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6725
6816
|
class: 'paren'
|
|
6817
|
+
}, `(${str})`))]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6818
|
+
class: 'bracket'
|
|
6726
6819
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs).import(cs)))))]);
|
|
6727
6820
|
}, ([as, bs = new parser_1.List()], context) => {
|
|
6728
6821
|
const {
|
|
@@ -6732,8 +6825,10 @@ const p2 = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.
|
|
|
6732
6825
|
linebreak
|
|
6733
6826
|
} = context;
|
|
6734
6827
|
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(
|
|
6828
|
+
return linebreak === 0 && indexF.test(str) ? new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6736
6829
|
class: 'paren'
|
|
6830
|
+
}, `(${str}`))]) : new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6831
|
+
class: 'bracket'
|
|
6737
6832
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(as.import(bs)))))]);
|
|
6738
6833
|
}));
|
|
6739
6834
|
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 +6910,7 @@ const inline_1 = __webpack_require__(7973);
|
|
|
6815
6910
|
const visibility_1 = __webpack_require__(6364);
|
|
6816
6911
|
const util_1 = __webpack_require__(4992);
|
|
6817
6912
|
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)(
|
|
6913
|
+
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
6914
|
buffer
|
|
6820
6915
|
}) => buffer.import(bs), ([, bs], {
|
|
6821
6916
|
buffer
|
|
@@ -6841,7 +6936,7 @@ const source_1 = __webpack_require__(8745);
|
|
|
6841
6936
|
const visibility_1 = __webpack_require__(6364);
|
|
6842
6937
|
const util_1 = __webpack_require__(4992);
|
|
6843
6938
|
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)(
|
|
6939
|
+
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
6940
|
|
|
6846
6941
|
/***/ },
|
|
6847
6942
|
|
|
@@ -6869,7 +6964,7 @@ const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, comb
|
|
|
6869
6964
|
// 開閉が明示的でない構文は開閉の不明確な記号による再帰的適用を行わず
|
|
6870
6965
|
// 可能な限り早く閉じるよう解析しなければならない。
|
|
6871
6966
|
// このため終端記号の後ろを見て終端を中止し同じ構文を再帰的に適用してはならない。
|
|
6872
|
-
exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('***', visibility_1.beforeNonblank, (0, combinator_1.recursion)(
|
|
6967
|
+
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
6968
|
const {
|
|
6874
6969
|
buffer
|
|
6875
6970
|
} = context;
|
|
@@ -7297,7 +7392,7 @@ const dom_1 = __webpack_require__(394);
|
|
|
7297
7392
|
// All syntax surrounded by square brackets shouldn't contain line breaks.
|
|
7298
7393
|
exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.surround)(
|
|
7299
7394
|
// ^はabbrで使用済みだが^:などのようにして分離使用可能
|
|
7300
|
-
(0, source_1.str)(/\[[:^|]/y, visibility_1.beforeNonblank), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(
|
|
7395
|
+
(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
7396
|
class: 'invalid',
|
|
7302
7397
|
...(0, util_1.invalid)('extension', 'syntax', `Invalid start symbol or linebreak`)
|
|
7303
7398
|
}, context.source.slice(context.position - context.range, context.position)))]), ([as, bs]) => bs && as.import(bs)));
|
|
@@ -7338,7 +7433,7 @@ exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/<[a-z]+(
|
|
|
7338
7433
|
// 可視のHTMLは優先度変更を検討する。
|
|
7339
7434
|
// このため`<>`記号は将来的に共通構造を変化させる可能性があり
|
|
7340
7435
|
// 共通構造を変化させない非構造文字列としては依然としてエスケープを要する。
|
|
7341
|
-
(0, combinator_1.precedence)(0, (0, combinator_1.recursion)(
|
|
7436
|
+
(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
7437
|
// https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
7343
7438
|
(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
7439
|
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 +7539,7 @@ const inline_1 = __webpack_require__(7973);
|
|
|
7444
7539
|
const visibility_1 = __webpack_require__(6364);
|
|
7445
7540
|
const util_1 = __webpack_require__(4992);
|
|
7446
7541
|
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)(
|
|
7542
|
+
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
7543
|
buffer
|
|
7449
7544
|
}) => buffer.import(bs), ([, bs], {
|
|
7450
7545
|
buffer
|
|
@@ -7471,7 +7566,7 @@ const dom_1 = __webpack_require__(394);
|
|
|
7471
7566
|
// 可読性のため実際にはオブリーク体を指定する。
|
|
7472
7567
|
// 斜体は単語に使うとかえって見づらく読み飛ばしやすくなるため使わないべきであり
|
|
7473
7568
|
// ある程度の長さのある文に使うのが望ましい。
|
|
7474
|
-
exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.precedence)(0, (0, util_1.repeat)('///', visibility_1.beforeNonblank, (0, combinator_1.recursion)(
|
|
7569
|
+
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
7570
|
buffer
|
|
7476
7571
|
}) => buffer.import(bs), ([, bs], {
|
|
7477
7572
|
buffer
|
|
@@ -7652,7 +7747,7 @@ const indexee_1 = __webpack_require__(7610);
|
|
|
7652
7747
|
const visibility_1 = __webpack_require__(6364);
|
|
7653
7748
|
const util_1 = __webpack_require__(4992);
|
|
7654
7749
|
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)(
|
|
7750
|
+
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
7751
|
buffer
|
|
7657
7752
|
}) => buffer.import(bs), ([, bs], {
|
|
7658
7753
|
buffer
|
|
@@ -7791,7 +7886,7 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* S
|
|
|
7791
7886
|
target: '_blank'
|
|
7792
7887
|
}, [el]))]);
|
|
7793
7888
|
}))));
|
|
7794
|
-
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')')), (0, source_1.str)(')'), true, [
|
|
7889
|
+
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')')), (0, source_1.str)(')'), true, [], undefined, () => new parser_1.List()), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']')), (0, source_1.str)(']'), true, [], undefined, () => new parser_1.List()), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}')), (0, source_1.str)('}'), true, [], undefined, () => new parser_1.List()), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"'))), (0, source_1.str)('"'), true, [], undefined, () => new parser_1.List())]));
|
|
7795
7890
|
const option = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, combinator_1.open)(/ /y, (0, source_1.str)(/[1-9][0-9]*/y)), (0, source_1.str)(/[x:]/y), (0, source_1.str)(/[1-9][0-9]*(?=[ }])/y), false, [], ([[{
|
|
7796
7891
|
value: a
|
|
7797
7892
|
}], [{
|
|
@@ -7935,7 +8030,7 @@ const inline_1 = __webpack_require__(7973);
|
|
|
7935
8030
|
const source_1 = __webpack_require__(8745);
|
|
7936
8031
|
const util_1 = __webpack_require__(4992);
|
|
7937
8032
|
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)(
|
|
8033
|
+
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
8034
|
class: 'remark'
|
|
7940
8035
|
}, [(0, dom_1.html)('input', {
|
|
7941
8036
|
type: 'checkbox'
|
|
@@ -8090,7 +8185,7 @@ const source_1 = __webpack_require__(8745);
|
|
|
8090
8185
|
const visibility_1 = __webpack_require__(6364);
|
|
8091
8186
|
const util_1 = __webpack_require__(4992);
|
|
8092
8187
|
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)(
|
|
8188
|
+
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
8189
|
|
|
8095
8190
|
/***/ },
|
|
8096
8191
|
|
|
@@ -8115,7 +8210,7 @@ exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, s
|
|
|
8115
8210
|
class: 'invalid',
|
|
8116
8211
|
...(0, util_1.invalid)('template', 'syntax', `Missing the closing symbol "}}"`)
|
|
8117
8212
|
}, context.source.slice(context.position - context.range, context.position)))])));
|
|
8118
|
-
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')')), (0, source_1.str)(')'), true, [
|
|
8213
|
+
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')')), (0, source_1.str)(')'), true, [], undefined, ([as, bs]) => bs && as.import(bs)), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']')), (0, source_1.str)(']'), true, [], undefined, ([as, bs]) => bs && as.import(bs)), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}'), true, [], undefined, ([as, bs]) => bs && as.import(bs)), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.escsource, /["\n]/y, [['"', 2], ['\n', 3]]))), (0, source_1.str)('"'), true, [], undefined, ([as, bs]) => bs && as.import(bs))]));
|
|
8119
8214
|
|
|
8120
8215
|
/***/ },
|
|
8121
8216
|
|
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
|
}
|