securemark 0.299.2 → 0.299.4
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 +2102 -2185
- package/index.ts +2 -2
- package/package.json +1 -1
- package/src/{parser/api → api}/bind.test.ts +2 -2
- package/src/{parser/api → api}/bind.ts +5 -5
- package/src/{parser/api → api}/body.test.ts +1 -1
- package/src/{parser/api → api}/cache.ts +1 -1
- package/src/{parser/api → api}/header.test.ts +1 -1
- package/src/{parser/api → api}/header.ts +2 -2
- package/src/{parser/api → api}/normalize.test.ts +1 -1
- package/src/{parser/api → api}/parse.test.ts +3 -3
- package/src/{parser/api → api}/parse.ts +5 -5
- package/src/combinator/control/manipulation/fence.ts +2 -2
- package/src/combinator/control/manipulation/match.ts +2 -2
- package/src/combinator/data/delimiter.ts +3 -3
- package/src/combinator/data/{node.ts → list/list.ts} +4 -4
- package/src/combinator/data/parser/context.ts +12 -38
- package/src/combinator/data/parser/inits.ts +3 -3
- package/src/combinator/data/parser/sequence.ts +3 -3
- package/src/combinator/data/parser/some.ts +0 -1
- package/src/combinator/data/parser/subsequence.ts +3 -3
- package/src/combinator/data/parser/tails.ts +3 -3
- package/src/combinator/data/parser.ts +1 -1
- package/src/parser/block/blockquote.ts +3 -3
- package/src/parser/block/extension/aside.ts +1 -1
- package/src/parser/block/extension/example.ts +1 -1
- package/src/parser/block.ts +1 -1
- package/src/parser/context.ts +4 -5
- package/src/parser/inline/annotation.ts +1 -1
- package/src/parser/inline/deletion.ts +1 -1
- package/src/parser/inline/emstrong.ts +1 -1
- package/src/parser/inline/insertion.ts +1 -1
- package/src/parser/inline/italic.ts +1 -1
- package/src/parser/inline/link.ts +4 -4
- package/src/parser/inline/mark.ts +1 -1
- package/src/parser/inline/media.ts +3 -3
- package/src/parser/inline.ts +1 -1
- package/src/parser/node.ts +1 -1
- package/src/parser/repeat.ts +7 -19
- package/src/parser/source/escapable.ts +5 -5
- package/src/parser/source/text.ts +8 -9
- package/src/parser/source/unescapable.ts +6 -6
- package/src/parser/visibility.ts +1 -1
- package/src/{parser/processor → processor}/figure.test.ts +4 -4
- package/src/{parser/processor → processor}/figure.ts +2 -2
- package/src/{parser/processor → processor}/note.test.ts +3 -3
- package/src/{parser/processor → processor}/note.ts +2 -2
- package/src/renderer/render/media/pdf.ts +1 -1
- package/src/renderer/render/media/twitter.ts +1 -1
- package/src/renderer/render/media.test.ts +1 -2
- package/src/renderer/render.test.ts +1 -1
- package/src/util/info.test.ts +1 -1
- package/src/util/quote.test.ts +1 -1
- package/src/util/toc.test.ts +1 -1
- package/src/parser.ts +0 -1
- /package/src/{parser/api → api}/body.ts +0 -0
- /package/src/{parser/api → api}/normalize.ts +0 -0
- /package/src/{parser/api.ts → api.ts} +0 -0
package/src/parser/repeat.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Parser, Result, List, Node } from '../combinator/data/parser';
|
|
2
2
|
import { tester } from '../combinator/data/delimiter';
|
|
3
|
+
import { recur } from '../combinator';
|
|
3
4
|
import { Context, Recursion, Command } from './context';
|
|
4
5
|
import { min } from 'spica/alias';
|
|
5
6
|
|
|
6
7
|
export function repeat<P extends Parser<HTMLElement | string, Context>>(
|
|
7
|
-
opener: string, after: string | RegExp, closer: string,
|
|
8
|
+
opener: string, after: string | RegExp, closer: string, recursion: Recursion, parser: P,
|
|
8
9
|
cons: (nodes: List<Node<Parser.Node<P>>>, context: Parser.Context<P>, lead: number, follow: number) =>
|
|
9
10
|
List<Node<Parser.Node<P>>>,
|
|
10
11
|
termination?: (acc: List<Node<Parser.Node<P>>>, context: Context, prefix: number, postfix: number, state: boolean) =>
|
|
11
12
|
Result<string | Parser.Node<P>>,
|
|
12
13
|
): P;
|
|
13
14
|
export function repeat<N extends HTMLElement | string>(
|
|
14
|
-
opener: string, after: string | RegExp, closer: string,
|
|
15
|
+
opener: string, after: string | RegExp, closer: string, recursion: Recursion, parser: Parser<N>,
|
|
15
16
|
cons: (nodes: List<Node<N>>, context: Context, lead: number, follow: number) =>
|
|
16
17
|
List<Node<N>>,
|
|
17
18
|
termination: (acc: List<Node<N>>, context: Context, prefix: number, postfix: number, state: boolean) =>
|
|
@@ -35,7 +36,7 @@ export function repeat<N extends HTMLElement | string>(
|
|
|
35
36
|
const test = tester(after, false);
|
|
36
37
|
return input => {
|
|
37
38
|
const context = input;
|
|
38
|
-
const { source, position, resources: { recursions }
|
|
39
|
+
const { source, position, resources: { recursions } } = context;
|
|
39
40
|
if (!source.startsWith(opener, context.position)) return;
|
|
40
41
|
let nodes = new List<Node<N>>();
|
|
41
42
|
let i = opener.length;
|
|
@@ -46,20 +47,11 @@ export function repeat<N extends HTMLElement | string>(
|
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
49
|
let depth = i / opener.length + 1 | 0;
|
|
49
|
-
|
|
50
|
-
const rec = min(recursion, recursions.length - 1);
|
|
51
|
-
if (rec === -1) continue;
|
|
52
|
-
if (recursions[rec] < depth - 1) throw new Error('Too much recursion');
|
|
53
|
-
recursions[rec] -= depth;
|
|
54
|
-
}
|
|
50
|
+
recur(recursions, recursion, depth, true);
|
|
55
51
|
let state = false;
|
|
56
52
|
let follow = 0;
|
|
57
53
|
for (; i >= opener.length; i -= opener.length, follow -= closer.length) {
|
|
58
|
-
|
|
59
|
-
const rec = min(recursion, recursions.length - 1);
|
|
60
|
-
if (rec === -1) continue;
|
|
61
|
-
recursions[rec] += 1;
|
|
62
|
-
}
|
|
54
|
+
recur(recursions, recursion, -1);
|
|
63
55
|
depth -= 1;
|
|
64
56
|
const lead = i - opener.length;
|
|
65
57
|
if (source.startsWith(closer, context.position)) {
|
|
@@ -109,11 +101,7 @@ export function repeat<N extends HTMLElement | string>(
|
|
|
109
101
|
}
|
|
110
102
|
break;
|
|
111
103
|
}
|
|
112
|
-
|
|
113
|
-
const rec = min(recursion, recursions.length - 1);
|
|
114
|
-
if (rec === -1) continue;
|
|
115
|
-
recursions[rec] += depth;
|
|
116
|
-
}
|
|
104
|
+
recur(recursions, recursion, -depth);
|
|
117
105
|
depth = 0;
|
|
118
106
|
const prefix = i;
|
|
119
107
|
i = 0;
|
|
@@ -2,18 +2,18 @@ import { EscapableSourceParser } from '../source';
|
|
|
2
2
|
import { Command } from '../context';
|
|
3
3
|
import { Flag } from '../node';
|
|
4
4
|
import { List, Node } from '../../combinator/data/parser';
|
|
5
|
-
import {
|
|
5
|
+
import { spend } from '../../combinator';
|
|
6
6
|
import { html } from 'typed-dom/dom';
|
|
7
7
|
|
|
8
8
|
export const escsource: EscapableSourceParser = context => {
|
|
9
9
|
const { source, position } = context;
|
|
10
10
|
if (position === source.length) return;
|
|
11
11
|
const char = source[position];
|
|
12
|
-
|
|
12
|
+
spend(context, 1);
|
|
13
13
|
context.position += 1;
|
|
14
14
|
switch (char) {
|
|
15
15
|
case Command.Escape:
|
|
16
|
-
|
|
16
|
+
spend(context, 1);
|
|
17
17
|
context.position += 1;
|
|
18
18
|
return new List([new Node(source.slice(position + 1, position + 2))]);
|
|
19
19
|
case '\\':
|
|
@@ -23,7 +23,7 @@ export const escsource: EscapableSourceParser = context => {
|
|
|
23
23
|
case '\n':
|
|
24
24
|
return new List([new Node(char)]);
|
|
25
25
|
default:
|
|
26
|
-
|
|
26
|
+
spend(context, 1);
|
|
27
27
|
context.position += 1;
|
|
28
28
|
return new List([new Node(source.slice(position, position + 2))]);
|
|
29
29
|
}
|
|
@@ -38,7 +38,7 @@ export const escsource: EscapableSourceParser = context => {
|
|
|
38
38
|
let i = seek(source, position);
|
|
39
39
|
assert(i > position);
|
|
40
40
|
i -= position;
|
|
41
|
-
|
|
41
|
+
spend(context, i - 1);
|
|
42
42
|
context.position += i - 1;
|
|
43
43
|
return new List([new Node(source.slice(position, context.position))]);
|
|
44
44
|
}
|
|
@@ -2,7 +2,7 @@ import { TextParser, TxtParser } from '../source';
|
|
|
2
2
|
import { State, Command } from '../context';
|
|
3
3
|
import { Flag } from '../node';
|
|
4
4
|
import { List, Node } from '../../combinator/data/parser';
|
|
5
|
-
import { union,
|
|
5
|
+
import { union, spend } from '../../combinator';
|
|
6
6
|
import { html } from 'typed-dom/dom';
|
|
7
7
|
|
|
8
8
|
export const nonWhitespace = /[^ \t ]/g;
|
|
@@ -12,7 +12,7 @@ export const text: TextParser = input => {
|
|
|
12
12
|
const { source, position, state } = context;
|
|
13
13
|
if (position === source.length) return;
|
|
14
14
|
const char = source[position];
|
|
15
|
-
|
|
15
|
+
spend(context, 1);
|
|
16
16
|
context.position += 1;
|
|
17
17
|
switch (char) {
|
|
18
18
|
case Command.Escape:
|
|
@@ -25,7 +25,7 @@ export const text: TextParser = input => {
|
|
|
25
25
|
assert(char !== Command.Escape);
|
|
26
26
|
return new List();
|
|
27
27
|
default:
|
|
28
|
-
|
|
28
|
+
spend(context, 1);
|
|
29
29
|
context.position += 1;
|
|
30
30
|
return new List([new Node(source.slice(position + 1, context.position))]);
|
|
31
31
|
}
|
|
@@ -51,7 +51,7 @@ export const text: TextParser = input => {
|
|
|
51
51
|
|| s && source[i] === '\n';
|
|
52
52
|
i -= position;
|
|
53
53
|
i = lineend ? i : i - +s || 1;
|
|
54
|
-
|
|
54
|
+
spend(context, i - 1);
|
|
55
55
|
context.position += i - 1;
|
|
56
56
|
const linestart = position === 0 || source[position - 1] === '\n';
|
|
57
57
|
if (position === context.position || s && !linestart || lineend) return new List();
|
|
@@ -86,7 +86,7 @@ function isWhitespace(char: string, linebreak: boolean): boolean {
|
|
|
86
86
|
function next(source: string, position: number, state: number): number {
|
|
87
87
|
let index= seek(source, position, state);
|
|
88
88
|
assert(index > position);
|
|
89
|
-
if (index === source.length) return
|
|
89
|
+
if (index === source.length) return index;
|
|
90
90
|
const char = source[index];
|
|
91
91
|
switch (char) {
|
|
92
92
|
case '%':
|
|
@@ -163,10 +163,9 @@ export function backToEmailHead(source: string, position: number, index: number)
|
|
|
163
163
|
}
|
|
164
164
|
export function isAlphanumeric(char: string): boolean {
|
|
165
165
|
assert(char.length === 1);
|
|
166
|
-
if (char < '0' || '
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|| 'a' <= char && char <= 'z';
|
|
166
|
+
if (char < '0' || 'z' < char) return false;
|
|
167
|
+
if (char <= '9' || 'a' <= char) return true;
|
|
168
|
+
return 'A' <= char && char <= 'Z';
|
|
170
169
|
}
|
|
171
170
|
|
|
172
171
|
function seek(source: string, position: number, state: number): number {
|
|
@@ -2,7 +2,7 @@ import { UnescapableSourceParser } from '../source';
|
|
|
2
2
|
import { State, Command } from '../context';
|
|
3
3
|
import { Flag } from '../node';
|
|
4
4
|
import { List, Node } from '../../combinator/data/parser';
|
|
5
|
-
import {
|
|
5
|
+
import { spend } from '../../combinator';
|
|
6
6
|
import { nonWhitespace, canSkip, backToUrlHead, backToEmailHead } from './text';
|
|
7
7
|
import { html } from 'typed-dom/dom';
|
|
8
8
|
|
|
@@ -10,11 +10,11 @@ export const unescsource: UnescapableSourceParser = context => {
|
|
|
10
10
|
const { source, position, state } = context;
|
|
11
11
|
if (position === source.length) return;
|
|
12
12
|
const char = source[position];
|
|
13
|
-
|
|
13
|
+
spend(context, 1);
|
|
14
14
|
context.position += 1;
|
|
15
15
|
switch (char) {
|
|
16
16
|
case Command.Escape:
|
|
17
|
-
|
|
17
|
+
spend(context, 1);
|
|
18
18
|
context.position += 1;
|
|
19
19
|
return new List([new Node(source.slice(position + 1, position + 2))]);
|
|
20
20
|
case '\r':
|
|
@@ -33,7 +33,7 @@ export const unescsource: UnescapableSourceParser = context => {
|
|
|
33
33
|
: next(source, position, state);
|
|
34
34
|
assert(i > position);
|
|
35
35
|
i -= position;
|
|
36
|
-
|
|
36
|
+
spend(context, i - 1);
|
|
37
37
|
context.position += i - 1;
|
|
38
38
|
return new List([new Node(source.slice(position, context.position))]);
|
|
39
39
|
}
|
|
@@ -42,7 +42,7 @@ export const unescsource: UnescapableSourceParser = context => {
|
|
|
42
42
|
function next(source: string, position: number, state: number): number {
|
|
43
43
|
let index= seek(source, position, state);
|
|
44
44
|
assert(index > position);
|
|
45
|
-
if (index === source.length) return
|
|
45
|
+
if (index === source.length) return index;
|
|
46
46
|
const char = source[index];
|
|
47
47
|
switch (char) {
|
|
48
48
|
case ':':
|
|
@@ -119,5 +119,5 @@ function seek(source: string, position: number, state: number): number {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
function category(char: string): boolean {
|
|
122
|
-
return '\
|
|
122
|
+
return char <= '\x7E' && '\x21' <= char;
|
|
123
123
|
}
|
package/src/parser/visibility.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Parser, List, Node } from '../combinator/data/parser';
|
|
|
2
2
|
import { Command } from './context';
|
|
3
3
|
import { Flag } from './node';
|
|
4
4
|
import { convert, fmap } from '../combinator';
|
|
5
|
-
import { invisibleBlankHTMLEntityNames } from '
|
|
5
|
+
import { invisibleBlankHTMLEntityNames } from '../api/normalize';
|
|
6
6
|
|
|
7
7
|
namespace blank {
|
|
8
8
|
export const line = new RegExp(
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { figure } from './figure';
|
|
2
|
-
import { ParserOptions } from '
|
|
3
|
-
import { parse as parse_ } from '
|
|
2
|
+
import { ParserOptions } from '../..';
|
|
3
|
+
import { parse as parse_ } from '../api';
|
|
4
4
|
import { html } from 'typed-dom/dom';
|
|
5
|
-
import { normalize } from '
|
|
5
|
+
import { normalize } from '../debug.test';
|
|
6
6
|
|
|
7
7
|
const parse = (s: string, o?: ParserOptions) => parse_(s, { test: true, ...o });
|
|
8
8
|
|
|
9
|
-
describe('Unit:
|
|
9
|
+
describe('Unit: processor/figure', () => {
|
|
10
10
|
describe('figure', () => {
|
|
11
11
|
it('empty', () => {
|
|
12
12
|
const target = parse('');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { number as calculate, isFixed } from '../inline/extension/label';
|
|
2
|
-
import { markInvalid, unmarkInvalid } from '../util';
|
|
1
|
+
import { number as calculate, isFixed } from '../parser/inline/extension/label';
|
|
2
|
+
import { markInvalid, unmarkInvalid } from '../parser/util';
|
|
3
3
|
import { MultiQueue } from 'spica/queue';
|
|
4
4
|
import { push } from 'spica/array';
|
|
5
5
|
import { define } from 'typed-dom/dom';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { note } from './note';
|
|
2
|
-
import { parse as parse_ } from '
|
|
2
|
+
import { parse as parse_ } from '../api';
|
|
3
3
|
import { html } from 'typed-dom/dom';
|
|
4
|
-
import { normalize } from '
|
|
4
|
+
import { normalize } from '../debug.test';
|
|
5
5
|
|
|
6
6
|
const parse = (s: string) => parse_(s, { test: true });
|
|
7
7
|
|
|
8
|
-
describe('Unit:
|
|
8
|
+
describe('Unit: processor/note', () => {
|
|
9
9
|
describe('annotation', () => {
|
|
10
10
|
it('empty', () => {
|
|
11
11
|
const target = parse('');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { identity, signature, text } from '../inline/extension/indexee';
|
|
2
|
-
import { markInvalid, unmarkInvalid } from '../util';
|
|
1
|
+
import { identity, signature, text } from '../parser/inline/extension/indexee';
|
|
2
|
+
import { markInvalid, unmarkInvalid } from '../parser/util';
|
|
3
3
|
import { memoize } from 'spica/memoize';
|
|
4
4
|
import { html, define } from 'typed-dom/dom';
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { render as render_ } from './render';
|
|
2
2
|
import { RenderingOptions } from '../../';
|
|
3
|
-
import { parse } from '../
|
|
3
|
+
import { parse } from '../api/parse';
|
|
4
4
|
|
|
5
5
|
function render(target: HTMLElement, opts: RenderingOptions = {}): HTMLElement {
|
|
6
6
|
render_(target, opts);
|
package/src/util/info.test.ts
CHANGED
package/src/util/quote.test.ts
CHANGED
package/src/util/toc.test.ts
CHANGED
package/src/parser.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './parser/api';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|