securemark 0.258.0 → 0.258.3
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 +12 -0
- package/dist/index.js +200 -196
- package/package.json +1 -1
- package/src/combinator/control/manipulation/convert.ts +7 -7
- package/src/combinator/control/manipulation/scope.ts +4 -4
- package/src/combinator/data/parser/context/memo.ts +20 -11
- package/src/combinator/data/parser/context.test.ts +3 -3
- package/src/combinator/data/parser/context.ts +22 -31
- package/src/combinator/data/parser/inits.ts +3 -2
- package/src/combinator/data/parser/sequence.ts +3 -2
- package/src/combinator/data/parser/some.ts +4 -2
- 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 -2
- package/src/parser/api/bind.ts +1 -1
- package/src/parser/api/parse.test.ts +15 -12
- package/src/parser/api/parse.ts +1 -1
- package/src/parser/block/blockquote.ts +4 -4
- package/src/parser/block/dlist.ts +3 -3
- package/src/parser/block/extension/table.ts +4 -4
- package/src/parser/block/ilist.ts +2 -2
- package/src/parser/block/olist.ts +2 -2
- package/src/parser/block/reply/cite.ts +2 -2
- package/src/parser/block/reply/quote.ts +2 -2
- package/src/parser/block/sidefence.ts +2 -2
- package/src/parser/block/table.ts +5 -5
- package/src/parser/block/ulist.ts +2 -2
- package/src/parser/block.ts +2 -2
- package/src/parser/context.ts +7 -7
- package/src/parser/inline/annotation.test.ts +5 -5
- package/src/parser/inline/annotation.ts +6 -5
- package/src/parser/inline/autolink/email.ts +2 -2
- package/src/parser/inline/autolink/url.ts +2 -2
- package/src/parser/inline/autolink.ts +2 -2
- package/src/parser/inline/bracket.ts +13 -13
- package/src/parser/inline/code.ts +2 -2
- package/src/parser/inline/comment.ts +2 -2
- 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 +8 -7
- package/src/parser/inline/extension/indexer.ts +2 -2
- package/src/parser/inline/extension/label.ts +2 -2
- package/src/parser/inline/extension/placeholder.ts +5 -4
- package/src/parser/inline/html.ts +2 -2
- package/src/parser/inline/htmlentity.ts +2 -2
- package/src/parser/inline/insertion.ts +5 -4
- package/src/parser/inline/link.test.ts +2 -1
- package/src/parser/inline/link.ts +26 -17
- package/src/parser/inline/mark.ts +5 -4
- package/src/parser/inline/math.ts +3 -3
- package/src/parser/inline/media.test.ts +1 -0
- package/src/parser/inline/media.ts +7 -6
- package/src/parser/inline/reference.test.ts +5 -5
- package/src/parser/inline/reference.ts +7 -6
- package/src/parser/inline/ruby.test.ts +1 -0
- package/src/parser/inline/ruby.ts +4 -4
- package/src/parser/inline/strong.ts +5 -4
- package/src/parser/inline/template.ts +6 -6
- package/src/parser/inline.test.ts +4 -1
- package/src/parser/source/escapable.ts +2 -2
- package/src/parser/source/str.ts +5 -5
- package/src/parser/source/text.ts +2 -2
- package/src/parser/source/unescapable.ts +2 -2
|
@@ -22,6 +22,7 @@ describe('Unit: parser/inline/media', () => {
|
|
|
22
22
|
assert.deepStrictEqual(inspect(parser('{}')), undefined);
|
|
23
23
|
assert.deepStrictEqual(inspect(parser('[]')), undefined);
|
|
24
24
|
assert.deepStrictEqual(inspect(parser('!{}')), undefined);
|
|
25
|
+
assert.deepStrictEqual(inspect(parser('![{b}')), undefined);
|
|
25
26
|
assert.deepStrictEqual(inspect(parser('![]')), undefined);
|
|
26
27
|
assert.deepStrictEqual(inspect(parser('![]{}')), undefined);
|
|
27
28
|
assert.deepStrictEqual(inspect(parser('![]{ }')), undefined);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { undefined, location } from 'spica/global';
|
|
2
2
|
import { MediaParser } from '../inline';
|
|
3
|
-
import { union, inits, tails, some,
|
|
3
|
+
import { union, inits, tails, some, creation, precedence, guard, syntax, validate, verify, surround, open, dup, lazy, fmap, bind } from '../../combinator';
|
|
4
4
|
import { textlink, uri, option as linkoption, resolve } from './link';
|
|
5
5
|
import { attributes } from './html';
|
|
6
6
|
import { unsafehtmlentity } from './htmlentity';
|
|
7
7
|
import { txt, str } from '../source';
|
|
8
|
-
import {
|
|
8
|
+
import { Syntax, State } from '../context';
|
|
9
9
|
import { html, define } from 'typed-dom/dom';
|
|
10
10
|
import { ReadonlyURL } from 'spica/url';
|
|
11
11
|
import { unshift, shift, push } from 'spica/array';
|
|
@@ -18,9 +18,10 @@ const optspec = {
|
|
|
18
18
|
} as const;
|
|
19
19
|
Object.setPrototypeOf(optspec, null);
|
|
20
20
|
|
|
21
|
-
export const media: MediaParser = lazy(() => validate(['![', '!{'],
|
|
21
|
+
export const media: MediaParser = lazy(() => validate(['![', '!{'], bind(verify(fmap(open(
|
|
22
22
|
'!',
|
|
23
23
|
guard(context => ~context.state! & State.media,
|
|
24
|
+
syntax(Syntax.media, 2, 10,
|
|
24
25
|
tails([
|
|
25
26
|
dup(surround(
|
|
26
27
|
'[',
|
|
@@ -28,7 +29,7 @@ export const media: MediaParser = lazy(() => validate(['![', '!{'], syntax(Rule.
|
|
|
28
29
|
']',
|
|
29
30
|
true)),
|
|
30
31
|
dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
|
|
31
|
-
]))),
|
|
32
|
+
])))),
|
|
32
33
|
([as, bs]) => bs ? [[as.join('').trim() || as.join('')], shift(bs)[1]] : [[''], shift(as)[1]]),
|
|
33
34
|
([[text]]) => text === '' || text.trim() !== ''),
|
|
34
35
|
([[text], params], rest, context) => {
|
|
@@ -58,9 +59,9 @@ export const media: MediaParser = lazy(() => validate(['![', '!{'], syntax(Rule.
|
|
|
58
59
|
textlink as MediaParser,
|
|
59
60
|
([link]) => [define(link, { target: '_blank' }, [el])])
|
|
60
61
|
(`{ ${INSECURE_URI}${params.join('')} }${rest}`, context);
|
|
61
|
-
})))
|
|
62
|
+
})));
|
|
62
63
|
|
|
63
|
-
const bracket: MediaParser.TextParser.BracketParser = lazy(() =>
|
|
64
|
+
const bracket: MediaParser.TextParser.BracketParser = lazy(() => creation(union([
|
|
64
65
|
surround(str('('), some(union([unsafehtmlentity, bracket, txt]), ')'), str(')'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
65
66
|
surround(str('['), some(union([unsafehtmlentity, bracket, txt]), ']'), str(']'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
66
67
|
surround(str('{'), some(union([unsafehtmlentity, bracket, txt]), '}'), str('}'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
@@ -18,11 +18,11 @@ describe('Unit: parser/inline/reference', () => {
|
|
|
18
18
|
assert.deepStrictEqual(inspect(parser('[[\n]]')), undefined);
|
|
19
19
|
assert.deepStrictEqual(inspect(parser('[[\na]]')), undefined);
|
|
20
20
|
assert.deepStrictEqual(inspect(parser('[[\\\na]]')), undefined);
|
|
21
|
-
assert.deepStrictEqual(inspect(parser('[[a\n]]')),
|
|
22
|
-
assert.deepStrictEqual(inspect(parser('[[a\\\n]]')),
|
|
23
|
-
assert.deepStrictEqual(inspect(parser('[[a\nb]]')),
|
|
24
|
-
assert.deepStrictEqual(inspect(parser('[[a\\\nb]]')),
|
|
25
|
-
assert.deepStrictEqual(inspect(parser('[[*a\nb*]]')),
|
|
21
|
+
assert.deepStrictEqual(inspect(parser('[[a\n]]')), undefined);
|
|
22
|
+
assert.deepStrictEqual(inspect(parser('[[a\\\n]]')), undefined);
|
|
23
|
+
assert.deepStrictEqual(inspect(parser('[[a\nb]]')), undefined);
|
|
24
|
+
assert.deepStrictEqual(inspect(parser('[[a\\\nb]]')), undefined);
|
|
25
|
+
assert.deepStrictEqual(inspect(parser('[[*a\nb*]]')), undefined);
|
|
26
26
|
assert.deepStrictEqual(inspect(parser('[[\\]]')), undefined);
|
|
27
27
|
assert.deepStrictEqual(inspect(parser('[[a]b]]')), undefined);
|
|
28
28
|
assert.deepStrictEqual(inspect(parser('[[[a]]')), undefined);
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { ReferenceParser } from '../inline';
|
|
3
|
-
import { union, subsequence, some, context,
|
|
3
|
+
import { union, subsequence, some, context, creation, guard, syntax, state, surround, open, lazy, bind } from '../../combinator';
|
|
4
4
|
import { inline } from '../inline';
|
|
5
5
|
import { optimize } from './link';
|
|
6
6
|
import { str, stropt } from '../source';
|
|
7
|
-
import {
|
|
7
|
+
import { Syntax, State } from '../context';
|
|
8
8
|
import { regBlankStart, startLoose, trimNode } from '../visibility';
|
|
9
9
|
import { stringify } from '../util';
|
|
10
10
|
import { html, defrag } from 'typed-dom/dom';
|
|
11
11
|
|
|
12
|
-
export const reference: ReferenceParser = lazy(() =>
|
|
12
|
+
export const reference: ReferenceParser = lazy(() => surround(
|
|
13
13
|
'[[',
|
|
14
14
|
guard(context => ~context.state! & State.reference,
|
|
15
|
+
syntax(Syntax.reference, 6, 1,
|
|
15
16
|
state(State.annotation | State.reference | State.media,
|
|
16
17
|
startLoose(
|
|
17
18
|
context({ delimiters: undefined },
|
|
@@ -19,13 +20,13 @@ export const reference: ReferenceParser = lazy(() => validate('[[', syntax(Rule.
|
|
|
19
20
|
abbr,
|
|
20
21
|
open(stropt(/^(?=\^)/), some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])),
|
|
21
22
|
some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]]),
|
|
22
|
-
])), ']'))),
|
|
23
|
+
])), ']')))),
|
|
23
24
|
']]',
|
|
24
25
|
false,
|
|
25
26
|
([, ns], rest) => [[html('sup', attributes(ns), [html('span', trimNode(defrag(ns)))])], rest],
|
|
26
|
-
([, ns, rest], next) => next[0] === ']' ? undefined : optimize('[[', ns, rest)))
|
|
27
|
+
([, ns, rest], next) => next[0] === ']' ? undefined : optimize('[[', ns, rest, next)));
|
|
27
28
|
|
|
28
|
-
const abbr: ReferenceParser.AbbrParser =
|
|
29
|
+
const abbr: ReferenceParser.AbbrParser = creation(bind(surround(
|
|
29
30
|
'^',
|
|
30
31
|
union([str(/^(?![0-9]+\s?[|\]])[0-9A-Za-z]+(?:(?:-|(?=\W)(?!'\d)'?(?!\.\d)\.?(?!,\S),? ?)[0-9A-Za-z]+)*(?:-|'?\.?,? ?)?/)]),
|
|
31
32
|
/^\|?(?=]])|^\|[^\S\n]*/),
|
|
@@ -8,6 +8,7 @@ describe('Unit: parser/inline/ruby', () => {
|
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
11
|
+
assert.deepStrictEqual(inspect(parser('[(b)')), undefined);
|
|
11
12
|
assert.deepStrictEqual(inspect(parser('[]()')), undefined);
|
|
12
13
|
assert.deepStrictEqual(inspect(parser('[](b)')), undefined);
|
|
13
14
|
assert.deepStrictEqual(inspect(parser('[ ](b)')), undefined);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { RubyParser } from '../inline';
|
|
3
3
|
import { eval, exec } from '../../combinator/data/parser';
|
|
4
|
-
import { sequence, syntax,
|
|
4
|
+
import { sequence, syntax, creation, validate, verify, focus, surround, lazy, fmap } from '../../combinator';
|
|
5
5
|
import { unsafehtmlentity } from './htmlentity';
|
|
6
6
|
import { text as txt } from '../source';
|
|
7
|
-
import {
|
|
7
|
+
import { Syntax } from '../context';
|
|
8
8
|
import { isStartTightNodes } from '../visibility';
|
|
9
9
|
import { html, defrag } from 'typed-dom/dom';
|
|
10
10
|
import { unshift, push } from 'spica/array';
|
|
11
11
|
|
|
12
|
-
export const ruby: RubyParser = lazy(() => validate('[', syntax(
|
|
12
|
+
export const ruby: RubyParser = lazy(() => validate('[', syntax(Syntax.none, 2, 1, fmap(verify(
|
|
13
13
|
sequence([
|
|
14
14
|
surround('[', focus(/^(?:\\[^\n]|[^\\[\](){}"\n])+(?=]\()/, text), ']'),
|
|
15
15
|
surround('(', focus(/^(?:\\[^\n]|[^\\[\](){}"\n])+(?=\))/, text), ')'),
|
|
@@ -48,7 +48,7 @@ export const ruby: RubyParser = lazy(() => validate('[', syntax(Rule.none, 2, fm
|
|
|
48
48
|
}
|
|
49
49
|
}))));
|
|
50
50
|
|
|
51
|
-
const text: RubyParser.TextParser =
|
|
51
|
+
const text: RubyParser.TextParser = creation((source, context) => {
|
|
52
52
|
const acc = [''];
|
|
53
53
|
while (source !== '') {
|
|
54
54
|
assert(source[0] !== '\n');
|
|
@@ -3,20 +3,21 @@ import { union, some, syntax, surround, open, lazy } from '../../combinator';
|
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { emstrong } from './emstrong';
|
|
5
5
|
import { str } from '../source';
|
|
6
|
-
import {
|
|
6
|
+
import { Syntax } from '../context';
|
|
7
7
|
import { startTight, blankWith } from '../visibility';
|
|
8
8
|
import { html, defrag } from 'typed-dom/dom';
|
|
9
9
|
import { unshift } from 'spica/array';
|
|
10
10
|
|
|
11
|
-
export const strong: StrongParser = lazy(() =>
|
|
11
|
+
export const strong: StrongParser = lazy(() => surround(
|
|
12
12
|
str('**'),
|
|
13
|
+
syntax(Syntax.none, 1, 1,
|
|
13
14
|
startTight(some(union([
|
|
14
15
|
some(inline, blankWith('**')),
|
|
15
16
|
open(some(inline, '*'), union([
|
|
16
17
|
emstrong,
|
|
17
18
|
strong,
|
|
18
19
|
])),
|
|
19
|
-
])), '*'),
|
|
20
|
+
])), '*')),
|
|
20
21
|
str('**'), false,
|
|
21
22
|
([, bs], rest) => [[html('strong', defrag(bs))], rest],
|
|
22
|
-
([as, bs], rest) => [unshift(as, bs), rest]))
|
|
23
|
+
([as, bs], rest) => [unshift(as, bs), rest]));
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { TemplateParser } from '../inline';
|
|
3
|
-
import { union, some, syntax,
|
|
3
|
+
import { union, some, syntax, creation, precedence, surround, lazy } from '../../combinator';
|
|
4
4
|
import { optimize } from './link';
|
|
5
5
|
import { escsource, str } from '../source';
|
|
6
|
-
import {
|
|
6
|
+
import { Syntax } from '../context';
|
|
7
7
|
import { html } from 'typed-dom/dom';
|
|
8
8
|
import { unshift } from 'spica/array';
|
|
9
9
|
|
|
10
|
-
export const template: TemplateParser = lazy(() =>
|
|
11
|
-
'{{', some(union([bracket, escsource]), '}'), '}}', true,
|
|
10
|
+
export const template: TemplateParser = lazy(() => surround(
|
|
11
|
+
'{{', syntax(Syntax.none, 2, 1, some(union([bracket, escsource]), '}')), '}}', true,
|
|
12
12
|
([, ns = []], rest) => [[html('span', { class: 'template' }, `{{${ns.join('').replace(/\x1B/g, '')}}}`)], rest],
|
|
13
|
-
([, ns = [], rest], next) => next[0] === '}' ? undefined : optimize('{{', ns, rest)))
|
|
13
|
+
([, ns = [], rest], next) => next[0] === '}' ? undefined : optimize('{{', ns, rest, next)));
|
|
14
14
|
|
|
15
|
-
const bracket: TemplateParser.BracketParser = lazy(() =>
|
|
15
|
+
const bracket: TemplateParser.BracketParser = lazy(() => creation(union([
|
|
16
16
|
surround(str('('), some(union([bracket, escsource]), ')'), str(')'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
17
17
|
surround(str('['), some(union([bracket, escsource]), ']'), str(']'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
18
18
|
surround(str('{'), some(union([bracket, escsource]), '}'), str('}'), true, undefined, ([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
@@ -159,6 +159,7 @@ describe('Unit: parser/inline', () => {
|
|
|
159
159
|
assert.deepStrictEqual(inspect(parser('[[${]]}$')), [['', '[[', '<span class="math" translate="no" data-src="${]]}$">${]]}$</span>'], '']);
|
|
160
160
|
assert.deepStrictEqual(inspect(parser('"[[""]]')), [['"', '<sup class="reference"><span>""</span></sup>'], '']);
|
|
161
161
|
assert.deepStrictEqual(inspect(parser('[[a](b)]{c}')), [['<a href="c"><ruby>a<rp>(</rp><rt>b</rt><rp>)</rp></ruby></a>'], '']);
|
|
162
|
+
assert.deepStrictEqual(inspect(parser('[[[[[[[{a}')), [['', '[[[[[[[', '<a href="a">a</a>'], '']);
|
|
162
163
|
assert.deepStrictEqual(inspect(parser('<http://host>')), [['<', '<a href="http://host" target="_blank">http://host</a>', '>'], '']);
|
|
163
164
|
assert.deepStrictEqual(inspect(parser('[~http://host')), [['', '[', '~', '<a href="http://host" target="_blank">http://host</a>'], '']);
|
|
164
165
|
assert.deepStrictEqual(inspect(parser('[~a@b')), [['', '[', '~', '<a class="email" href="mailto:a@b">a@b</a>'], '']);
|
|
@@ -167,7 +168,9 @@ describe('Unit: parser/inline', () => {
|
|
|
167
168
|
assert.deepStrictEqual(inspect(parser('[^a@b')), [['[^', '<a class="email" href="mailto:a@b">a@b</a>'], '']);
|
|
168
169
|
assert.deepStrictEqual(inspect(parser('[#a*b\nc*]')), [['[', '<a href="/hashtags/a" class="hashtag">#a</a>', '<em>b<br>c</em>', ']'], '']);
|
|
169
170
|
assert.deepStrictEqual(inspect(parser('[*a\nb*]{/}')), [['[', '<em>a<br>b</em>', ']', '<a href="/">/</a>'], '']);
|
|
170
|
-
assert.deepStrictEqual(inspect(parser('[
|
|
171
|
+
assert.deepStrictEqual(inspect(parser('[*a\nb]*')), [['[', '*', 'a', '<br>', 'b', ']', '*'], '']);
|
|
172
|
+
assert.deepStrictEqual(inspect(parser('[*[a\nb*]')), [['', '[', '*', '[', 'a', '<br>', 'b', '*', ']'], '']);
|
|
173
|
+
assert.deepStrictEqual(inspect(parser('[[*a\nb*]]')), [['[', '[', '<em>a<br>b</em>', ']', ']'], '']);
|
|
171
174
|
assert.deepStrictEqual(inspect(parser('"[% *"*"*')), [['"', '[%', ' ', '*', '"', '*', '"', '*'], '']);
|
|
172
175
|
assert.deepStrictEqual(inspect(parser('"[% "*"* %]')), [['"', '[%', ' ', '"', '*', '"', '*', ' ', '%', ']'], '']);
|
|
173
176
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EscapableSourceParser } from '../source';
|
|
2
|
-
import {
|
|
2
|
+
import { creation } from '../../combinator';
|
|
3
3
|
import { nonWhitespace } from './text';
|
|
4
4
|
|
|
5
5
|
const delimiter = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
|
|
6
6
|
|
|
7
|
-
export const escsource: EscapableSourceParser =
|
|
7
|
+
export const escsource: EscapableSourceParser = creation(source => {
|
|
8
8
|
if (source === '') return;
|
|
9
9
|
const i = source.search(delimiter);
|
|
10
10
|
switch (i) {
|
package/src/parser/source/str.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { StrParser } from '../source';
|
|
3
3
|
import { Parser, Context } from '../../combinator/data/parser';
|
|
4
|
-
import {
|
|
4
|
+
import { creation } from '../../combinator';
|
|
5
5
|
|
|
6
6
|
export function str(pattern: string | RegExp): StrParser;
|
|
7
7
|
export function str(pattern: string | RegExp): Parser<string, Context<StrParser>, []> {
|
|
8
8
|
assert(pattern);
|
|
9
9
|
return typeof pattern === 'string'
|
|
10
|
-
?
|
|
10
|
+
? creation(source => {
|
|
11
11
|
if (source === '') return;
|
|
12
12
|
return source.slice(0, pattern.length) === pattern
|
|
13
13
|
? [[pattern], source.slice(pattern.length)]
|
|
14
14
|
: undefined;
|
|
15
15
|
})
|
|
16
|
-
:
|
|
16
|
+
: creation(source => {
|
|
17
17
|
if (source === '') return;
|
|
18
18
|
const m = source.match(pattern);
|
|
19
19
|
return m && m[0].length > 0
|
|
@@ -26,13 +26,13 @@ export function stropt(pattern: string | RegExp): StrParser;
|
|
|
26
26
|
export function stropt(pattern: string | RegExp): Parser<string, Context<StrParser>, []> {
|
|
27
27
|
assert(pattern);
|
|
28
28
|
return typeof pattern === 'string'
|
|
29
|
-
?
|
|
29
|
+
? creation(source => {
|
|
30
30
|
if (source === '') return;
|
|
31
31
|
return source.slice(0, pattern.length) === pattern
|
|
32
32
|
? [[pattern], source.slice(pattern.length)]
|
|
33
33
|
: undefined;
|
|
34
34
|
})
|
|
35
|
-
:
|
|
35
|
+
: creation(source => {
|
|
36
36
|
if (source === '') return;
|
|
37
37
|
const m = source.match(pattern);
|
|
38
38
|
return m
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { TextParser, TxtParser, LinebreakParser } from '../source';
|
|
3
|
-
import { union,
|
|
3
|
+
import { union, creation, focus } from '../../combinator';
|
|
4
4
|
import { str } from './str';
|
|
5
5
|
import { html } from 'typed-dom/dom';
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ export const nonWhitespace = /[\S\n]|$/;
|
|
|
9
9
|
export const nonAlphanumeric = /[^0-9A-Za-z]|\S#|$/;
|
|
10
10
|
const repeat = str(/^(.)\1*/);
|
|
11
11
|
|
|
12
|
-
export const text: TextParser =
|
|
12
|
+
export const text: TextParser = creation((source, context) => {
|
|
13
13
|
if (source === '') return;
|
|
14
14
|
const i = source.search(delimiter);
|
|
15
15
|
switch (i) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { UnescapableSourceParser } from '../source';
|
|
2
|
-
import {
|
|
2
|
+
import { creation } from '../../combinator';
|
|
3
3
|
import { delimiter, nonWhitespace, nonAlphanumeric, isAlphanumeric } from './text';
|
|
4
4
|
|
|
5
|
-
export const unescsource: UnescapableSourceParser =
|
|
5
|
+
export const unescsource: UnescapableSourceParser = creation(source => {
|
|
6
6
|
assert(source[0] !== '\x1B');
|
|
7
7
|
if (source === '') return;
|
|
8
8
|
const i = source.search(delimiter);
|