securemark 0.235.0 → 0.235.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/securemark.js +197 -177
- package/markdown.d.ts +5 -2
- package/package-lock.json +36 -60
- package/package.json +3 -3
- package/src/combinator/control/manipulation/context.test.ts +4 -4
- package/src/combinator/control/manipulation/resource.ts +6 -3
- package/src/combinator/control/manipulation/surround.ts +3 -4
- package/src/combinator/data/parser/inits.ts +1 -1
- package/src/combinator/data/parser/sequence.ts +1 -1
- package/src/combinator/data/parser/some.ts +23 -25
- package/src/combinator/data/parser.ts +33 -10
- package/src/parser/api/bind.test.ts +3 -3
- package/src/parser/api/parse.test.ts +12 -5
- package/src/parser/block/blockquote.test.ts +1 -1
- package/src/parser/block/extension/aside.test.ts +1 -1
- package/src/parser/block/extension/example.test.ts +2 -2
- package/src/parser/block/extension/fig.test.ts +20 -20
- package/src/parser/block/extension/figure.test.ts +31 -28
- package/src/parser/block/extension/figure.ts +5 -3
- package/src/parser/block/extension/table.ts +6 -6
- package/src/parser/block/paragraph.test.ts +1 -1
- package/src/parser/block.ts +1 -2
- package/src/parser/inline/annotation.ts +3 -3
- package/src/parser/inline/bracket.test.ts +10 -10
- package/src/parser/inline/bracket.ts +5 -8
- package/src/parser/inline/deletion.test.ts +4 -1
- package/src/parser/inline/deletion.ts +7 -4
- package/src/parser/inline/emphasis.ts +3 -6
- package/src/parser/inline/emstrong.ts +7 -8
- package/src/parser/inline/html.test.ts +25 -17
- package/src/parser/inline/html.ts +39 -15
- package/src/parser/inline/htmlentity.test.ts +1 -1
- package/src/parser/inline/htmlentity.ts +17 -10
- package/src/parser/inline/insertion.test.ts +4 -1
- package/src/parser/inline/insertion.ts +7 -4
- package/src/parser/inline/link.test.ts +3 -0
- package/src/parser/inline/link.ts +6 -7
- package/src/parser/inline/mark.ts +3 -6
- package/src/parser/inline/media.test.ts +3 -0
- package/src/parser/inline/media.ts +1 -1
- package/src/parser/inline/reference.ts +6 -6
- package/src/parser/inline/ruby.ts +1 -1
- package/src/parser/inline/strong.test.ts +1 -1
- package/src/parser/inline/strong.ts +3 -6
- package/src/parser/inline.test.ts +2 -3
- package/src/parser/processor/figure.test.ts +28 -28
- package/src/parser/processor/figure.ts +1 -1
- package/src/parser/util.ts +43 -39
|
@@ -2,10 +2,10 @@ import { undefined } from 'spica/global';
|
|
|
2
2
|
import { isFrozen, ObjectEntries, ObjectFreeze, ObjectSetPrototypeOf, ObjectValues } from 'spica/alias';
|
|
3
3
|
import { MarkdownParser } from '../../../markdown';
|
|
4
4
|
import { HTMLParser } from '../inline';
|
|
5
|
-
import { union, some, validate, context, creator, surround, match, lazy } from '../../combinator';
|
|
5
|
+
import { union, some, validate, context, creator, surround, open, match, lazy } from '../../combinator';
|
|
6
6
|
import { inline } from '../inline';
|
|
7
7
|
import { str } from '../source';
|
|
8
|
-
import { startLoose,
|
|
8
|
+
import { startLoose, blank } from '../util';
|
|
9
9
|
import { html as h, defrag } from 'typed-dom';
|
|
10
10
|
import { memoize } from 'spica/memoize';
|
|
11
11
|
import { Cache } from 'spica/cache';
|
|
@@ -26,17 +26,17 @@ export const html: HTMLParser = lazy(() => creator(validate('<', validate(/^<[a-
|
|
|
26
26
|
memoize(
|
|
27
27
|
([, tag]) =>
|
|
28
28
|
surround(
|
|
29
|
-
`<${tag}`, some(union([attribute])),
|
|
29
|
+
`<${tag}`, some(union([attribute])), /^\s*>/, true,
|
|
30
30
|
([, bs = []], rest) =>
|
|
31
31
|
[[h(tag as 'span', attributes('html', [], attrspec[tag], bs))], rest]),
|
|
32
32
|
([, tag]) => tag)),
|
|
33
33
|
match(
|
|
34
|
-
/^(?=<(sup|sub|small
|
|
34
|
+
/^(?=<(sup|sub|small)(?=[^\S\n]|>))/,
|
|
35
35
|
memoize(
|
|
36
36
|
([, tag]) =>
|
|
37
37
|
validate(`<${tag}`, `</${tag}>`,
|
|
38
38
|
surround<HTMLParser.TagParser, string>(surround(
|
|
39
|
-
str(`<${tag}`), some(attribute), str(
|
|
39
|
+
str(`<${tag}`), some(attribute), str(/^\s*>/), true),
|
|
40
40
|
startLoose(
|
|
41
41
|
context((() => {
|
|
42
42
|
switch (tag) {
|
|
@@ -58,25 +58,49 @@ export const html: HTMLParser = lazy(() => creator(validate('<', validate(/^<[a-
|
|
|
58
58
|
}},
|
|
59
59
|
};
|
|
60
60
|
default:
|
|
61
|
+
assert(false);
|
|
61
62
|
return {};
|
|
62
63
|
}
|
|
63
64
|
})(),
|
|
64
|
-
some(union([
|
|
65
|
+
some(union([
|
|
66
|
+
some(inline, blank(/\n?/, `</${tag}>`)),
|
|
67
|
+
open(/^\n?/, some(inline, '</'), true),
|
|
68
|
+
]), `</${tag}>`)), `</${tag}>`),
|
|
65
69
|
str(`</${tag}>`), false,
|
|
66
70
|
([as, bs, cs], rest, context) =>
|
|
67
|
-
[[elem(tag, as,
|
|
71
|
+
[[elem(tag, as, defrag(bs), cs, context)], rest])),
|
|
68
72
|
([, tag]) => tag)),
|
|
73
|
+
match(
|
|
74
|
+
/^(?=<(bdo|bdi)(?=[^\S\n]|>))/,
|
|
75
|
+
memoize(
|
|
76
|
+
([, tag]) =>
|
|
77
|
+
validate(`<${tag}`, `</${tag}>`,
|
|
78
|
+
surround<HTMLParser.TagParser, string>(surround(
|
|
79
|
+
str(`<${tag}`), some(attribute), str(/^\s*>/), true),
|
|
80
|
+
startLoose(some(union([
|
|
81
|
+
some(inline, blank(/\n?/, `</${tag}>`)),
|
|
82
|
+
open(/^\n?/, some(inline, '</'), true),
|
|
83
|
+
]), `</${tag}>`), `</${tag}>`),
|
|
84
|
+
str(`</${tag}>`), false,
|
|
85
|
+
([as, bs, cs], rest) =>
|
|
86
|
+
[[elem(tag, as, defrag(bs), cs, {})], rest],
|
|
87
|
+
([as, bs], rest) =>
|
|
88
|
+
as.length === 1 ? [unshift(as, bs), rest] : undefined)),
|
|
89
|
+
([, tag]) => tag)),
|
|
69
90
|
match(
|
|
70
91
|
/^(?=<([a-z]+)(?=[^\S\n]|>))/,
|
|
71
92
|
memoize(
|
|
72
93
|
([, tag]) =>
|
|
73
94
|
validate(`<${tag}`, `</${tag}>`,
|
|
74
95
|
surround<HTMLParser.TagParser, string>(surround(
|
|
75
|
-
str(`<${tag}`), some(attribute), str(
|
|
76
|
-
startLoose(some(union([
|
|
96
|
+
str(`<${tag}`), some(attribute), str(/^\s*>/), true),
|
|
97
|
+
startLoose(some(union([
|
|
98
|
+
some(inline, blank(/\n?/, `</${tag}>`)),
|
|
99
|
+
open(/^\n?/, some(inline, '</'), true),
|
|
100
|
+
]), `</${tag}>`), `</${tag}>`),
|
|
77
101
|
str(`</${tag}>`), false,
|
|
78
102
|
([as, bs, cs], rest) =>
|
|
79
|
-
[[elem(tag, as,
|
|
103
|
+
[[elem(tag, as, defrag(bs), cs, {})], rest],
|
|
80
104
|
([as, bs], rest) =>
|
|
81
105
|
as.length === 1 ? [unshift(as, bs), rest] : undefined)),
|
|
82
106
|
([, tag]) => tag,
|
|
@@ -87,8 +111,11 @@ export const attribute: HTMLParser.TagParser.AttributeParser = union([
|
|
|
87
111
|
str(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/),
|
|
88
112
|
]);
|
|
89
113
|
|
|
90
|
-
function elem(tag: string, as:
|
|
114
|
+
function elem(tag: string, as: string[], bs: (HTMLElement | string)[], cs: string[], context: MarkdownParser.Context): HTMLElement {
|
|
115
|
+
assert(as.length > 0);
|
|
116
|
+
assert(as[0][0] === '<' && as[as.length - 1].slice(-1) === '>');
|
|
91
117
|
assert(bs.length === defrag(bs).length);
|
|
118
|
+
assert(cs.length === 1);
|
|
92
119
|
if (!tags.includes(tag)) return invalid('tag', `Invalid HTML tag <${tag}>.`, as, bs, cs);
|
|
93
120
|
switch (tag) {
|
|
94
121
|
case 'sup':
|
|
@@ -108,11 +135,8 @@ function elem(tag: string, as: (HTMLElement | string)[], bs: (HTMLElement | stri
|
|
|
108
135
|
}
|
|
109
136
|
let attrs: Record<string, string | undefined> | undefined;
|
|
110
137
|
switch (true) {
|
|
111
|
-
case
|
|
112
|
-
|| 'data-invalid-syntax' in (attrs = attributes('html', [], attrspec[tag], as.slice(1, -1) as string[])):
|
|
138
|
+
case 'data-invalid-syntax' in (attrs = attributes('html', [], attrspec[tag], as.slice(1, -1) as string[])):
|
|
113
139
|
return invalid('attribute', 'Invalid HTML attribute.', as, bs, cs);
|
|
114
|
-
case cs.length === 0:
|
|
115
|
-
return invalid('closer', `Missing the closing HTML tag <${tag}>.`, as, bs, cs);
|
|
116
140
|
default:
|
|
117
141
|
assert(attrs);
|
|
118
142
|
return h(tag as 'span', attrs, bs);
|
|
@@ -14,7 +14,6 @@ describe('Unit: parser/inline/htmlentity', () => {
|
|
|
14
14
|
assert.deepStrictEqual(inspect(parser('& ;')), undefined);
|
|
15
15
|
assert.deepStrictEqual(inspect(parser('&\n;')), undefined);
|
|
16
16
|
assert.deepStrictEqual(inspect(parser('&a;')), [['<span class="invalid">&a;</span>'], '']);
|
|
17
|
-
assert.deepStrictEqual(inspect(parser('
')), undefined);
|
|
18
17
|
assert.deepStrictEqual(inspect(parser('&#;')), undefined);
|
|
19
18
|
assert.deepStrictEqual(inspect(parser('&#g;')), undefined);
|
|
20
19
|
assert.deepStrictEqual(inspect(parser('&#x;')), undefined);
|
|
@@ -36,6 +35,7 @@ describe('Unit: parser/inline/htmlentity', () => {
|
|
|
36
35
|
});
|
|
37
36
|
|
|
38
37
|
it('entity', () => {
|
|
38
|
+
assert.deepStrictEqual(inspect(parser('
')), [[' '], '']);
|
|
39
39
|
assert.deepStrictEqual(inspect(parser(' ')), [['\u00A0'], '']);
|
|
40
40
|
assert.deepStrictEqual(inspect(parser('&')), [['&'], '']);
|
|
41
41
|
assert.deepStrictEqual(inspect(parser('©')), [['©'], '']);
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
+
import { undefined } from 'spica/global';
|
|
1
2
|
import { HTMLEntityParser, UnsafeHTMLEntityParser } from '../inline';
|
|
2
3
|
import { union, validate, focus, creator, fmap } from '../../combinator';
|
|
3
4
|
import { html } from 'typed-dom';
|
|
5
|
+
import { reduce } from 'spica/memoize';
|
|
4
6
|
|
|
5
7
|
export const unsafehtmlentity: UnsafeHTMLEntityParser = creator(validate('&', focus(
|
|
6
|
-
/^&
|
|
7
|
-
|
|
8
|
-
parser.innerHTML = entity,
|
|
9
|
-
entity = parser.textContent!,
|
|
10
|
-
[[`${entity[0] !== '&' || entity.length === 1 ? '' : '\0'}${entity}`], '']
|
|
11
|
-
))(html('b')))));
|
|
8
|
+
/^&[0-9A-Za-z]+;/,
|
|
9
|
+
entity => [[parse(entity) ?? `\0${entity}`], ''])));
|
|
12
10
|
|
|
13
11
|
export const htmlentity: HTMLEntityParser = fmap(
|
|
14
12
|
union([unsafehtmlentity]),
|
|
15
|
-
([
|
|
16
|
-
|
|
13
|
+
([test]) => [
|
|
14
|
+
test[0] === '\0'
|
|
17
15
|
? html('span', {
|
|
18
16
|
class: 'invalid',
|
|
19
17
|
'data-invalid-syntax': 'htmlentity',
|
|
20
18
|
'data-invalid-type': 'syntax',
|
|
21
19
|
'data-invalid-description': 'Invalid HTML entity.',
|
|
22
|
-
},
|
|
23
|
-
:
|
|
20
|
+
}, test.slice(1))
|
|
21
|
+
: test,
|
|
24
22
|
]);
|
|
23
|
+
|
|
24
|
+
const parse = reduce((el => (entity: string): string | undefined => {
|
|
25
|
+
if (entity === '
') return ' ';
|
|
26
|
+
el.innerHTML = entity;
|
|
27
|
+
const text = el.textContent!;
|
|
28
|
+
return entity === text
|
|
29
|
+
? undefined
|
|
30
|
+
: text;
|
|
31
|
+
})(html('b')));
|
|
@@ -18,7 +18,6 @@ describe('Unit: parser/inline/insertion', () => {
|
|
|
18
18
|
it('basic', () => {
|
|
19
19
|
assert.deepStrictEqual(inspect(parser('++a++')), [['<ins>a</ins>'], '']);
|
|
20
20
|
assert.deepStrictEqual(inspect(parser('++a+b++')), [['<ins>a+b</ins>'], '']);
|
|
21
|
-
assert.deepStrictEqual(inspect(parser('++a ++')), [['<ins>a </ins>'], '']);
|
|
22
21
|
assert.deepStrictEqual(inspect(parser('++ ++')), [['<ins> </ins>'], '']);
|
|
23
22
|
assert.deepStrictEqual(inspect(parser('++ a++')), [['<ins> a</ins>'], '']);
|
|
24
23
|
assert.deepStrictEqual(inspect(parser('++ a ++')), [['<ins> a </ins>'], '']);
|
|
@@ -26,7 +25,11 @@ describe('Unit: parser/inline/insertion', () => {
|
|
|
26
25
|
assert.deepStrictEqual(inspect(parser('++\na++')), [['<ins><br>a</ins>'], '']);
|
|
27
26
|
assert.deepStrictEqual(inspect(parser('++\\\na++')), [['<ins><span class="linebreak"> </span>a</ins>'], '']);
|
|
28
27
|
assert.deepStrictEqual(inspect(parser('++<wbr>a++')), [['<ins><wbr>a</ins>'], '']);
|
|
28
|
+
assert.deepStrictEqual(inspect(parser('++a ++')), [['<ins>a </ins>'], '']);
|
|
29
|
+
assert.deepStrictEqual(inspect(parser('++a \n ++')), [['<ins>a </ins>'], '']);
|
|
29
30
|
assert.deepStrictEqual(inspect(parser('++a\n++')), [['<ins>a</ins>'], '']);
|
|
31
|
+
assert.deepStrictEqual(inspect(parser('++a\n ++')), [['<ins>a </ins>'], '']);
|
|
32
|
+
assert.deepStrictEqual(inspect(parser('++a\n<wbr>++')), [['<ins>a<wbr></ins>'], '']);
|
|
30
33
|
assert.deepStrictEqual(inspect(parser('++a\nb++')), [['<ins>a<br>b</ins>'], '']);
|
|
31
34
|
assert.deepStrictEqual(inspect(parser('++a\\\nb++')), [['<ins>a<span class="linebreak"> </span>b</ins>'], '']);
|
|
32
35
|
assert.deepStrictEqual(inspect(parser('++\\+++')), [['<ins>+</ins>'], '']);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { InsertionParser } from '../inline';
|
|
2
|
-
import { union, some, creator, surround, lazy } from '../../combinator';
|
|
2
|
+
import { union, some, creator, surround, open, lazy } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
|
-
import {
|
|
5
|
+
import { blank } from '../util';
|
|
6
6
|
import { html, defrag } from 'typed-dom';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
|
|
9
9
|
export const insertion: InsertionParser = lazy(() => creator(surround(
|
|
10
10
|
str('++'),
|
|
11
|
-
union([
|
|
11
|
+
some(union([
|
|
12
|
+
some(inline, blank(/\n?/, '++')),
|
|
13
|
+
open(/^\n?/, some(inline, '+'), true),
|
|
14
|
+
])),
|
|
12
15
|
str('++'), false,
|
|
13
|
-
([, bs], rest) => [[html('ins', defrag(
|
|
16
|
+
([, bs], rest) => [[html('ins', defrag(bs))], rest],
|
|
14
17
|
([as, bs], rest) => [unshift(as, bs), rest])));
|
|
@@ -93,6 +93,9 @@ describe('Unit: parser/inline/link', () => {
|
|
|
93
93
|
assert.deepStrictEqual(inspect(parser('[]{b }')), [['<a href="b">b</a>'], '']);
|
|
94
94
|
assert.deepStrictEqual(inspect(parser('[]{ b }')), [['<a href="b">b</a>'], '']);
|
|
95
95
|
assert.deepStrictEqual(inspect(parser('[]{ b }')), [['<a href="b">b</a>'], '']);
|
|
96
|
+
assert.deepStrictEqual(inspect(parser('[]{ b }')), [['<a href="b">b</a>'], '']);
|
|
97
|
+
assert.deepStrictEqual(inspect(parser('[]{ b }')), [['<a href="b">b</a>'], '']);
|
|
98
|
+
assert.deepStrictEqual(inspect(parser('[]{ b }')), [['<a href="b">b</a>'], '']);
|
|
96
99
|
assert.deepStrictEqual(inspect(parser('[]{\\}')), [[`<a href="\\">\\</a>`], '']);
|
|
97
100
|
assert.deepStrictEqual(inspect(parser('[]{\\ }')), [[`<a href="\\">\\</a>`], '']);
|
|
98
101
|
assert.deepStrictEqual(inspect(parser('[]{\\b}')), [[`<a href="\\b">\\b</a>`], '']);
|
|
@@ -7,7 +7,7 @@ import { inline, media, shortmedia } from '../inline';
|
|
|
7
7
|
import { attributes } from './html';
|
|
8
8
|
import { autolink } from '../autolink';
|
|
9
9
|
import { str } from '../source';
|
|
10
|
-
import { startLoose,
|
|
10
|
+
import { startLoose, trimSpaceStart, trimNodeEnd, stringify } from '../util';
|
|
11
11
|
import { html, define, defrag } from 'typed-dom';
|
|
12
12
|
import { ReadonlyURL } from 'spica/url';
|
|
13
13
|
|
|
@@ -38,11 +38,11 @@ export const link: LinkParser = lazy(() => creator(10, validate(['[', '{'], '}',
|
|
|
38
38
|
media: false,
|
|
39
39
|
autolink: false,
|
|
40
40
|
}}},
|
|
41
|
-
some(inline, ']', /^\\?\n/))
|
|
41
|
+
trimSpaceStart(some(inline, ']', /^\\?\n/)))),
|
|
42
42
|
']',
|
|
43
43
|
true),
|
|
44
44
|
]))),
|
|
45
|
-
dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]
|
|
45
|
+
dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
|
|
46
46
|
]))),
|
|
47
47
|
([params, content = []]: [string[], (HTMLElement | string)[]], rest, context) => {
|
|
48
48
|
assert(params.every(p => typeof p === 'string'));
|
|
@@ -53,7 +53,7 @@ export const link: LinkParser = lazy(() => creator(10, validate(['[', '{'], '}',
|
|
|
53
53
|
assert(!INSECURE_URI.match(/\s/));
|
|
54
54
|
const el = elem(
|
|
55
55
|
INSECURE_URI,
|
|
56
|
-
|
|
56
|
+
trimNodeEnd(defrag(content)),
|
|
57
57
|
new ReadonlyURL(
|
|
58
58
|
resolve(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location),
|
|
59
59
|
context.host?.href || location.href),
|
|
@@ -64,15 +64,14 @@ export const link: LinkParser = lazy(() => creator(10, validate(['[', '{'], '}',
|
|
|
64
64
|
}))));
|
|
65
65
|
|
|
66
66
|
export const uri: LinkParser.ParameterParser.UriParser = union([
|
|
67
|
-
open(/^[^\S\n]
|
|
67
|
+
open(/^[^\S\n]+/, str(/^\S+/)),
|
|
68
68
|
str(/^[^\s{}]+/),
|
|
69
69
|
]);
|
|
70
70
|
|
|
71
71
|
export const option: LinkParser.ParameterParser.OptionParser = union([
|
|
72
72
|
fmap(str(/^[^\S\n]+nofollow(?=[^\S\n]|})/), () => [` rel="nofollow"`]),
|
|
73
73
|
str(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|})/),
|
|
74
|
-
fmap(str(/^[^\S\n]+
|
|
75
|
-
fmap(str(/^[^\S\n]+[^\n{}]+/), opt => [` \\${opt.slice(1)}`]),
|
|
74
|
+
fmap(str(/^[^\S\n]+[^\s{}]+/), opt => [` \\${opt.slice(1)}`]),
|
|
76
75
|
]);
|
|
77
76
|
|
|
78
77
|
export function resolve(uri: string, host: URL | Location, source: URL | Location): string {
|
|
@@ -2,19 +2,16 @@ import { MarkParser } from '../inline';
|
|
|
2
2
|
import { union, some, creator, surround, open, lazy } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
|
-
import { startTight,
|
|
5
|
+
import { startTight, blank } from '../util';
|
|
6
6
|
import { html, defrag } from 'typed-dom';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
|
|
9
9
|
export const mark: MarkParser = lazy(() => creator(surround(
|
|
10
10
|
str('=='),
|
|
11
11
|
startTight(some(union([
|
|
12
|
-
some(inline,
|
|
12
|
+
some(inline, blank('', '==')),
|
|
13
13
|
open(some(inline, '='), inline),
|
|
14
14
|
]))),
|
|
15
15
|
str('=='), false,
|
|
16
|
-
([
|
|
17
|
-
isEndTightNodes(bs)
|
|
18
|
-
? [[html('mark', defrag(bs))], rest]
|
|
19
|
-
: [unshift(as, bs), cs[0] + rest],
|
|
16
|
+
([, bs], rest) => [[html('mark', defrag(bs))], rest],
|
|
20
17
|
([as, bs], rest) => [unshift(as, bs), rest])));
|
|
@@ -67,6 +67,9 @@ describe('Unit: parser/inline/media', () => {
|
|
|
67
67
|
assert.deepStrictEqual(inspect(parser('![]{b }')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt=""></a>'], '']);
|
|
68
68
|
assert.deepStrictEqual(inspect(parser('![]{ b }')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt=""></a>'], '']);
|
|
69
69
|
assert.deepStrictEqual(inspect(parser('![]{ b }')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt=""></a>'], '']);
|
|
70
|
+
assert.deepStrictEqual(inspect(parser('![]{ b }')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt=""></a>'], '']);
|
|
71
|
+
assert.deepStrictEqual(inspect(parser('![]{ b }')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt=""></a>'], '']);
|
|
72
|
+
assert.deepStrictEqual(inspect(parser('![]{ b }')), [['<a href="b" target="_blank"><img class="media" data-src="b" alt=""></a>'], '']);
|
|
70
73
|
assert.deepStrictEqual(inspect(parser('![]{\\}')), [['<a href="\\" target="_blank"><img class="media" data-src="\\" alt=""></a>'], '']);
|
|
71
74
|
assert.deepStrictEqual(inspect(parser('![]{\\ }')), [['<a href="\\" target="_blank"><img class="media" data-src="\\" alt=""></a>'], '']);
|
|
72
75
|
assert.deepStrictEqual(inspect(parser('![]{\\b}')), [['<a href="\\b" target="_blank"><img class="media" data-src="\\b" alt=""></a>'], '']);
|
|
@@ -27,7 +27,7 @@ export const media: MediaParser = lazy(() => creator(10, validate(['![', '!{'],
|
|
|
27
27
|
some(union([unsafehtmlentity, bracket, txt]), ']', /^\\?\n/),
|
|
28
28
|
']',
|
|
29
29
|
true)),
|
|
30
|
-
dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]
|
|
30
|
+
dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
|
|
31
31
|
]))),
|
|
32
32
|
([as, bs]) => bs ? [[join(as).trim() || join(as)], bs] : [[''], as]),
|
|
33
33
|
([[text]]) => text === '' || text.trim() !== ''),
|
|
@@ -3,7 +3,7 @@ import { ReferenceParser } from '../inline';
|
|
|
3
3
|
import { union, subsequence, some, validate, verify, focus, guard, context, creator, surround, lazy, fmap } from '../../combinator';
|
|
4
4
|
import { inline } from '../inline';
|
|
5
5
|
import { str } from '../source';
|
|
6
|
-
import { startLoose, isStartLoose,
|
|
6
|
+
import { startLoose, isStartLoose, trimSpaceStart, trimNodeEnd, stringify } from '../util';
|
|
7
7
|
import { html, defrag } from 'typed-dom';
|
|
8
8
|
|
|
9
9
|
export const reference: ReferenceParser = lazy(() => creator(validate('[[', ']]', '\n', fmap(surround(
|
|
@@ -22,16 +22,16 @@ export const reference: ReferenceParser = lazy(() => creator(validate('[[', ']]'
|
|
|
22
22
|
}}, state: undefined },
|
|
23
23
|
subsequence([
|
|
24
24
|
abbr,
|
|
25
|
-
focus(
|
|
26
|
-
some(inline, ']', /^\\?\n/),
|
|
27
|
-
]))
|
|
25
|
+
focus(/^\^[^\S\n]*/, source => [['', source], '']),
|
|
26
|
+
trimSpaceStart(some(inline, ']', /^\\?\n/)),
|
|
27
|
+
])))),
|
|
28
28
|
']]'),
|
|
29
|
-
ns => [html('sup', attributes(ns),
|
|
29
|
+
ns => [html('sup', attributes(ns), trimNodeEnd(defrag(ns)))]))));
|
|
30
30
|
|
|
31
31
|
const abbr: ReferenceParser.AbbrParser = creator(fmap(verify(surround(
|
|
32
32
|
'^',
|
|
33
33
|
union([str(/^(?![0-9]+\s?[|\]])[0-9A-Za-z]+(?:(?:-|(?=\W)(?!'\d)'?(?!\.\d)\.?(?!,\S),? ?)[0-9A-Za-z]+)*(?:-|'?\.?,? ?)?/)]),
|
|
34
|
-
/^\|?(?=]])|^\|[^\S\n]
|
|
34
|
+
/^\|?(?=]])|^\|[^\S\n]+/),
|
|
35
35
|
(_, rest, context) => isStartLoose(rest, context)),
|
|
36
36
|
([source]) => [html('abbr', source)]));
|
|
37
37
|
|
|
@@ -83,7 +83,7 @@ function attributes(texts: string[], rubies: string[]): Record<string, string> {
|
|
|
83
83
|
let attrs: Record<string, string> | undefined;
|
|
84
84
|
for (const ss of [texts, rubies]) {
|
|
85
85
|
for (let i = 0; i < ss.length; ++i) {
|
|
86
|
-
if (
|
|
86
|
+
if (ss[i].indexOf('\0') === -1) continue;
|
|
87
87
|
ss[i] = ss[i].replace(/\0/g, '');
|
|
88
88
|
attrs ??= {
|
|
89
89
|
class: 'invalid',
|
|
@@ -9,11 +9,11 @@ describe('Unit: parser/inline/strong', () => {
|
|
|
9
9
|
it('invalid', () => {
|
|
10
10
|
assert.deepStrictEqual(inspect(parser('**')), undefined);
|
|
11
11
|
assert.deepStrictEqual(inspect(parser('**a')), [['**', 'a'], '']);
|
|
12
|
-
assert.deepStrictEqual(inspect(parser('**a*')), [['**', 'a', '*'], '']);
|
|
13
12
|
assert.deepStrictEqual(inspect(parser('**a **')), [['**', 'a', ' ', '**'], '']);
|
|
14
13
|
assert.deepStrictEqual(inspect(parser('**a\n**')), [['**', 'a', '<br>', '**'], '']);
|
|
15
14
|
assert.deepStrictEqual(inspect(parser('**a\\ **')), [['**', 'a', ' ', '**'], '']);
|
|
16
15
|
assert.deepStrictEqual(inspect(parser('**a\\\n**')), [['**', 'a', '<span class="linebreak"> </span>', '**'], '']);
|
|
16
|
+
assert.deepStrictEqual(inspect(parser('**a*')), [['**', 'a', '*'], '']);
|
|
17
17
|
assert.deepStrictEqual(inspect(parser('**a*b**')), [['**', 'a', '<em>b</em>', '*'], '']);
|
|
18
18
|
assert.deepStrictEqual(inspect(parser('** **')), undefined);
|
|
19
19
|
assert.deepStrictEqual(inspect(parser('** a**')), undefined);
|
|
@@ -2,19 +2,16 @@ import { StrongParser } from '../inline';
|
|
|
2
2
|
import { union, some, creator, surround, open, lazy } from '../../combinator';
|
|
3
3
|
import { inline } from '../inline';
|
|
4
4
|
import { str } from '../source';
|
|
5
|
-
import { startTight,
|
|
5
|
+
import { startTight, blank } from '../util';
|
|
6
6
|
import { html, defrag } from 'typed-dom';
|
|
7
7
|
import { unshift } from 'spica/array';
|
|
8
8
|
|
|
9
9
|
export const strong: StrongParser = lazy(() => creator(surround(
|
|
10
10
|
str('**'),
|
|
11
11
|
startTight(some(union([
|
|
12
|
-
some(inline,
|
|
12
|
+
some(inline, blank('', '**')),
|
|
13
13
|
open(some(inline, '*'), inline),
|
|
14
14
|
])), '*'),
|
|
15
15
|
str('**'), false,
|
|
16
|
-
([
|
|
17
|
-
isEndTightNodes(bs)
|
|
18
|
-
? [[html('strong', defrag(bs))], rest]
|
|
19
|
-
: [unshift(as, bs), cs[0] + rest],
|
|
16
|
+
([, bs], rest) => [[html('strong', defrag(bs))], rest],
|
|
20
17
|
([as, bs], rest) => [unshift(as, bs), rest])));
|
|
@@ -92,7 +92,6 @@ describe('Unit: parser/inline', () => {
|
|
|
92
92
|
assert.deepStrictEqual(inspect(parser('***a***')), [['<em><strong>a</strong></em>'], '']);
|
|
93
93
|
assert.deepStrictEqual(inspect(parser('***a***b')), [['<em><strong>a</strong></em>', 'b'], '']);
|
|
94
94
|
assert.deepStrictEqual(inspect(parser('***a****')), [['<em><strong>a</strong></em>', '*'], '']);
|
|
95
|
-
assert.deepStrictEqual(inspect(parser('***a *b****')), [['<em><strong>a <em>b</em></strong></em>'], '']);
|
|
96
95
|
assert.deepStrictEqual(inspect(parser('****a***')), [['****', 'a', '***'], '']);
|
|
97
96
|
assert.deepStrictEqual(inspect(parser('****a****')), [['****', 'a', '****'], '']);
|
|
98
97
|
assert.deepStrictEqual(inspect(parser('*(*a*)*')), [['<em><span class="paren">(<em>a</em>)</span></em>'], '']);
|
|
@@ -118,9 +117,9 @@ describe('Unit: parser/inline', () => {
|
|
|
118
117
|
assert.deepStrictEqual(inspect(parser('[[#a]]')), [['<sup class="reference"><a href="/hashtags/a" class="hashtag">#a</a></sup>'], '']);
|
|
119
118
|
assert.deepStrictEqual(inspect(parser('[[$-1]]')), [['<sup class="reference"><a class="label" data-label="$-1">$-1</a></sup>'], '']);
|
|
120
119
|
assert.deepStrictEqual(inspect(parser('[[#-1]]{b}')), [['<sup class="reference">#-1</sup>', '<a href="b">b</a>'], '']);
|
|
121
|
-
assert.deepStrictEqual(inspect(parser('[[#-1]](b)')), [['<sup class="reference">#-1</sup>', '(b)'], '']);
|
|
120
|
+
assert.deepStrictEqual(inspect(parser('[[#-1]](b)')), [['<sup class="reference">#-1</sup>', '(', 'b', ')'], '']);
|
|
122
121
|
assert.deepStrictEqual(inspect(parser('[[#-1]a]{b}')), [['<a href="b">[#-1]a</a>'], '']);
|
|
123
|
-
assert.deepStrictEqual(inspect(parser('[[#-1]a](b)')), [['[', '<a class="index" href="#index:-1">-1</a>', 'a', ']', '(b)'], '']);
|
|
122
|
+
assert.deepStrictEqual(inspect(parser('[[#-1]a](b)')), [['[', '<a class="index" href="#index:-1">-1</a>', 'a', ']', '(', 'b', ')'], '']);
|
|
124
123
|
assert.deepStrictEqual(inspect(parser('[#a]{b}')), [['<a class="index" href="#index:a">a</a>', '<a href="b">b</a>'], '']);
|
|
125
124
|
assert.deepStrictEqual(inspect(parser('[@a]{b}')), [['[', '<a href="/@a" class="account">@a</a>', ']', '<a href="b">b</a>'], '']);
|
|
126
125
|
assert.deepStrictEqual(inspect(parser('[http://host]{http://evil}')), [['[', '<a href="http://host" target="_blank">http://host</a>', ']', '<a href="http://evil" target="_blank">http://evil</a>'], '']);
|
|
@@ -28,7 +28,7 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
28
28
|
assert.deepStrictEqual(
|
|
29
29
|
[...target.children].map(el => el.outerHTML),
|
|
30
30
|
[
|
|
31
|
-
'<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div
|
|
31
|
+
'<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
|
|
32
32
|
'<p><a class="label" data-label="fig-a" href="#label:fig-a">Fig. 1</a></p>',
|
|
33
33
|
'<p><a class="label" data-label="fig-a" href="#label:fig-a">Fig. 1</a></p>',
|
|
34
34
|
]);
|
|
@@ -47,10 +47,10 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
47
47
|
assert.deepStrictEqual(
|
|
48
48
|
[...target.children].map(el => el.outerHTML),
|
|
49
49
|
[
|
|
50
|
-
'<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div
|
|
50
|
+
'<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
|
|
51
51
|
'<h2 id="index:0">0</h2>',
|
|
52
|
-
'<figure data-label="fig-b" data-group="fig" data-number="2" id="label:fig-b"><div
|
|
53
|
-
'<figure data-label="table-a" data-group="table" data-number="1" id="label:table-a"><div
|
|
52
|
+
'<figure data-label="fig-b" data-group="fig" data-number="2" id="label:fig-b"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 2. </span></figcaption></figure>',
|
|
53
|
+
'<figure data-label="table-a" data-group="table" data-number="1" id="label:table-a"><div><blockquote></blockquote></div><figcaption><span class="figindex">Table 1. </span></figcaption></figure>',
|
|
54
54
|
]);
|
|
55
55
|
}
|
|
56
56
|
});
|
|
@@ -65,7 +65,7 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
65
65
|
assert.deepStrictEqual(
|
|
66
66
|
[...target.children].map(el => el.outerHTML),
|
|
67
67
|
[
|
|
68
|
-
'<figure data-label="$-a" data-group="$" data-number="1" id="label:$-a"><div
|
|
68
|
+
'<figure data-label="$-a" data-group="$" data-number="1" id="label:$-a"><div><div class="math" translate="no">$$\n$$</div></div><figcaption><span class="figindex">(1)</span></figcaption></figure>',
|
|
69
69
|
'<p><a class="label" data-label="$-a" href="#label:$-a">(1)</a></p>',
|
|
70
70
|
]);
|
|
71
71
|
}
|
|
@@ -87,11 +87,11 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
87
87
|
assert.deepStrictEqual(
|
|
88
88
|
[...target.children].map(el => el.outerHTML),
|
|
89
89
|
[
|
|
90
|
-
'<figure data-label="fig-2" data-group="fig" data-number="2" id="label:fig-2"><div
|
|
91
|
-
'<figure data-label="fig-3.1" data-group="fig" data-number="3.1" id="label:fig-3.1"><div
|
|
92
|
-
'<figure data-label="$-4.1.1" data-group="$" data-number="4.1.1" id="label:$-4.1.1"><div
|
|
93
|
-
'<figure data-label="$-a" data-group="$" data-number="1" id="label:$-a"><div
|
|
94
|
-
'<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div
|
|
90
|
+
'<figure data-label="fig-2" data-group="fig" data-number="2" id="label:fig-2"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 2. </span></figcaption></figure>',
|
|
91
|
+
'<figure data-label="fig-3.1" data-group="fig" data-number="3.1" id="label:fig-3.1"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 3.1. </span></figcaption></figure>',
|
|
92
|
+
'<figure data-label="$-4.1.1" data-group="$" data-number="4.1.1" id="label:$-4.1.1"><div><div class="math" translate="no">$$\n$$</div></div><figcaption><span class="figindex">(4.1.1)</span></figcaption></figure>',
|
|
93
|
+
'<figure data-label="$-a" data-group="$" data-number="1" id="label:$-a"><div><div class="math" translate="no">$$\n$$</div></div><figcaption><span class="figindex">(1)</span></figcaption></figure>',
|
|
94
|
+
'<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
|
|
95
95
|
'<p><a class="label" data-label="fig-2" href="#label:fig-2">Fig. 2</a></p>',
|
|
96
96
|
'<p><a class="label" data-label="$-4.1.1" href="#label:$-4.1.1">(4.1.1)</a></p>',
|
|
97
97
|
'<p><a class="label disabled invalid" data-label="fig-1" data-invalid-syntax="label" data-invalid-type="reference" data-invalid-description="Missing the reference.">$fig-1</a></p>',
|
|
@@ -111,10 +111,10 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
111
111
|
assert.deepStrictEqual(
|
|
112
112
|
[...target.children].map(el => el.outerHTML),
|
|
113
113
|
[
|
|
114
|
-
'<blockquote><blockquote><section><figure data-label="fig-a" data-group="fig" data-number="1"><div
|
|
115
|
-
'<aside class="example" data-type="markdown"><pre translate="no">~~~figure $fig-a\n> \n\n~~~\n\n$fig-a</pre><hr><section><figure data-label="fig-a" data-group="fig" data-number="1"><div
|
|
116
|
-
'<figure data-label="fig-b" data-group="fig" data-number="1" id="label:fig-b"><div
|
|
117
|
-
'<figure data-label="fig-a" data-group="fig" data-number="2" id="label:fig-a"><div
|
|
114
|
+
'<blockquote><blockquote><section><figure data-label="fig-a" data-group="fig" data-number="1"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure><ol class="annotations"></ol><ol class="references"></ol></section></blockquote><section><figure data-label="fig-a" data-group="fig" data-number="1"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure><ol class="annotations"></ol><ol class="references"></ol></section></blockquote>',
|
|
115
|
+
'<aside class="example" data-type="markdown"><pre translate="no">~~~figure $fig-a\n> \n\n~~~\n\n$fig-a</pre><hr><section><figure data-label="fig-a" data-group="fig" data-number="1"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure><p><a class="label disabled" data-label="fig-a">Fig. 1</a></p><ol class="annotations"></ol><ol class="references"></ol></section></aside>',
|
|
116
|
+
'<figure data-label="fig-b" data-group="fig" data-number="1" id="label:fig-b"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
|
|
117
|
+
'<figure data-label="fig-a" data-group="fig" data-number="2" id="label:fig-a"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 2. </span></figcaption></figure>',
|
|
118
118
|
]);
|
|
119
119
|
}
|
|
120
120
|
});
|
|
@@ -163,16 +163,16 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
163
163
|
'<h1 id="index:0">0</h1>',
|
|
164
164
|
'<figure data-label="$-0.0" data-group="$" hidden="" data-number="0.0"></figure>',
|
|
165
165
|
'<h2 id="index:0">0</h2>',
|
|
166
|
-
'<figure data-label="fig-1" data-group="fig" data-number="1" id="label:fig-1"><div
|
|
166
|
+
'<figure data-label="fig-1" data-group="fig" data-number="1" id="label:fig-1"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
|
|
167
167
|
'<h2 id="index:0">0</h2>',
|
|
168
168
|
'<blockquote><section><h2>0</h2><ol class="annotations"></ol><ol class="references"></ol></section></blockquote>',
|
|
169
|
-
'<figure data-label="fig-b" data-group="fig" data-number="2.1" id="label:fig-b"><div
|
|
169
|
+
'<figure data-label="fig-b" data-group="fig" data-number="2.1" id="label:fig-b"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 2.1. </span></figcaption></figure>',
|
|
170
170
|
'<h2 id="index:0">0</h2>',
|
|
171
171
|
'<figure data-label="$-0.0.0" data-group="$" hidden=""></figure>',
|
|
172
|
-
'<figure data-label="fig-c" data-group="fig" data-number="3.1" id="label:fig-c"><div
|
|
172
|
+
'<figure data-label="fig-c" data-group="fig" data-number="3.1" id="label:fig-c"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 3.1. </span></figcaption></figure>',
|
|
173
173
|
'<h2 id="index:0">0</h2>',
|
|
174
174
|
'<figure data-label="$-0.1.0" data-group="$" hidden=""></figure>',
|
|
175
|
-
'<figure data-label="fig-d" data-group="fig" data-number="4.1" id="label:fig-d"><div
|
|
175
|
+
'<figure data-label="fig-d" data-group="fig" data-number="4.1" id="label:fig-d"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 4.1. </span></figcaption></figure>',
|
|
176
176
|
'<figure data-label="$-0.0" data-group="$" hidden=""></figure>',
|
|
177
177
|
'<figure data-label="$-0.1.0" data-group="$" hidden=""></figure>',
|
|
178
178
|
'<figure data-label="$-0.4.0" data-group="$" hidden=""></figure>',
|
|
@@ -180,19 +180,19 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
180
180
|
'<h2 id="index:0">0</h2>',
|
|
181
181
|
'<h2 id="index:0">0</h2>',
|
|
182
182
|
'<figure data-label="$-0.0" data-group="$" hidden="" data-number="6.0"></figure>',
|
|
183
|
-
'<figure data-label="fig-e" data-group="fig" data-number="6.1" id="label:fig-e"><div
|
|
183
|
+
'<figure data-label="fig-e" data-group="fig" data-number="6.1" id="label:fig-e"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 6.1. </span></figcaption></figure>',
|
|
184
184
|
'<h2 id="index:0">0</h2>',
|
|
185
185
|
'<figure data-label="$-5.0" data-group="$" hidden="" data-number="5.0"></figure>',
|
|
186
|
-
'<figure data-label="fig-f" data-group="fig" data-number="5.1" id="label:fig-f"><div
|
|
186
|
+
'<figure data-label="fig-f" data-group="fig" data-number="5.1" id="label:fig-f"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 5.1. </span></figcaption></figure>',
|
|
187
187
|
'<figure data-label="$-0" data-group="$" hidden=""></figure>',
|
|
188
|
-
'<figure data-label="fig-g" data-group="fig" data-number="5.2" id="label:fig-g"><div
|
|
188
|
+
'<figure data-label="fig-g" data-group="fig" data-number="5.2" id="label:fig-g"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 5.2. </span></figcaption></figure>',
|
|
189
189
|
'<h3 id="index:0">0</h3>',
|
|
190
190
|
'<figure data-label="$-0.0.0" data-group="$" hidden=""></figure>',
|
|
191
|
-
'<figure data-label="fig-h" data-group="fig" data-number="5.3" id="label:fig-h"><div
|
|
191
|
+
'<figure data-label="fig-h" data-group="fig" data-number="5.3" id="label:fig-h"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 5.3. </span></figcaption></figure>',
|
|
192
192
|
'<h3 id="index:0">0</h3>',
|
|
193
|
-
'<figure data-label="fig-i" data-group="fig" data-number="5.4" id="label:fig-i"><div
|
|
193
|
+
'<figure data-label="fig-i" data-group="fig" data-number="5.4" id="label:fig-i"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 5.4. </span></figcaption></figure>',
|
|
194
194
|
'<h1 id="index:0">0</h1>',
|
|
195
|
-
'<figure data-label="fig-j" data-group="fig" data-number="6.1" id="label:fig-j"><div
|
|
195
|
+
'<figure data-label="fig-j" data-group="fig" data-number="6.1" id="label:fig-j"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 6.1. </span></figcaption></figure>',
|
|
196
196
|
]);
|
|
197
197
|
}
|
|
198
198
|
});
|
|
@@ -219,10 +219,10 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
219
219
|
'<h2 id="index:0">0</h2>',
|
|
220
220
|
'<h2 id="index:0">0</h2>',
|
|
221
221
|
'<figure data-label="$-1.0" data-group="$" hidden="" data-number="1.0"></figure>',
|
|
222
|
-
'<figure data-label="fig-a" data-group="fig" data-number="1.1" id="label:fig-a"><div
|
|
222
|
+
'<figure data-label="fig-a" data-group="fig" data-number="1.1" id="label:fig-a"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1.1. </span></figcaption></figure>',
|
|
223
223
|
'<h2 id="index:0">0</h2>',
|
|
224
224
|
'<figure data-label="$-0.0" data-group="$" hidden="" data-number="2.0"></figure>',
|
|
225
|
-
'<figure data-label="fig-b" data-group="fig" data-number="2.1" id="label:fig-b"><div
|
|
225
|
+
'<figure data-label="fig-b" data-group="fig" data-number="2.1" id="label:fig-b"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 2.1. </span></figcaption></figure>',
|
|
226
226
|
]);
|
|
227
227
|
}
|
|
228
228
|
});
|
|
@@ -238,7 +238,7 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
238
238
|
assert.deepStrictEqual(
|
|
239
239
|
[...target.children].map(el => el.outerHTML),
|
|
240
240
|
[
|
|
241
|
-
'<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div
|
|
241
|
+
'<figure data-label="fig-a" data-group="fig" data-number="1" id="label:fig-a"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
|
|
242
242
|
'<p><a class="label" data-label="fig-a" href="#label:fig-a">Fig. 1</a></p>',
|
|
243
243
|
'<p><a class="label" data-label="fig-a" href="#label:fig-a">Fig. 1</a></p>',
|
|
244
244
|
]);
|
|
@@ -255,7 +255,7 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
255
255
|
assert.deepStrictEqual(
|
|
256
256
|
[...target.children].map(el => el.outerHTML),
|
|
257
257
|
[
|
|
258
|
-
'<figure data-label="fig-a" data-group="fig" data-number="1" id="label:0:fig-a"><div
|
|
258
|
+
'<figure data-label="fig-a" data-group="fig" data-number="1" id="label:0:fig-a"><div><blockquote></blockquote></div><figcaption><span class="figindex">Fig. 1. </span></figcaption></figure>',
|
|
259
259
|
'<p><a class="label" data-label="fig-a" href="#label:0:fig-a">Fig. 1</a></p>',
|
|
260
260
|
]);
|
|
261
261
|
}
|