securemark 0.259.1 → 0.259.2
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/design.md +2 -1
- package/dist/index.js +427 -154
- package/package.json +1 -1
- package/src/combinator/control/constraint/block.test.ts +5 -5
- package/src/combinator/control/constraint/block.ts +3 -2
- package/src/combinator/control/constraint/contract.ts +7 -5
- package/src/combinator/control/constraint/line.test.ts +6 -6
- package/src/combinator/control/constraint/line.ts +6 -5
- package/src/combinator/control/manipulation/convert.ts +6 -5
- package/src/combinator/control/manipulation/fence.ts +2 -1
- package/src/combinator/control/manipulation/indent.test.ts +14 -14
- package/src/combinator/control/manipulation/indent.ts +5 -5
- package/src/combinator/control/manipulation/lazy.ts +2 -2
- package/src/combinator/control/manipulation/match.ts +3 -2
- package/src/combinator/control/manipulation/recovery.ts +6 -6
- package/src/combinator/control/manipulation/scope.ts +13 -10
- package/src/combinator/control/manipulation/surround.ts +9 -8
- package/src/combinator/control/manipulation/trim.test.ts +9 -9
- package/src/combinator/control/monad/bind.ts +3 -2
- package/src/combinator/data/parser/context/memo.ts +3 -4
- package/src/combinator/data/parser/context.test.ts +9 -9
- package/src/combinator/data/parser/context.ts +23 -18
- package/src/combinator/data/parser/inits.ts +3 -2
- package/src/combinator/data/parser/sequence.test.ts +10 -10
- package/src/combinator/data/parser/sequence.ts +3 -2
- package/src/combinator/data/parser/some.test.ts +13 -13
- package/src/combinator/data/parser/some.ts +3 -2
- package/src/combinator/data/parser/subsequence.test.ts +14 -14
- package/src/combinator/data/parser/union.test.ts +10 -10
- package/src/combinator/data/parser/union.ts +2 -2
- package/src/combinator/data/parser.ts +6 -1
- package/src/parser/api/bind.ts +1 -1
- package/src/parser/api/header.ts +1 -1
- package/src/parser/api/normalize.ts +1 -1
- package/src/parser/api/parse.ts +1 -1
- package/src/parser/autolink.test.ts +1 -1
- package/src/parser/autolink.ts +2 -2
- package/src/parser/block/blockquote.test.ts +1 -1
- package/src/parser/block/blockquote.ts +1 -1
- package/src/parser/block/codeblock.test.ts +1 -1
- package/src/parser/block/codeblock.ts +1 -1
- package/src/parser/block/dlist.test.ts +1 -1
- package/src/parser/block/extension/aside.test.ts +1 -1
- package/src/parser/block/extension/example.test.ts +1 -1
- package/src/parser/block/extension/example.ts +1 -1
- package/src/parser/block/extension/fig.test.ts +1 -1
- package/src/parser/block/extension/figbase.test.ts +1 -1
- package/src/parser/block/extension/figure.test.ts +1 -1
- package/src/parser/block/extension/figure.ts +1 -1
- package/src/parser/block/extension/message.test.ts +1 -1
- package/src/parser/block/extension/message.ts +1 -1
- package/src/parser/block/extension/placeholder.test.ts +1 -1
- package/src/parser/block/extension/table.test.ts +1 -1
- package/src/parser/block/extension/table.ts +1 -1
- package/src/parser/block/extension.test.ts +1 -1
- package/src/parser/block/heading.test.ts +3 -3
- package/src/parser/block/heading.ts +1 -1
- package/src/parser/block/horizontalrule.test.ts +1 -1
- package/src/parser/block/ilist.test.ts +1 -1
- package/src/parser/block/mathblock.test.ts +1 -1
- package/src/parser/block/olist.test.ts +1 -1
- package/src/parser/block/olist.ts +5 -5
- package/src/parser/block/paragraph.test.ts +1 -1
- package/src/parser/block/reply/cite.test.ts +1 -1
- package/src/parser/block/reply/cite.ts +2 -2
- package/src/parser/block/reply/quote.test.ts +1 -1
- package/src/parser/block/reply/quote.ts +2 -2
- package/src/parser/block/reply.test.ts +1 -1
- package/src/parser/block/sidefence.test.ts +1 -1
- package/src/parser/block/table.test.ts +1 -1
- package/src/parser/block/table.ts +1 -1
- package/src/parser/block/ulist.test.ts +1 -1
- package/src/parser/block/ulist.ts +1 -1
- package/src/parser/block.ts +2 -2
- package/src/parser/header.test.ts +1 -1
- package/src/parser/header.ts +3 -3
- package/src/parser/inline/annotation.test.ts +1 -1
- package/src/parser/inline/autolink/account.test.ts +1 -1
- package/src/parser/inline/autolink/anchor.test.ts +1 -1
- package/src/parser/inline/autolink/channel.test.ts +1 -1
- package/src/parser/inline/autolink/email.test.ts +1 -1
- package/src/parser/inline/autolink/email.ts +1 -1
- package/src/parser/inline/autolink/hashnum.test.ts +1 -1
- package/src/parser/inline/autolink/hashtag.test.ts +1 -1
- package/src/parser/inline/autolink/url.test.ts +1 -1
- package/src/parser/inline/bracket.test.ts +1 -1
- package/src/parser/inline/code.test.ts +1 -1
- package/src/parser/inline/code.ts +2 -2
- package/src/parser/inline/comment.test.ts +1 -1
- package/src/parser/inline/deletion.test.ts +1 -1
- package/src/parser/inline/emphasis.test.ts +1 -1
- package/src/parser/inline/emstrong.ts +2 -2
- package/src/parser/inline/escape.ts +3 -3
- package/src/parser/inline/extension/index.test.ts +1 -1
- package/src/parser/inline/extension/indexer.test.ts +1 -1
- package/src/parser/inline/extension/label.test.ts +1 -1
- package/src/parser/inline/extension/placeholder.test.ts +1 -1
- package/src/parser/inline/html.test.ts +1 -1
- package/src/parser/inline/htmlentity.test.ts +1 -1
- package/src/parser/inline/htmlentity.ts +1 -1
- package/src/parser/inline/insertion.test.ts +1 -1
- package/src/parser/inline/link.test.ts +1 -1
- package/src/parser/inline/link.ts +1 -1
- package/src/parser/inline/mark.test.ts +1 -1
- package/src/parser/inline/math.test.ts +1 -1
- package/src/parser/inline/math.ts +1 -1
- package/src/parser/inline/media.test.ts +1 -1
- package/src/parser/inline/media.ts +2 -2
- package/src/parser/inline/reference.test.ts +1 -1
- package/src/parser/inline/ruby.test.ts +1 -1
- package/src/parser/inline/ruby.ts +3 -3
- package/src/parser/inline/shortmedia.test.ts +1 -1
- package/src/parser/inline/strong.test.ts +1 -1
- package/src/parser/inline/template.test.ts +1 -1
- package/src/parser/inline.test.ts +1 -1
- package/src/parser/locale.test.ts +1 -1
- package/src/parser/segment.ts +1 -1
- package/src/parser/source/escapable.test.ts +1 -1
- package/src/parser/source/escapable.ts +1 -1
- package/src/parser/source/line.test.ts +1 -1
- package/src/parser/source/line.ts +2 -2
- package/src/parser/source/str.ts +4 -4
- package/src/parser/source/text.test.ts +1 -1
- package/src/parser/source/text.ts +3 -3
- package/src/parser/source/unescapable.test.ts +1 -1
- package/src/parser/source/unescapable.ts +1 -1
- package/src/parser/visibility.ts +13 -13
- package/src/util/quote.ts +1 -1
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/block/reply/cite', () => {
|
|
6
6
|
describe('cite', () => {
|
|
7
|
-
const parser = (source: string) => some(cite)(source, {});
|
|
7
|
+
const parser = (source: string) => some(cite)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -13,8 +13,8 @@ export const cite: ReplyParser.CiteParser = creation(line(fmap(validate(
|
|
|
13
13
|
// Subject page representation.
|
|
14
14
|
// リンクの実装は後で検討
|
|
15
15
|
focus(/^>>\.[^\S\n]*(?:$|\n)/, () => [[html('a', { class: 'anchor' }, '>>.')], '']),
|
|
16
|
-
focus(/^>>#\S*[^\S\n]*(?:$|\n)/, source => [[html('a', { class: 'anchor' }, source)], '']),
|
|
17
|
-
focus(/^>>https?:\/\/\w\S*[^\S\n]*(?:$|\n)/, source => [[html('a', { class: 'anchor', href: source.slice(2).trimEnd(), target: '_blank' }, source)], '']),
|
|
16
|
+
focus(/^>>#\S*[^\S\n]*(?:$|\n)/, ({ source }) => [[html('a', { class: 'anchor' }, source)], '']),
|
|
17
|
+
focus(/^>>https?:\/\/\w\S*[^\S\n]*(?:$|\n)/, ({ source }) => [[html('a', { class: 'anchor', href: source.slice(2).trimEnd(), target: '_blank' }, source)], '']),
|
|
18
18
|
]),
|
|
19
19
|
]))),
|
|
20
20
|
([el, quotes = '']: [HTMLElement, string?]) => [
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/block/reply/quote', () => {
|
|
6
6
|
describe('quote', () => {
|
|
7
|
-
const parser = (source: string) => some(quote)(source, {});
|
|
7
|
+
const parser = (source: string) => some(quote)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -33,7 +33,7 @@ export const quote: ReplyParser.QuoteParser = lazy(() => creation(block(fmap(val
|
|
|
33
33
|
]),
|
|
34
34
|
false)));
|
|
35
35
|
|
|
36
|
-
const qblock: ReplyParser.QuoteParser.BlockParser = (source, context) => {
|
|
36
|
+
const qblock: ReplyParser.QuoteParser.BlockParser = ({ source, context }) => {
|
|
37
37
|
source = source.replace(/\n$/, '');
|
|
38
38
|
const lines = source.match(/^.*\n?/mg)!;
|
|
39
39
|
assert(lines);
|
|
@@ -41,7 +41,7 @@ const qblock: ReplyParser.QuoteParser.BlockParser = (source, context) => {
|
|
|
41
41
|
assert(quotes);
|
|
42
42
|
assert(quotes.length > 0);
|
|
43
43
|
const content = lines.reduce((acc, line, row) => acc + line.slice(quotes[row].length), '');
|
|
44
|
-
const nodes = eval(some(text)(content, context), []);
|
|
44
|
+
const nodes = eval(some(text)({ source: content, context }), []);
|
|
45
45
|
nodes.unshift(quotes.shift()!);
|
|
46
46
|
for (let i = 0; i < nodes.length; ++i) {
|
|
47
47
|
const child = nodes[i] as string | Text | Element;
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/block/reply', () => {
|
|
6
6
|
describe('reply', () => {
|
|
7
|
-
const parser = (source: string) => some(reply)(source, {});
|
|
7
|
+
const parser = (source: string) => some(reply)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('basic', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('>>1')), [['<p><span class="cite">><a href="?at=1" class="anchor" data-depth="1">>1</a></span></p>'], '']);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/block/sidefence', () => {
|
|
6
6
|
describe('sidefence', () => {
|
|
7
|
-
const parser = (source: string) => some(sidefence)(source, {});
|
|
7
|
+
const parser = (source: string) => some(sidefence)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/block/table', () => {
|
|
6
6
|
describe('table', () => {
|
|
7
|
-
const parser = (source: string) => some(table)(source, {});
|
|
7
|
+
const parser = (source: string) => some(table)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -28,7 +28,7 @@ export const table: TableParser = lazy(() => block(fmap(validate(
|
|
|
28
28
|
const row = <P extends CellParser | AlignParser>(parser: P, optional: boolean): RowParser<P> => creation(fallback(fmap(
|
|
29
29
|
line(surround(/^(?=\|)/, some(union([parser])), /^[|\\]?\s*$/, optional)),
|
|
30
30
|
es => [html('tr', es)]),
|
|
31
|
-
rewrite(contentline, source => [[
|
|
31
|
+
rewrite(contentline, ({ source }) => [[
|
|
32
32
|
html('tr', {
|
|
33
33
|
class: 'invalid',
|
|
34
34
|
'data-invalid-syntax': 'table-row',
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/block/ulist', () => {
|
|
6
6
|
describe('ulist', () => {
|
|
7
|
-
const parser = (source: string) => some(ulist)(source, {});
|
|
7
|
+
const parser = (source: string) => some(ulist)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -28,7 +28,7 @@ export const ulist_: UListParser = lazy(() => block(fmap(validate(
|
|
|
28
28
|
|
|
29
29
|
export const checkbox = creation(focus(
|
|
30
30
|
/^\[[xX ]\](?=$|\s)/,
|
|
31
|
-
source => [[
|
|
31
|
+
({ source }) => [[
|
|
32
32
|
html('span', { class: 'checkbox' }, source[1].trimStart() ? '☑' : '☐'),
|
|
33
33
|
], '']));
|
|
34
34
|
|
package/src/parser/block.ts
CHANGED
|
@@ -57,9 +57,9 @@ export const block: BlockParser = creation(error(
|
|
|
57
57
|
|
|
58
58
|
function error(parser: BlockParser): BlockParser {
|
|
59
59
|
return recover<BlockParser>(fallback(
|
|
60
|
-
open('\x07', source => { throw new Error(source.split('\n', 1)[0]); }),
|
|
60
|
+
open('\x07', ({source}) => { throw new Error(source.split('\n', 1)[0]); }),
|
|
61
61
|
parser),
|
|
62
|
-
(source, { id }, reason) => [[
|
|
62
|
+
({ source, context: { id } }, reason) => [[
|
|
63
63
|
html('h1',
|
|
64
64
|
{
|
|
65
65
|
id: id !== '' ? `error:${rnd0Z(8)}` : undefined,
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/header', () => {
|
|
6
6
|
describe('header', () => {
|
|
7
|
-
const parser = (source: string) => some(header)(source, {});
|
|
7
|
+
const parser = (source: string) => some(header)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
package/src/parser/header.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const header: MarkdownParser.HeaderParser = lazy(() => validate(
|
|
|
9
9
|
/^---+[^\S\v\f\r\n]*\r?\n[^\S\n]*(?=\S)/,
|
|
10
10
|
inits([
|
|
11
11
|
rewrite(
|
|
12
|
-
(source, context) =>
|
|
12
|
+
({ source, context }) =>
|
|
13
13
|
[[], context.header ?? true ? source.slice(segment(source).next().value!.length) : ''],
|
|
14
14
|
block(
|
|
15
15
|
union([
|
|
@@ -27,7 +27,7 @@ export const header: MarkdownParser.HeaderParser = lazy(() => validate(
|
|
|
27
27
|
])),
|
|
28
28
|
]),
|
|
29
29
|
])))),
|
|
30
|
-
source => [[
|
|
30
|
+
({ source }) => [[
|
|
31
31
|
html('pre', {
|
|
32
32
|
class: 'invalid',
|
|
33
33
|
translate: 'no',
|
|
@@ -40,7 +40,7 @@ export const header: MarkdownParser.HeaderParser = lazy(() => validate(
|
|
|
40
40
|
clear(str(/^[^\S\v\f\r\n]*\r?\n/)),
|
|
41
41
|
])));
|
|
42
42
|
|
|
43
|
-
const field: MarkdownParser.HeaderParser.FieldParser = line(source => {
|
|
43
|
+
const field: MarkdownParser.HeaderParser.FieldParser = line(({ source }) => {
|
|
44
44
|
const name = source.slice(0, source.indexOf(':'));
|
|
45
45
|
const value = source.slice(name.length + 1).trim();
|
|
46
46
|
return [[
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/annotation', () => {
|
|
6
6
|
describe('annotation', () => {
|
|
7
|
-
const parser = (source: string) => some(annotation)(source, {});
|
|
7
|
+
const parser = (source: string) => some(annotation)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/autolink/account', () => {
|
|
6
6
|
describe('account', () => {
|
|
7
|
-
const parser = (source: string) => some(autolink)(source, {});
|
|
7
|
+
const parser = (source: string) => some(autolink)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/autolink/anchor', () => {
|
|
6
6
|
describe('anchor', () => {
|
|
7
|
-
const parser = (source: string) => some(autolink)(source, {});
|
|
7
|
+
const parser = (source: string) => some(autolink)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/autolink/channel', () => {
|
|
6
6
|
describe('channel', () => {
|
|
7
|
-
const parser = (source: string) => some(autolink)(source, {});
|
|
7
|
+
const parser = (source: string) => some(autolink)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/autolink/email', () => {
|
|
6
6
|
describe('email', () => {
|
|
7
|
-
const parser = (source: string) => some(autolink)(source, {});
|
|
7
|
+
const parser = (source: string) => some(autolink)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -8,4 +8,4 @@ import { html } from 'typed-dom/dom';
|
|
|
8
8
|
export const email: AutolinkParser.EmailParser = creation(rewrite(verify(
|
|
9
9
|
str(/^[0-9A-Za-z]+(?:[.+_-][0-9A-Za-z]+)*@[0-9A-Za-z](?:(?:[0-9A-Za-z]|-(?=\w)){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-(?=\w)){0,61}[0-9A-Za-z])?)*(?![0-9A-Za-z])/),
|
|
10
10
|
([source]) => source.indexOf('@') <= 64 && source.length <= 255),
|
|
11
|
-
source => [[html('a', { class: 'email', href: `mailto:${source}` }, source)], '']));
|
|
11
|
+
({ source }) => [[html('a', { class: 'email', href: `mailto:${source}` }, source)], '']));
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/autolink/hashnum', () => {
|
|
6
6
|
describe('hashnum', () => {
|
|
7
|
-
const parser = (source: string) => some(autolink)(source, {});
|
|
7
|
+
const parser = (source: string) => some(autolink)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/autolink/hashtag', () => {
|
|
6
6
|
describe('hashtag', () => {
|
|
7
|
-
const parser = (source: string) => some(autolink)(source, {});
|
|
7
|
+
const parser = (source: string) => some(autolink)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/autolink/url', () => {
|
|
6
6
|
describe('url', () => {
|
|
7
|
-
const parser = (source: string) => some(autolink)(source, {});
|
|
7
|
+
const parser = (source: string) => some(autolink)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/bracket', () => {
|
|
6
6
|
describe('bracket', () => {
|
|
7
|
-
const parser = (source: string) => some(bracket)(source, {});
|
|
7
|
+
const parser = (source: string) => some(bracket)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('(', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('(')), [['', '('], '']);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/code', () => {
|
|
6
6
|
describe('code', () => {
|
|
7
|
-
const parser = (source: string) => some(code)(source, {});
|
|
7
|
+
const parser = (source: string) => some(code)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,8 +4,8 @@ import { html } from 'typed-dom/dom';
|
|
|
4
4
|
|
|
5
5
|
export const code: CodeParser = creation(validate('`', match(
|
|
6
6
|
/^(`+)(?!`)([^\n]*?[^`\n])\1(?!`)/,
|
|
7
|
-
([whole, , body]) =>
|
|
8
|
-
[[html('code', { 'data-src': whole }, format(body))],
|
|
7
|
+
([whole, , body]) => ({ source }) =>
|
|
8
|
+
[[html('code', { 'data-src': whole }, format(body))], source.slice(whole.length)])));
|
|
9
9
|
|
|
10
10
|
function format(text: string): string {
|
|
11
11
|
assert(text.length > 0);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/comment', () => {
|
|
6
6
|
describe('comment', () => {
|
|
7
|
-
const parser = (source: string) => some(comment)(source, {});
|
|
7
|
+
const parser = (source: string) => some(comment)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/deletion', () => {
|
|
6
6
|
describe('deletion', () => {
|
|
7
|
-
const parser = (source: string) => some(deletion)(source, {});
|
|
7
|
+
const parser = (source: string) => some(deletion)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/emphasis', () => {
|
|
6
6
|
describe('emphasis', () => {
|
|
7
|
-
const parser = (source: string) => some(emphasis)(source, {});
|
|
7
|
+
const parser = (source: string) => some(emphasis)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('*')), undefined);
|
|
@@ -47,7 +47,7 @@ export const emstrong: EmStrongParser = lazy(() => surround(
|
|
|
47
47
|
rest.slice(0, 1) === '*'
|
|
48
48
|
? [[html('em', unshift([html('strong', defrag(bs))], defrag(ds)))], rest.slice(1)]
|
|
49
49
|
: [unshift(['*', html('strong', defrag(bs))], ds), rest])
|
|
50
|
-
(rest, context) ?? [['*', html('strong', defrag(bs))], rest];
|
|
50
|
+
({ source: rest, context }) ?? [['*', html('strong', defrag(bs))], rest];
|
|
51
51
|
case '*':
|
|
52
52
|
return bind<StrongParser>(
|
|
53
53
|
substrong,
|
|
@@ -55,7 +55,7 @@ export const emstrong: EmStrongParser = lazy(() => surround(
|
|
|
55
55
|
rest.slice(0, 2) === '**'
|
|
56
56
|
? [[html('strong', unshift([html('em', defrag(bs))], defrag(ds)))], rest.slice(2)]
|
|
57
57
|
: [unshift(['**', html('em', defrag(bs))], ds), rest])
|
|
58
|
-
(rest, context) ?? [['**', html('em', defrag(bs))], rest];
|
|
58
|
+
({ source: rest, context }) ?? [['**', html('em', defrag(bs))], rest];
|
|
59
59
|
}
|
|
60
60
|
assert(false);
|
|
61
61
|
},
|
|
@@ -5,7 +5,7 @@ import { str } from '../source';
|
|
|
5
5
|
|
|
6
6
|
const repeat = str(/^(.)\1*/);
|
|
7
7
|
|
|
8
|
-
export const escape: EscapeParser = union([(source, context) => {
|
|
8
|
+
export const escape: EscapeParser = union([({ source, context }) => {
|
|
9
9
|
if (source.length < 3) return;
|
|
10
10
|
switch (source[0]) {
|
|
11
11
|
case '*':
|
|
@@ -14,7 +14,7 @@ export const escape: EscapeParser = union([(source, context) => {
|
|
|
14
14
|
return source[3] === source[0]
|
|
15
15
|
&& source[2] === source[0]
|
|
16
16
|
&& source[1] === source[0]
|
|
17
|
-
? repeat(source, context)
|
|
17
|
+
? repeat({ source, context })
|
|
18
18
|
: undefined;
|
|
19
19
|
case '+':
|
|
20
20
|
case '~':
|
|
@@ -22,7 +22,7 @@ export const escape: EscapeParser = union([(source, context) => {
|
|
|
22
22
|
assert(source[2]);
|
|
23
23
|
return source[2] === source[0]
|
|
24
24
|
&& source[1] === source[0]
|
|
25
|
-
? repeat(source, context)
|
|
25
|
+
? repeat({ source, context })
|
|
26
26
|
: undefined;
|
|
27
27
|
default:
|
|
28
28
|
return;
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/extension/index', () => {
|
|
6
6
|
describe('index', () => {
|
|
7
|
-
const parser = (source: string) => some(index)(source, {});
|
|
7
|
+
const parser = (source: string) => some(index)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('[]')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/extension/indexer', () => {
|
|
6
6
|
describe('indexer', () => {
|
|
7
|
-
const parser = (source: string) => some(indexer)(source, {});
|
|
7
|
+
const parser = (source: string) => some(indexer)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/extension/label', () => {
|
|
6
6
|
describe('label', () => {
|
|
7
|
-
const parser = (source: string) => some(label)(source, {});
|
|
7
|
+
const parser = (source: string) => some(label)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('[]')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/extension/placeholder', () => {
|
|
6
6
|
describe('placeholder', () => {
|
|
7
|
-
const parser = (source: string) => some(placeholder)(source, {});
|
|
7
|
+
const parser = (source: string) => some(placeholder)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('[]')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/html', () => {
|
|
6
6
|
describe('html', () => {
|
|
7
|
-
const parser = (source: string) => some(html)(source, {});
|
|
7
|
+
const parser = (source: string) => some(html)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('xss', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('<script>')), [['<span class="invalid"><script></span>'], '']);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/htmlentity', () => {
|
|
6
6
|
describe('htmlentity', () => {
|
|
7
|
-
const parser = (source: string) => some(htmlentity)(source, {});
|
|
7
|
+
const parser = (source: string) => some(htmlentity)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -6,7 +6,7 @@ import { reduce } from 'spica/memoize';
|
|
|
6
6
|
|
|
7
7
|
export const unsafehtmlentity: UnsafeHTMLEntityParser = creation(validate('&', focus(
|
|
8
8
|
/^&[0-9A-Za-z]+;/,
|
|
9
|
-
|
|
9
|
+
({ source }) => [[parse(source) ?? `\x1B${source}`], ''])));
|
|
10
10
|
|
|
11
11
|
export const htmlentity: HTMLEntityParser = fmap(
|
|
12
12
|
union([unsafehtmlentity]),
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/insertion', () => {
|
|
6
6
|
describe('insertion', () => {
|
|
7
|
-
const parser = (source: string) => some(insertion)(source, {});
|
|
7
|
+
const parser = (source: string) => some(insertion)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -5,7 +5,7 @@ import { MarkdownParser } from '../../../markdown';
|
|
|
5
5
|
|
|
6
6
|
describe('Unit: parser/inline/link', () => {
|
|
7
7
|
describe('link', () => {
|
|
8
|
-
const parser = (source: string, context: MarkdownParser.Context = {}) => some(link)(source, context);
|
|
8
|
+
const parser = (source: string, context: MarkdownParser.Context = {}) => some(link)({ source, context });
|
|
9
9
|
|
|
10
10
|
it('xss', () => {
|
|
11
11
|
assert.deepStrictEqual(inspect(parser('[]{javascript:alert}')), [['<a class="invalid">javascript:alert</a>'], '']);
|
|
@@ -38,7 +38,7 @@ const textlink: LinkParser.TextLinkParser = lazy(() =>
|
|
|
38
38
|
assert(!html('div', content).querySelector('a, .media, .annotation, .reference'));
|
|
39
39
|
if (content.length !== 0 && trimNode(content).length === 0) return;
|
|
40
40
|
for (let source = stringify(content); source;) {
|
|
41
|
-
const result = state(State.autolink, false, autolink)(source, context);
|
|
41
|
+
const result = state(State.autolink, false, autolink)({ source, context });
|
|
42
42
|
if (typeof eval(result!)[0] === 'object') return;
|
|
43
43
|
source = exec(result!);
|
|
44
44
|
}
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/mark', () => {
|
|
6
6
|
describe('mark', () => {
|
|
7
|
-
const parser = (source: string) => some(mark)(source, {});
|
|
7
|
+
const parser = (source: string) => some(mark)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/math', () => {
|
|
6
6
|
describe('math', () => {
|
|
7
|
-
const parser = (source: string) => some(math)(source, {});
|
|
7
|
+
const parser = (source: string) => some(math)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -16,7 +16,7 @@ export const math: MathParser = lazy(() => validate('$', creation(rewrite(
|
|
|
16
16
|
]))),
|
|
17
17
|
/^\$(?![0-9A-Za-z])/),
|
|
18
18
|
]),
|
|
19
|
-
(source, { caches: { math: cache } = {} }) => [[
|
|
19
|
+
({ source, context: { caches: { math: cache } = {} } }) => [[
|
|
20
20
|
cache?.get(source)?.cloneNode(true) ||
|
|
21
21
|
html('span',
|
|
22
22
|
!forbiddenCommand.test(source)
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/media', () => {
|
|
6
6
|
describe('media', () => {
|
|
7
|
-
const parser = (source: string) => some(media)(source, {});
|
|
7
|
+
const parser = (source: string) => some(media)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('xss', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('![]{javascript:alert}')), [['<img class="media invalid" data-src="javascript:alert" alt="">'], '']);
|
|
@@ -55,11 +55,11 @@ export const media: MediaParser = lazy(() => validate(['![', '!{'], open(
|
|
|
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 creation(10, (..._) => [[el!], rest])('!', context);
|
|
58
|
+
if (cache && cache.tagName !== 'IMG') return creation(10, (..._) => [[el!], rest])({ source: '!', context });
|
|
59
59
|
return fmap(
|
|
60
60
|
unsafelink as MediaParser,
|
|
61
61
|
([link]) => [define(link, { target: '_blank' }, [el])])
|
|
62
|
-
(`{ ${INSECURE_URI}${params.join('')} }${rest}`, context);
|
|
62
|
+
({ source: `{ ${INSECURE_URI}${params.join('')} }${rest}`, context });
|
|
63
63
|
}))))));
|
|
64
64
|
|
|
65
65
|
const bracket: MediaParser.TextParser.BracketParser = lazy(() => creation(union([
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/reference', () => {
|
|
6
6
|
describe('reference', () => {
|
|
7
|
-
const parser = (source: string) => some(reference)(source, {});
|
|
7
|
+
const parser = (source: string) => some(reference)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/ruby', () => {
|
|
6
6
|
describe('ruby', () => {
|
|
7
|
-
const parser = (source: string) => some(ruby)(source, {});
|
|
7
|
+
const parser = (source: string) => some(ruby)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -48,14 +48,14 @@ export const ruby: RubyParser = lazy(() => validate('[', syntax(Syntax.none, 2,
|
|
|
48
48
|
}
|
|
49
49
|
}))));
|
|
50
50
|
|
|
51
|
-
const text: RubyParser.TextParser = creation((source, context) => {
|
|
51
|
+
const text: RubyParser.TextParser = creation(({ source, context }) => {
|
|
52
52
|
const acc = [''];
|
|
53
53
|
while (source !== '') {
|
|
54
54
|
assert(source[0] !== '\n');
|
|
55
55
|
switch (source[0]) {
|
|
56
56
|
// @ts-expect-error
|
|
57
57
|
case '&': {
|
|
58
|
-
const result = unsafehtmlentity(source, context);
|
|
58
|
+
const result = unsafehtmlentity({ source, context });
|
|
59
59
|
if (result) {
|
|
60
60
|
acc[acc.length - 1] += eval(result)[0];
|
|
61
61
|
source = exec(result, source.slice(1));
|
|
@@ -69,7 +69,7 @@ const text: RubyParser.TextParser = creation((source, context) => {
|
|
|
69
69
|
source = source.slice(1);
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
72
|
-
const result = txt(source, context)!;
|
|
72
|
+
const result = txt({ source, context })!;
|
|
73
73
|
assert(result);
|
|
74
74
|
acc[acc.length - 1] += eval(result)[0] ?? source.slice(0, source.length - exec(result).length);
|
|
75
75
|
source = exec(result);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/shortmedia', () => {
|
|
6
6
|
describe('shortmedia', () => {
|
|
7
|
-
const parser = (source: string) => some(shortmedia)(source, {});
|
|
7
|
+
const parser = (source: string) => some(shortmedia)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/strong', () => {
|
|
6
6
|
describe('strong', () => {
|
|
7
|
-
const parser = (source: string) => some(strong)(source, {});
|
|
7
|
+
const parser = (source: string) => some(strong)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('**')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline/template', () => {
|
|
6
6
|
describe('template', () => {
|
|
7
|
-
const parser = (source: string) => some(template)(source, {});
|
|
7
|
+
const parser = (source: string) => some(template)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/inline', () => {
|
|
6
6
|
describe('inline', () => {
|
|
7
|
-
const parser = (source: string) => some(inline)(source, {});
|
|
7
|
+
const parser = (source: string) => some(inline)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('empty', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
@@ -4,7 +4,7 @@ import { inspect } from '../debug.test';
|
|
|
4
4
|
|
|
5
5
|
describe('Unit: parser/locale', () => {
|
|
6
6
|
describe('locale', () => {
|
|
7
|
-
const parser = (source: string) => some(block)(source, {});
|
|
7
|
+
const parser = (source: string) => some(block)({ source, context: {} });
|
|
8
8
|
|
|
9
9
|
it('basic', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('。\\\n0')), [['<p>。<span class="linebreak"></span>0</p>'], '']);
|