securemark 0.240.0 → 0.241.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/design.md +2 -2
- package/dist/securemark.js +1260 -2745
- package/gulpfile.js +1 -1
- package/index.d.ts +0 -1
- package/package-lock.json +285 -160
- package/package.json +8 -8
- package/src/combinator/control/manipulation/fallback.ts +0 -1
- package/src/combinator/control/manipulation/indent.ts +3 -3
- package/src/combinator/data/parser/some.ts +28 -6
- package/src/combinator/data/parser.ts +21 -16
- package/src/debug.test.ts +1 -1
- package/src/parser/api/bind.test.ts +1 -1
- package/src/parser/api/parse.test.ts +7 -1
- package/src/parser/api/parse.ts +1 -1
- package/src/parser/block/blockquote.ts +1 -1
- package/src/parser/block/codeblock.ts +1 -1
- 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/figbase.ts +1 -1
- package/src/parser/block/extension/figure.ts +21 -20
- package/src/parser/block/extension/message.ts +1 -1
- package/src/parser/block/extension/placeholder.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/heading.ts +1 -1
- package/src/parser/block/horizontalrule.ts +1 -1
- package/src/parser/block/ilist.ts +1 -1
- package/src/parser/block/mathblock.ts +1 -1
- package/src/parser/block/olist.ts +8 -8
- 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/table.ts +1 -1
- package/src/parser/block/ulist.ts +1 -1
- package/src/parser/block.ts +1 -1
- package/src/parser/header.ts +1 -1
- package/src/parser/inline/annotation.ts +2 -2
- 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.test.ts +5 -1
- package/src/parser/inline/bracket.ts +3 -3
- package/src/parser/inline/code.ts +1 -1
- package/src/parser/inline/comment.ts +2 -2
- 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 +1 -1
- 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 +2 -2
- 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/inline.test.ts +4 -0
- package/src/parser/locale.ts +1 -1
- package/src/parser/processor/figure.test.ts +1 -1
- package/src/parser/processor/figure.ts +1 -1
- package/src/parser/processor/footnote.test.ts +1 -1
- package/src/parser/processor/footnote.ts +5 -4
- 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/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
|
@@ -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
|
|
|
@@ -16,12 +16,16 @@ describe('Unit: parser/inline/bracket', () => {
|
|
|
16
16
|
assert.deepStrictEqual(inspect(parser('(1)')), [['(', '1', ')'], '']);
|
|
17
17
|
assert.deepStrictEqual(inspect(parser('(10)')), [['(', '10', ')'], '']);
|
|
18
18
|
assert.deepStrictEqual(inspect(parser('(2000)')), [['(', '2000', ')'], '']);
|
|
19
|
-
assert.deepStrictEqual(inspect(parser('(
|
|
19
|
+
assert.deepStrictEqual(inspect(parser('(1, 2)')), [['(', '1, 2', ')'], '']);
|
|
20
|
+
assert.deepStrictEqual(inspect(parser('(0-1)')), [['(', '0-1', ')'], '']);
|
|
20
21
|
assert.deepStrictEqual(inspect(parser('(0)-1')), [['(', '0', ')'], '-1']);
|
|
21
22
|
assert.deepStrictEqual(inspect(parser('(0.1)')), [['(', '0.1', ')'], '']);
|
|
22
23
|
assert.deepStrictEqual(inspect(parser('(0.1.2)')), [['(', '0.1.2', ')'], '']);
|
|
24
|
+
assert.deepStrictEqual(inspect(parser('(1.1, 1.2-1.3, 1.4)')), [['(', '1.1, 1.2-1.3, 1.4', ')'], '']);
|
|
23
25
|
assert.deepStrictEqual(inspect(parser('(a)')), [['(', 'a', ')'], '']);
|
|
24
26
|
assert.deepStrictEqual(inspect(parser('(A)')), [['(', 'A', ')'], '']);
|
|
27
|
+
assert.deepStrictEqual(inspect(parser('(1,2)')), [['(', '1,2', ')'], '']);
|
|
28
|
+
assert.deepStrictEqual(inspect(parser('(0-1)')), [['(', '0-1', ')'], '']);
|
|
25
29
|
assert.deepStrictEqual(inspect(parser('(0.1)(A)')), [['(', '0.1', ')', '(', 'A', ')'], '']);
|
|
26
30
|
});
|
|
27
31
|
|
|
@@ -3,17 +3,17 @@ 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
|
-
const index = /^(?:[0-9]+(
|
|
9
|
+
const index = /^(?:[0-9]+(?:(?:[.-]|, )[0-9]+)*|[A-Za-z])/;
|
|
10
10
|
|
|
11
11
|
export const bracket: BracketParser = lazy(() => creator(union([
|
|
12
12
|
surround(str('('), str(index), str(')')),
|
|
13
13
|
surround(str('('), some(inline, ')'), str(')'), true,
|
|
14
14
|
([as, bs = [], cs], rest) => [[html('span', { class: 'paren' }, defrag(push(unshift(as, bs), cs)))], rest],
|
|
15
15
|
([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
16
|
-
surround(str('('), str(new RegExp(index.source.replace(/[09AZaz
|
|
16
|
+
surround(str('('), str(new RegExp(index.source.replace(/[09AZaz., ]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 0xFEE0)))), str(')')),
|
|
17
17
|
surround(str('('), some(inline, ')'), str(')'), true,
|
|
18
18
|
([as, bs = [], cs], rest) => [[html('span', { class: 'paren' }, defrag(push(unshift(as, bs), cs)))], rest],
|
|
19
19
|
([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
@@ -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
|
|
|
@@ -21,4 +21,4 @@ export const comment: CommentParser = lazy(() => creator(validate('[#', match(
|
|
|
21
21
|
]),
|
|
22
22
|
], rest],
|
|
23
23
|
([as, bs = []], rest) => [unshift(as, bs), rest]),
|
|
24
|
-
([, fence]) => fence.length)))));
|
|
24
|
+
([, fence]) => fence.length, [])))));
|
|
@@ -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: !#$@&*+~=
|
|
@@ -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
|
'[[',
|
|
@@ -19,7 +19,7 @@ export const reference: ReferenceParser = lazy(() => creator(validate('[[', ']]'
|
|
|
19
19
|
//label: true,
|
|
20
20
|
//link: true,
|
|
21
21
|
//autolink: true,
|
|
22
|
-
}}, state: undefined },
|
|
22
|
+
}}, state: undefined, delimiters: undefined },
|
|
23
23
|
subsequence([
|
|
24
24
|
abbr,
|
|
25
25
|
focus(/^\^[^\S\n]*/, source => [['', source], '']),
|
|
@@ -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(
|
|
@@ -2,7 +2,7 @@ import { undefined } from 'spica/global';
|
|
|
2
2
|
import { TemplateParser } from '../inline';
|
|
3
3
|
import { union, some, rewrite, creator, surround, lazy } from '../../combinator';
|
|
4
4
|
import { escsource, str } from '../source';
|
|
5
|
-
import { html } from 'typed-dom';
|
|
5
|
+
import { html } from 'typed-dom/dom';
|
|
6
6
|
import { unshift } from 'spica/array';
|
|
7
7
|
|
|
8
8
|
export const template: TemplateParser = lazy(() => creator(rewrite(
|
|
@@ -144,6 +144,7 @@ describe('Unit: parser/inline', () => {
|
|
|
144
144
|
assert.deepStrictEqual(inspect(parser('(((a))')), [['(', '<sup class="annotation">a</sup>'], '']);
|
|
145
145
|
assert.deepStrictEqual(inspect(parser('((((a))')), [['(', '(', '<sup class="annotation">a</sup>'], '']);
|
|
146
146
|
assert.deepStrictEqual(inspect(parser('((((a))))')), [['<sup class="annotation"><span class="paren">((a))</span></sup>'], '']);
|
|
147
|
+
assert.deepStrictEqual(inspect(parser('"((""))')), [['"', '<sup class="annotation">""</sup>'], '']);
|
|
147
148
|
assert.deepStrictEqual(inspect(parser('[[[a]]')), [['[', '<sup class="reference">a</sup>'], '']);
|
|
148
149
|
assert.deepStrictEqual(inspect(parser('[[[[a]]')), [['[', '[', '<sup class="reference">a</sup>'], '']);
|
|
149
150
|
assert.deepStrictEqual(inspect(parser('[[[[a]]]]')), [['<sup class="reference">[[a]]</sup>'], '']);
|
|
@@ -151,6 +152,7 @@ describe('Unit: parser/inline', () => {
|
|
|
151
152
|
assert.deepStrictEqual(inspect(parser('[[[]{a}]]')), [['<sup class="reference"><a href="a">a</a></sup>'], '']);
|
|
152
153
|
assert.deepStrictEqual(inspect(parser('[[[a]{b}]]')), [['<sup class="reference"><a href="b">a</a></sup>'], '']);
|
|
153
154
|
assert.deepStrictEqual(inspect(parser('[(([a]{#}))]{#}')), [['<a href="#"><span class="paren">(<span class="paren">([a]{#})</span>)</span></a>'], '']);
|
|
155
|
+
assert.deepStrictEqual(inspect(parser('"[[""]]')), [['"', '<sup class="reference">""</sup>'], '']);
|
|
154
156
|
assert.deepStrictEqual(inspect(parser('<http://host>')), [['<', '<a href="http://host" target="_blank">http://host</a>', '>'], '']);
|
|
155
157
|
assert.deepStrictEqual(inspect(parser('<<small>a<</small>')), [['<', '<small>a<</small>'], '']);
|
|
156
158
|
assert.deepStrictEqual(inspect(parser('<sup><sub>a</sub>')), [['<', 'sup', '>', '<sub>a</sub>'], '']);
|
|
@@ -162,6 +164,8 @@ describe('Unit: parser/inline', () => {
|
|
|
162
164
|
assert.deepStrictEqual(inspect(parser('[#a*b\nc*]')), [['[', '<a href="/hashtags/a" class="hashtag">#a</a>', '<em>b<br>c</em>', ']'], '']);
|
|
163
165
|
assert.deepStrictEqual(inspect(parser('[*a\nb*]{/}')), [['[', '<em>a<br>b</em>', ']', '<a href="/">/</a>'], '']);
|
|
164
166
|
assert.deepStrictEqual(inspect(parser('[[*a\nb*]]')), [['[', '[', '<em>a<br>b</em>', ']', ']'], '']);
|
|
167
|
+
assert.deepStrictEqual(inspect(parser('"[# *"*"*')), [['"', '[#', ' ', '*', '"', '*', '"', '*'], '']);
|
|
168
|
+
assert.deepStrictEqual(inspect(parser('"[# "*"* #]')), [['"', '[#', ' ', '"', '*', '"', '*', ' ', '#', ']'], '']);
|
|
165
169
|
});
|
|
166
170
|
|
|
167
171
|
it('uri', () => {
|
package/src/parser/locale.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Parser } from '../combinator/data/parser';
|
|
2
2
|
import { fmap } from '../combinator';
|
|
3
3
|
import { japanese } from './locale/ja';
|
|
4
|
-
import { html } from 'typed-dom';
|
|
4
|
+
import { html } from 'typed-dom/dom';
|
|
5
5
|
|
|
6
6
|
export function localize<P extends Parser<HTMLElement | string>>(parser: P): P;
|
|
7
7
|
export function localize(parser: Parser<HTMLElement | string>): Parser<HTMLElement | string> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { figure } from './figure';
|
|
2
2
|
import { parse as parse_ } from '../../parser';
|
|
3
|
-
import { html } from 'typed-dom';
|
|
3
|
+
import { html } from 'typed-dom/dom';
|
|
4
4
|
import { normalize } from '../../debug.test';
|
|
5
5
|
|
|
6
6
|
const parse = (s: string) => parse_(s, { test: true });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Infinity, Set, Map } from 'spica/global';
|
|
2
2
|
import { number as calculate, isFixed } from '../inline/extension/label';
|
|
3
|
-
import { define } from 'typed-dom';
|
|
3
|
+
import { define } from 'typed-dom/dom';
|
|
4
4
|
import { MultiMap } from 'spica/multimap';
|
|
5
5
|
import { push, join } from 'spica/array';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { undefined, Infinity, Map, WeakMap } from 'spica/global';
|
|
2
2
|
import { text } from '../inline/extension/indexee';
|
|
3
|
-
import { frag, html, define } from 'typed-dom';
|
|
3
|
+
import { frag, html, define } from 'typed-dom/dom';
|
|
4
4
|
import { MultiMap } from 'spica/multimap';
|
|
5
5
|
import { memoize } from 'spica/memoize';
|
|
6
6
|
|
|
@@ -127,12 +127,13 @@ function build(
|
|
|
127
127
|
}
|
|
128
128
|
if (!footnote) return;
|
|
129
129
|
const { children } = footnote;
|
|
130
|
+
const size = defs.size;
|
|
130
131
|
let count = 0;
|
|
131
132
|
let length = children.length;
|
|
132
133
|
I:
|
|
133
134
|
for (const def of defs.values()) {
|
|
134
135
|
++count;
|
|
135
|
-
while (length >
|
|
136
|
+
while (length > size) {
|
|
136
137
|
const node = children[count - 1] as HTMLLIElement;
|
|
137
138
|
if (equal(node, def)) continue I;
|
|
138
139
|
yield footnote.removeChild(node);
|
|
@@ -148,8 +149,8 @@ function build(
|
|
|
148
149
|
++length;
|
|
149
150
|
assert(children.length === length);
|
|
150
151
|
}
|
|
151
|
-
while (length >
|
|
152
|
-
yield footnote.removeChild(children[
|
|
152
|
+
while (length > size) {
|
|
153
|
+
yield footnote.removeChild(children[size] as HTMLLIElement);
|
|
153
154
|
--length;
|
|
154
155
|
assert(children.length === length);
|
|
155
156
|
}
|
|
@@ -2,7 +2,7 @@ import { undefined } from 'spica/global';
|
|
|
2
2
|
import { TextParser, TxtParser, LinebreakParser } from '../source';
|
|
3
3
|
import { union, focus, creator } from '../../combinator';
|
|
4
4
|
import { str } from './str';
|
|
5
|
-
import { html } from 'typed-dom';
|
|
5
|
+
import { html } from 'typed-dom/dom';
|
|
6
6
|
|
|
7
7
|
export const separator = /[\s\x00-\x7F]|\S#|[、。!?][^\S\n]*(?=\\\n)/;
|
|
8
8
|
export const nonWhitespace = /[\S\n]|$/;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { undefined } from 'spica/global';
|
|
2
2
|
import { Collection } from 'spica/collection';
|
|
3
|
-
import { html, define } from 'typed-dom';
|
|
3
|
+
import { html, define } from 'typed-dom/dom';
|
|
4
4
|
|
|
5
5
|
export function math(target: HTMLElement, cache?: Collection<string, HTMLElement>): void {
|
|
6
6
|
assert(target.children.length === 0);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { window, document } from 'spica/global';
|
|
2
2
|
import { parse } from '../../../parser';
|
|
3
|
-
import {
|
|
3
|
+
import { html, define } from 'typed-dom/dom';
|
|
4
4
|
import { sanitize } from 'dompurify';
|
|
5
5
|
|
|
6
6
|
declare global {
|
|
@@ -21,26 +21,24 @@ export function twitter(source: HTMLImageElement, url: URL): HTMLElement | undef
|
|
|
21
21
|
if (!origins.includes(url.origin)) return;
|
|
22
22
|
if (url.pathname.split('/').pop()!.includes('.')) return;
|
|
23
23
|
if (!url.pathname.match(/^\/\w+\/status\/[0-9]{15,}(?!\w)/)) return;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return el;
|
|
45
|
-
}).element;
|
|
24
|
+
const el = html('div', { class: source.className, 'data-type': 'twitter' }, [
|
|
25
|
+
html('em', `Loading ${source.getAttribute('data-src')}...`),
|
|
26
|
+
]);
|
|
27
|
+
$.ajax(`https://publish.twitter.com/oembed?url=${url.href.replace('?', '&')}&omit_script=true`, {
|
|
28
|
+
dataType: 'jsonp',
|
|
29
|
+
timeout: 10 * 1e3,
|
|
30
|
+
cache: true,
|
|
31
|
+
success({ html }): void {
|
|
32
|
+
el.innerHTML = sanitize(html);
|
|
33
|
+
if (window.twttr) return void window.twttr.widgets.load(el);
|
|
34
|
+
const id = 'twitter-wjs';
|
|
35
|
+
if (document.getElementById(id)) return;
|
|
36
|
+
document.body.appendChild(html('script', { id, src: 'https://platform.twitter.com/widgets.js' }));
|
|
37
|
+
},
|
|
38
|
+
error({ status, statusText }) {
|
|
39
|
+
assert(Number.isSafeInteger(status));
|
|
40
|
+
define(el, [parse(`*{ ${source.getAttribute('data-src')} }*\n\n\`\`\`\n${status}\n${statusText}\n\`\`\``)]);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
return el;
|
|
46
44
|
}
|
package/src/util/quote.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Element } from 'spica/global';
|
|
2
2
|
import { exec } from '../combinator/data/parser';
|
|
3
3
|
import { cite } from '../parser/block/reply/cite';
|
|
4
|
-
import { define } from 'typed-dom';
|
|
4
|
+
import { define } from 'typed-dom/dom';
|
|
5
5
|
|
|
6
6
|
export function quote(anchor: string, range: Range): string {
|
|
7
7
|
if (exec(cite(`>>${anchor}`, {})) !== '') throw new Error(`Invalid anchor: ${anchor}`);
|
package/src/util/toc.test.ts
CHANGED
package/src/util/toc.ts
CHANGED
package/src/util.ts
CHANGED