securemark 0.299.4 → 0.300.1
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 +8 -0
- package/design.md +0 -6
- package/dist/index.js +2847 -1993
- package/index.d.ts +2 -1
- package/markdown.d.ts +209 -183
- package/package.json +1 -1
- package/src/api/bind.test.ts +0 -22
- package/src/api/bind.ts +15 -10
- package/src/api/header.ts +8 -5
- package/src/api/parse.test.ts +118 -122
- package/src/api/parse.ts +13 -31
- package/src/api/run.ts +6 -0
- package/src/api.ts +1 -0
- package/src/combinator/control/inits.ts +35 -0
- package/src/combinator/control/sequence.test.ts +38 -0
- package/src/combinator/control/sequence.ts +19 -0
- package/src/combinator/control/some.test.ts +41 -0
- package/src/combinator/{data/parser → control}/some.ts +39 -26
- package/src/combinator/control/state.ts +33 -0
- package/src/combinator/control/subsequence.test.ts +47 -0
- package/src/combinator/control/subsequence.ts +16 -0
- package/src/combinator/control/tails.ts +8 -0
- package/src/combinator/control/union.test.ts +37 -0
- package/src/combinator/control/union.ts +31 -0
- package/src/combinator/{data/delimiter.ts → delimiter.ts} +40 -60
- package/src/combinator/effect/backtrack.ts +64 -0
- package/src/combinator/effect/clock.ts +10 -0
- package/src/combinator/effect/precedence.ts +50 -0
- package/src/combinator/effect/recursion.ts +30 -0
- package/src/combinator/effect/scope.ts +100 -0
- package/src/combinator/effect/state.ts +72 -0
- package/src/combinator/{data/list → parser}/list.ts +35 -10
- package/src/combinator/parser.ts +303 -0
- package/src/combinator/process/bind.ts +34 -0
- package/src/combinator/process/block.test.ts +20 -0
- package/src/combinator/process/block.ts +33 -0
- package/src/combinator/process/clear.ts +16 -0
- package/src/combinator/process/contract.ts +35 -0
- package/src/combinator/process/duplicate.ts +7 -0
- package/src/combinator/process/error.ts +13 -0
- package/src/combinator/{control/manipulation → process}/fallback.ts +3 -3
- package/src/combinator/process/fence.ts +59 -0
- package/src/combinator/process/fmap.ts +10 -0
- package/src/combinator/process/indent.test.ts +31 -0
- package/src/combinator/process/indent.ts +51 -0
- package/src/combinator/process/lazy.ts +8 -0
- package/src/combinator/process/line.test.ts +21 -0
- package/src/combinator/process/line.ts +55 -0
- package/src/combinator/process/match.ts +37 -0
- package/src/combinator/process/reverse.ts +7 -0
- package/src/combinator/process/scope.ts +102 -0
- package/src/combinator/process/surround.ts +273 -0
- package/src/combinator.ts +28 -24
- package/src/debug.test.ts +11 -8
- package/src/parser/autolink.test.ts +17 -18
- package/src/parser/block/blockquote.test.ts +78 -79
- package/src/parser/block/blockquote.ts +32 -25
- package/src/parser/block/codeblock.test.ts +54 -57
- package/src/parser/block/codeblock.ts +44 -26
- package/src/parser/block/dlist.test.ts +56 -57
- package/src/parser/block/dlist.ts +5 -5
- package/src/parser/block/extension/aside.test.ts +7 -9
- package/src/parser/block/extension/aside.ts +76 -47
- package/src/parser/block/extension/example.test.ts +16 -19
- package/src/parser/block/extension/example.ts +88 -48
- package/src/parser/block/extension/fig.test.ts +37 -36
- package/src/parser/block/extension/fig.ts +20 -25
- package/src/parser/block/extension/figbase.test.ts +18 -19
- package/src/parser/block/extension/figbase.ts +3 -3
- package/src/parser/block/extension/figure.test.ts +58 -63
- package/src/parser/block/extension/figure.ts +23 -21
- package/src/parser/block/extension/message.test.ts +12 -14
- package/src/parser/block/extension/message.ts +52 -39
- package/src/parser/block/extension/placeholder.test.ts +13 -13
- package/src/parser/block/extension/placeholder.ts +23 -21
- package/src/parser/block/extension/table.test.ts +69 -71
- package/src/parser/block/extension/table.ts +43 -31
- package/src/parser/block/extension.test.ts +24 -24
- package/src/parser/block/extension.ts +3 -3
- package/src/parser/block/heading.test.ts +58 -59
- package/src/parser/block/heading.ts +19 -18
- package/src/parser/block/ilist.test.ts +8 -8
- package/src/parser/block/ilist.ts +9 -7
- package/src/parser/block/mathblock.test.ts +29 -32
- package/src/parser/block/mathblock.ts +24 -23
- package/src/parser/block/mediablock.ts +7 -7
- package/src/parser/block/olist.test.ts +102 -103
- package/src/parser/block/olist.ts +11 -12
- package/src/parser/block/pagebreak.test.ts +15 -16
- package/src/parser/block/pagebreak.ts +5 -5
- package/src/parser/block/paragraph.test.ts +57 -58
- package/src/parser/block/paragraph.ts +1 -1
- package/src/parser/block/reply/cite.test.ts +39 -40
- package/src/parser/block/reply/cite.ts +5 -5
- package/src/parser/block/reply/quote.test.ts +50 -51
- package/src/parser/block/reply/quote.ts +8 -7
- package/src/parser/block/reply.test.ts +19 -20
- package/src/parser/block/reply.ts +2 -2
- package/src/parser/block/sidefence.test.ts +41 -48
- package/src/parser/block/sidefence.ts +17 -11
- package/src/parser/block/table.test.ts +48 -49
- package/src/parser/block/table.ts +10 -9
- package/src/parser/block/ulist.test.ts +52 -53
- package/src/parser/block/ulist.ts +9 -8
- package/src/parser/block.ts +63 -51
- package/src/parser/context.ts +40 -40
- package/src/parser/document.ts +48 -0
- package/src/parser/header.test.ts +19 -20
- package/src/parser/header.ts +31 -25
- package/src/parser/inline/annotation.test.ts +49 -50
- package/src/parser/inline/annotation.ts +14 -16
- package/src/parser/inline/autolink/account.test.ts +32 -33
- package/src/parser/inline/autolink/account.ts +18 -19
- package/src/parser/inline/autolink/anchor.test.ts +21 -22
- package/src/parser/inline/autolink/anchor.ts +7 -8
- package/src/parser/inline/autolink/channel.test.ts +14 -15
- package/src/parser/inline/autolink/email.test.ts +36 -37
- package/src/parser/inline/autolink/email.ts +6 -6
- package/src/parser/inline/autolink/hashnum.test.ts +32 -33
- package/src/parser/inline/autolink/hashnum.ts +7 -8
- package/src/parser/inline/autolink/hashtag.test.ts +59 -60
- package/src/parser/inline/autolink/hashtag.ts +8 -9
- package/src/parser/inline/autolink/url.test.ts +75 -76
- package/src/parser/inline/autolink/url.ts +17 -18
- package/src/parser/inline/autolink.ts +24 -11
- package/src/parser/inline/bracket.test.ts +73 -74
- package/src/parser/inline/bracket.ts +88 -63
- package/src/parser/inline/code.test.ts +30 -31
- package/src/parser/inline/code.ts +6 -6
- package/src/parser/inline/deletion.test.ts +27 -28
- package/src/parser/inline/deletion.ts +5 -5
- package/src/parser/inline/emphasis.test.ts +39 -40
- package/src/parser/inline/emphasis.ts +5 -5
- package/src/parser/inline/emstrong.test.ts +101 -102
- package/src/parser/inline/emstrong.ts +103 -85
- package/src/parser/inline/extension/index.test.ts +91 -92
- package/src/parser/inline/extension/index.ts +17 -13
- package/src/parser/inline/extension/indexee.ts +4 -4
- package/src/parser/inline/extension/indexer.test.ts +23 -24
- package/src/parser/inline/extension/indexer.ts +6 -5
- package/src/parser/inline/extension/label.test.ts +32 -33
- package/src/parser/inline/extension/label.ts +14 -5
- package/src/parser/inline/extension/placeholder.test.ts +42 -43
- package/src/parser/inline/extension/placeholder.ts +8 -9
- package/src/parser/inline/html.test.ts +109 -109
- package/src/parser/inline/html.ts +27 -27
- package/src/parser/inline/htmlentity.test.ts +37 -38
- package/src/parser/inline/htmlentity.ts +6 -7
- package/src/parser/inline/insertion.test.ts +27 -28
- package/src/parser/inline/insertion.ts +5 -5
- package/src/parser/inline/italic.test.ts +55 -56
- package/src/parser/inline/italic.ts +5 -5
- package/src/parser/inline/link.test.ts +186 -187
- package/src/parser/inline/link.ts +29 -30
- package/src/parser/inline/mark.test.ts +31 -32
- package/src/parser/inline/mark.ts +6 -6
- package/src/parser/inline/math.test.ts +140 -141
- package/src/parser/inline/math.ts +7 -8
- package/src/parser/inline/media.test.ts +92 -93
- package/src/parser/inline/media.ts +35 -41
- package/src/parser/inline/reference.test.ts +111 -112
- package/src/parser/inline/reference.ts +61 -32
- package/src/parser/inline/remark.test.ts +49 -50
- package/src/parser/inline/remark.ts +13 -13
- package/src/parser/inline/ruby.test.ts +49 -50
- package/src/parser/inline/ruby.ts +100 -52
- package/src/parser/inline/shortmedia.test.ts +9 -10
- package/src/parser/inline/shortmedia.ts +11 -9
- package/src/parser/inline/strong.test.ts +36 -37
- package/src/parser/inline/strong.ts +5 -5
- package/src/parser/inline/template.test.ts +22 -23
- package/src/parser/inline/template.ts +17 -20
- package/src/parser/inline.test.ts +225 -226
- package/src/parser/inline.ts +68 -34
- package/src/parser/parser.ts +51 -0
- package/src/parser/repeat.ts +118 -91
- package/src/parser/segment.test.ts +0 -11
- package/src/parser/segment.ts +25 -28
- package/src/parser/source/escapable.test.ts +23 -24
- package/src/parser/source/escapable.ts +19 -20
- package/src/parser/source/line.test.ts +17 -18
- package/src/parser/source/line.ts +19 -24
- package/src/parser/source/str.ts +17 -10
- package/src/parser/source/text.test.ts +88 -89
- package/src/parser/source/text.ts +32 -62
- package/src/parser/source/unescapable.test.ts +23 -24
- package/src/parser/source/unescapable.ts +15 -16
- package/src/parser/source/whitespace.ts +36 -0
- package/src/parser/source.ts +1 -0
- package/src/parser/util.ts +1 -1
- package/src/parser/visibility.ts +37 -15
- package/src/processor/figure.test.ts +20 -20
- package/src/processor/figure.ts +18 -10
- package/src/processor/note.test.ts +13 -13
- package/src/processor/note.ts +4 -2
- package/src/renderer/render/media/pdf.ts +2 -2
- package/src/renderer/render/media/twitter.ts +2 -2
- package/src/renderer/render/media.test.ts +12 -12
- package/src/renderer/render.test.ts +11 -11
- package/src/util/info.test.ts +2 -2
- package/src/util/quote.test.ts +3 -3
- package/src/util/quote.ts +6 -5
- package/src/util/toc.test.ts +12 -12
- package/src/combinator/control/constraint/block.test.ts +0 -20
- package/src/combinator/control/constraint/block.ts +0 -28
- package/src/combinator/control/constraint/contract.ts +0 -27
- package/src/combinator/control/constraint/line.test.ts +0 -21
- package/src/combinator/control/constraint/line.ts +0 -42
- package/src/combinator/control/manipulation/clear.ts +0 -5
- package/src/combinator/control/manipulation/convert.ts +0 -22
- package/src/combinator/control/manipulation/duplicate.ts +0 -7
- package/src/combinator/control/manipulation/fence.ts +0 -54
- package/src/combinator/control/manipulation/indent.test.ts +0 -31
- package/src/combinator/control/manipulation/indent.ts +0 -39
- package/src/combinator/control/manipulation/lazy.ts +0 -8
- package/src/combinator/control/manipulation/match.ts +0 -27
- package/src/combinator/control/manipulation/recovery.ts +0 -18
- package/src/combinator/control/manipulation/reverse.ts +0 -8
- package/src/combinator/control/manipulation/scope.ts +0 -61
- package/src/combinator/control/manipulation/surround.ts +0 -223
- package/src/combinator/control/monad/bind.ts +0 -26
- package/src/combinator/control/monad/fmap.ts +0 -10
- package/src/combinator/data/parser/context.ts +0 -96
- package/src/combinator/data/parser/inits.ts +0 -20
- package/src/combinator/data/parser/sequence.test.ts +0 -33
- package/src/combinator/data/parser/sequence.ts +0 -20
- package/src/combinator/data/parser/some.test.ts +0 -37
- package/src/combinator/data/parser/subsequence.test.ts +0 -41
- package/src/combinator/data/parser/subsequence.ts +0 -13
- package/src/combinator/data/parser/tails.ts +0 -8
- package/src/combinator/data/parser/union.test.ts +0 -33
- package/src/combinator/data/parser/union.ts +0 -18
- package/src/combinator/data/parser.ts +0 -144
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { unescsource } from './unescapable';
|
|
2
2
|
import { some } from '../../combinator';
|
|
3
|
-
import { input } from '
|
|
4
|
-
import { Context } from '../context';
|
|
3
|
+
import { input } from '../context';
|
|
5
4
|
import { inspect } from '../../debug.test';
|
|
6
5
|
|
|
7
6
|
describe('Unit: parser/source/unescapable', () => {
|
|
@@ -9,40 +8,40 @@ describe('Unit: parser/source/unescapable', () => {
|
|
|
9
8
|
const parser = some(unescsource);
|
|
10
9
|
|
|
11
10
|
it('invalid', () => {
|
|
12
|
-
assert.deepStrictEqual(inspect(parser, input(''
|
|
11
|
+
assert.deepStrictEqual(inspect(parser, input('')), undefined);
|
|
13
12
|
});
|
|
14
13
|
|
|
15
14
|
it('basic', () => {
|
|
16
|
-
assert.deepStrictEqual(inspect(parser, input('a'
|
|
17
|
-
assert.deepStrictEqual(inspect(parser, input('ab'
|
|
18
|
-
assert.deepStrictEqual(inspect(parser, input('a b c'
|
|
19
|
-
assert.deepStrictEqual(inspect(parser, input('09あいAZaz'
|
|
15
|
+
assert.deepStrictEqual(inspect(parser, input('a')), [['a'], '']);
|
|
16
|
+
assert.deepStrictEqual(inspect(parser, input('ab')), [['ab'], '']);
|
|
17
|
+
assert.deepStrictEqual(inspect(parser, input('a b c')), [['a', ' b c'], '']);
|
|
18
|
+
assert.deepStrictEqual(inspect(parser, input('09あいAZaz')), [['09', 'あいAZaz'], '']);
|
|
20
19
|
});
|
|
21
20
|
|
|
22
21
|
it('space', () => {
|
|
23
|
-
assert.deepStrictEqual(inspect(parser, input(' '
|
|
24
|
-
assert.deepStrictEqual(inspect(parser, input(' '
|
|
25
|
-
assert.deepStrictEqual(inspect(parser, input(' '
|
|
26
|
-
assert.deepStrictEqual(inspect(parser, input(' \n'
|
|
27
|
-
assert.deepStrictEqual(inspect(parser, input(' \n'
|
|
28
|
-
assert.deepStrictEqual(inspect(parser, input(' \n'
|
|
22
|
+
assert.deepStrictEqual(inspect(parser, input(' ')), [[' '], '']);
|
|
23
|
+
assert.deepStrictEqual(inspect(parser, input(' ')), [[' '], '']);
|
|
24
|
+
assert.deepStrictEqual(inspect(parser, input(' ')), [[' '], '']);
|
|
25
|
+
assert.deepStrictEqual(inspect(parser, input(' \n')), [[' ', '<br>'], '']);
|
|
26
|
+
assert.deepStrictEqual(inspect(parser, input(' \n')), [[' ', '<br>'], '']);
|
|
27
|
+
assert.deepStrictEqual(inspect(parser, input(' \n')), [[' ', '<br>'], '']);
|
|
29
28
|
});
|
|
30
29
|
|
|
31
30
|
it('linebreak', () => {
|
|
32
|
-
assert.deepStrictEqual(inspect(parser, input('\n\n'
|
|
31
|
+
assert.deepStrictEqual(inspect(parser, input('\n\n')), [['<br>', '<br>'], '']);
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
it('\\', () => {
|
|
36
|
-
assert.deepStrictEqual(inspect(parser, input('\\'
|
|
37
|
-
assert.deepStrictEqual(inspect(parser, input('\\\\'
|
|
38
|
-
assert.deepStrictEqual(inspect(parser, input('\\\\\\'
|
|
39
|
-
assert.deepStrictEqual(inspect(parser, input('\\ '
|
|
40
|
-
assert.deepStrictEqual(inspect(parser, input('\\_'
|
|
41
|
-
assert.deepStrictEqual(inspect(parser, input('\\0'
|
|
42
|
-
assert.deepStrictEqual(inspect(parser, input('\\a'
|
|
43
|
-
assert.deepStrictEqual(inspect(parser, input('\\`'
|
|
44
|
-
assert.deepStrictEqual(inspect(parser, input('\\ '
|
|
45
|
-
assert.deepStrictEqual(inspect(parser, input('\\\n'
|
|
35
|
+
assert.deepStrictEqual(inspect(parser, input('\\')), [['\\'], '']);
|
|
36
|
+
assert.deepStrictEqual(inspect(parser, input('\\\\')), [['\\', '\\'], '']);
|
|
37
|
+
assert.deepStrictEqual(inspect(parser, input('\\\\\\')), [['\\', '\\', '\\'], '']);
|
|
38
|
+
assert.deepStrictEqual(inspect(parser, input('\\ ')), [['\\', ' '], '']);
|
|
39
|
+
assert.deepStrictEqual(inspect(parser, input('\\_')), [['\\', '_'], '']);
|
|
40
|
+
assert.deepStrictEqual(inspect(parser, input('\\0')), [['\\0'], '']);
|
|
41
|
+
assert.deepStrictEqual(inspect(parser, input('\\a')), [['\\a'], '']);
|
|
42
|
+
assert.deepStrictEqual(inspect(parser, input('\\`')), [['\\', '`'], '']);
|
|
43
|
+
assert.deepStrictEqual(inspect(parser, input('\\ ')), [['\\', ' '], '']);
|
|
44
|
+
assert.deepStrictEqual(inspect(parser, input('\\\n')), [['\\', '<br>'], '']);
|
|
46
45
|
});
|
|
47
46
|
|
|
48
47
|
});
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { UnescapableSourceParser } from '../source';
|
|
2
|
+
import { Result, Node } from '../../combinator/parser';
|
|
3
|
+
import { spend } from '../../combinator';
|
|
2
4
|
import { State, Command } from '../context';
|
|
3
5
|
import { Flag } from '../node';
|
|
4
|
-
import { List, Node } from '../../combinator/data/parser';
|
|
5
|
-
import { spend } from '../../combinator';
|
|
6
6
|
import { nonWhitespace, canSkip, backToUrlHead, backToEmailHead } from './text';
|
|
7
7
|
import { html } from 'typed-dom/dom';
|
|
8
8
|
|
|
9
|
-
export const unescsource: UnescapableSourceParser =
|
|
10
|
-
const { source, position, state } =
|
|
9
|
+
export const unescsource: UnescapableSourceParser = (input, output) => {
|
|
10
|
+
const { source, position, state } = input;
|
|
11
11
|
if (position === source.length) return;
|
|
12
12
|
const char = source[position];
|
|
13
|
-
spend(
|
|
14
|
-
|
|
13
|
+
spend(input, output, 1);
|
|
14
|
+
input.position += 1;
|
|
15
15
|
switch (char) {
|
|
16
16
|
case Command.Escape:
|
|
17
|
-
spend(
|
|
18
|
-
|
|
19
|
-
return
|
|
17
|
+
spend(input, output, 1);
|
|
18
|
+
input.position += 1;
|
|
19
|
+
return output.append(new Node(source.slice(position + 1, position + 2)));
|
|
20
20
|
case '\r':
|
|
21
|
-
return
|
|
21
|
+
return Result.succ;
|
|
22
22
|
case '\n':
|
|
23
|
-
|
|
24
|
-
return
|
|
23
|
+
input.linebreak ||= source.length - position;
|
|
24
|
+
return output.append(new Node(html('br'), Flag.blank));
|
|
25
25
|
default:
|
|
26
26
|
assert(char !== '\n');
|
|
27
|
-
if (context.sequential) return new List([new Node(char)]);
|
|
28
27
|
nonWhitespace.lastIndex = position + 1;
|
|
29
28
|
let i = canSkip(source, position)
|
|
30
29
|
? nonWhitespace.test(source)
|
|
@@ -33,9 +32,9 @@ export const unescsource: UnescapableSourceParser = context => {
|
|
|
33
32
|
: next(source, position, state);
|
|
34
33
|
assert(i > position);
|
|
35
34
|
i -= position;
|
|
36
|
-
spend(
|
|
37
|
-
|
|
38
|
-
return
|
|
35
|
+
spend(input, output, i - 1);
|
|
36
|
+
input.position += i - 1;
|
|
37
|
+
return output.append(new Node(source.slice(position, input.position)));
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
40
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// https://util.unicode.org/UnicodeJsps/list-unicodeset.jsp?a=%5Cp%7BWhite_Space%7D&g=&i=
|
|
2
|
+
// https://en.wikipedia.org/wiki/Whitespace_character
|
|
3
|
+
// https://en.wikipedia.org/wiki/Newline
|
|
4
|
+
export function isWhitespace(char: string, linebreak: boolean = true): boolean {
|
|
5
|
+
switch (char) {
|
|
6
|
+
case '\u0009':
|
|
7
|
+
case '\u000B':
|
|
8
|
+
case '\u000C':
|
|
9
|
+
case '\u0020':
|
|
10
|
+
case '\u0085':
|
|
11
|
+
case '\u00A0':
|
|
12
|
+
case '\u1680':
|
|
13
|
+
case '\u2000':
|
|
14
|
+
case '\u2001':
|
|
15
|
+
case '\u2002':
|
|
16
|
+
case '\u2003':
|
|
17
|
+
case '\u2004':
|
|
18
|
+
case '\u2005':
|
|
19
|
+
case '\u2006':
|
|
20
|
+
case '\u2007':
|
|
21
|
+
case '\u2008':
|
|
22
|
+
case '\u2009':
|
|
23
|
+
case '\u200A':
|
|
24
|
+
case '\u2028':
|
|
25
|
+
case '\u2029':
|
|
26
|
+
case '\u202F':
|
|
27
|
+
case '\u205F':
|
|
28
|
+
case '\u3000':
|
|
29
|
+
return true;
|
|
30
|
+
case '\u000A':
|
|
31
|
+
case '\u000D':
|
|
32
|
+
return linebreak;
|
|
33
|
+
default:
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/parser/source.ts
CHANGED
|
@@ -15,4 +15,5 @@ export { text, txt } from './source/text';
|
|
|
15
15
|
export { escsource } from './source/escapable';
|
|
16
16
|
export { unescsource } from './source/unescapable';
|
|
17
17
|
export { str, strs } from './source/str';
|
|
18
|
+
export { isWhitespace } from './source/whitespace';
|
|
18
19
|
export { contentline, emptyline, emptysegment, anyline } from './source/line';
|
package/src/parser/util.ts
CHANGED
package/src/parser/visibility.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Parser, List, Node } from '../combinator/
|
|
2
|
-
import { Command } from './context';
|
|
1
|
+
import { Parser, List, Node } from '../combinator/parser';
|
|
2
|
+
import { Input, Command } from './context';
|
|
3
3
|
import { Flag } from './node';
|
|
4
|
-
import {
|
|
4
|
+
import { always, fmap } from '../combinator';
|
|
5
5
|
import { invisibleBlankHTMLEntityNames } from '../api/normalize';
|
|
6
|
+
import { isWhitespace } from './source';
|
|
6
7
|
|
|
7
8
|
namespace blank {
|
|
8
9
|
export const line = new RegExp(
|
|
@@ -19,10 +20,32 @@ namespace blank {
|
|
|
19
20
|
'y');
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
export function visualize<P extends Parser>(parser: P): P
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export function visualize<P extends Parser>(parser: P): P;
|
|
24
|
+
export function visualize<T>(parser: Parser<T>): Parser<T> {
|
|
25
|
+
interface Memory {
|
|
26
|
+
readonly scope: boolean;
|
|
27
|
+
}
|
|
28
|
+
return always<Parser<T, Input<Memory>>>([
|
|
29
|
+
(input, output) => {
|
|
30
|
+
const { source, position } = input;
|
|
31
|
+
const src = source.slice(position).replace(blank.line, `$1${Command.Escape}$2`);
|
|
32
|
+
input.memory = {
|
|
33
|
+
scope: src.length !== source.length - position,
|
|
34
|
+
};
|
|
35
|
+
if (input.memory.scope) {
|
|
36
|
+
input.scope.push(src);
|
|
37
|
+
}
|
|
38
|
+
return output.context;
|
|
39
|
+
},
|
|
40
|
+
parser,
|
|
41
|
+
(input, output) => {
|
|
42
|
+
if (input.memory.scope) {
|
|
43
|
+
input = input.scope.pop();
|
|
44
|
+
}
|
|
45
|
+
input.position = input.source.length;
|
|
46
|
+
return output.context;
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
26
49
|
}
|
|
27
50
|
|
|
28
51
|
export const beforeNonblank = beforeNonblankWith('');
|
|
@@ -80,7 +103,7 @@ function isNonblank({ value: node, flags }: Node<HTMLElement | string>, strpos?:
|
|
|
80
103
|
case '\n':
|
|
81
104
|
return false;
|
|
82
105
|
default:
|
|
83
|
-
return str.trimStart()
|
|
106
|
+
return !isWhitespace(str.trimStart());
|
|
84
107
|
}
|
|
85
108
|
}
|
|
86
109
|
|
|
@@ -91,17 +114,16 @@ export function trimBlank<N extends HTMLElement | string>(parser: Parser<N>): Pa
|
|
|
91
114
|
}
|
|
92
115
|
function trimBlankStart<P extends Parser>(parser: P): P;
|
|
93
116
|
function trimBlankStart<N>(parser: Parser<N>): Parser<N> {
|
|
94
|
-
return input => {
|
|
95
|
-
const
|
|
96
|
-
const { source, position } = context;
|
|
117
|
+
return (input, output) => {
|
|
118
|
+
const { source, position } = input;
|
|
97
119
|
if (position === source.length) return;
|
|
98
120
|
const reg = blank.start;
|
|
99
121
|
reg.lastIndex = position;
|
|
100
122
|
reg.test(source);
|
|
101
|
-
|
|
102
|
-
return
|
|
103
|
-
?
|
|
104
|
-
: parser(input);
|
|
123
|
+
input.position = reg.lastIndex || position;
|
|
124
|
+
return input.position === source.length
|
|
125
|
+
? output.context
|
|
126
|
+
: parser(input, output);
|
|
105
127
|
};
|
|
106
128
|
}
|
|
107
129
|
export function trimBlankEnd<P extends Parser<HTMLElement | string>>(parser: P): P;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { figure } from './figure';
|
|
2
2
|
import { ParserOptions } from '../..';
|
|
3
|
-
import { parse as parse_ } from '../api';
|
|
3
|
+
import { run, parse as parse_ } from '../api';
|
|
4
4
|
import { html } from 'typed-dom/dom';
|
|
5
5
|
import { normalize } from '../debug.test';
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ const parse = (s: string, o?: ParserOptions) => parse_(s, { test: true, ...o });
|
|
|
9
9
|
describe('Unit: processor/figure', () => {
|
|
10
10
|
describe('figure', () => {
|
|
11
11
|
it('empty', () => {
|
|
12
|
-
const target = parse('');
|
|
12
|
+
const target = run(parse(''));
|
|
13
13
|
for (let i = 0; i < 3; ++i) {
|
|
14
14
|
[...figure(target)];
|
|
15
15
|
assert.deepStrictEqual(
|
|
@@ -19,12 +19,12 @@ describe('Unit: processor/figure', () => {
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it('one', () => {
|
|
22
|
-
const target = parse([
|
|
22
|
+
const target = run(parse([
|
|
23
23
|
'$test-a\n> ',
|
|
24
24
|
'$test-a',
|
|
25
25
|
'$test-b',
|
|
26
26
|
'$test-a',
|
|
27
|
-
].join('\n\n'));
|
|
27
|
+
].join('\n\n')));
|
|
28
28
|
for (let i = 0; i < 3; ++i) {
|
|
29
29
|
[...figure(target)];
|
|
30
30
|
assert.deepStrictEqual(
|
|
@@ -39,14 +39,14 @@ describe('Unit: processor/figure', () => {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
it('some', () => {
|
|
42
|
-
const target = parse([
|
|
42
|
+
const target = run(parse([
|
|
43
43
|
'$test-a\n> ',
|
|
44
44
|
'## 0',
|
|
45
45
|
'$test-b\n> ',
|
|
46
46
|
'$quote-a\n> ',
|
|
47
47
|
'$test-b\n> ',
|
|
48
48
|
'$test-c\n> ',
|
|
49
|
-
].join('\n\n'));
|
|
49
|
+
].join('\n\n')));
|
|
50
50
|
for (let i = 0; i < 3; ++i) {
|
|
51
51
|
[...figure(target)];
|
|
52
52
|
assert.deepStrictEqual(
|
|
@@ -63,10 +63,10 @@ describe('Unit: processor/figure', () => {
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
it('number', () => {
|
|
66
|
-
const target = parse([
|
|
66
|
+
const target = run(parse([
|
|
67
67
|
'$-a\n$$\n$$',
|
|
68
68
|
'$-a',
|
|
69
|
-
].join('\n\n'));
|
|
69
|
+
].join('\n\n')));
|
|
70
70
|
for (let i = 0; i < 3; ++i) {
|
|
71
71
|
[...figure(target)];
|
|
72
72
|
assert.deepStrictEqual(
|
|
@@ -79,7 +79,7 @@ describe('Unit: processor/figure', () => {
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
it('fixed', () => {
|
|
82
|
-
const target = parse([
|
|
82
|
+
const target = run(parse([
|
|
83
83
|
'$test-2\n> ',
|
|
84
84
|
'$test-3.1\n> ',
|
|
85
85
|
'$-4.1.1\n$$\n$$',
|
|
@@ -88,7 +88,7 @@ describe('Unit: processor/figure', () => {
|
|
|
88
88
|
'$test-2',
|
|
89
89
|
'$-4.1.1',
|
|
90
90
|
'$test-1',
|
|
91
|
-
].join('\n\n'));
|
|
91
|
+
].join('\n\n')));
|
|
92
92
|
for (let i = 0; i < 3; ++i) {
|
|
93
93
|
[...figure(target)];
|
|
94
94
|
assert.deepStrictEqual(
|
|
@@ -107,12 +107,12 @@ describe('Unit: processor/figure', () => {
|
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
it('separation', () => {
|
|
110
|
-
const target = html('blockquote', parse([
|
|
110
|
+
const target = html('blockquote', run(parse([
|
|
111
111
|
'!>> ~~~figure $test-a\n>> > \n>>\n~~~\n> ~~~figure $test-a\n> > \n>\n~~~',
|
|
112
112
|
'~~~~example/markdown\n~~~figure $test-a\n> \n\n~~~\n\n$test-a\n~~~~',
|
|
113
113
|
'~~~figure $test-b\n> \n\n~~~',
|
|
114
114
|
'~~~figure $test-a\n> \n\n~~~',
|
|
115
|
-
].join('\n\n')).children);
|
|
115
|
+
].join('\n\n'))).children);
|
|
116
116
|
for (let i = 0; i < 3; ++i) {
|
|
117
117
|
[...figure(target)];
|
|
118
118
|
assert.deepStrictEqual(
|
|
@@ -127,7 +127,7 @@ describe('Unit: processor/figure', () => {
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
it('base', () => {
|
|
130
|
-
const target = parse([
|
|
130
|
+
const target = run(parse([
|
|
131
131
|
'# 0',
|
|
132
132
|
'$-0.0',
|
|
133
133
|
'## 0',
|
|
@@ -163,7 +163,7 @@ describe('Unit: processor/figure', () => {
|
|
|
163
163
|
'$test-i\n> ',
|
|
164
164
|
'# 0',
|
|
165
165
|
'$test-j\n> ',
|
|
166
|
-
].join('\n\n'));
|
|
166
|
+
].join('\n\n')));
|
|
167
167
|
for (let i = 0; i < 3; ++i) {
|
|
168
168
|
[...figure(target)];
|
|
169
169
|
assert.deepStrictEqual(
|
|
@@ -209,7 +209,7 @@ describe('Unit: processor/figure', () => {
|
|
|
209
209
|
});
|
|
210
210
|
|
|
211
211
|
it('concat', () => {
|
|
212
|
-
const target = parse([
|
|
212
|
+
const target = run(parse([
|
|
213
213
|
'$-0.0',
|
|
214
214
|
'## 0',
|
|
215
215
|
'$-0.0',
|
|
@@ -229,7 +229,7 @@ describe('Unit: processor/figure', () => {
|
|
|
229
229
|
'## 0',
|
|
230
230
|
'$-9.0',
|
|
231
231
|
'$test-e\n> ',
|
|
232
|
-
].join('\n\n'));
|
|
232
|
+
].join('\n\n')));
|
|
233
233
|
for (let i = 0; i < 3; ++i) {
|
|
234
234
|
[...figure(target)];
|
|
235
235
|
assert.deepStrictEqual(
|
|
@@ -259,11 +259,11 @@ describe('Unit: processor/figure', () => {
|
|
|
259
259
|
});
|
|
260
260
|
|
|
261
261
|
it('verbose', () => {
|
|
262
|
-
const target = parse([
|
|
262
|
+
const target = run(parse([
|
|
263
263
|
'~~~figure [$test-a]\n> \n\n~~~',
|
|
264
264
|
'[$test-a]',
|
|
265
265
|
'[$test-a]',
|
|
266
|
-
].join('\n\n'));
|
|
266
|
+
].join('\n\n')));
|
|
267
267
|
for (let i = 0; i < 3; ++i) {
|
|
268
268
|
[...figure(target)];
|
|
269
269
|
assert.deepStrictEqual(
|
|
@@ -277,11 +277,11 @@ describe('Unit: processor/figure', () => {
|
|
|
277
277
|
});
|
|
278
278
|
|
|
279
279
|
it('id', () => {
|
|
280
|
-
const target = parse([
|
|
280
|
+
const target = run(parse([
|
|
281
281
|
'$test-a\n> ',
|
|
282
282
|
'==$test-a==',
|
|
283
283
|
'- $test-a',
|
|
284
|
-
].join('\n\n'), { id: '0' });
|
|
284
|
+
].join('\n\n'), { id: '0' }));
|
|
285
285
|
for (let i = 0; i < 3; ++i) {
|
|
286
286
|
[...figure(target, undefined, { id: '0' })];
|
|
287
287
|
assert.deepStrictEqual(
|
package/src/processor/figure.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { markInvalid, unmarkInvalid } from '../parser/util';
|
|
|
3
3
|
import { MultiQueue } from 'spica/queue';
|
|
4
4
|
import { push } from 'spica/array';
|
|
5
5
|
import { define } from 'typed-dom/dom';
|
|
6
|
-
import { querySelectorAll } from 'typed-dom/query';
|
|
7
6
|
|
|
8
7
|
export function* figure(
|
|
9
8
|
target: ParentNode & Node,
|
|
@@ -14,19 +13,26 @@ export function* figure(
|
|
|
14
13
|
} = {},
|
|
15
14
|
): Generator<HTMLAnchorElement | undefined, undefined, undefined> {
|
|
16
15
|
const selector = ':is(figure[data-label], h1, h2)';
|
|
17
|
-
const refs = new MultiQueue<string, HTMLAnchorElement>(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
const refs = new MultiQueue<string, HTMLAnchorElement>(
|
|
17
|
+
!notes || notes.references.parentNode === target
|
|
18
|
+
? Array.from(
|
|
19
|
+
target.querySelectorAll('a.label:not(.local)[data-label]'),
|
|
20
|
+
el => [el.getAttribute('data-label')!, el])
|
|
21
|
+
: push(
|
|
22
|
+
Array.from(
|
|
23
|
+
target.querySelectorAll('a.label:not(.local)[data-label]'),
|
|
24
|
+
el => [el.getAttribute('data-label')!, el] as const),
|
|
25
|
+
Array.from(
|
|
26
|
+
notes.references.querySelectorAll('a.label:not(.local)'),
|
|
27
|
+
el => [el.getAttribute('data-label')!, el] as const)));
|
|
21
28
|
const labels = new Set<string>();
|
|
22
29
|
const numbers = new Map<string, string>();
|
|
23
30
|
let base = '0';
|
|
24
31
|
let bases: readonly string[] = base.split('.');
|
|
25
|
-
let index: readonly string[] = bases;
|
|
26
32
|
for (
|
|
27
33
|
let defs = target instanceof Element
|
|
28
34
|
? target.querySelectorAll(`:scope > ${selector}`)
|
|
29
|
-
: target.querySelectorAll(
|
|
35
|
+
: target.querySelectorAll(`:not(* > *)${selector}`),
|
|
30
36
|
len = defs.length, i = 0; i < len; ++i) {
|
|
31
37
|
yield;
|
|
32
38
|
const def = defs[i];
|
|
@@ -36,7 +42,7 @@ export function* figure(
|
|
|
36
42
|
assert(base === '0' || bases.length > 1);
|
|
37
43
|
const label = tagName === 'FIGURE'
|
|
38
44
|
? def.getAttribute('data-label')!
|
|
39
|
-
: `$-${increment(
|
|
45
|
+
: `$-${increment(bases, def as HTMLHeadingElement)}`;
|
|
40
46
|
if (label.endsWith('-')) continue;
|
|
41
47
|
if (label.endsWith('-0')) {
|
|
42
48
|
markInvalid(def, 'figure', 'argument', 'Invalid base index');
|
|
@@ -76,7 +82,7 @@ export function* figure(
|
|
|
76
82
|
if (group !== '$' || tagName === 'FIGURE' && def.firstChild) continue;
|
|
77
83
|
if (number.startsWith('0.')) {
|
|
78
84
|
assert(number.endsWith('.0'));
|
|
79
|
-
number =
|
|
85
|
+
number = bases.slice(0)
|
|
80
86
|
.reduce((ns, _, i, xs) => {
|
|
81
87
|
i === ns.length
|
|
82
88
|
? xs.length = i
|
|
@@ -90,7 +96,7 @@ export function* figure(
|
|
|
90
96
|
.join('.');
|
|
91
97
|
}
|
|
92
98
|
base = number;
|
|
93
|
-
bases =
|
|
99
|
+
bases = base.split('.');
|
|
94
100
|
tagName !== 'FIGURE' && numbers.clear();
|
|
95
101
|
assert(def.tagName !== 'FIGURE' || !+def.setAttribute('data-number', number));
|
|
96
102
|
continue;
|
|
@@ -135,6 +141,8 @@ export function* figure(
|
|
|
135
141
|
}
|
|
136
142
|
yield ref;
|
|
137
143
|
}
|
|
144
|
+
assert(opts.id !== '' || !target.querySelector('[id], .index[href], .label[href], .annotation > a[href], .reference > a[href]'));
|
|
145
|
+
assert(opts.id !== '' || !notes?.references.querySelector('[id], .index[href], .label[href]'));
|
|
138
146
|
}
|
|
139
147
|
|
|
140
148
|
const messages = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { note } from './note';
|
|
2
|
-
import { parse as parse_ } from '../api';
|
|
2
|
+
import { run, parse as parse_ } from '../api';
|
|
3
3
|
import { html } from 'typed-dom/dom';
|
|
4
4
|
import { normalize } from '../debug.test';
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ const parse = (s: string) => parse_(s, { test: true });
|
|
|
8
8
|
describe('Unit: processor/note', () => {
|
|
9
9
|
describe('annotation', () => {
|
|
10
10
|
it('empty', () => {
|
|
11
|
-
const target = parse('');
|
|
11
|
+
const target = run(parse(''));
|
|
12
12
|
[...note(target)];
|
|
13
13
|
assert.deepStrictEqual(
|
|
14
14
|
[...target.children].map(el => normalize(el.outerHTML)),
|
|
@@ -16,7 +16,7 @@ describe('Unit: processor/note', () => {
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
it('1', () => {
|
|
19
|
-
const target = parse('((a b))');
|
|
19
|
+
const target = run(parse('((a b))'));
|
|
20
20
|
for (let i = 0; i < 3; ++i) {
|
|
21
21
|
assert.deepStrictEqual([...note(target)].length, i === 0 ? 2 : 3);
|
|
22
22
|
assert.deepStrictEqual(
|
|
@@ -38,7 +38,7 @@ describe('Unit: processor/note', () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
it('2', () => {
|
|
41
|
-
const target = parse('((1))((12345678901234567890))');
|
|
41
|
+
const target = run(parse('((1))((12345678901234567890))'));
|
|
42
42
|
for (let i = 0; i < 3; ++i) {
|
|
43
43
|
assert.deepStrictEqual([...note(target)].length, i === 0 ? 4 : 6);
|
|
44
44
|
assert.deepStrictEqual(
|
|
@@ -67,7 +67,7 @@ describe('Unit: processor/note', () => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
it('unify', () => {
|
|
70
|
-
const target = parse('((1))((2))((3))((2))((4))');
|
|
70
|
+
const target = run(parse('((1))((2))((3))((2))((4))'));
|
|
71
71
|
for (let i = 0; i < 3; ++i) {
|
|
72
72
|
[...note(target)];
|
|
73
73
|
assert.deepStrictEqual(
|
|
@@ -116,11 +116,11 @@ describe('Unit: processor/note', () => {
|
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
it('separation', () => {
|
|
119
|
-
const target = parse([
|
|
119
|
+
const target = run(parse([
|
|
120
120
|
'!>> ((1))\n> ((2))\n~~~',
|
|
121
121
|
'~~~~example/markdown\n((3))\n~~~~',
|
|
122
122
|
'((4))',
|
|
123
|
-
].join('\n\n'));
|
|
123
|
+
].join('\n\n')));
|
|
124
124
|
for (let i = 0; i < 3; ++i) {
|
|
125
125
|
[...note(target)];
|
|
126
126
|
assert.deepStrictEqual(
|
|
@@ -135,7 +135,7 @@ describe('Unit: processor/note', () => {
|
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
it('split', () => {
|
|
138
|
-
const target = parse('((1))\n\n## a\n\n((2))((1))((3))((2))\n\n## b\n\n((2))');
|
|
138
|
+
const target = run(parse('((1))\n\n## a\n\n((2))((1))((3))((2))\n\n## b\n\n((2))'));
|
|
139
139
|
for (let i = 0; i < 3; ++i) {
|
|
140
140
|
[...note(target)];
|
|
141
141
|
assert.deepStrictEqual(
|
|
@@ -201,7 +201,7 @@ describe('Unit: processor/note', () => {
|
|
|
201
201
|
});
|
|
202
202
|
|
|
203
203
|
it('id', () => {
|
|
204
|
-
const target = parse('((a b))');
|
|
204
|
+
const target = run(parse('((a b))'));
|
|
205
205
|
for (let i = 0; i < 3; ++i) {
|
|
206
206
|
assert.deepStrictEqual([...note(target, undefined, { id: '0' })].length, i === 0 ? 2 : 3);
|
|
207
207
|
assert.deepStrictEqual(
|
|
@@ -223,7 +223,7 @@ describe('Unit: processor/note', () => {
|
|
|
223
223
|
});
|
|
224
224
|
|
|
225
225
|
it('nest', () => {
|
|
226
|
-
const target = parse('((a((b))))((a))((b))');
|
|
226
|
+
const target = run(parse('((a((b))))((a))((b))'));
|
|
227
227
|
for (let i = 0; i < 3; ++i) {
|
|
228
228
|
[...note(target)];
|
|
229
229
|
assert.deepStrictEqual(
|
|
@@ -278,7 +278,7 @@ describe('Unit: processor/note', () => {
|
|
|
278
278
|
|
|
279
279
|
describe('reference', () => {
|
|
280
280
|
it('1', () => {
|
|
281
|
-
const target = parse('[[a b]]');
|
|
281
|
+
const target = run(parse('[[a b]]'));
|
|
282
282
|
const notes = { references: html('ol') };
|
|
283
283
|
for (let i = 0; i < 3; ++i) {
|
|
284
284
|
[...note(target, notes)];
|
|
@@ -305,7 +305,7 @@ describe('Unit: processor/note', () => {
|
|
|
305
305
|
});
|
|
306
306
|
|
|
307
307
|
it('abbr', () => {
|
|
308
|
-
const target = parse('[[^A 1]][[^A 1|b]][[^A 1]]');
|
|
308
|
+
const target = run(parse('[[^A 1]][[^A 1|b]][[^A 1]]'));
|
|
309
309
|
const notes = { references: html('ol') };
|
|
310
310
|
for (let i = 0; i < 3; ++i) {
|
|
311
311
|
[...note(target, notes)];
|
|
@@ -342,7 +342,7 @@ describe('Unit: processor/note', () => {
|
|
|
342
342
|
});
|
|
343
343
|
|
|
344
344
|
it('nest', () => {
|
|
345
|
-
const target = parse('((a[[^B]]))[[^B|c]]');
|
|
345
|
+
const target = run(parse('((a[[^B]]))[[^B|c]]'));
|
|
346
346
|
const notes = { references: html('ol') };
|
|
347
347
|
for (let i = 0; i < 3; ++i) {
|
|
348
348
|
[...note(target, notes)];
|
package/src/processor/note.ts
CHANGED
|
@@ -52,7 +52,7 @@ const annotation = build(
|
|
|
52
52
|
'annotations',
|
|
53
53
|
'.annotation:not(:is(.annotations, .references) &, .local)',
|
|
54
54
|
n => `*${n}`,
|
|
55
|
-
'h1, h2, h3, h4, h5, h6, aside.aside, hr');
|
|
55
|
+
'h1, h2, h3, h4, h5, h6, aside.aside, hr, .references');
|
|
56
56
|
const reference = build(
|
|
57
57
|
'reference',
|
|
58
58
|
'references',
|
|
@@ -112,7 +112,7 @@ function build(
|
|
|
112
112
|
const splitters = splitter
|
|
113
113
|
? target instanceof Element
|
|
114
114
|
? target.querySelectorAll(`:scope > :is(${splitter}, .${list})`)
|
|
115
|
-
: target.querySelectorAll(`:is(${splitter}, .${list})
|
|
115
|
+
: target.querySelectorAll(`:not(* > *):is(${splitter}, .${list})`)
|
|
116
116
|
: [];
|
|
117
117
|
let iSplitters = 0;
|
|
118
118
|
let total = 0;
|
|
@@ -226,6 +226,8 @@ function build(
|
|
|
226
226
|
splitter.remove();
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
+
assert(opts.id !== '' || !target.querySelector('[id], .index[href], .label[href], .annotation > a[href], .reference > a[href]'));
|
|
230
|
+
assert(opts.id !== '' || !note?.querySelector('[id], .index[href], .label[href]'));
|
|
229
231
|
};
|
|
230
232
|
}
|
|
231
233
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parse } from '../../../api';
|
|
1
|
+
import { run, parse } from '../../../api';
|
|
2
2
|
import { html, define } from 'typed-dom/dom';
|
|
3
3
|
|
|
4
4
|
const extensions = [
|
|
@@ -13,7 +13,7 @@ export function pdf(source: HTMLImageElement, url: URL): HTMLElement | undefined
|
|
|
13
13
|
data: source.getAttribute('data-src'),
|
|
14
14
|
}),
|
|
15
15
|
html('div', [
|
|
16
|
-
define(parse(`{ ${source.getAttribute('data-src')} }`).querySelector('a')!, {
|
|
16
|
+
define(run(parse(`{ ${source.getAttribute('data-src')} }`)).querySelector('a')!, {
|
|
17
17
|
class: null,
|
|
18
18
|
target: '_blank',
|
|
19
19
|
}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parse } from '../../../api';
|
|
1
|
+
import { run, parse } from '../../../api';
|
|
2
2
|
import { html as h, define } from 'typed-dom/dom';
|
|
3
3
|
import DOMPurify from 'dompurify';
|
|
4
4
|
|
|
@@ -37,7 +37,7 @@ export function twitter(source: HTMLImageElement, url: URL): HTMLElement | undef
|
|
|
37
37
|
error({ status, statusText }) {
|
|
38
38
|
assert(Number.isSafeInteger(status));
|
|
39
39
|
define(el, [
|
|
40
|
-
define(parse(`{ ${source.getAttribute('data-src')} }`).querySelector('a')!, {
|
|
40
|
+
define(run(parse(`{ ${source.getAttribute('data-src')} }`)).querySelector('a')!, {
|
|
41
41
|
class: null,
|
|
42
42
|
target: '_blank',
|
|
43
43
|
}),
|