securemark 0.281.4 → 0.283.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 +9 -0
- package/design.md +5 -9
- package/dist/index.js +7354 -7166
- package/package.json +2 -2
- package/src/combinator/control/manipulation/convert.ts +4 -8
- package/src/combinator/control/manipulation/indent.ts +3 -5
- package/src/combinator/control/manipulation/scope.ts +6 -3
- package/src/combinator/control/manipulation/surround.ts +17 -2
- package/src/combinator/data/parser/context.test.ts +6 -6
- package/src/combinator/data/parser/context.ts +25 -39
- package/src/combinator/data/parser.ts +2 -3
- package/src/parser/api/bind.ts +6 -6
- package/src/parser/api/parse.test.ts +17 -16
- package/src/parser/api/parse.ts +0 -3
- package/src/parser/block/blockquote.ts +4 -3
- package/src/parser/block/dlist.test.ts +1 -1
- package/src/parser/block/dlist.ts +6 -6
- package/src/parser/block/extension/aside.ts +4 -3
- package/src/parser/block/extension/example.ts +4 -3
- package/src/parser/block/extension/table.ts +7 -7
- package/src/parser/block/heading.ts +3 -2
- package/src/parser/block/ilist.ts +2 -1
- package/src/parser/block/olist.ts +4 -3
- package/src/parser/block/reply/cite.ts +3 -3
- package/src/parser/block/reply/quote.ts +3 -3
- package/src/parser/block/sidefence.ts +2 -1
- package/src/parser/block/table.ts +9 -9
- package/src/parser/block/ulist.ts +6 -5
- package/src/parser/block.ts +16 -5
- package/src/parser/context.ts +9 -21
- package/src/parser/inline/annotation.ts +5 -4
- package/src/parser/inline/autolink/email.ts +2 -1
- package/src/parser/inline/autolink/url.ts +6 -5
- package/src/parser/inline/autolink.ts +2 -2
- package/src/parser/inline/bracket.ts +17 -17
- package/src/parser/inline/code.test.ts +1 -1
- package/src/parser/inline/code.ts +2 -1
- package/src/parser/inline/deletion.ts +3 -3
- package/src/parser/inline/emphasis.ts +3 -3
- package/src/parser/inline/emstrong.ts +3 -3
- package/src/parser/inline/extension/index.test.ts +4 -4
- package/src/parser/inline/extension/index.ts +18 -6
- package/src/parser/inline/extension/indexee.ts +37 -7
- package/src/parser/inline/extension/indexer.test.ts +2 -2
- package/src/parser/inline/extension/indexer.ts +2 -1
- package/src/parser/inline/extension/label.ts +2 -2
- package/src/parser/inline/extension/placeholder.ts +4 -4
- package/src/parser/inline/html.ts +2 -2
- package/src/parser/inline/htmlentity.ts +2 -1
- package/src/parser/inline/insertion.ts +3 -3
- package/src/parser/inline/link.test.ts +2 -2
- package/src/parser/inline/link.ts +7 -7
- package/src/parser/inline/mark.test.ts +2 -2
- package/src/parser/inline/mark.ts +3 -3
- package/src/parser/inline/math.test.ts +3 -3
- package/src/parser/inline/math.ts +6 -5
- package/src/parser/inline/media.test.ts +1 -1
- package/src/parser/inline/media.ts +5 -5
- package/src/parser/inline/reference.ts +6 -5
- package/src/parser/inline/remark.ts +2 -2
- package/src/parser/inline/ruby.ts +3 -3
- package/src/parser/inline/strong.ts +3 -3
- package/src/parser/inline/template.ts +4 -4
- package/src/parser/inline.ts +1 -0
- package/src/parser/source/escapable.ts +2 -1
- package/src/parser/source/str.ts +3 -2
- package/src/parser/source/text.ts +2 -1
- package/src/parser/source/unescapable.ts +2 -1
- package/src/combinator/data/parser/context/memo.ts +0 -57
|
@@ -6,13 +6,19 @@ import { define } from 'typed-dom/dom';
|
|
|
6
6
|
|
|
7
7
|
export function indexee<P extends Parser<unknown, MarkdownParser.Context>>(parser: P): P;
|
|
8
8
|
export function indexee(parser: Parser<HTMLElement, MarkdownParser.Context>): Parser<HTMLElement> {
|
|
9
|
-
return fmap(parser, ([el], _, { id }) => [define(el, { id: identity('index', id, el) })]);
|
|
9
|
+
return fmap(parser, ([el], _, { id }) => [define(el, { id: identity('index', id, el), 'data-index': null })]);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const MAX = 60;
|
|
13
13
|
const ELLIPSIS = '...';
|
|
14
14
|
const PART = (MAX - ELLIPSIS.length) / 2 | 0;
|
|
15
15
|
const REM = MAX - PART * 2 - ELLIPSIS.length;
|
|
16
|
+
const table = [
|
|
17
|
+
...[...Array(36)].map((_, i) => i.toString(36)),
|
|
18
|
+
...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26),
|
|
19
|
+
'-', '=',
|
|
20
|
+
].join('');
|
|
21
|
+
assert(table.length === 64);
|
|
16
22
|
export function identity(
|
|
17
23
|
type: 'index' | 'mark' | '',
|
|
18
24
|
id: string | undefined,
|
|
@@ -21,7 +27,7 @@ export function identity(
|
|
|
21
27
|
assert(id?.match(/^[0-9a-z/-]*$/i) ?? true);
|
|
22
28
|
if (id === '') return undefined;
|
|
23
29
|
if (typeof text !== 'string') {
|
|
24
|
-
const index = text.
|
|
30
|
+
const index = text.getAttribute('data-index') ?? undefined;
|
|
25
31
|
if (index === '' && text.tagName === 'LI') return undefined;
|
|
26
32
|
return index
|
|
27
33
|
? `${type}:${id ?? ''}:${index}`
|
|
@@ -32,7 +38,7 @@ export function identity(
|
|
|
32
38
|
const str = text.replace(/\s/g, '_');
|
|
33
39
|
const cs = [...str];
|
|
34
40
|
if (type === '' || cs.length <= MAX) {
|
|
35
|
-
return `${type}:${id ?? ''}:${str}${/_|[^\S ]|=[0-
|
|
41
|
+
return `${type}:${id ?? ''}:${str}${/_|[^\S ]|=[0-9A-Za-z]{1,6}$/.test(text) ? `=${hash(text)}` : ''}`;
|
|
36
42
|
}
|
|
37
43
|
const s1 = cs.slice(0, PART + REM).join('');
|
|
38
44
|
const s2 = cs.slice(-PART).join('');
|
|
@@ -42,6 +48,9 @@ export function identity(
|
|
|
42
48
|
assert.deepStrictEqual(
|
|
43
49
|
identity('index', undefined, ' 0 '),
|
|
44
50
|
identity('index', undefined, ' 0 '.trim()));
|
|
51
|
+
assert.notDeepStrictEqual(
|
|
52
|
+
identity('index', undefined, '0 0'),
|
|
53
|
+
identity('index', undefined, '0 0'));
|
|
45
54
|
assert.notDeepStrictEqual(
|
|
46
55
|
identity('index', undefined, '0 0'),
|
|
47
56
|
identity('index', undefined, '0_0'));
|
|
@@ -56,23 +65,44 @@ assert.deepStrictEqual(
|
|
|
56
65
|
`${'0'.repeat(MAX - 1)}1`);
|
|
57
66
|
assert.deepStrictEqual(
|
|
58
67
|
identity('index', undefined, `0${'1'.repeat(MAX / 2)}${'2'.repeat(MAX / 2)}3`)!.slice(7),
|
|
59
|
-
`0${'1'.repeat(PART + REM - 1)}${ELLIPSIS}${'2'.repeat(PART - 1)}3=
|
|
68
|
+
`0${'1'.repeat(PART + REM - 1)}${ELLIPSIS}${'2'.repeat(PART - 1)}3=MYkmc`);
|
|
60
69
|
assert.deepStrictEqual(
|
|
61
70
|
identity('index', undefined, `0${'1'.repeat(MAX * 2)}${'2'.repeat(MAX * 2)}3`)!.slice(7),
|
|
62
|
-
`0${'1'.repeat(PART + REM - 1)}${ELLIPSIS}${'2'.repeat(PART - 1)}3=
|
|
71
|
+
`0${'1'.repeat(PART + REM - 1)}${ELLIPSIS}${'2'.repeat(PART - 1)}3=3bF8VU`);
|
|
63
72
|
function hash(source: string): string {
|
|
64
73
|
let x = 0;
|
|
65
74
|
for (let i = 0; i < source.length; ++i) {
|
|
66
|
-
|
|
75
|
+
const c = source.charCodeAt(i);
|
|
76
|
+
x = x ^ c << 1 || ~x ^ c << 1; // 16+1bit
|
|
77
|
+
assert(x !== 0);
|
|
67
78
|
x ^= x << 13; // shift <= 32-17bit
|
|
68
79
|
x ^= x >>> 17;
|
|
69
80
|
x ^= x << 15;
|
|
70
81
|
}
|
|
71
|
-
return (x >>> 0)
|
|
82
|
+
return baseR(x >>> 0, 62);
|
|
72
83
|
}
|
|
73
84
|
assert(hash('\x00') !== '0');
|
|
74
85
|
assert(hash('\x01') !== '0');
|
|
75
86
|
assert(hash('\x00') !== hash(String.fromCharCode(1 << 15)));
|
|
87
|
+
// 62も64も最大6桁
|
|
88
|
+
function baseR(n: number, r: number): string {
|
|
89
|
+
assert(n >= 0);
|
|
90
|
+
assert(Math.floor(n) === n);
|
|
91
|
+
assert(r <= 64);
|
|
92
|
+
let acc = '';
|
|
93
|
+
do {
|
|
94
|
+
const mod = n % r;
|
|
95
|
+
n = (n - mod) / r;
|
|
96
|
+
assert(Math.floor(n) === n);
|
|
97
|
+
acc = table[mod] + acc;
|
|
98
|
+
} while (n > 0)
|
|
99
|
+
assert(acc !== '');
|
|
100
|
+
return acc;
|
|
101
|
+
}
|
|
102
|
+
assert(baseR(0, 36) === (0).toString(36));
|
|
103
|
+
assert(baseR(~0 >>> 0, 36) === (~0 >>> 0).toString(36));
|
|
104
|
+
assert(baseR(61, 62) === 'Z');
|
|
105
|
+
assert(baseR(62, 62) === '10');
|
|
76
106
|
|
|
77
107
|
export function signature(source: Element | DocumentFragment): string {
|
|
78
108
|
assert(!navigator.userAgent.includes('Chrome') || !source.querySelector('br:not(:has(+ :is(ul, ol)))'));
|
|
@@ -25,8 +25,8 @@ describe('Unit: parser/inline/extension/indexer', () => {
|
|
|
25
25
|
assert.deepStrictEqual(inspect(parser(' [|a ]')), [['<span class="indexer" data-index="a"></span>'], '']);
|
|
26
26
|
assert.deepStrictEqual(inspect(parser(' [|a b]')), [['<span class="indexer" data-index="a_b"></span>'], '']);
|
|
27
27
|
assert.deepStrictEqual(inspect(parser(' [|a b]')), [['<span class="indexer" data-index="a__b"></span>'], '']);
|
|
28
|
-
assert.deepStrictEqual(inspect(parser(' [|a\tb]')), [['<span class="indexer" data-index="a_b=
|
|
29
|
-
assert.deepStrictEqual(inspect(parser(' [|a_b]')), [['<span class="indexer" data-index="a_b=
|
|
28
|
+
assert.deepStrictEqual(inspect(parser(' [|a\tb]')), [['<span class="indexer" data-index="a_b=33Mw2l"></span>'], '']);
|
|
29
|
+
assert.deepStrictEqual(inspect(parser(' [|a_b]')), [['<span class="indexer" data-index="a_b=2H8oCG"></span>'], '']);
|
|
30
30
|
assert.deepStrictEqual(inspect(parser(' [|A]')), [['<span class="indexer" data-index="A"></span>'], '']);
|
|
31
31
|
assert.deepStrictEqual(inspect(parser(' [|*A*]')), [['<span class="indexer" data-index="*A*"></span>'], '']);
|
|
32
32
|
assert.deepStrictEqual(inspect(parser(' [|`A`]')), [['<span class="indexer" data-index="`A`"></span>'], '']);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ExtensionParser } from '../../inline';
|
|
2
2
|
import { union, creation, focus, surround } from '../../../combinator';
|
|
3
3
|
import { signature } from './index';
|
|
4
|
+
import { Recursion } from '../../context';
|
|
4
5
|
import { html } from 'typed-dom/dom';
|
|
5
6
|
|
|
6
7
|
export const indexer: ExtensionParser.IndexerParser = surround(
|
|
7
8
|
/^\s+\[(?=\|\S)/,
|
|
8
9
|
union([
|
|
9
10
|
signature,
|
|
10
|
-
creation(focus(/^\|(?=\])/, () => [[html('span', { class: 'indexer', 'data-index': '' })], ''])),
|
|
11
|
+
creation(1, Recursion.ignore, focus(/^\|(?=\])/, () => [[html('span', { class: 'indexer', 'data-index': '' })], ''])),
|
|
11
12
|
]),
|
|
12
13
|
/^\]\s*$/);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExtensionParser } from '../../inline';
|
|
2
2
|
import { union, constraint, creation, validate, surround, clear, fmap } from '../../../combinator';
|
|
3
3
|
import { str } from '../../source';
|
|
4
|
-
import { State } from '../../context';
|
|
4
|
+
import { State, Recursion } from '../../context';
|
|
5
5
|
import { html } from 'typed-dom/dom';
|
|
6
6
|
|
|
7
7
|
const body = str(/^\$[A-Za-z]*(?:(?:-[A-Za-z][0-9A-Za-z]*)+|-(?:(?:0|[1-9][0-9]*)\.)*(?:0|[1-9][0-9]*)(?![0-9A-Za-z]))/);
|
|
@@ -11,7 +11,7 @@ export const segment: ExtensionParser.LabelParser.SegmentParser = clear(validate
|
|
|
11
11
|
body,
|
|
12
12
|
])));
|
|
13
13
|
|
|
14
|
-
export const label: ExtensionParser.LabelParser = validate(['[$', '$'], creation(fmap(
|
|
14
|
+
export const label: ExtensionParser.LabelParser = validate(['[$', '$'], creation(1, Recursion.ignore, fmap(
|
|
15
15
|
constraint(State.label, false,
|
|
16
16
|
union([
|
|
17
17
|
surround('[', body, ']'),
|
|
@@ -2,7 +2,7 @@ import { ExtensionParser } from '../../inline';
|
|
|
2
2
|
import { union, some, syntax, creation, validate, surround, lazy } from '../../../combinator';
|
|
3
3
|
import { inline } from '../../inline';
|
|
4
4
|
import { str } from '../../source';
|
|
5
|
-
import {
|
|
5
|
+
import { State, Recursion } from '../../context';
|
|
6
6
|
import { startTight } from '../../visibility';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
import { html, defrag } from 'typed-dom/dom';
|
|
@@ -11,9 +11,9 @@ import { html, defrag } from 'typed-dom/dom';
|
|
|
11
11
|
|
|
12
12
|
// All syntax surrounded by square brackets shouldn't contain line breaks.
|
|
13
13
|
|
|
14
|
-
export const placeholder: ExtensionParser.PlaceholderParser = lazy(() => validate('[', creation(surround(
|
|
14
|
+
export const placeholder: ExtensionParser.PlaceholderParser = lazy(() => validate('[', creation(1, Recursion.inline, surround(
|
|
15
15
|
str(/^\[[:^|]/),
|
|
16
|
-
syntax(
|
|
16
|
+
syntax(2, State.none,
|
|
17
17
|
startTight(some(union([inline]), ']', [[']', 2]]))),
|
|
18
18
|
str(']'), false,
|
|
19
19
|
([, bs], rest) => [[
|
|
@@ -24,4 +24,4 @@ export const placeholder: ExtensionParser.PlaceholderParser = lazy(() => validat
|
|
|
24
24
|
'data-invalid-message': `Invalid start symbol or linebreak`,
|
|
25
25
|
}, defrag(bs)),
|
|
26
26
|
], rest],
|
|
27
|
-
([as, bs], rest) => [unshift(as, bs), rest]))));
|
|
27
|
+
([as, bs], rest) => [unshift(as, bs), rest], 3))));
|
|
@@ -2,7 +2,7 @@ import { HTMLParser } from '../inline';
|
|
|
2
2
|
import { union, subsequence, some, syntax, creation, validate, focus, surround, open, match, lazy } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
|
-
import {
|
|
5
|
+
import { State, Recursion } from '../context';
|
|
6
6
|
import { isStartLooseNodes, blankWith } from '../visibility';
|
|
7
7
|
import { memoize } from 'spica/memoize';
|
|
8
8
|
import { Clock } from 'spica/clock';
|
|
@@ -18,7 +18,7 @@ const attrspecs = {
|
|
|
18
18
|
Object.setPrototypeOf(attrspecs, null);
|
|
19
19
|
Object.values(attrspecs).forEach(o => Object.setPrototypeOf(o, null));
|
|
20
20
|
|
|
21
|
-
export const html: HTMLParser = lazy(() => validate('<', validate(/^<[a-z]+(?=[^\S\n]|>)/i, creation(
|
|
21
|
+
export const html: HTMLParser = lazy(() => validate('<', validate(/^<[a-z]+(?=[^\S\n]|>)/i, creation(1, Recursion.inline, syntax(4, State.none, union([
|
|
22
22
|
focus(
|
|
23
23
|
/^<wbr[^\S\n]*>/i,
|
|
24
24
|
() => [[h('wbr')], '']),
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { HTMLEntityParser, UnsafeHTMLEntityParser } from '../inline';
|
|
2
2
|
import { union, creation, validate, focus, fmap } from '../../combinator';
|
|
3
|
+
import { Recursion } from '../context';
|
|
3
4
|
import { html } from 'typed-dom/dom';
|
|
4
5
|
import { reduce } from 'spica/memoize';
|
|
5
6
|
|
|
6
|
-
export const unsafehtmlentity: UnsafeHTMLEntityParser = creation(validate('&', focus(
|
|
7
|
+
export const unsafehtmlentity: UnsafeHTMLEntityParser = creation(1, Recursion.ignore, validate('&', focus(
|
|
7
8
|
/^&[0-9A-Za-z]+;/,
|
|
8
9
|
({ source }) => [[parse(source) ?? `\x1B${source}`], ''])));
|
|
9
10
|
|
|
@@ -2,14 +2,14 @@ import { InsertionParser } from '../inline';
|
|
|
2
2
|
import { union, some, syntax, creation, surround, open, lazy } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
|
-
import {
|
|
5
|
+
import { State, Recursion } from '../context';
|
|
6
6
|
import { blankWith } from '../visibility';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
import { html, defrag } from 'typed-dom/dom';
|
|
9
9
|
|
|
10
|
-
export const insertion: InsertionParser = lazy(() => creation(surround(
|
|
10
|
+
export const insertion: InsertionParser = lazy(() => creation(1, Recursion.inline, surround(
|
|
11
11
|
str('++', '+'),
|
|
12
|
-
syntax(
|
|
12
|
+
syntax(1, State.none,
|
|
13
13
|
some(union([
|
|
14
14
|
some(inline, blankWith('\n', '++')),
|
|
15
15
|
open('\n', some(inline, '+'), true),
|
|
@@ -13,10 +13,10 @@ describe('Unit: parser/inline/link', () => {
|
|
|
13
13
|
assert.deepStrictEqual(inspect(parser('[]{data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K}')), [['<a class="invalid">data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K</a>'], '']);
|
|
14
14
|
assert.deepStrictEqual(inspect(parser('[]{any:alert}')), [['<a class="invalid">any:alert</a>'], '']);
|
|
15
15
|
assert.deepStrictEqual(inspect(parser('[]{"}')), [['<a class="url" href=""">"</a>'], '']);
|
|
16
|
-
assert.deepStrictEqual(inspect(parser('[]{<}')), [['<a class="url" href="
|
|
16
|
+
assert.deepStrictEqual(inspect(parser('[]{<}')), [['<a class="url" href="<"><</a>'], '']);
|
|
17
17
|
assert.deepStrictEqual(inspect(parser('[]{\\}')), [['<a class="url" href="\\">\\</a>'], '']);
|
|
18
18
|
assert.deepStrictEqual(inspect(parser('[]{\\"}')), [['<a class="url" href="\\"">\\"</a>'], '']);
|
|
19
|
-
assert.deepStrictEqual(inspect(parser('[]{\\<}')), [['<a class="url" href="
|
|
19
|
+
assert.deepStrictEqual(inspect(parser('[]{\\<}')), [['<a class="url" href="\\<">\\<</a>'], '']);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('fishing', () => {
|
|
@@ -4,7 +4,7 @@ import { union, inits, tails, sequence, some, constraint, syntax, creation, prec
|
|
|
4
4
|
import { inline, media, shortmedia } from '../inline';
|
|
5
5
|
import { attributes } from './html';
|
|
6
6
|
import { linebreak, unescsource, str } from '../source';
|
|
7
|
-
import {
|
|
7
|
+
import { State, Recursion } from '../context';
|
|
8
8
|
import { trimBlankStart, trimNodeEnd } from '../visibility';
|
|
9
9
|
import { stringify } from '../util';
|
|
10
10
|
import { ReadonlyURL } from 'spica/url';
|
|
@@ -20,15 +20,15 @@ export const link: LinkParser = lazy(() => validate(['[', '{'], union([
|
|
|
20
20
|
textlink,
|
|
21
21
|
])));
|
|
22
22
|
|
|
23
|
-
export const textlink: LinkParser.TextLinkParser = lazy(() => creation(
|
|
23
|
+
export const textlink: LinkParser.TextLinkParser = lazy(() => creation(1, Recursion.ignore,
|
|
24
24
|
constraint(State.link, false,
|
|
25
|
-
syntax(
|
|
25
|
+
syntax(2, State.linkers | State.media,
|
|
26
26
|
bind(reverse(tails([
|
|
27
27
|
dup(surround(
|
|
28
28
|
'[',
|
|
29
29
|
trimBlankStart(some(union([inline]), ']', [[/^\\?\n/, 9], [']', 2]])),
|
|
30
30
|
']',
|
|
31
|
-
true)),
|
|
31
|
+
true, undefined, undefined, 1)),
|
|
32
32
|
dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
|
|
33
33
|
])),
|
|
34
34
|
([params, content = []]: [string[], (HTMLElement | string)[]], rest, context) => {
|
|
@@ -38,9 +38,9 @@ export const textlink: LinkParser.TextLinkParser = lazy(() => creation(10,
|
|
|
38
38
|
return [[parse(content, params, context)], rest];
|
|
39
39
|
})))));
|
|
40
40
|
|
|
41
|
-
export const medialink: LinkParser.MediaLinkParser = lazy(() => creation(
|
|
41
|
+
export const medialink: LinkParser.MediaLinkParser = lazy(() => creation(1, Recursion.ignore,
|
|
42
42
|
constraint(State.link | State.media, false,
|
|
43
|
-
syntax(
|
|
43
|
+
syntax(2, State.linkers,
|
|
44
44
|
bind(reverse(sequence([
|
|
45
45
|
dup(surround(
|
|
46
46
|
'[',
|
|
@@ -57,7 +57,7 @@ export const linemedialink: LinkParser.LineMediaLinkParser = surround(
|
|
|
57
57
|
/^(?=[^\S\n]*(?:$|\n))/);
|
|
58
58
|
|
|
59
59
|
export const unsafelink: LinkParser.UnsafeLinkParser = lazy(() =>
|
|
60
|
-
creation(
|
|
60
|
+
creation(1, Recursion.ignore, precedence(2,
|
|
61
61
|
bind(reverse(tails([
|
|
62
62
|
dup(surround(
|
|
63
63
|
'[',
|
|
@@ -30,7 +30,7 @@ describe('Unit: parser/inline/mark', () => {
|
|
|
30
30
|
|
|
31
31
|
it('basic', () => {
|
|
32
32
|
assert.deepStrictEqual(inspect(parser('==a==')), [['<mark id="mark::a">a</mark>', '<a href="#mark::a"></a>'], '']);
|
|
33
|
-
assert.deepStrictEqual(inspect(parser('==a=b==')), [['<mark id="mark::a=b=
|
|
33
|
+
assert.deepStrictEqual(inspect(parser('==a=b==')), [['<mark id="mark::a=b=3lYfIw">a=b</mark>', '<a href="#mark::a=b=3lYfIw"></a>'], '']);
|
|
34
34
|
assert.deepStrictEqual(inspect(parser('==\\===')), [['<mark id="mark::=">=</mark>', '<a href="#mark::="></a>'], '']);
|
|
35
35
|
assert.deepStrictEqual(inspect(parser('==a===')), [['<mark id="mark::a">a</mark>', '<a href="#mark::a"></a>'], '=']);
|
|
36
36
|
});
|
|
@@ -38,7 +38,7 @@ describe('Unit: parser/inline/mark', () => {
|
|
|
38
38
|
it('nest', () => {
|
|
39
39
|
assert.deepStrictEqual(inspect(parser('==a ==b====')), [['<mark id="mark::a_b">a <mark id="mark::b">b</mark><a href="#mark::b"></a></mark>', '<a href="#mark::a_b"></a>'], '']);
|
|
40
40
|
assert.deepStrictEqual(inspect(parser('==a\\ ==b====')), [['<mark id="mark::a_b">a <mark id="mark::b">b</mark><a href="#mark::b"></a></mark>', '<a href="#mark::a_b"></a>'], '']);
|
|
41
|
-
assert.deepStrictEqual(inspect(parser('==a	==b====')), [['<mark id="mark::a_b=
|
|
41
|
+
assert.deepStrictEqual(inspect(parser('==a	==b====')), [['<mark id="mark::a_b=33Mw2l">a\t<mark id="mark::b">b</mark><a href="#mark::b"></a></mark>', '<a href="#mark::a_b=33Mw2l"></a>'], '']);
|
|
42
42
|
assert.deepStrictEqual(inspect(parser('==a<wbr>==b====')), [['<mark id="mark::ab">a<wbr><mark id="mark::b">b</mark><a href="#mark::b"></a></mark>', '<a href="#mark::ab"></a>'], '']);
|
|
43
43
|
assert.deepStrictEqual(inspect(parser('==*==a==*==')), [['<mark id="mark::a"><em><mark id="mark::a">a</mark><a href="#mark::a"></a></em></mark>', '<a href="#mark::a"></a>'], '']);
|
|
44
44
|
});
|
|
@@ -4,14 +4,14 @@ import { inline } from '../inline';
|
|
|
4
4
|
import { identity, signature } from './extension/indexee';
|
|
5
5
|
import { str } from '../source';
|
|
6
6
|
import { startTight, blankWith } from '../visibility';
|
|
7
|
-
import {
|
|
7
|
+
import { State, Recursion } from '../context';
|
|
8
8
|
import { unshift } from 'spica/array';
|
|
9
9
|
import { html, define, defrag } from 'typed-dom/dom';
|
|
10
10
|
|
|
11
|
-
export const mark: MarkParser = lazy(() => creation(surround(
|
|
11
|
+
export const mark: MarkParser = lazy(() => creation(1, Recursion.inline, surround(
|
|
12
12
|
str('==', '='),
|
|
13
13
|
constraint(State.mark, false,
|
|
14
|
-
syntax(
|
|
14
|
+
syntax(1, State.none,
|
|
15
15
|
startTight(some(union([
|
|
16
16
|
some(inline, blankWith('=='), [[/^\\?\n/, 9]]),
|
|
17
17
|
open(some(inline, '=', [[/^\\?\n/, 9]]), mark),
|
|
@@ -115,8 +115,8 @@ describe('Unit: parser/inline/math', () => {
|
|
|
115
115
|
assert.deepStrictEqual(inspect(parser('$(0, 1]$)')), [['<span class="math" translate="no" data-src="$(0, 1]$">$(0, 1]$</span>'], ')']);
|
|
116
116
|
assert.deepStrictEqual(inspect(parser('$\\{0,1\\}$')), [['<span class="math" translate="no" data-src="$\\{0,1\\}$">$\\{0,1\\}$</span>'], '']);
|
|
117
117
|
assert.deepStrictEqual(inspect(parser('$n=1$')), [['<span class="math" translate="no" data-src="$n=1$">$n=1$</span>'], '']);
|
|
118
|
-
assert.deepStrictEqual(inspect(parser('$n<m$')), [['<span class="math" translate="no" data-src="$n
|
|
119
|
-
assert.deepStrictEqual(inspect(parser('$n>m$')), [['<span class="math" translate="no" data-src="$n
|
|
118
|
+
assert.deepStrictEqual(inspect(parser('$n<m$')), [['<span class="math" translate="no" data-src="$n<m$">$n<m$</span>'], '']);
|
|
119
|
+
assert.deepStrictEqual(inspect(parser('$n>m$')), [['<span class="math" translate="no" data-src="$n>m$">$n>m$</span>'], '']);
|
|
120
120
|
assert.deepStrictEqual(inspect(parser('$E = mc^2$')), [['<span class="math" translate="no" data-src="$E = mc^2$">$E = mc^2$</span>'], '']);
|
|
121
121
|
assert.deepStrictEqual(inspect(parser('$f(x)$')), [['<span class="math" translate="no" data-src="$f(x)$">$f(x)$</span>'], '']);
|
|
122
122
|
assert.deepStrictEqual(inspect(parser('$f: x \\to y$')), [['<span class="math" translate="no" data-src="$f: x \\to y$">$f: x \\to y$</span>'], '']);
|
|
@@ -143,7 +143,7 @@ describe('Unit: parser/inline/math', () => {
|
|
|
143
143
|
|
|
144
144
|
it('nest', () => {
|
|
145
145
|
assert.deepStrictEqual(inspect(parser('${*a*}$')), [['<span class="math" translate="no" data-src="${*a*}$">${*a*}$</span>'], '']);
|
|
146
|
-
assert.deepStrictEqual(inspect(parser('${<wbr>}$')), [['<span class="math" translate="no" data-src="${
|
|
146
|
+
assert.deepStrictEqual(inspect(parser('${<wbr>}$')), [['<span class="math" translate="no" data-src="${<wbr>}$">${<wbr>}$</span>'], '']);
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MathParser } from '../inline';
|
|
2
2
|
import { union, some, creation, precedence, validate, focus, rewrite, surround, lazy } from '../../combinator';
|
|
3
|
-
import { escsource, unescsource } from '../source';
|
|
3
|
+
import { escsource, unescsource, str } from '../source';
|
|
4
|
+
import { Recursion } from '../context';
|
|
4
5
|
import { html } from 'typed-dom/dom';
|
|
5
6
|
|
|
6
7
|
const forbiddenCommand = /\\(?:begin|tiny|huge|large)(?![a-z])/i;
|
|
7
8
|
|
|
8
|
-
export const math: MathParser = lazy(() => validate('$', creation(rewrite(
|
|
9
|
+
export const math: MathParser = lazy(() => validate('$', creation(1, Recursion.ignore, rewrite(
|
|
9
10
|
union([
|
|
10
11
|
surround('$', precedence(6, bracket), '$'),
|
|
11
12
|
surround(
|
|
@@ -31,11 +32,11 @@ export const math: MathParser = lazy(() => validate('$', creation(rewrite(
|
|
|
31
32
|
source)
|
|
32
33
|
], '']))));
|
|
33
34
|
|
|
34
|
-
const bracket: MathParser.BracketParser = lazy(() => creation(surround(
|
|
35
|
-
'{',
|
|
35
|
+
const bracket: MathParser.BracketParser = lazy(() => creation(0, Recursion.terminal, surround(
|
|
36
|
+
str('{'),
|
|
36
37
|
some(union([
|
|
37
38
|
bracket,
|
|
38
39
|
some(escsource, /^(?:[{}$]|\\?\n)/),
|
|
39
40
|
])),
|
|
40
|
-
'}',
|
|
41
|
+
str('}'),
|
|
41
42
|
true)));
|
|
@@ -91,7 +91,7 @@ describe('Unit: parser/inline/media', () => {
|
|
|
91
91
|
assert.deepStrictEqual(inspect(parser('![\\[]{/}')), [['<a href="/" target="_blank"><img class="media" data-src="/" alt="["></a>'], '']);
|
|
92
92
|
assert.deepStrictEqual(inspect(parser('![\\"]{"?"#"}')), [['<a href=""?"#"" target="_blank"><img class="media" data-src=""?"#"" alt="""></a>'], '']);
|
|
93
93
|
assert.deepStrictEqual(inspect(parser('![*a*]{/}')), [['<a href="/" target="_blank"><img class="media" data-src="/" alt="*a*"></a>'], '']);
|
|
94
|
-
assert.deepStrictEqual(inspect(parser('![<wbr>]{/}')), [['<a href="/" target="_blank"><img class="media" data-src="/" alt="
|
|
94
|
+
assert.deepStrictEqual(inspect(parser('![<wbr>]{/}')), [['<a href="/" target="_blank"><img class="media" data-src="/" alt="<wbr>"></a>'], '']);
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
it('external', () => {
|
|
@@ -4,7 +4,7 @@ import { unsafelink, uri, option as linkoption, resolve } from './link';
|
|
|
4
4
|
import { attributes } from './html';
|
|
5
5
|
import { unsafehtmlentity } from './htmlentity';
|
|
6
6
|
import { txt, linebreak, str } from '../source';
|
|
7
|
-
import {
|
|
7
|
+
import { State, Recursion } from '../context';
|
|
8
8
|
import { markInvalid } from '../util';
|
|
9
9
|
import { ReadonlyURL } from 'spica/url';
|
|
10
10
|
import { unshift, push } from 'spica/array';
|
|
@@ -18,10 +18,10 @@ const optspec = {
|
|
|
18
18
|
} as const;
|
|
19
19
|
Object.setPrototypeOf(optspec, null);
|
|
20
20
|
|
|
21
|
-
export const media: MediaParser = lazy(() => validate(['![', '!{'], creation(
|
|
21
|
+
export const media: MediaParser = lazy(() => validate(['![', '!{'], creation(1, Recursion.ignore, open(
|
|
22
22
|
'!',
|
|
23
23
|
constraint(State.media, false,
|
|
24
|
-
syntax(
|
|
24
|
+
syntax(2, ~State.link,
|
|
25
25
|
bind(verify(fmap(tails([
|
|
26
26
|
dup(surround(
|
|
27
27
|
'[',
|
|
@@ -55,7 +55,7 @@ export const media: MediaParser = lazy(() => validate(['![', '!{'], creation(10,
|
|
|
55
55
|
el.style.aspectRatio = el.getAttribute('aspect-ratio')!;
|
|
56
56
|
}
|
|
57
57
|
if (context.state! & State.link) return [[el], rest];
|
|
58
|
-
if (cache && cache.tagName !== 'IMG') return
|
|
58
|
+
if (cache && cache.tagName !== 'IMG') return [[el], rest];
|
|
59
59
|
return fmap(
|
|
60
60
|
unsafelink as MediaParser,
|
|
61
61
|
([link]) => [define(link, { class: null, target: '_blank' }, [el])])
|
|
@@ -67,7 +67,7 @@ export const linemedia: MediaParser.LineMediaParser = surround(
|
|
|
67
67
|
union([media]),
|
|
68
68
|
/^(?=[^\S\n]*(?:$|\n))/);
|
|
69
69
|
|
|
70
|
-
const bracket: MediaParser.TextParser.BracketParser = lazy(() => creation(union([
|
|
70
|
+
const bracket: MediaParser.TextParser.BracketParser = lazy(() => creation(0, Recursion.terminal, union([
|
|
71
71
|
surround(str('('), some(union([unsafehtmlentity, bracket, txt]), ')'), str(')'), true,
|
|
72
72
|
undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
73
73
|
surround(str('['), some(union([unsafehtmlentity, bracket, txt]), ']'), str(']'), true,
|
|
@@ -2,24 +2,25 @@ import { ReferenceParser } from '../inline';
|
|
|
2
2
|
import { union, subsequence, some, syntax, creation, constraint, surround, lazy } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
|
-
import {
|
|
5
|
+
import { State, Recursion } from '../context';
|
|
6
6
|
import { blank, trimBlankStart, trimNodeEnd } from '../visibility';
|
|
7
7
|
import { html, defrag } from 'typed-dom/dom';
|
|
8
8
|
|
|
9
|
-
export const reference: ReferenceParser = lazy(() => creation(surround(
|
|
9
|
+
export const reference: ReferenceParser = lazy(() => creation(1, Recursion.ignore, surround(
|
|
10
10
|
'[[',
|
|
11
11
|
constraint(State.reference, false,
|
|
12
|
-
syntax(
|
|
12
|
+
syntax(6, State.annotation | State.reference | State.media,
|
|
13
13
|
subsequence([
|
|
14
14
|
abbr,
|
|
15
15
|
trimBlankStart(some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])),
|
|
16
16
|
]))),
|
|
17
17
|
']]',
|
|
18
18
|
false,
|
|
19
|
-
([, ns], rest) => [[html('sup', attributes(ns), [html('span', trimNodeEnd(defrag(ns)))])], rest]
|
|
19
|
+
([, ns], rest) => [[html('sup', attributes(ns), [html('span', trimNodeEnd(defrag(ns)))])], rest],
|
|
20
|
+
undefined, 1)));
|
|
20
21
|
|
|
21
22
|
// Chicago-Style
|
|
22
|
-
const abbr: ReferenceParser.AbbrParser = creation(surround(
|
|
23
|
+
const abbr: ReferenceParser.AbbrParser = creation(1, Recursion.ignore, surround(
|
|
23
24
|
'^',
|
|
24
25
|
union([str(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]),
|
|
25
26
|
/^\|?(?=]])|^\|[^\S\n]*/,
|
|
@@ -2,12 +2,12 @@ import { RemarkParser } from '../inline';
|
|
|
2
2
|
import { union, some, syntax, creation, validate, surround, open, close, match, lazy } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { text, str } from '../source';
|
|
5
|
-
import {
|
|
5
|
+
import { State, Recursion } from '../context';
|
|
6
6
|
import { memoize } from 'spica/memoize';
|
|
7
7
|
import { unshift, push } from 'spica/array';
|
|
8
8
|
import { html, defrag } from 'typed-dom/dom';
|
|
9
9
|
|
|
10
|
-
export const remark: RemarkParser = lazy(() => validate('[%', creation(
|
|
10
|
+
export const remark: RemarkParser = lazy(() => validate('[%', creation(1, Recursion.inline, syntax(5, State.none, match(
|
|
11
11
|
/^\[(%+)\s/,
|
|
12
12
|
memoize(
|
|
13
13
|
([, fence]) =>
|
|
@@ -3,12 +3,12 @@ import { eval, exec } from '../../combinator/data/parser';
|
|
|
3
3
|
import { sequence, syntax, creation, validate, verify, surround, lazy, fmap } from '../../combinator';
|
|
4
4
|
import { unsafehtmlentity } from './htmlentity';
|
|
5
5
|
import { text as txt, str } from '../source';
|
|
6
|
-
import {
|
|
6
|
+
import { State, Recursion } from '../context';
|
|
7
7
|
import { isStartTightNodes } from '../visibility';
|
|
8
8
|
import { unshift, push } from 'spica/array';
|
|
9
9
|
import { html, defrag } from 'typed-dom/dom';
|
|
10
10
|
|
|
11
|
-
export const ruby: RubyParser = lazy(() => validate('[', creation(
|
|
11
|
+
export const ruby: RubyParser = lazy(() => validate('[', creation(1, Recursion.ignore, syntax(2, State.all, fmap(verify(fmap(
|
|
12
12
|
sequence([
|
|
13
13
|
surround('[', str(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ']'),
|
|
14
14
|
surround('(', str(/^(?:\\[^\n]|[^\\[\](){}"\n])+/), ')'),
|
|
@@ -51,7 +51,7 @@ export const ruby: RubyParser = lazy(() => validate('[', creation(syntax(Syntax.
|
|
|
51
51
|
}
|
|
52
52
|
})))));
|
|
53
53
|
|
|
54
|
-
const text: RubyParser.TextParser = creation(1,
|
|
54
|
+
const text: RubyParser.TextParser = creation(1, Recursion.ignore, ({ source, context }) => {
|
|
55
55
|
const acc = [''];
|
|
56
56
|
while (source !== '') {
|
|
57
57
|
assert(source[0] !== '\n');
|
|
@@ -3,14 +3,14 @@ import { union, some, syntax, creation, surround, open, lazy } from '../../combi
|
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { emstrong } from './emstrong';
|
|
5
5
|
import { str } from '../source';
|
|
6
|
-
import {
|
|
6
|
+
import { State, Recursion } from '../context';
|
|
7
7
|
import { startTight, blankWith } from '../visibility';
|
|
8
8
|
import { unshift } from 'spica/array';
|
|
9
9
|
import { html, defrag } from 'typed-dom/dom';
|
|
10
10
|
|
|
11
|
-
export const strong: StrongParser = lazy(() => creation(surround(
|
|
11
|
+
export const strong: StrongParser = lazy(() => creation(1, Recursion.inline, surround(
|
|
12
12
|
str('**', '*'),
|
|
13
|
-
syntax(
|
|
13
|
+
syntax(1, State.none,
|
|
14
14
|
startTight(some(union([
|
|
15
15
|
some(inline, blankWith('**'), [[/^\\?\n/, 9]]),
|
|
16
16
|
open(some(inline, '*', [[/^\\?\n/, 9]]), union([
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { TemplateParser } from '../inline';
|
|
2
2
|
import { union, some, syntax, creation, precedence, surround, lazy } from '../../combinator';
|
|
3
3
|
import { escsource, str } from '../source';
|
|
4
|
-
import {
|
|
4
|
+
import { State, Recursion } from '../context';
|
|
5
5
|
import { unshift } from 'spica/array';
|
|
6
6
|
import { html } from 'typed-dom/dom';
|
|
7
7
|
|
|
8
|
-
export const template: TemplateParser = lazy(() => creation(surround(
|
|
8
|
+
export const template: TemplateParser = lazy(() => creation(1, Recursion.ignore, surround(
|
|
9
9
|
'{{',
|
|
10
|
-
syntax(
|
|
10
|
+
syntax(6, State.all, some(union([bracket, escsource]), '}', [['}}', 6]])),
|
|
11
11
|
'}}',
|
|
12
12
|
true,
|
|
13
13
|
([, ns = []], rest) => [[html('span', { class: 'template' }, `{{${ns.join('').replace(/\x1B/g, '')}}}`)], rest])));
|
|
14
14
|
|
|
15
|
-
const bracket: TemplateParser.BracketParser = lazy(() => creation(union([
|
|
15
|
+
const bracket: TemplateParser.BracketParser = lazy(() => creation(0, Recursion.terminal, union([
|
|
16
16
|
surround(str('('), some(union([bracket, escsource]), ')'), str(')'), true,
|
|
17
17
|
undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
18
18
|
surround(str('['), some(union([bracket, escsource]), ']'), str(']'), true,
|
package/src/parser/inline.ts
CHANGED
|
@@ -70,6 +70,7 @@ export const inline: InlineParser = lazy(() => union([
|
|
|
70
70
|
|
|
71
71
|
export { indexee } from './inline/extension/indexee';
|
|
72
72
|
export { indexer } from './inline/extension/indexer';
|
|
73
|
+
export { dataindex } from './inline/extension/index';
|
|
73
74
|
export { medialink } from './inline/link';
|
|
74
75
|
export { media } from './inline/media';
|
|
75
76
|
export { shortmedia } from './inline/shortmedia';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { EscapableSourceParser } from '../source';
|
|
2
2
|
import { creation } from '../../combinator';
|
|
3
3
|
import { nonWhitespace } from './text';
|
|
4
|
+
import { Recursion } from '../context';
|
|
4
5
|
|
|
5
6
|
const delimiter = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
|
|
6
7
|
|
|
7
|
-
export const escsource: EscapableSourceParser = creation(1,
|
|
8
|
+
export const escsource: EscapableSourceParser = creation(1, Recursion.ignore, ({ source, context }) => {
|
|
8
9
|
if (source === '') return;
|
|
9
10
|
const i = source.search(delimiter);
|
|
10
11
|
switch (i) {
|
package/src/parser/source/str.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { StrParser } from '../source';
|
|
2
2
|
import { Parser, Context } from '../../combinator/data/parser';
|
|
3
3
|
import { creation } from '../../combinator';
|
|
4
|
+
import { Recursion } from '../context';
|
|
4
5
|
|
|
5
6
|
export function str(pattern: string | RegExp, not?: string): StrParser;
|
|
6
7
|
export function str(pattern: string | RegExp, not?: string): Parser<string, Context<StrParser>, []> {
|
|
7
8
|
assert(pattern);
|
|
8
9
|
return typeof pattern === 'string'
|
|
9
|
-
? creation(1,
|
|
10
|
+
? creation(1, Recursion.ignore, ({ source }) => {
|
|
10
11
|
if (source === '') return;
|
|
11
12
|
if (not && source.slice(pattern.length, pattern.length + not.length) === not) return;
|
|
12
13
|
return source.slice(0, pattern.length) === pattern
|
|
13
14
|
? [[pattern], source.slice(pattern.length)]
|
|
14
15
|
: undefined;
|
|
15
16
|
})
|
|
16
|
-
: creation(1,
|
|
17
|
+
: creation(1, Recursion.ignore, ({ source }) => {
|
|
17
18
|
if (source === '') return;
|
|
18
19
|
const m = source.match(pattern);
|
|
19
20
|
if (m && not && source.slice(m[0].length, m[0].length + not.length) === not) return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TextParser, TxtParser, LinebreakParser } from '../source';
|
|
2
2
|
import { union, creation, focus } from '../../combinator';
|
|
3
3
|
import { str } from './str';
|
|
4
|
+
import { Recursion } from '../context';
|
|
4
5
|
import { html } from 'typed-dom/dom';
|
|
5
6
|
|
|
6
7
|
export const delimiter = /[\s\x00-\x7F()[]{}“”‘’「」『』]|\S[#>]/u;
|
|
@@ -8,7 +9,7 @@ export const nonWhitespace = /[\S\n]|$/u;
|
|
|
8
9
|
export const nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/u;
|
|
9
10
|
const repeat = str(/^(.)\1*/);
|
|
10
11
|
|
|
11
|
-
export const text: TextParser = creation(1,
|
|
12
|
+
export const text: TextParser = creation(1, Recursion.ignore, ({ source, context }) => {
|
|
12
13
|
if (source === '') return;
|
|
13
14
|
const i = source.search(delimiter);
|
|
14
15
|
switch (i) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { UnescapableSourceParser } from '../source';
|
|
2
2
|
import { creation } from '../../combinator';
|
|
3
3
|
import { delimiter, nonWhitespace, nonAlphanumeric, isAlphanumeric } from './text';
|
|
4
|
+
import { Recursion } from '../context';
|
|
4
5
|
|
|
5
|
-
export const unescsource: UnescapableSourceParser = creation(1,
|
|
6
|
+
export const unescsource: UnescapableSourceParser = creation(1, Recursion.ignore, ({ source, context }) => {
|
|
6
7
|
assert(source[0] !== '\x1B');
|
|
7
8
|
if (source === '') return;
|
|
8
9
|
const i = source.search(delimiter);
|