securemark 0.257.3 → 0.258.0
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/index.js +1216 -606
- package/markdown.d.ts +1 -12
- package/package.json +9 -9
- package/src/combinator/control/manipulation/convert.ts +8 -4
- package/src/combinator/control/manipulation/scope.ts +10 -2
- package/src/combinator/data/parser/context/delimiter.ts +70 -0
- package/src/combinator/data/parser/context/memo.ts +30 -0
- package/src/combinator/{control/manipulation → data/parser}/context.test.ts +9 -9
- package/src/combinator/data/parser/context.ts +161 -0
- package/src/combinator/data/parser/sequence.test.ts +1 -1
- package/src/combinator/data/parser/sequence.ts +1 -1
- package/src/combinator/data/parser/some.test.ts +1 -1
- package/src/combinator/data/parser/some.ts +14 -37
- package/src/combinator/data/parser/subsequence.test.ts +1 -1
- package/src/combinator/data/parser/union.test.ts +1 -1
- package/src/combinator/data/parser.ts +7 -47
- package/src/combinator.ts +1 -2
- package/src/parser/api/bind.ts +5 -5
- package/src/parser/api/parse.ts +3 -1
- package/src/parser/block/blockquote.ts +1 -1
- package/src/parser/block/dlist.ts +4 -10
- package/src/parser/block/extension/figure.ts +4 -3
- package/src/parser/block/extension/table.ts +2 -2
- package/src/parser/block/heading.ts +5 -13
- package/src/parser/block/ilist.ts +3 -2
- package/src/parser/block/olist.ts +10 -7
- package/src/parser/block/paragraph.ts +1 -1
- package/src/parser/block/reply/cite.ts +1 -1
- package/src/parser/block/reply/quote.ts +1 -1
- package/src/parser/block/reply.ts +1 -1
- package/src/parser/block/sidefence.ts +1 -1
- package/src/parser/block/table.ts +9 -9
- package/src/parser/block/ulist.ts +4 -3
- package/src/parser/block.ts +1 -1
- package/src/parser/context.ts +32 -0
- package/src/parser/header.ts +1 -1
- package/src/parser/inline/annotation.ts +9 -17
- package/src/parser/inline/autolink/email.ts +1 -1
- package/src/parser/inline/autolink/url.ts +1 -1
- package/src/parser/inline/autolink.ts +5 -3
- package/src/parser/inline/bracket.ts +16 -15
- package/src/parser/inline/code.ts +1 -1
- package/src/parser/inline/comment.ts +4 -3
- package/src/parser/inline/deletion.ts +5 -4
- package/src/parser/inline/emphasis.ts +5 -4
- package/src/parser/inline/emstrong.ts +5 -4
- package/src/parser/inline/extension/index.ts +7 -14
- package/src/parser/inline/extension/indexee.ts +8 -10
- package/src/parser/inline/extension/indexer.ts +4 -3
- package/src/parser/inline/extension/label.ts +3 -2
- package/src/parser/inline/extension/placeholder.ts +5 -4
- package/src/parser/inline/html.ts +5 -4
- package/src/parser/inline/htmlentity.ts +1 -1
- package/src/parser/inline/insertion.ts +5 -4
- package/src/parser/inline/link.ts +11 -20
- package/src/parser/inline/mark.ts +5 -4
- package/src/parser/inline/math.ts +1 -1
- package/src/parser/inline/media.ts +8 -7
- package/src/parser/inline/reference.ts +10 -16
- package/src/parser/inline/ruby.ts +4 -3
- package/src/parser/inline/shortmedia.ts +3 -2
- package/src/parser/inline/strong.ts +5 -4
- package/src/parser/inline/template.test.ts +1 -1
- package/src/parser/inline/template.ts +9 -6
- package/src/parser/locale.ts +6 -7
- package/src/parser/processor/footnote.ts +5 -3
- package/src/parser/source/text.ts +1 -1
- package/src/parser/util.ts +0 -220
- package/src/parser/visibility.ts +205 -0
- package/src/util/info.ts +4 -2
- package/src/util/quote.ts +12 -15
- package/src/util/toc.ts +14 -17
- package/webpack.config.js +1 -0
- package/src/combinator/control/manipulation/context.ts +0 -70
- package/src/combinator/control/manipulation/resource.ts +0 -54
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Parser } from '../../data/parser';
|
|
2
|
-
|
|
3
|
-
export function creator<P extends Parser<unknown>>(parser: P): P;
|
|
4
|
-
export function creator<P extends Parser<unknown>>(cost: number, parser: P): P;
|
|
5
|
-
export function creator(cost: number | Parser<unknown>, parser?: Parser<unknown>): Parser<unknown> {
|
|
6
|
-
if (typeof cost === 'function') return creator(1, cost);
|
|
7
|
-
assert(cost >= 0);
|
|
8
|
-
return (source, context) => {
|
|
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;
|
|
13
|
-
const result = parser!(source, context);
|
|
14
|
-
++resources.recursion;
|
|
15
|
-
if (result) {
|
|
16
|
-
resources.budget -= cost;
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function uncreator<P extends Parser<unknown>>(parser: P): P;
|
|
23
|
-
export function uncreator<P extends Parser<unknown>>(cost: number, parser: P): P;
|
|
24
|
-
export function uncreator(cost: number | Parser<unknown>, parser?: Parser<unknown>): Parser<unknown> {
|
|
25
|
-
if (typeof cost === 'function') return uncreator(1, cost);
|
|
26
|
-
assert(cost >= 0);
|
|
27
|
-
return (source, context) => {
|
|
28
|
-
const { resources = { budget: 1, recursion: 1 } } = context;
|
|
29
|
-
if (resources.budget <= 0) throw new Error('Too many creations');
|
|
30
|
-
if (resources.recursion <= 0) throw new Error('Too much recursion');
|
|
31
|
-
++resources.recursion;
|
|
32
|
-
const result = parser!(source, context);
|
|
33
|
-
--resources.recursion;
|
|
34
|
-
if (result) {
|
|
35
|
-
resources.budget += cost;
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function recursion<P extends Parser<unknown>>(parser: P): P;
|
|
42
|
-
export function recursion<P extends Parser<unknown>>(cost: number, parser: P): P;
|
|
43
|
-
export function recursion(cost: number | Parser<unknown>, parser?: Parser<unknown>): Parser<unknown> {
|
|
44
|
-
if (typeof cost === 'function') return recursion(1, cost);
|
|
45
|
-
assert(cost >= 0);
|
|
46
|
-
return (source, context) => {
|
|
47
|
-
const { resources = { recursion: 1 } } = context;
|
|
48
|
-
if (resources.recursion <= 0) throw new Error('Too much recursion');
|
|
49
|
-
--resources.recursion;
|
|
50
|
-
const result = parser!(source, context);
|
|
51
|
-
++resources.recursion;
|
|
52
|
-
return result;
|
|
53
|
-
};
|
|
54
|
-
}
|