securemark 0.235.0 → 0.235.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/securemark.js +93 -84
- package/package-lock.json +19 -19
- package/package.json +1 -1
- package/src/combinator/control/manipulation/context.test.ts +4 -4
- package/src/combinator/control/manipulation/resource.ts +6 -3
- package/src/combinator/control/manipulation/surround.ts +3 -4
- package/src/combinator/data/parser/inits.ts +1 -1
- package/src/combinator/data/parser/sequence.ts +1 -1
- package/src/combinator/data/parser/some.ts +23 -25
- package/src/combinator/data/parser.ts +33 -10
- package/src/parser/api/bind.test.ts +3 -3
- package/src/parser/api/parse.test.ts +12 -5
- package/src/parser/block/blockquote.test.ts +1 -1
- package/src/parser/block/extension/aside.test.ts +1 -1
- package/src/parser/block/extension/example.test.ts +2 -2
- package/src/parser/block/extension/fig.test.ts +20 -20
- package/src/parser/block/extension/figure.test.ts +31 -28
- package/src/parser/block/extension/figure.ts +4 -2
- package/src/parser/block/extension/table.ts +6 -6
- package/src/parser/block.ts +1 -2
- package/src/parser/inline/bracket.ts +3 -3
- package/src/parser/inline/emphasis.ts +2 -5
- package/src/parser/inline/emstrong.ts +4 -5
- package/src/parser/inline/html.ts +3 -3
- package/src/parser/inline/mark.ts +2 -5
- package/src/parser/inline/strong.test.ts +1 -1
- package/src/parser/inline/strong.ts +2 -5
- package/src/parser/inline.test.ts +0 -1
- package/src/parser/processor/figure.test.ts +28 -28
- package/src/parser/processor/figure.ts +1 -1
- package/src/parser/util.ts +5 -7
package/CHANGELOG.md
CHANGED
package/dist/securemark.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.235.
|
|
1
|
+
/*! securemark v0.235.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
|
|
2
2
|
require = function () {
|
|
3
3
|
function r(e, n, t) {
|
|
4
4
|
function o(i, f) {
|
|
@@ -3578,11 +3578,20 @@ require = function () {
|
|
|
3578
3578
|
if (typeof cost === 'function')
|
|
3579
3579
|
return creator(1, cost);
|
|
3580
3580
|
return (source, context) => {
|
|
3581
|
-
const {
|
|
3582
|
-
|
|
3581
|
+
const {
|
|
3582
|
+
resources = {
|
|
3583
|
+
budget: 1,
|
|
3584
|
+
recursion: 1
|
|
3585
|
+
}
|
|
3586
|
+
} = context;
|
|
3587
|
+
if (resources.budget <= 0)
|
|
3583
3588
|
throw new Error('Too many creations.');
|
|
3589
|
+
if (resources.recursion <= 0)
|
|
3590
|
+
throw new Error('Too much recursion.');
|
|
3591
|
+
--resources.recursion;
|
|
3584
3592
|
const result = parser(source, context);
|
|
3585
|
-
|
|
3593
|
+
++resources.recursion;
|
|
3594
|
+
if (result) {
|
|
3586
3595
|
resources.budget -= cost;
|
|
3587
3596
|
}
|
|
3588
3597
|
return result;
|
|
@@ -3665,7 +3674,6 @@ require = function () {
|
|
|
3665
3674
|
const global_1 = _dereq_('spica/global');
|
|
3666
3675
|
const parser_1 = _dereq_('../../data/parser');
|
|
3667
3676
|
const fmap_1 = _dereq_('../monad/fmap');
|
|
3668
|
-
const resource_1 = _dereq_('./resource');
|
|
3669
3677
|
const array_1 = _dereq_('spica/array');
|
|
3670
3678
|
function surround(opener, parser, closer, optional = false, f, g) {
|
|
3671
3679
|
switch (typeof opener) {
|
|
@@ -3713,18 +3721,18 @@ require = function () {
|
|
|
3713
3721
|
function match(pattern) {
|
|
3714
3722
|
switch (typeof pattern) {
|
|
3715
3723
|
case 'string':
|
|
3716
|
-
return
|
|
3724
|
+
return source => source.slice(0, pattern.length) === pattern ? [
|
|
3717
3725
|
[],
|
|
3718
3726
|
source.slice(pattern.length)
|
|
3719
|
-
] : global_1.undefined
|
|
3727
|
+
] : global_1.undefined;
|
|
3720
3728
|
case 'object':
|
|
3721
|
-
return
|
|
3729
|
+
return source => {
|
|
3722
3730
|
const m = source.match(pattern);
|
|
3723
3731
|
return m ? [
|
|
3724
3732
|
[],
|
|
3725
3733
|
source.slice(m[0].length)
|
|
3726
3734
|
] : global_1.undefined;
|
|
3727
|
-
}
|
|
3735
|
+
};
|
|
3728
3736
|
}
|
|
3729
3737
|
}
|
|
3730
3738
|
function open(opener, parser, optional = false) {
|
|
@@ -3743,7 +3751,6 @@ require = function () {
|
|
|
3743
3751
|
{
|
|
3744
3752
|
'../../data/parser': 47,
|
|
3745
3753
|
'../monad/fmap': 46,
|
|
3746
|
-
'./resource': 40,
|
|
3747
3754
|
'spica/array': 6,
|
|
3748
3755
|
'spica/global': 15
|
|
3749
3756
|
}
|
|
@@ -3816,7 +3823,37 @@ require = function () {
|
|
|
3816
3823
|
function (_dereq_, module, exports) {
|
|
3817
3824
|
'use strict';
|
|
3818
3825
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3819
|
-
exports.check = exports.exec = exports.eval = void 0;
|
|
3826
|
+
exports.check = exports.exec = exports.eval = exports.Delimiters = void 0;
|
|
3827
|
+
class Delimiters {
|
|
3828
|
+
constructor() {
|
|
3829
|
+
this.stack = [];
|
|
3830
|
+
this.matchers = {};
|
|
3831
|
+
}
|
|
3832
|
+
push(delimiter) {
|
|
3833
|
+
var _a;
|
|
3834
|
+
var _b;
|
|
3835
|
+
const {signature, matcher} = delimiter;
|
|
3836
|
+
this.stack.push(signature);
|
|
3837
|
+
(_a = (_b = this.matchers)[signature]) !== null && _a !== void 0 ? _a : _b[signature] = matcher;
|
|
3838
|
+
}
|
|
3839
|
+
pop() {
|
|
3840
|
+
this.stack.pop();
|
|
3841
|
+
}
|
|
3842
|
+
match(source) {
|
|
3843
|
+
const {stack, matchers} = this;
|
|
3844
|
+
const log = {};
|
|
3845
|
+
for (let i = 0; i < stack.length; ++i) {
|
|
3846
|
+
const sig = stack[i];
|
|
3847
|
+
if (sig in log)
|
|
3848
|
+
continue;
|
|
3849
|
+
if (matchers[sig](source))
|
|
3850
|
+
return true;
|
|
3851
|
+
log[sig] = false;
|
|
3852
|
+
}
|
|
3853
|
+
return false;
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
exports.Delimiters = Delimiters;
|
|
3820
3857
|
function eval_(result, default_) {
|
|
3821
3858
|
return result ? result[0] : default_;
|
|
3822
3859
|
}
|
|
@@ -3927,7 +3964,7 @@ require = function () {
|
|
|
3927
3964
|
return `r/${ pattern.source }/${ pattern.flags }`;
|
|
3928
3965
|
}
|
|
3929
3966
|
};
|
|
3930
|
-
const
|
|
3967
|
+
const matcher = (0, memoize_1.memoize)(pattern => {
|
|
3931
3968
|
switch (typeof pattern) {
|
|
3932
3969
|
case 'undefined':
|
|
3933
3970
|
return () => false;
|
|
@@ -3936,35 +3973,31 @@ require = function () {
|
|
|
3936
3973
|
case 'object':
|
|
3937
3974
|
return (0, memoize_1.reduce)(source => pattern.test(source));
|
|
3938
3975
|
}
|
|
3939
|
-
}, signature)
|
|
3976
|
+
}, signature);
|
|
3940
3977
|
function some(parser, until, deep, limit = -1) {
|
|
3941
3978
|
if (typeof until === 'number')
|
|
3942
3979
|
return some(parser, global_1.undefined, deep, until);
|
|
3943
3980
|
const match = matcher(until);
|
|
3944
|
-
const
|
|
3945
|
-
|
|
3981
|
+
const delimiter = {
|
|
3982
|
+
signature: signature(deep),
|
|
3983
|
+
matcher: matcher(deep)
|
|
3984
|
+
};
|
|
3946
3985
|
return (source, context) => {
|
|
3947
|
-
var _a, _b
|
|
3948
|
-
var _d;
|
|
3986
|
+
var _a, _b;
|
|
3949
3987
|
if (source === '')
|
|
3950
3988
|
return;
|
|
3951
3989
|
let rest = source;
|
|
3952
3990
|
let nodes;
|
|
3953
|
-
if (
|
|
3954
|
-
(_a = context.delimiters) !== null && _a !== void 0 ? _a : context.delimiters =
|
|
3955
|
-
|
|
3956
|
-
matchers: {}
|
|
3957
|
-
};
|
|
3958
|
-
context.delimiters.stack.push(sig);
|
|
3959
|
-
(_b = (_d = context.delimiters.matchers)[sig]) !== null && _b !== void 0 ? _b : _d[sig] = delim;
|
|
3991
|
+
if (deep && context) {
|
|
3992
|
+
(_a = context.delimiters) !== null && _a !== void 0 ? _a : context.delimiters = new parser_1.Delimiters();
|
|
3993
|
+
context.delimiters.push(delimiter);
|
|
3960
3994
|
}
|
|
3961
|
-
const {stack, matchers} = (_c = context.delimiters) !== null && _c !== void 0 ? _c : {};
|
|
3962
3995
|
while (true) {
|
|
3963
3996
|
if (rest === '')
|
|
3964
3997
|
break;
|
|
3965
3998
|
if (match(rest))
|
|
3966
3999
|
break;
|
|
3967
|
-
if (
|
|
4000
|
+
if ((_b = context.delimiters) === null || _b === void 0 ? void 0 : _b.match(rest))
|
|
3968
4001
|
break;
|
|
3969
4002
|
const result = parser(rest, context);
|
|
3970
4003
|
if (!result)
|
|
@@ -3974,8 +4007,8 @@ require = function () {
|
|
|
3974
4007
|
if (limit >= 0 && source.length - rest.length > limit)
|
|
3975
4008
|
break;
|
|
3976
4009
|
}
|
|
3977
|
-
if (
|
|
3978
|
-
|
|
4010
|
+
if (deep && context.delimiters) {
|
|
4011
|
+
context.delimiters.pop();
|
|
3979
4012
|
}
|
|
3980
4013
|
return nodes && rest.length < source.length ? [
|
|
3981
4014
|
nodes,
|
|
@@ -4590,7 +4623,12 @@ require = function () {
|
|
|
4590
4623
|
const paragraph_1 = _dereq_('./block/paragraph');
|
|
4591
4624
|
const typed_dom_1 = _dereq_('typed-dom');
|
|
4592
4625
|
const random_1 = _dereq_('spica/random');
|
|
4593
|
-
exports.block = (0, combinator_1.creator)(error((0, combinator_1.reset)({
|
|
4626
|
+
exports.block = (0, combinator_1.creator)(error((0, combinator_1.reset)({
|
|
4627
|
+
resources: {
|
|
4628
|
+
budget: 100 * 1000,
|
|
4629
|
+
recursion: 200
|
|
4630
|
+
}
|
|
4631
|
+
}, (0, combinator_1.union)([
|
|
4594
4632
|
source_1.emptyline,
|
|
4595
4633
|
horizontalrule_1.horizontalrule,
|
|
4596
4634
|
heading_1.heading,
|
|
@@ -4613,8 +4651,7 @@ require = function () {
|
|
|
4613
4651
|
[
|
|
4614
4652
|
(0, typed_dom_1.html)('h1', {
|
|
4615
4653
|
id: id !== '' ? `error:${ (0, random_1.rnd0Z)(8) }` : global_1.undefined,
|
|
4616
|
-
class: 'error'
|
|
4617
|
-
translate: 'no'
|
|
4654
|
+
class: 'error'
|
|
4618
4655
|
}, reason instanceof Error ? `${ reason.name }: ${ reason.message }` : `UnknownError: ${ reason }`),
|
|
4619
4656
|
(0, typed_dom_1.html)('pre', {
|
|
4620
4657
|
class: 'error',
|
|
@@ -5073,6 +5110,7 @@ require = function () {
|
|
|
5073
5110
|
const util_1 = _dereq_('../../util');
|
|
5074
5111
|
const typed_dom_1 = _dereq_('typed-dom');
|
|
5075
5112
|
const memoize_1 = _dereq_('spica/memoize');
|
|
5113
|
+
const array_1 = _dereq_('spica/array');
|
|
5076
5114
|
exports.segment = (0, combinator_1.block)((0, combinator_1.match)(/^(~{3,})(?:figure[^\S\n]+)?(?=\[?\$[A-Za-z-][^\n]*\n(?:[^\n]*\n)*?\1[^\S\n]*(?:$|\n))/, (0, memoize_1.memoize)(([, fence], closer = new RegExp(String.raw`^${ fence }[^\S\n]*(?:$|\n)`)) => (0, combinator_1.close)((0, combinator_1.sequence)([
|
|
5077
5115
|
(0, combinator_1.line)((0, combinator_1.close)(label_1.segment, /^.*\n/)),
|
|
5078
5116
|
(0, combinator_1.inits)([
|
|
@@ -5113,8 +5151,7 @@ require = function () {
|
|
|
5113
5151
|
])
|
|
5114
5152
|
])), ([label, param, content, ...caption]) => [(0, typed_dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [
|
|
5115
5153
|
(0, typed_dom_1.html)('div', { class: 'figcontent' }, [content]),
|
|
5116
|
-
(0, typed_dom_1.html)('span', { class: 'figindex' }),
|
|
5117
|
-
(0, typed_dom_1.html)('figcaption', (0, typed_dom_1.defrag)(caption))
|
|
5154
|
+
(0, typed_dom_1.html)('figcaption', (0, array_1.unshift)([(0, typed_dom_1.html)('span', { class: 'figindex' })], (0, typed_dom_1.defrag)(caption)))
|
|
5118
5155
|
])])));
|
|
5119
5156
|
function attributes(label, param, content, caption) {
|
|
5120
5157
|
const group = label.split('-', 1)[0];
|
|
@@ -5156,6 +5193,7 @@ require = function () {
|
|
|
5156
5193
|
'./example': 69,
|
|
5157
5194
|
'./placeholder': 74,
|
|
5158
5195
|
'./table': 75,
|
|
5196
|
+
'spica/array': 6,
|
|
5159
5197
|
'spica/global': 15,
|
|
5160
5198
|
'spica/memoize': 18,
|
|
5161
5199
|
'typed-dom': 26
|
|
@@ -5273,6 +5311,7 @@ require = function () {
|
|
|
5273
5311
|
exports.table = exports.segment_ = exports.segment = void 0;
|
|
5274
5312
|
const global_1 = _dereq_('spica/global');
|
|
5275
5313
|
const alias_1 = _dereq_('spica/alias');
|
|
5314
|
+
const parser_1 = _dereq_('../../../combinator/data/parser');
|
|
5276
5315
|
const combinator_1 = _dereq_('../../../combinator');
|
|
5277
5316
|
const inline_1 = _dereq_('../../inline');
|
|
5278
5317
|
const source_1 = _dereq_('../../source');
|
|
@@ -5283,23 +5322,17 @@ require = function () {
|
|
|
5283
5322
|
const opener = /^(~{3,})table(?!\S)([^\n]*)(?:$|\n)/;
|
|
5284
5323
|
exports.segment = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 10000))));
|
|
5285
5324
|
exports.segment_ = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.clear)((0, combinator_1.fence)(opener, 10000, false))), false);
|
|
5286
|
-
exports.table = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.recover)((0, combinator_1.
|
|
5325
|
+
exports.table = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0, combinator_1.recover)((0, combinator_1.fmap)((0, combinator_1.fence)(opener, 10000), ([body, closer, opener, delim, param], _, context) => {
|
|
5287
5326
|
var _a;
|
|
5288
5327
|
if (!closer || param.trimStart())
|
|
5289
|
-
return [
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
''
|
|
5298
|
-
];
|
|
5299
|
-
return (_a = parser(body, context)) !== null && _a !== void 0 ? _a : [
|
|
5300
|
-
[(0, typed_dom_1.html)('table')],
|
|
5301
|
-
''
|
|
5302
|
-
];
|
|
5328
|
+
return [(0, typed_dom_1.html)('pre', {
|
|
5329
|
+
class: 'invalid',
|
|
5330
|
+
translate: 'no',
|
|
5331
|
+
'data-invalid-syntax': 'table',
|
|
5332
|
+
'data-invalid-type': !closer ? 'closer' : 'argument',
|
|
5333
|
+
'data-invalid-description': !closer ? `Missing the closing delimiter "${ delim }".` : 'Invalid argument.'
|
|
5334
|
+
}, `${ opener }${ body }${ closer }`)];
|
|
5335
|
+
return (_a = (0, parser_1.eval)(parser(body, context))) !== null && _a !== void 0 ? _a : [(0, typed_dom_1.html)('table')];
|
|
5303
5336
|
}), (source, _, reason) => reason instanceof Error && reason.message === 'Number of columns must be 32 or less.' ? [
|
|
5304
5337
|
[(0, typed_dom_1.html)('pre', {
|
|
5305
5338
|
class: 'invalid',
|
|
@@ -5528,6 +5561,7 @@ require = function () {
|
|
|
5528
5561
|
},
|
|
5529
5562
|
{
|
|
5530
5563
|
'../../../combinator': 27,
|
|
5564
|
+
'../../../combinator/data/parser': 47,
|
|
5531
5565
|
'../../inline': 88,
|
|
5532
5566
|
'../../locale': 123,
|
|
5533
5567
|
'../../source': 128,
|
|
@@ -6573,7 +6607,7 @@ require = function () {
|
|
|
6573
6607
|
const array_1 = _dereq_('spica/array');
|
|
6574
6608
|
const index = /^(?:[0-9]+(?:\.[0-9]+)*|[A-Za-z])/;
|
|
6575
6609
|
const indexFW = new RegExp(index.source.replace(/[019AZaz](?!,)/g, c => String.fromCharCode(c.charCodeAt(0) + 65248)));
|
|
6576
|
-
exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([
|
|
6610
|
+
exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.union)([
|
|
6577
6611
|
(0, combinator_1.surround)((0, source_1.str)('('), (0, source_1.str)(index), (0, source_1.str)(')'), false, ([as, bs = [], cs], rest) => [
|
|
6578
6612
|
(0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)),
|
|
6579
6613
|
rest
|
|
@@ -6608,7 +6642,7 @@ require = function () {
|
|
|
6608
6642
|
(0, array_1.unshift)(as, bs),
|
|
6609
6643
|
rest
|
|
6610
6644
|
])
|
|
6611
|
-
]));
|
|
6645
|
+
])));
|
|
6612
6646
|
},
|
|
6613
6647
|
{
|
|
6614
6648
|
'../../combinator': 27,
|
|
@@ -6714,12 +6748,9 @@ require = function () {
|
|
|
6714
6748
|
strong_1.strong,
|
|
6715
6749
|
(0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*/)),
|
|
6716
6750
|
(0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
|
|
6717
|
-
])), '*'), (0, source_1.str)('*'), false, ([
|
|
6751
|
+
])), '*'), (0, source_1.str)('*'), false, ([, bs], rest) => [
|
|
6718
6752
|
[(0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))],
|
|
6719
6753
|
rest
|
|
6720
|
-
] : [
|
|
6721
|
-
(0, array_1.unshift)(as, bs),
|
|
6722
|
-
cs[0] + rest
|
|
6723
6754
|
], ([as, bs], rest) => [
|
|
6724
6755
|
(0, array_1.unshift)(as, bs),
|
|
6725
6756
|
rest
|
|
@@ -6759,13 +6790,8 @@ require = function () {
|
|
|
6759
6790
|
exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('***'), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
|
|
6760
6791
|
(0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*/)),
|
|
6761
6792
|
(0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
|
|
6762
|
-
]))), (0, source_1.str)(/^\*{1,3}/), false, ([
|
|
6793
|
+
]))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], rest, context) => {
|
|
6763
6794
|
var _a, _b;
|
|
6764
|
-
if (!(0, util_1.isEndTightNodes)(bs))
|
|
6765
|
-
return [
|
|
6766
|
-
(0, array_1.unshift)(as, bs),
|
|
6767
|
-
cs[0] + rest
|
|
6768
|
-
];
|
|
6769
6795
|
switch (cs[0]) {
|
|
6770
6796
|
case '***':
|
|
6771
6797
|
return [
|
|
@@ -6773,7 +6799,7 @@ require = function () {
|
|
|
6773
6799
|
rest
|
|
6774
6800
|
];
|
|
6775
6801
|
case '**':
|
|
6776
|
-
return (_a = (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*'
|
|
6802
|
+
return (_a = (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' ? [
|
|
6777
6803
|
[(0, typed_dom_1.html)('em', (0, array_1.unshift)([(0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))], (0, typed_dom_1.defrag)(ds)))],
|
|
6778
6804
|
rest.slice(1)
|
|
6779
6805
|
] : [
|
|
@@ -6790,7 +6816,7 @@ require = function () {
|
|
|
6790
6816
|
rest
|
|
6791
6817
|
];
|
|
6792
6818
|
case '*':
|
|
6793
|
-
return (_b = (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**'
|
|
6819
|
+
return (_b = (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' ? [
|
|
6794
6820
|
[(0, typed_dom_1.html)('strong', (0, array_1.unshift)([(0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))], (0, typed_dom_1.defrag)(ds)))],
|
|
6795
6821
|
rest.slice(2)
|
|
6796
6822
|
] : [
|
|
@@ -7214,8 +7240,6 @@ require = function () {
|
|
|
7214
7240
|
switch (true) {
|
|
7215
7241
|
case as[as.length - 1] !== '>' || 'data-invalid-syntax' in (attrs = attributes('html', [], attrspec[tag], as.slice(1, -1))):
|
|
7216
7242
|
return invalid('attribute', 'Invalid HTML attribute.', as, bs, cs);
|
|
7217
|
-
case cs.length === 0:
|
|
7218
|
-
return invalid('closer', `Missing the closing HTML tag <${ tag }>.`, as, bs, cs);
|
|
7219
7243
|
default:
|
|
7220
7244
|
return (0, typed_dom_1.html)(tag, attrs, bs);
|
|
7221
7245
|
}
|
|
@@ -7477,12 +7501,9 @@ require = function () {
|
|
|
7477
7501
|
exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('=='), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
|
|
7478
7502
|
(0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/==/)),
|
|
7479
7503
|
(0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '='), inline_1.inline)
|
|
7480
|
-
]))), (0, source_1.str)('=='), false, ([
|
|
7504
|
+
]))), (0, source_1.str)('=='), false, ([, bs], rest) => [
|
|
7481
7505
|
[(0, typed_dom_1.html)('mark', (0, typed_dom_1.defrag)(bs))],
|
|
7482
7506
|
rest
|
|
7483
|
-
] : [
|
|
7484
|
-
(0, array_1.unshift)(as, bs),
|
|
7485
|
-
cs[0] + rest
|
|
7486
7507
|
], ([as, bs], rest) => [
|
|
7487
7508
|
(0, array_1.unshift)(as, bs),
|
|
7488
7509
|
rest
|
|
@@ -7896,12 +7917,9 @@ require = function () {
|
|
|
7896
7917
|
exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('**'), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
|
|
7897
7918
|
(0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(/\*\*/)),
|
|
7898
7919
|
(0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
|
|
7899
|
-
])), '*'), (0, source_1.str)('**'), false, ([
|
|
7920
|
+
])), '*'), (0, source_1.str)('**'), false, ([, bs], rest) => [
|
|
7900
7921
|
[(0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))],
|
|
7901
7922
|
rest
|
|
7902
|
-
] : [
|
|
7903
|
-
(0, array_1.unshift)(as, bs),
|
|
7904
|
-
cs[0] + rest
|
|
7905
7923
|
], ([as, bs], rest) => [
|
|
7906
7924
|
(0, array_1.unshift)(as, bs),
|
|
7907
7925
|
rest
|
|
@@ -8115,7 +8133,7 @@ require = function () {
|
|
|
8115
8133
|
!(0, label_1.isFixed)(label) && numbers.set(group, number);
|
|
8116
8134
|
opts.id !== '' && def.setAttribute('id', `label:${ opts.id ? `${ opts.id }:` : '' }${ label }`);
|
|
8117
8135
|
const figindex = group === '$' ? `(${ number })` : `${ capitalize(group) }${ group === 'fig' ? '.' : '' } ${ number }`;
|
|
8118
|
-
(0, typed_dom_1.define)(def.querySelector(':scope > .figindex'), group === '$' ? figindex : `${ figindex }. `);
|
|
8136
|
+
(0, typed_dom_1.define)(def.querySelector(':scope > figcaption > .figindex'), group === '$' ? figindex : `${ figindex }. `);
|
|
8119
8137
|
for (const ref of refs.take(label, global_1.Infinity)) {
|
|
8120
8138
|
if (ref.hash.slice(1) === def.id && ref.innerText === figindex)
|
|
8121
8139
|
continue;
|
|
@@ -8687,7 +8705,7 @@ require = function () {
|
|
|
8687
8705
|
function (_dereq_, module, exports) {
|
|
8688
8706
|
'use strict';
|
|
8689
8707
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8690
|
-
exports.stringify = exports.trimNodeEndBR = exports.trimNodeEnd = exports.trimNode = exports.
|
|
8708
|
+
exports.stringify = exports.trimNodeEndBR = exports.trimNodeEnd = exports.trimNode = exports.isStartTightNodes = exports.startTight = exports.isStartLoose = exports.startLoose = exports.visualize = exports.delimiter = void 0;
|
|
8691
8709
|
const global_1 = _dereq_('spica/global');
|
|
8692
8710
|
const parser_1 = _dereq_('../combinator/data/parser');
|
|
8693
8711
|
const combinator_1 = _dereq_('../combinator');
|
|
@@ -8736,10 +8754,7 @@ require = function () {
|
|
|
8736
8754
|
}
|
|
8737
8755
|
exports.startLoose = startLoose;
|
|
8738
8756
|
function isStartLoose(source, context, except) {
|
|
8739
|
-
|
|
8740
|
-
if (source === '')
|
|
8741
|
-
return true;
|
|
8742
|
-
return isStartTight(source, context, except);
|
|
8757
|
+
return isStartTight(source.replace(/^[^\S\n]+/, ''), context, except);
|
|
8743
8758
|
}
|
|
8744
8759
|
exports.isStartLoose = isStartLoose;
|
|
8745
8760
|
function startTight(parser, except) {
|
|
@@ -8782,12 +8797,6 @@ require = function () {
|
|
|
8782
8797
|
return isVisible(nodes[0], 0);
|
|
8783
8798
|
}
|
|
8784
8799
|
exports.isStartTightNodes = isStartTightNodes;
|
|
8785
|
-
function isEndTightNodes(nodes) {
|
|
8786
|
-
if (nodes.length === 0)
|
|
8787
|
-
return true;
|
|
8788
|
-
return isVisible(nodes[nodes.length - 1], -1);
|
|
8789
|
-
}
|
|
8790
|
-
exports.isEndTightNodes = isEndTightNodes;
|
|
8791
8800
|
function isVisible(node, strpos) {
|
|
8792
8801
|
switch (typeof node) {
|
|
8793
8802
|
case 'string':
|
package/package-lock.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securemark",
|
|
3
|
-
"version": "0.235.
|
|
3
|
+
"version": "0.235.1",
|
|
4
4
|
"lockfileVersion": 1,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"dependencies": {
|
|
@@ -449,9 +449,9 @@
|
|
|
449
449
|
},
|
|
450
450
|
"dependencies": {
|
|
451
451
|
"lru-cache": {
|
|
452
|
-
"version": "7.7.
|
|
453
|
-
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.
|
|
454
|
-
"integrity": "sha512-
|
|
452
|
+
"version": "7.7.3",
|
|
453
|
+
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.3.tgz",
|
|
454
|
+
"integrity": "sha512-WY9wjJNQt9+PZilnLbuFKM+SwDull9+6IAguOrarOMoOHTcJ9GnXSO11+Gw6c7xtDkBkthR57OZMtZKYr+1CEw==",
|
|
455
455
|
"dev": true
|
|
456
456
|
},
|
|
457
457
|
"mkdirp": {
|
|
@@ -1801,9 +1801,9 @@
|
|
|
1801
1801
|
},
|
|
1802
1802
|
"dependencies": {
|
|
1803
1803
|
"lru-cache": {
|
|
1804
|
-
"version": "7.7.
|
|
1805
|
-
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.
|
|
1806
|
-
"integrity": "sha512-
|
|
1804
|
+
"version": "7.7.3",
|
|
1805
|
+
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.3.tgz",
|
|
1806
|
+
"integrity": "sha512-WY9wjJNQt9+PZilnLbuFKM+SwDull9+6IAguOrarOMoOHTcJ9GnXSO11+Gw6c7xtDkBkthR57OZMtZKYr+1CEw==",
|
|
1807
1807
|
"dev": true
|
|
1808
1808
|
},
|
|
1809
1809
|
"mkdirp": {
|
|
@@ -3033,9 +3033,9 @@
|
|
|
3033
3033
|
"dev": true
|
|
3034
3034
|
},
|
|
3035
3035
|
"electron-to-chromium": {
|
|
3036
|
-
"version": "1.4.
|
|
3037
|
-
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.
|
|
3038
|
-
"integrity": "sha512-
|
|
3036
|
+
"version": "1.4.103",
|
|
3037
|
+
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.103.tgz",
|
|
3038
|
+
"integrity": "sha512-c/uKWR1Z/W30Wy/sx3dkZoj4BijbXX85QKWu9jJfjho3LBAXNEGAEW3oWiGb+dotA6C6BzCTxL2/aLes7jlUeg==",
|
|
3039
3039
|
"dev": true
|
|
3040
3040
|
},
|
|
3041
3041
|
"elliptic": {
|
|
@@ -7119,9 +7119,9 @@
|
|
|
7119
7119
|
},
|
|
7120
7120
|
"dependencies": {
|
|
7121
7121
|
"lru-cache": {
|
|
7122
|
-
"version": "7.7.
|
|
7123
|
-
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.
|
|
7124
|
-
"integrity": "sha512-
|
|
7122
|
+
"version": "7.7.3",
|
|
7123
|
+
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.3.tgz",
|
|
7124
|
+
"integrity": "sha512-WY9wjJNQt9+PZilnLbuFKM+SwDull9+6IAguOrarOMoOHTcJ9GnXSO11+Gw6c7xtDkBkthR57OZMtZKYr+1CEw==",
|
|
7125
7125
|
"dev": true
|
|
7126
7126
|
}
|
|
7127
7127
|
}
|
|
@@ -8151,9 +8151,9 @@
|
|
|
8151
8151
|
}
|
|
8152
8152
|
},
|
|
8153
8153
|
"lru-cache": {
|
|
8154
|
-
"version": "7.7.
|
|
8155
|
-
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.
|
|
8156
|
-
"integrity": "sha512-
|
|
8154
|
+
"version": "7.7.3",
|
|
8155
|
+
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.3.tgz",
|
|
8156
|
+
"integrity": "sha512-WY9wjJNQt9+PZilnLbuFKM+SwDull9+6IAguOrarOMoOHTcJ9GnXSO11+Gw6c7xtDkBkthR57OZMtZKYr+1CEw==",
|
|
8157
8157
|
"dev": true
|
|
8158
8158
|
}
|
|
8159
8159
|
}
|
|
@@ -9190,9 +9190,9 @@
|
|
|
9190
9190
|
}
|
|
9191
9191
|
},
|
|
9192
9192
|
"lru-cache": {
|
|
9193
|
-
"version": "7.7.
|
|
9194
|
-
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.
|
|
9195
|
-
"integrity": "sha512-
|
|
9193
|
+
"version": "7.7.3",
|
|
9194
|
+
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.7.3.tgz",
|
|
9195
|
+
"integrity": "sha512-WY9wjJNQt9+PZilnLbuFKM+SwDull9+6IAguOrarOMoOHTcJ9GnXSO11+Gw6c7xtDkBkthR57OZMtZKYr+1CEw==",
|
|
9196
9196
|
"dev": true
|
|
9197
9197
|
},
|
|
9198
9198
|
"normalize-package-data": {
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ describe('Unit: combinator/context', () => {
|
|
|
13
13
|
(s, context) => [[context.resources?.budget ?? NaN], s.slice(1)]));
|
|
14
14
|
|
|
15
15
|
it('root', () => {
|
|
16
|
-
const base: Context = { resources: { budget: 3 } };
|
|
16
|
+
const base: Context = { resources: { budget: 3, recursion: 1 } };
|
|
17
17
|
const ctx: Context = {};
|
|
18
18
|
assert.deepStrictEqual(reset(base, parser)('123', ctx), [[3, 2, 1], '']);
|
|
19
19
|
assert(base.resources?.budget === 3);
|
|
@@ -24,8 +24,8 @@ describe('Unit: combinator/context', () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it('node', () => {
|
|
27
|
-
const base: Context = { resources: { budget: 3 } };
|
|
28
|
-
const ctx: Context = { resources: { budget: 1 } };
|
|
27
|
+
const base: Context = { resources: { budget: 3, recursion: 1 } };
|
|
28
|
+
const ctx: Context = { resources: { budget: 1, recursion: 1 } };
|
|
29
29
|
assert.deepStrictEqual(reset(base, parser)('1', ctx), [[1], '']);
|
|
30
30
|
assert(base.resources?.budget === 3);
|
|
31
31
|
assert(ctx.resources?.budget === 0);
|
|
@@ -41,7 +41,7 @@ describe('Unit: combinator/context', () => {
|
|
|
41
41
|
|
|
42
42
|
it('', () => {
|
|
43
43
|
const base: Context = { state: true };
|
|
44
|
-
const ctx: Context = { resources: { budget: 3 } };
|
|
44
|
+
const ctx: Context = { resources: { budget: 3, recursion: 1 } };
|
|
45
45
|
assert.deepStrictEqual(context(base, parser)('123', ctx), [[true, true, true], '']);
|
|
46
46
|
assert(ctx.resources?.budget === 0);
|
|
47
47
|
assert(ctx.state === undefined);
|
|
@@ -6,10 +6,13 @@ export function creator(cost: number | Parser<unknown>, parser?: Parser<unknown>
|
|
|
6
6
|
if (typeof cost === 'function') return creator(1, cost);
|
|
7
7
|
assert(cost > 0);
|
|
8
8
|
return (source, context) => {
|
|
9
|
-
const { resources } = context;
|
|
10
|
-
if (resources
|
|
9
|
+
const { resources = { budget: 1, recursion: 1 } } = context;
|
|
10
|
+
if (resources.budget <= 0) throw new Error('Too many creations.');
|
|
11
|
+
if (resources.recursion <= 0) throw new Error('Too much recursion.');
|
|
12
|
+
--resources.recursion;
|
|
11
13
|
const result = parser!(source, context);
|
|
12
|
-
|
|
14
|
+
++resources.recursion;
|
|
15
|
+
if (result) {
|
|
13
16
|
resources.budget -= cost;
|
|
14
17
|
}
|
|
15
18
|
return result;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { Parser, Result, Ctx, Tree, Context, SubParsers, SubTree, IntermediateParser, eval, exec, check } from '../../data/parser';
|
|
3
3
|
import { fmap } from '../monad/fmap';
|
|
4
|
-
import { creator } from './resource';
|
|
5
4
|
import { unshift, push } from 'spica/array';
|
|
6
5
|
|
|
7
6
|
export function surround<P extends Parser<unknown>, S = string>(
|
|
@@ -69,14 +68,14 @@ export function surround<T>(
|
|
|
69
68
|
function match(pattern: string | RegExp): (source: string, context: Ctx) => [never[], string] | undefined {
|
|
70
69
|
switch (typeof pattern) {
|
|
71
70
|
case 'string':
|
|
72
|
-
return
|
|
71
|
+
return source => source.slice(0, pattern.length) === pattern ? [[], source.slice(pattern.length)] : undefined;
|
|
73
72
|
case 'object':
|
|
74
|
-
return
|
|
73
|
+
return source => {
|
|
75
74
|
const m = source.match(pattern);
|
|
76
75
|
return m
|
|
77
76
|
? [[], source.slice(m[0].length)]
|
|
78
77
|
: undefined;
|
|
79
|
-
}
|
|
78
|
+
};
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
|
|
@@ -14,7 +14,7 @@ export function inits<T, D extends Parser<T>[]>(parsers: D): Parser<T, Ctx, D> {
|
|
|
14
14
|
const result = parsers[i](rest, context);
|
|
15
15
|
assert(check(rest, result));
|
|
16
16
|
if (!result) break;
|
|
17
|
-
assert(!context?.delimiters?.
|
|
17
|
+
assert(!context?.delimiters?.match(rest));
|
|
18
18
|
nodes = nodes
|
|
19
19
|
? push(nodes, eval(result))
|
|
20
20
|
: eval(result);
|
|
@@ -14,7 +14,7 @@ export function sequence<T, D extends Parser<T>[]>(parsers: D): Parser<T, Ctx, D
|
|
|
14
14
|
const result = parsers[i](rest, context);
|
|
15
15
|
assert(check(rest, result));
|
|
16
16
|
if (!result) return;
|
|
17
|
-
assert(!context?.delimiters?.
|
|
17
|
+
assert(!context?.delimiters?.match(rest));
|
|
18
18
|
nodes = nodes
|
|
19
19
|
? push(nodes, eval(result))
|
|
20
20
|
: eval(result);
|