securemark 0.240.2 → 0.243.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 +12 -0
- package/dist/securemark.js +1082 -2461
- package/global.dev.d.ts +6 -2
- package/index.d.ts +0 -1
- package/markdown.d.ts +61 -32
- package/package-lock.json +169 -77
- package/package.json +5 -4
- package/src/combinator/control/manipulation/fallback.ts +0 -1
- package/src/combinator/control/manipulation/indent.test.ts +3 -1
- package/src/combinator/control/manipulation/indent.ts +7 -6
- package/src/debug.test.ts +1 -1
- package/src/parser/api/bind.test.ts +1 -1
- package/src/parser/api/parse.test.ts +1 -1
- package/src/parser/api/parse.ts +1 -1
- package/src/parser/block/blockquote.test.ts +4 -4
- package/src/parser/block/blockquote.ts +2 -8
- package/src/parser/block/codeblock.test.ts +27 -27
- package/src/parser/block/codeblock.ts +2 -2
- package/src/parser/block/dlist.ts +1 -1
- package/src/parser/block/extension/aside.ts +1 -1
- package/src/parser/block/extension/example.ts +1 -1
- package/src/parser/block/extension/fig.test.ts +3 -3
- package/src/parser/block/extension/fig.ts +7 -6
- package/src/parser/block/extension/figbase.ts +1 -1
- package/src/parser/block/extension/figure.test.ts +10 -10
- package/src/parser/block/extension/figure.ts +16 -6
- package/src/parser/block/extension/message.test.ts +7 -7
- package/src/parser/block/extension/message.ts +6 -2
- package/src/parser/block/extension/placeholder.ts +9 -3
- package/src/parser/block/extension/table.test.ts +1 -1
- package/src/parser/block/extension/table.ts +1 -1
- package/src/parser/block/heading.ts +1 -1
- package/src/parser/block/horizontalrule.ts +1 -1
- package/src/parser/block/ilist.ts +1 -1
- package/src/parser/block/indentblock.test.ts +30 -0
- package/src/parser/block/indentblock.ts +13 -0
- package/src/parser/block/mathblock.ts +1 -1
- package/src/parser/block/olist.ts +6 -6
- package/src/parser/block/paragraph.ts +1 -1
- package/src/parser/block/reply/cite.ts +1 -1
- package/src/parser/block/reply/quote.ts +1 -1
- package/src/parser/block/reply.ts +1 -1
- package/src/parser/block/sidefence.test.ts +66 -0
- package/src/parser/block/sidefence.ts +31 -0
- package/src/parser/block/table.ts +1 -1
- package/src/parser/block/ulist.ts +1 -1
- package/src/parser/block.ts +8 -2
- package/src/parser/header.ts +1 -1
- package/src/parser/inline/annotation.ts +1 -1
- package/src/parser/inline/autolink/account.ts +1 -1
- package/src/parser/inline/autolink/anchor.ts +1 -1
- package/src/parser/inline/autolink/channel.ts +1 -1
- package/src/parser/inline/autolink/email.ts +1 -1
- package/src/parser/inline/autolink/hashnum.ts +1 -1
- package/src/parser/inline/autolink/hashtag.ts +1 -1
- package/src/parser/inline/bracket.ts +1 -1
- package/src/parser/inline/code.ts +1 -1
- package/src/parser/inline/comment.ts +1 -1
- package/src/parser/inline/deletion.ts +1 -1
- package/src/parser/inline/emphasis.ts +1 -1
- package/src/parser/inline/emstrong.ts +1 -1
- package/src/parser/inline/extension/index.ts +1 -1
- package/src/parser/inline/extension/indexee.ts +1 -1
- package/src/parser/inline/extension/indexer.ts +1 -1
- package/src/parser/inline/extension/label.ts +1 -1
- package/src/parser/inline/extension/placeholder.ts +3 -3
- package/src/parser/inline/html.ts +1 -1
- package/src/parser/inline/htmlentity.ts +1 -1
- package/src/parser/inline/insertion.ts +1 -1
- package/src/parser/inline/link.ts +1 -1
- package/src/parser/inline/mark.ts +1 -1
- package/src/parser/inline/math.ts +1 -1
- package/src/parser/inline/media.ts +1 -1
- package/src/parser/inline/reference.ts +1 -1
- package/src/parser/inline/ruby.ts +1 -1
- package/src/parser/inline/strong.ts +1 -1
- package/src/parser/inline/template.ts +1 -1
- package/src/parser/locale.ts +1 -1
- package/src/parser/processor/figure.test.ts +1 -1
- package/src/parser/processor/figure.ts +4 -4
- package/src/parser/processor/footnote.test.ts +1 -1
- package/src/parser/processor/footnote.ts +6 -5
- package/src/parser/source/text.ts +1 -1
- package/src/renderer/render/math.ts +1 -1
- package/src/renderer/render/media/audio.ts +1 -1
- package/src/renderer/render/media/image.ts +1 -1
- package/src/renderer/render/media/pdf.ts +1 -1
- package/src/renderer/render/media/twitter.ts +21 -23
- package/src/renderer/render/media/video.ts +1 -1
- package/src/renderer/render/media/youtube.ts +1 -1
- package/src/renderer/render/media.test.ts +1 -1
- package/src/renderer/render.ts +3 -5
- package/src/util/info.ts +3 -7
- package/src/util/quote.ts +1 -1
- package/src/util/toc.test.ts +1 -1
- package/src/util/toc.ts +1 -1
- package/src/util.ts +0 -1
- package/src/util/sync.ts +0 -57
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { indentblock } from './indentblock';
|
|
2
|
+
import { some } from '../../combinator';
|
|
3
|
+
import { inspect } from '../../debug.test';
|
|
4
|
+
|
|
5
|
+
describe('Unit: parser/block/indentblock', () => {
|
|
6
|
+
describe('indentblock', () => {
|
|
7
|
+
const parser = (source: string) => some(indentblock)(source, {});
|
|
8
|
+
|
|
9
|
+
it('invalid', () => {
|
|
10
|
+
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
11
|
+
assert.deepStrictEqual(inspect(parser('\na')), undefined);
|
|
12
|
+
assert.deepStrictEqual(inspect(parser(' a')), undefined);
|
|
13
|
+
assert.deepStrictEqual(inspect(parser(' \ta')), undefined);
|
|
14
|
+
assert.deepStrictEqual(inspect(parser(' a\nb')), undefined);
|
|
15
|
+
assert.deepStrictEqual(inspect(parser(' a\n b')), undefined);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('valid', () => {
|
|
19
|
+
assert.deepStrictEqual(inspect(parser(' a')), [['<pre class="text">a</pre>'], '']);
|
|
20
|
+
assert.deepStrictEqual(inspect(parser(' a ')), [['<pre class="text">a </pre>'], '']);
|
|
21
|
+
assert.deepStrictEqual(inspect(parser(' a \n')), [['<pre class="text">a </pre>'], '']);
|
|
22
|
+
assert.deepStrictEqual(inspect(parser(' a \n b')), [['<pre class="text">a <br> b</pre>'], '']);
|
|
23
|
+
assert.deepStrictEqual(inspect(parser(' a\\\n b')), [['<pre class="text">a\\<br>b</pre>'], '']);
|
|
24
|
+
assert.deepStrictEqual(inspect(parser('\ta')), [['<pre class="text">a</pre>'], '']);
|
|
25
|
+
assert.deepStrictEqual(inspect(parser('\t a')), [['<pre class="text"> a</pre>'], '']);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IndentBlockParser } from '../block';
|
|
2
|
+
import { union, block, validate, indent, convert } from '../../combinator';
|
|
3
|
+
import { codeblock } from './codeblock';
|
|
4
|
+
|
|
5
|
+
// 空行を含むインデントブロックはインデントの違いによるセグメント分割の境界が視認不能となるため採用しない
|
|
6
|
+
|
|
7
|
+
export const indentblock: IndentBlockParser = block(validate(/^(?: |\t)/, indent(convert(
|
|
8
|
+
source => {
|
|
9
|
+
const fence = (source.match(/^`{3,}(?=[^\S\n]*$)/mg) ?? [])
|
|
10
|
+
.reduce((max, fence) => fence > max ? fence : max, '``') + '`';
|
|
11
|
+
return `${fence}\n${source}\n${fence}`;
|
|
12
|
+
},
|
|
13
|
+
union([codeblock])), true)));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { MathBlockParser } from '../block';
|
|
3
3
|
import { block, validate, fence, clear, fmap } from '../../combinator';
|
|
4
|
-
import { html } from 'typed-dom';
|
|
4
|
+
import { html } from 'typed-dom/dom';
|
|
5
5
|
|
|
6
6
|
const opener = /^(\${2,})(?!\$)([^\n]*)(?:$|\n)/;
|
|
7
7
|
|
|
@@ -5,7 +5,7 @@ import { checkbox, ulist_, fillFirstLine } from './ulist';
|
|
|
5
5
|
import { ilist_ } from './ilist';
|
|
6
6
|
import { inline, indexee, indexer } from '../inline';
|
|
7
7
|
import { contentline } from '../source';
|
|
8
|
-
import { html, define, defrag } from 'typed-dom';
|
|
8
|
+
import { html, define, defrag } from 'typed-dom/dom';
|
|
9
9
|
import { memoize } from 'spica/memoize';
|
|
10
10
|
import { shift } from 'spica/array';
|
|
11
11
|
|
|
@@ -31,17 +31,17 @@ export const olist_: OListParser = lazy(() => block(union([
|
|
|
31
31
|
memoize(ms => list(type(ms[1]), '('), ms => type(ms[1]).charCodeAt(0) || 0, [])),
|
|
32
32
|
])));
|
|
33
33
|
|
|
34
|
-
const list = (type: string,
|
|
34
|
+
const list = (type: string, form: string): OListParser.ListParser => fmap(
|
|
35
35
|
some(creator(union([
|
|
36
36
|
indexee(fmap(fallback(
|
|
37
37
|
inits([
|
|
38
|
-
line(open(heads[
|
|
38
|
+
line(open(heads[form], trim(subsequence([checkbox, trimStart(some(union([indexer, inline])))])), true)),
|
|
39
39
|
indent(union([ulist_, olist_, ilist_])),
|
|
40
40
|
]),
|
|
41
41
|
invalid),
|
|
42
42
|
(ns: [string, ...(HTMLElement | string)[]]) => [html('li', { 'data-marker': ns[0] }, defrag(fillFirstLine(shift(ns)[1])))]), true),
|
|
43
43
|
]))),
|
|
44
|
-
es => [format(html('ol', es), type,
|
|
44
|
+
es => [format(html('ol', es), type, form)]);
|
|
45
45
|
|
|
46
46
|
const heads = {
|
|
47
47
|
'.': focus(
|
|
@@ -107,13 +107,13 @@ function initial(type: string): RegExp {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
function format(el: HTMLOListElement, type: string,
|
|
110
|
+
function format(el: HTMLOListElement, type: string, form: string): HTMLOListElement {
|
|
111
111
|
if (el.firstElementChild?.firstElementChild?.classList.contains('checkbox')) {
|
|
112
112
|
el.setAttribute('class', 'checklist');
|
|
113
113
|
}
|
|
114
114
|
define(el, {
|
|
115
115
|
type: type || undefined,
|
|
116
|
-
'data-format':
|
|
116
|
+
'data-format': form === '.' ? undefined : 'paren',
|
|
117
117
|
'data-type': style(type) || undefined,
|
|
118
118
|
});
|
|
119
119
|
const marker = el.firstElementChild?.getAttribute('data-marker')!.match(initial(type))?.[0] ?? '';
|
|
@@ -3,7 +3,7 @@ import { union, some, block, trim, fmap } from '../../combinator';
|
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { localize } from '../locale';
|
|
5
5
|
import { visualize } from '../util';
|
|
6
|
-
import { html, defrag } from 'typed-dom';
|
|
6
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
|
|
8
8
|
export const paragraph: ParagraphParser = block(localize(fmap(
|
|
9
9
|
trim(visualize(some(union([inline])))),
|
|
@@ -2,7 +2,7 @@ import { ReplyParser } from '../../block';
|
|
|
2
2
|
import { union, tails, line, validate, focus, creator, reverse, fmap } from '../../../combinator';
|
|
3
3
|
import { anchor } from '../../inline/autolink/anchor';
|
|
4
4
|
import { str } from '../../source';
|
|
5
|
-
import { html, define, defrag } from 'typed-dom';
|
|
5
|
+
import { html, define, defrag } from 'typed-dom/dom';
|
|
6
6
|
|
|
7
7
|
export const cite: ReplyParser.CiteParser = creator(line(fmap(validate(
|
|
8
8
|
'>>',
|
|
@@ -4,7 +4,7 @@ import { union, some, block, line, validate, rewrite, creator, lazy, fmap } from
|
|
|
4
4
|
import { math } from '../../inline/math';
|
|
5
5
|
import { str, anyline } from '../../source';
|
|
6
6
|
import { autolink } from '../../autolink';
|
|
7
|
-
import { html, defrag } from 'typed-dom';
|
|
7
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
8
8
|
|
|
9
9
|
export const syntax = /^>+(?=[^\S\n])|^>(?=[^\s>])|^>+(?=[^\s>])(?![0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:]))/;
|
|
10
10
|
|
|
@@ -6,7 +6,7 @@ import { inline } from '../inline';
|
|
|
6
6
|
import { anyline } from '../source';
|
|
7
7
|
import { localize } from '../locale';
|
|
8
8
|
import { visualize } from '../util';
|
|
9
|
-
import { html, defrag } from 'typed-dom';
|
|
9
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
10
10
|
import { push, pop } from 'spica/array';
|
|
11
11
|
|
|
12
12
|
/*
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { sidefence } from './sidefence';
|
|
2
|
+
import { some } from '../../combinator';
|
|
3
|
+
import { inspect } from '../../debug.test';
|
|
4
|
+
|
|
5
|
+
describe('Unit: parser/block/sidefence', () => {
|
|
6
|
+
describe('sidefence', () => {
|
|
7
|
+
const parser = (source: string) => some(sidefence)(source, {});
|
|
8
|
+
|
|
9
|
+
it('invalid', () => {
|
|
10
|
+
assert.deepStrictEqual(inspect(parser('')), undefined);
|
|
11
|
+
assert.deepStrictEqual(inspect(parser('\n')), undefined);
|
|
12
|
+
assert.deepStrictEqual(inspect(parser('|')), undefined);
|
|
13
|
+
assert.deepStrictEqual(inspect(parser('|a')), undefined);
|
|
14
|
+
assert.deepStrictEqual(inspect(parser('|\n')), undefined);
|
|
15
|
+
assert.deepStrictEqual(inspect(parser(' | ')), undefined);
|
|
16
|
+
assert.deepStrictEqual(inspect(parser('||')), undefined);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('basic', () => {
|
|
20
|
+
assert.deepStrictEqual(inspect(parser('| ')), [['<blockquote class="invalid"></blockquote>'], '']);
|
|
21
|
+
assert.deepStrictEqual(inspect(parser('| \\')), [['<blockquote class="invalid"><pre>\\</pre></blockquote>'], '']);
|
|
22
|
+
assert.deepStrictEqual(inspect(parser('| \\\n')), [['<blockquote class="invalid"><pre>\\</pre></blockquote>'], '']);
|
|
23
|
+
assert.deepStrictEqual(inspect(parser('| a')), [['<blockquote class="invalid"><pre>a</pre></blockquote>'], '']);
|
|
24
|
+
assert.deepStrictEqual(inspect(parser('| a\n')), [['<blockquote class="invalid"><pre>a</pre></blockquote>'], '']);
|
|
25
|
+
assert.deepStrictEqual(inspect(parser('| a\nb')), undefined);
|
|
26
|
+
assert.deepStrictEqual(inspect(parser('| a\n b ')), undefined);
|
|
27
|
+
assert.deepStrictEqual(inspect(parser('| a\n|')), [['<blockquote class="invalid"><pre>a<br></pre></blockquote>'], '']);
|
|
28
|
+
assert.deepStrictEqual(inspect(parser('| a\n>>1')), undefined);
|
|
29
|
+
assert.deepStrictEqual(inspect(parser('| a\n| b ')), [['<blockquote class="invalid"><pre>a<br>b </pre></blockquote>'], '']);
|
|
30
|
+
assert.deepStrictEqual(inspect(parser('| a\n|\n')), [['<blockquote class="invalid"><pre>a<br></pre></blockquote>'], '']);
|
|
31
|
+
assert.deepStrictEqual(inspect(parser('| a\n|\nb')), undefined);
|
|
32
|
+
assert.deepStrictEqual(inspect(parser('| a\n|\n b ')), undefined);
|
|
33
|
+
assert.deepStrictEqual(inspect(parser('| a\n|\n|')), [['<blockquote class="invalid"><pre>a<br><br></pre></blockquote>'], '']);
|
|
34
|
+
assert.deepStrictEqual(inspect(parser('| a\n|\n>>1')), undefined);
|
|
35
|
+
assert.deepStrictEqual(inspect(parser('| a\n|\n| b ')), [['<blockquote class="invalid"><pre>a<br><br>b </pre></blockquote>'], '']);
|
|
36
|
+
assert.deepStrictEqual(inspect(parser('| a\\\nb')), undefined);
|
|
37
|
+
assert.deepStrictEqual(inspect(parser('| a ')), [['<blockquote class="invalid"><pre> a </pre></blockquote>'], '']);
|
|
38
|
+
assert.deepStrictEqual(inspect(parser('| \na')), undefined);
|
|
39
|
+
assert.deepStrictEqual(inspect(parser('|\na')), undefined);
|
|
40
|
+
assert.deepStrictEqual(inspect(parser('|\n a')), undefined);
|
|
41
|
+
assert.deepStrictEqual(inspect(parser('|\n|')), [['<blockquote class="invalid"><pre><br></pre></blockquote>'], '']);
|
|
42
|
+
assert.deepStrictEqual(inspect(parser('|\n| a')), [['<blockquote class="invalid"><pre><br>a</pre></blockquote>'], '']);
|
|
43
|
+
assert.deepStrictEqual(inspect(parser('| http://host')), [['<blockquote class="invalid"><pre><a href="http://host" target="_blank">http://host</a></pre></blockquote>'], '']);
|
|
44
|
+
assert.deepStrictEqual(inspect(parser('| !http://host')), [['<blockquote class="invalid"><pre>!<a href="http://host" target="_blank">http://host</a></pre></blockquote>'], '']);
|
|
45
|
+
assert.deepStrictEqual(inspect(parser('| #a')), [['<blockquote class="invalid"><pre><a href="/hashtags/a" class="hashtag">#a</a></pre></blockquote>'], '']);
|
|
46
|
+
assert.deepStrictEqual(inspect(parser('| @a#b')), [['<blockquote class="invalid"><pre><a href="/@a?ch=b" class="channel">@a#b</a></pre></blockquote>'], '']);
|
|
47
|
+
assert.deepStrictEqual(inspect(parser('| >>1\n| | b')), [['<blockquote class="invalid"><pre><a href="?at=1" class="anchor">>>1</a><br>| b</pre></blockquote>'], '']);
|
|
48
|
+
assert.deepStrictEqual(inspect(parser('| >>1\n| | b\n| c')), [['<blockquote class="invalid"><pre><a href="?at=1" class="anchor">>>1</a><br>| b<br>c</pre></blockquote>'], '']);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('nest', () => {
|
|
52
|
+
assert.deepStrictEqual(inspect(parser('| a\n||')), [['<blockquote class="invalid"><pre>a</pre><blockquote></blockquote></blockquote>'], '']);
|
|
53
|
+
assert.deepStrictEqual(inspect(parser('| a\n|| b\n| c')), [['<blockquote class="invalid"><pre>a</pre><blockquote><pre>b</pre></blockquote><pre>c</pre></blockquote>'], '']);
|
|
54
|
+
assert.deepStrictEqual(inspect(parser('| a\n|| b\n|| c')), [['<blockquote class="invalid"><pre>a</pre><blockquote><pre>b<br>c</pre></blockquote></blockquote>'], '']);
|
|
55
|
+
assert.deepStrictEqual(inspect(parser('| a\n|| b\n||| c')), [['<blockquote class="invalid"><pre>a</pre><blockquote><pre>b</pre><blockquote><pre>c</pre></blockquote></blockquote></blockquote>'], '']);
|
|
56
|
+
assert.deepStrictEqual(inspect(parser('|| a')), [['<blockquote class="invalid"><blockquote><pre>a</pre></blockquote></blockquote>'], '']);
|
|
57
|
+
assert.deepStrictEqual(inspect(parser('|| a\n|')), [['<blockquote class="invalid"><blockquote><pre>a</pre></blockquote></blockquote>'], '']);
|
|
58
|
+
assert.deepStrictEqual(inspect(parser('|| a\n| b')), [['<blockquote class="invalid"><blockquote><pre>a</pre></blockquote><pre>b</pre></blockquote>'], '']);
|
|
59
|
+
assert.deepStrictEqual(inspect(parser('|| a\n||| b\n| c')), [['<blockquote class="invalid"><blockquote><pre>a</pre><blockquote><pre>b</pre></blockquote></blockquote><pre>c</pre></blockquote>'], '']);
|
|
60
|
+
assert.deepStrictEqual(inspect(parser('|| a\n| b\n||| c')), [['<blockquote class="invalid"><blockquote><pre>a</pre></blockquote><pre>b</pre><blockquote><blockquote><pre>c</pre></blockquote></blockquote></blockquote>'], '']);
|
|
61
|
+
assert.deepStrictEqual(inspect(parser('||| a\n|| b\n| c')), [['<blockquote class="invalid"><blockquote><blockquote><pre>a</pre></blockquote><pre>b</pre></blockquote><pre>c</pre></blockquote>'], '']);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SidefenceParser } from '../block';
|
|
2
|
+
import { union, some, block, focus, rewrite, creator, convert, lazy, fmap } from '../../combinator';
|
|
3
|
+
import { autolink } from '../autolink';
|
|
4
|
+
import { contentline } from '../source';
|
|
5
|
+
import { html, define, defrag } from 'typed-dom/dom';
|
|
6
|
+
|
|
7
|
+
export const sidefence: SidefenceParser = lazy(() => block(fmap(focus(
|
|
8
|
+
/^(?=\|+(?:[^\S\n]|\n\|))(?:\|+(?:[^\S\n][^\n]*)?(?:$|\n))+$/,
|
|
9
|
+
union([source])),
|
|
10
|
+
([el]) => [
|
|
11
|
+
define(el, {
|
|
12
|
+
class: 'invalid',
|
|
13
|
+
'data-invalid-syntax': 'sidefence',
|
|
14
|
+
'data-invalid-type': 'syntax',
|
|
15
|
+
'data-invalid-message': 'Reserved syntax',
|
|
16
|
+
}),
|
|
17
|
+
])));
|
|
18
|
+
|
|
19
|
+
const opener = /^(?=\|\|+(?:$|\s))/;
|
|
20
|
+
const unindent = (source: string) => source.replace(/(^|\n)\|(?:[^\S\n]|(?=\|*(?:$|\s)))|\n$/g, '$1');
|
|
21
|
+
|
|
22
|
+
const source: SidefenceParser.SourceParser = lazy(() => fmap(
|
|
23
|
+
some(creator(union([
|
|
24
|
+
focus(
|
|
25
|
+
/^(?:\|\|+(?:[^\S\n][^\n]*)?(?:$|\n))+/,
|
|
26
|
+
convert(unindent, source)),
|
|
27
|
+
rewrite(
|
|
28
|
+
some(contentline, opener),
|
|
29
|
+
convert(unindent, fmap(some(autolink), ns => [html('pre', defrag(ns))]))),
|
|
30
|
+
]))),
|
|
31
|
+
ns => [html('blockquote', ns)]));
|
|
@@ -2,7 +2,7 @@ import { TableParser } from '../block';
|
|
|
2
2
|
import { union, sequence, some, block, line, validate, focus, rewrite, creator, surround, open, fallback, lazy, fmap } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { contentline } from '../source';
|
|
5
|
-
import { html, defrag } from 'typed-dom';
|
|
5
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
6
6
|
import { push } from 'spica/array';
|
|
7
7
|
|
|
8
8
|
import RowParser = TableParser.RowParser;
|
|
@@ -3,7 +3,7 @@ import { union, inits, subsequence, some, block, line, validate, indent, focus,
|
|
|
3
3
|
import { olist_ } from './olist';
|
|
4
4
|
import { ilist_ } from './ilist';
|
|
5
5
|
import { inline, indexer, indexee } from '../inline';
|
|
6
|
-
import { html, defrag } from 'typed-dom';
|
|
6
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
import { contentline } from '../source';
|
|
9
9
|
|
package/src/parser/block.ts
CHANGED
|
@@ -9,13 +9,15 @@ import { olist } from './block/olist';
|
|
|
9
9
|
import { ilist } from './block/ilist';
|
|
10
10
|
import { dlist } from './block/dlist';
|
|
11
11
|
import { table } from './block/table';
|
|
12
|
-
import {
|
|
12
|
+
import { indentblock } from './block/indentblock';
|
|
13
13
|
import { codeblock } from './block/codeblock';
|
|
14
14
|
import { mathblock } from './block/mathblock';
|
|
15
15
|
import { extension } from './block/extension';
|
|
16
|
+
import { sidefence } from './block/sidefence';
|
|
17
|
+
import { blockquote } from './block/blockquote';
|
|
16
18
|
import { reply } from './block/reply';
|
|
17
19
|
import { paragraph } from './block/paragraph';
|
|
18
|
-
import { html } from 'typed-dom';
|
|
20
|
+
import { html } from 'typed-dom/dom';
|
|
19
21
|
import { rnd0Z } from 'spica/random';
|
|
20
22
|
|
|
21
23
|
export import BlockParser = MarkdownParser.BlockParser;
|
|
@@ -26,9 +28,11 @@ export import OListParser = BlockParser.OListParser;
|
|
|
26
28
|
export import IListParser = BlockParser.IListParser;
|
|
27
29
|
export import DListParser = BlockParser.DListParser;
|
|
28
30
|
export import TableParser = BlockParser.TableParser;
|
|
31
|
+
export import IndentBlockParser = BlockParser.IndentBlockParser;
|
|
29
32
|
export import CodeBlockParser = BlockParser.CodeBlockParser;
|
|
30
33
|
export import MathBlockParser = BlockParser.MathBlockParser;
|
|
31
34
|
export import ExtensionParser = BlockParser.ExtensionParser;
|
|
35
|
+
export import SidefenceParser = BlockParser.SidefenceParser;
|
|
32
36
|
export import BlockquoteParser = BlockParser.BlockquoteParser;
|
|
33
37
|
export import ReplyParser = BlockParser.ReplyParser;
|
|
34
38
|
export import ParagraphParser = BlockParser.ParagraphParser;
|
|
@@ -44,9 +48,11 @@ export const block: BlockParser = creator(error(
|
|
|
44
48
|
ilist,
|
|
45
49
|
dlist,
|
|
46
50
|
table,
|
|
51
|
+
indentblock,
|
|
47
52
|
codeblock,
|
|
48
53
|
mathblock,
|
|
49
54
|
extension,
|
|
55
|
+
sidefence,
|
|
50
56
|
blockquote,
|
|
51
57
|
reply,
|
|
52
58
|
paragraph
|
package/src/parser/header.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { union, inits, some, block, line, validate, focus, rewrite, guard, clear
|
|
|
3
3
|
import { segment } from './segment';
|
|
4
4
|
import { str } from './source';
|
|
5
5
|
import { normalize } from './api/normalize';
|
|
6
|
-
import { html, defrag } from 'typed-dom';
|
|
6
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
|
|
8
8
|
export const header: MarkdownParser.HeaderParser = lazy(() => validate(
|
|
9
9
|
/^---+[^\S\v\f\r\n]*\r?\n[^\S\n]*(?=\S)/,
|
|
@@ -3,7 +3,7 @@ import { AnnotationParser } from '../inline';
|
|
|
3
3
|
import { union, some, validate, guard, context, creator, surround, lazy, fmap } from '../../combinator';
|
|
4
4
|
import { inline } from '../inline';
|
|
5
5
|
import { startLoose, trimSpaceStart, trimNodeEnd } from '../util';
|
|
6
|
-
import { html, defrag } from 'typed-dom';
|
|
6
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
|
|
8
8
|
export const annotation: AnnotationParser = lazy(() => creator(validate('((', '))', '\n', fmap(surround(
|
|
9
9
|
'((',
|
|
@@ -2,7 +2,7 @@ import { AutolinkParser } from '../../inline';
|
|
|
2
2
|
import { union, tails, verify, rewrite, context, open, convert, fmap, lazy } from '../../../combinator';
|
|
3
3
|
import { link } from '../link';
|
|
4
4
|
import { str } from '../../source';
|
|
5
|
-
import { define } from 'typed-dom';
|
|
5
|
+
import { define } from 'typed-dom/dom';
|
|
6
6
|
|
|
7
7
|
// https://example/@user must be a user page or a redirect page going there.
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AutolinkParser } from '../../inline';
|
|
2
2
|
import { union, validate, focus, context, convert, fmap, lazy } from '../../../combinator';
|
|
3
3
|
import { link } from '../link';
|
|
4
|
-
import { define } from 'typed-dom';
|
|
4
|
+
import { define } from 'typed-dom/dom';
|
|
5
5
|
|
|
6
6
|
// Timeline(pseudonym): user/tid
|
|
7
7
|
// Thread(anonymous): cid
|
|
@@ -3,7 +3,7 @@ import { sequence, some, validate, bind } from '../../../combinator';
|
|
|
3
3
|
import { account } from './account';
|
|
4
4
|
import { hashtag } from './hashtag';
|
|
5
5
|
import { stringify } from '../../util';
|
|
6
|
-
import { define } from 'typed-dom';
|
|
6
|
+
import { define } from 'typed-dom/dom';
|
|
7
7
|
|
|
8
8
|
// https://example/@user?ch=a+b must be a user channel page or a redirect page going there.
|
|
9
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AutolinkParser } from '../../inline';
|
|
2
2
|
import { verify, rewrite, creator } from '../../../combinator';
|
|
3
3
|
import { str } from '../../source';
|
|
4
|
-
import { html } from 'typed-dom';
|
|
4
|
+
import { html } from 'typed-dom/dom';
|
|
5
5
|
|
|
6
6
|
// https://html.spec.whatwg.org/multipage/input.html
|
|
7
7
|
|
|
@@ -3,7 +3,7 @@ import { union, rewrite, context, open, convert, fmap, lazy } from '../../../com
|
|
|
3
3
|
import { link } from '../link';
|
|
4
4
|
import { emoji } from './hashtag';
|
|
5
5
|
import { str } from '../../source';
|
|
6
|
-
import { define } from 'typed-dom';
|
|
6
|
+
import { define } from 'typed-dom/dom';
|
|
7
7
|
|
|
8
8
|
export const hashnum: AutolinkParser.HashnumParser = lazy(() => fmap(rewrite(
|
|
9
9
|
open('#', str(new RegExp(String.raw`^[0-9]{1,16}(?![^\p{C}\p{S}\p{P}\s]|${emoji}|['_])`, 'u'))),
|
|
@@ -2,7 +2,7 @@ import { AutolinkParser } from '../../inline';
|
|
|
2
2
|
import { union, tails, verify, rewrite, context, open, convert, fmap, lazy } from '../../../combinator';
|
|
3
3
|
import { link } from '../link';
|
|
4
4
|
import { str } from '../../source';
|
|
5
|
-
import { define } from 'typed-dom';
|
|
5
|
+
import { define } from 'typed-dom/dom';
|
|
6
6
|
|
|
7
7
|
// https://example/hashtags/a must be a hashtag page or a redirect page going there.
|
|
8
8
|
|
|
@@ -3,7 +3,7 @@ import { BracketParser } from '../inline';
|
|
|
3
3
|
import { union, some, creator, surround, lazy } from '../../combinator';
|
|
4
4
|
import { inline } from '../inline';
|
|
5
5
|
import { str } from '../source';
|
|
6
|
-
import { html, defrag } from 'typed-dom';
|
|
6
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
import { unshift, push } from 'spica/array';
|
|
8
8
|
|
|
9
9
|
const index = /^(?:[0-9]+(?:(?:[.-]|, )[0-9]+)*|[A-Za-z])/;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CodeParser } from '../inline';
|
|
2
2
|
import { validate, creator, match } from '../../combinator';
|
|
3
|
-
import { html } from 'typed-dom';
|
|
3
|
+
import { html } from 'typed-dom/dom';
|
|
4
4
|
|
|
5
5
|
export const code: CodeParser = creator(validate('`', match(
|
|
6
6
|
/^(`+)(?!`)([^\n]*?[^`\n])\1(?!`)/,
|
|
@@ -2,7 +2,7 @@ import { CommentParser } from '../inline';
|
|
|
2
2
|
import { union, some, validate, creator, surround, open, close, match, lazy } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { text, str } from '../source';
|
|
5
|
-
import { html, defrag } from 'typed-dom';
|
|
5
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
6
6
|
import { memoize } from 'spica/memoize';
|
|
7
7
|
import { unshift, push } from 'spica/array';
|
|
8
8
|
|
|
@@ -3,7 +3,7 @@ import { union, some, creator, surround, open, lazy } from '../../combinator';
|
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
5
|
import { blank } from '../util';
|
|
6
|
-
import { html, defrag } from 'typed-dom';
|
|
6
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
|
|
9
9
|
export const deletion: DeletionParser = lazy(() => creator(surround(
|
|
@@ -4,7 +4,7 @@ import { inline } from '../inline';
|
|
|
4
4
|
import { strong } from './strong';
|
|
5
5
|
import { str } from '../source';
|
|
6
6
|
import { startTight, blank } from '../util';
|
|
7
|
-
import { html, defrag } from 'typed-dom';
|
|
7
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
8
8
|
import { unshift } from 'spica/array';
|
|
9
9
|
|
|
10
10
|
export const emphasis: EmphasisParser = lazy(() => creator(surround(
|
|
@@ -6,7 +6,7 @@ import { inline } from '../inline';
|
|
|
6
6
|
import { strong } from './strong';
|
|
7
7
|
import { str } from '../source';
|
|
8
8
|
import { startTight, blank } from '../util';
|
|
9
|
-
import { html, defrag } from 'typed-dom';
|
|
9
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
10
10
|
import { unshift } from 'spica/array';
|
|
11
11
|
|
|
12
12
|
const substrong: IntermediateParser<StrongParser> = lazy(() => some(union([
|
|
@@ -5,7 +5,7 @@ import { inline } from '../../inline';
|
|
|
5
5
|
import { indexee, identity } from './indexee';
|
|
6
6
|
import { txt, str, stropt } from '../../source';
|
|
7
7
|
import { startTight, trimNodeEnd } from '../../util';
|
|
8
|
-
import { html, define, defrag } from 'typed-dom';
|
|
8
|
+
import { html, define, defrag } from 'typed-dom/dom';
|
|
9
9
|
import { join } from 'spica/array';
|
|
10
10
|
|
|
11
11
|
import IndexParser = ExtensionParser.IndexParser;
|
|
@@ -2,7 +2,7 @@ import { undefined } from 'spica/global';
|
|
|
2
2
|
import { MarkdownParser } from '../../../../markdown';
|
|
3
3
|
import { Parser } from '../../../combinator/data/parser';
|
|
4
4
|
import { fmap } from '../../../combinator';
|
|
5
|
-
import { define } from 'typed-dom';
|
|
5
|
+
import { define } from 'typed-dom/dom';
|
|
6
6
|
|
|
7
7
|
export function indexee<P extends Parser<unknown, MarkdownParser.Context>>(parser: P, optional?: boolean): P;
|
|
8
8
|
export function indexee(parser: Parser<HTMLElement, MarkdownParser.Context>, optional?: boolean): Parser<HTMLElement> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExtensionParser } from '../../inline';
|
|
2
2
|
import { union, verify, focus, creator, context, surround, fmap } from '../../../combinator';
|
|
3
3
|
import { index } from './index';
|
|
4
|
-
import { html } from 'typed-dom';
|
|
4
|
+
import { html } from 'typed-dom/dom';
|
|
5
5
|
|
|
6
6
|
export const indexer: ExtensionParser.IndexerParser = creator(fmap(verify(surround(
|
|
7
7
|
/^\s+(?=\[#\S)/,
|
|
@@ -2,7 +2,7 @@ import { Array } from 'spica/global';
|
|
|
2
2
|
import { ExtensionParser } from '../../inline';
|
|
3
3
|
import { union, validate, guard, creator, surround, clear, fmap } from '../../../combinator';
|
|
4
4
|
import { str } from '../../source';
|
|
5
|
-
import { html } from 'typed-dom';
|
|
5
|
+
import { html } from 'typed-dom/dom';
|
|
6
6
|
import { join } from 'spica/array';
|
|
7
7
|
|
|
8
8
|
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]))/);
|
|
@@ -3,7 +3,7 @@ import { union, some, validate, creator, surround, lazy } from '../../../combina
|
|
|
3
3
|
import { inline } from '../../inline';
|
|
4
4
|
import { str } from '../../source';
|
|
5
5
|
import { startTight } from '../../util';
|
|
6
|
-
import { html, defrag } from 'typed-dom';
|
|
6
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
|
|
9
9
|
// Don't use the symbols already used: !#$@&*+~=
|
|
@@ -14,12 +14,12 @@ export const placeholder: ExtensionParser.PlaceholderParser = lazy(() => creator
|
|
|
14
14
|
str(/^\[[:^]/),
|
|
15
15
|
startTight(some(union([inline]), ']')),
|
|
16
16
|
str(']'), false,
|
|
17
|
-
([, bs], rest) => [[
|
|
17
|
+
([as, bs], rest) => [[
|
|
18
18
|
html('span', {
|
|
19
19
|
class: 'invalid',
|
|
20
20
|
'data-invalid-syntax': 'extension',
|
|
21
21
|
'data-invalid-type': 'syntax',
|
|
22
|
-
'data-invalid-message':
|
|
22
|
+
'data-invalid-message': `Reserved start symbol "${as[0][1]}" cannot be used in "[]"`,
|
|
23
23
|
}, defrag(bs)),
|
|
24
24
|
], rest],
|
|
25
25
|
([as, bs], rest) => [unshift(as, bs), rest]))));
|
|
@@ -6,7 +6,7 @@ import { union, some, validate, context, creator, surround, open, match, lazy }
|
|
|
6
6
|
import { inline } from '../inline';
|
|
7
7
|
import { str } from '../source';
|
|
8
8
|
import { startLoose, blank } from '../util';
|
|
9
|
-
import { html as h, defrag } from 'typed-dom';
|
|
9
|
+
import { html as h, defrag } from 'typed-dom/dom';
|
|
10
10
|
import { memoize } from 'spica/memoize';
|
|
11
11
|
import { Cache } from 'spica/cache';
|
|
12
12
|
import { unshift, push, splice, join } from 'spica/array';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { HTMLEntityParser, UnsafeHTMLEntityParser } from '../inline';
|
|
3
3
|
import { union, validate, focus, creator, fmap } from '../../combinator';
|
|
4
|
-
import { html } from 'typed-dom';
|
|
4
|
+
import { html } from 'typed-dom/dom';
|
|
5
5
|
import { reduce } from 'spica/memoize';
|
|
6
6
|
|
|
7
7
|
export const unsafehtmlentity: UnsafeHTMLEntityParser = creator(validate('&', focus(
|
|
@@ -3,7 +3,7 @@ import { union, some, creator, surround, open, lazy } from '../../combinator';
|
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
5
|
import { blank } from '../util';
|
|
6
|
-
import { html, defrag } from 'typed-dom';
|
|
6
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
|
|
9
9
|
export const insertion: InsertionParser = lazy(() => creator(surround(
|
|
@@ -8,7 +8,7 @@ import { attributes } from './html';
|
|
|
8
8
|
import { autolink } from '../autolink';
|
|
9
9
|
import { str } from '../source';
|
|
10
10
|
import { startLoose, trimSpaceStart, trimNodeEnd, stringify } from '../util';
|
|
11
|
-
import { html, define, defrag } from 'typed-dom';
|
|
11
|
+
import { html, define, defrag } from 'typed-dom/dom';
|
|
12
12
|
import { ReadonlyURL } from 'spica/url';
|
|
13
13
|
|
|
14
14
|
const optspec = {
|
|
@@ -3,7 +3,7 @@ import { union, some, creator, surround, open, lazy } from '../../combinator';
|
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
5
|
import { startTight, blank } from '../util';
|
|
6
|
-
import { html, defrag } from 'typed-dom';
|
|
6
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
|
|
9
9
|
export const mark: MarkParser = lazy(() => creator(surround(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MathParser } from '../inline';
|
|
2
2
|
import { union, some, validate, rewrite, creator, surround, lazy } from '../../combinator';
|
|
3
3
|
import { escsource, str } from '../source';
|
|
4
|
-
import { html } from 'typed-dom';
|
|
4
|
+
import { html } from 'typed-dom/dom';
|
|
5
5
|
|
|
6
6
|
const disallowedCommand = /\\(?:begin|tiny|huge|large)(?![0-9a-z])/i;
|
|
7
7
|
|
|
@@ -6,7 +6,7 @@ import { link, uri, option as linkoption, resolve } from './link';
|
|
|
6
6
|
import { attributes } from './html';
|
|
7
7
|
import { unsafehtmlentity } from './htmlentity';
|
|
8
8
|
import { txt, str } from '../source';
|
|
9
|
-
import { html, define } from 'typed-dom';
|
|
9
|
+
import { html, define } from 'typed-dom/dom';
|
|
10
10
|
import { ReadonlyURL } from 'spica/url';
|
|
11
11
|
import { unshift, push, join } from 'spica/array';
|
|
12
12
|
|
|
@@ -4,7 +4,7 @@ import { union, subsequence, some, validate, verify, focus, guard, context, crea
|
|
|
4
4
|
import { inline } from '../inline';
|
|
5
5
|
import { str } from '../source';
|
|
6
6
|
import { startLoose, isStartLoose, trimSpaceStart, trimNodeEnd, stringify } from '../util';
|
|
7
|
-
import { html, defrag } from 'typed-dom';
|
|
7
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
8
8
|
|
|
9
9
|
export const reference: ReferenceParser = lazy(() => creator(validate('[[', ']]', '\n', fmap(surround(
|
|
10
10
|
'[[',
|
|
@@ -5,7 +5,7 @@ import { sequence, validate, verify, focus, creator, surround, lazy, bind } from
|
|
|
5
5
|
import { unsafehtmlentity } from './htmlentity';
|
|
6
6
|
import { text as txt } from '../source';
|
|
7
7
|
import { isStartTightNodes } from '../util';
|
|
8
|
-
import { html, defrag } from 'typed-dom';
|
|
8
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
9
9
|
import { unshift, push, join } from 'spica/array';
|
|
10
10
|
|
|
11
11
|
export const ruby: RubyParser = lazy(() => creator(validate('[', ')', '\n', bind(verify(
|
|
@@ -3,7 +3,7 @@ import { union, some, creator, surround, open, lazy } from '../../combinator';
|
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
5
|
import { startTight, blank } from '../util';
|
|
6
|
-
import { html, defrag } from 'typed-dom';
|
|
6
|
+
import { html, defrag } from 'typed-dom/dom';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
|
|
9
9
|
export const strong: StrongParser = lazy(() => creator(surround(
|