securemark 0.253.1 → 0.254.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/.eslintrc.json +7 -1
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/design.md +6 -0
- package/dist/index.js +32 -27
- package/markdown.d.ts +3 -2
- package/package.json +3 -3
- package/src/parser/api/parse.test.ts +2 -2
- 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 +23 -23
- package/src/parser/block/extension/figure.test.ts +36 -36
- package/src/parser/block/extension/figure.ts +4 -4
- package/src/parser/block/extension/table.ts +5 -4
- package/src/parser/inline/emphasis.test.ts +1 -1
- package/src/parser/inline/html.test.ts +65 -62
- package/src/parser/inline/html.ts +162 -21
- package/src/parser/inline/strong.test.ts +1 -1
- package/src/parser/inline.test.ts +4 -5
- package/src/parser/processor/figure.test.ts +33 -33
- package/src/parser/processor/footnote.test.ts +2 -2
- package/src/parser/processor/footnote.ts +10 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { undefined, Object } from 'spica/global';
|
|
2
2
|
import { HTMLParser } from '../inline';
|
|
3
|
-
import { union, some, validate, creator, surround, open, match, lazy } from '../../combinator';
|
|
3
|
+
import { union, some, validate, focus, creator, surround, open, match, lazy } from '../../combinator';
|
|
4
4
|
import { inline } from '../inline';
|
|
5
5
|
import { str } from '../source';
|
|
6
6
|
import { startLoose, blankWith } from '../util';
|
|
@@ -9,44 +9,42 @@ import { memoize } from 'spica/memoize';
|
|
|
9
9
|
import { Cache } from 'spica/cache';
|
|
10
10
|
import { unshift, push, splice } from 'spica/array';
|
|
11
11
|
|
|
12
|
-
const tags = Object.freeze(['
|
|
13
|
-
const
|
|
12
|
+
const tags = Object.freeze(['bdo', 'bdi']);
|
|
13
|
+
const attrspecs = {
|
|
14
14
|
bdo: {
|
|
15
|
-
dir: Object.freeze(['ltr', 'rtl']
|
|
15
|
+
dir: Object.freeze(['ltr', 'rtl']),
|
|
16
16
|
},
|
|
17
17
|
} as const;
|
|
18
|
-
Object.setPrototypeOf(
|
|
19
|
-
Object.values(
|
|
18
|
+
Object.setPrototypeOf(attrspecs, null);
|
|
19
|
+
Object.values(attrspecs).forEach(o => Object.setPrototypeOf(o, null));
|
|
20
20
|
|
|
21
21
|
export const html: HTMLParser = lazy(() => creator(validate('<', validate(/^<[a-z]+(?=[^\S\n]|>)/, union([
|
|
22
|
+
focus(
|
|
23
|
+
'<wbr>',
|
|
24
|
+
() => [[h('wbr')], '']),
|
|
25
|
+
focus(
|
|
26
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
27
|
+
/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/,
|
|
28
|
+
source => [[source], '']),
|
|
22
29
|
match(
|
|
23
|
-
|
|
24
|
-
memoize(
|
|
25
|
-
([, tag]) =>
|
|
26
|
-
surround(
|
|
27
|
-
`<${tag}`, some(union([attribute])), /^\s*>/, true,
|
|
28
|
-
([, bs = []], rest) =>
|
|
29
|
-
[[h(tag as 'span', attributes('html', [], attrspec[tag], bs))], rest]),
|
|
30
|
-
([, tag]) => tags.indexOf(tag), [])),
|
|
31
|
-
match(
|
|
32
|
-
/^<(sup|sub|small|bdo|bdi)(?=[^\S\n]|>)/,
|
|
30
|
+
new RegExp(String.raw`^<(${TAGS.join('|')})(?=[^\S\n]|>)`),
|
|
33
31
|
memoize(
|
|
34
32
|
([, tag]) =>
|
|
35
33
|
surround<HTMLParser.TagParser, string>(surround(
|
|
36
|
-
str(`<${tag}`), some(attribute), str(
|
|
34
|
+
str(`<${tag}`), some(attribute), str(/^[^\S\n]*>/), true),
|
|
37
35
|
startLoose(some(union([
|
|
38
36
|
open(/^\n?/, some(inline, blankWith('\n', `</${tag}>`)), true),
|
|
39
37
|
])), `</${tag}>`),
|
|
40
38
|
str(`</${tag}>`), false,
|
|
41
39
|
([as, bs, cs], rest) =>
|
|
42
40
|
[[elem(tag, as, bs, cs)], rest]),
|
|
43
|
-
([, tag]) =>
|
|
41
|
+
([, tag]) => TAGS.indexOf(tag), [])),
|
|
44
42
|
match(
|
|
45
43
|
/^<([a-z]+)(?=[^\S\n]|>)/,
|
|
46
44
|
memoize(
|
|
47
45
|
([, tag]) =>
|
|
48
46
|
surround<HTMLParser.TagParser, string>(surround(
|
|
49
|
-
str(`<${tag}`), some(attribute), str(
|
|
47
|
+
str(`<${tag}`), some(attribute), str(/^[^\S\n]*>/), true),
|
|
50
48
|
startLoose(some(union([
|
|
51
49
|
open(/^\n?/, some(inline, blankWith('\n', `</${tag}>`)), true),
|
|
52
50
|
])), `</${tag}>`),
|
|
@@ -61,16 +59,159 @@ export const attribute: HTMLParser.TagParser.AttributeParser = union([
|
|
|
61
59
|
str(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/),
|
|
62
60
|
]);
|
|
63
61
|
|
|
62
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
|
|
63
|
+
// [...document.querySelectorAll('tbody > tr > td:first-child')].map(el => el.textContent.slice(1, -1))
|
|
64
|
+
const TAGS = Object.freeze([
|
|
65
|
+
"html",
|
|
66
|
+
"base",
|
|
67
|
+
"head",
|
|
68
|
+
"link",
|
|
69
|
+
"meta",
|
|
70
|
+
"style",
|
|
71
|
+
"title",
|
|
72
|
+
"body",
|
|
73
|
+
"address",
|
|
74
|
+
"article",
|
|
75
|
+
"aside",
|
|
76
|
+
"footer",
|
|
77
|
+
"header",
|
|
78
|
+
"h1", "h2", "h3", "h4", "h5", "h6",
|
|
79
|
+
"main",
|
|
80
|
+
"nav",
|
|
81
|
+
"section",
|
|
82
|
+
"blockquote",
|
|
83
|
+
"dd",
|
|
84
|
+
"div",
|
|
85
|
+
"dl",
|
|
86
|
+
"dt",
|
|
87
|
+
"figcaption",
|
|
88
|
+
"figure",
|
|
89
|
+
"hr",
|
|
90
|
+
"li",
|
|
91
|
+
"menu",
|
|
92
|
+
"ol",
|
|
93
|
+
"p",
|
|
94
|
+
"pre",
|
|
95
|
+
"ul",
|
|
96
|
+
"a",
|
|
97
|
+
"abbr",
|
|
98
|
+
"b",
|
|
99
|
+
"bdi",
|
|
100
|
+
"bdo",
|
|
101
|
+
"br",
|
|
102
|
+
"cite",
|
|
103
|
+
"code",
|
|
104
|
+
"data",
|
|
105
|
+
"dfn",
|
|
106
|
+
"em",
|
|
107
|
+
"i",
|
|
108
|
+
"kbd",
|
|
109
|
+
"mark",
|
|
110
|
+
"q",
|
|
111
|
+
"rp",
|
|
112
|
+
"rt",
|
|
113
|
+
"ruby",
|
|
114
|
+
"s",
|
|
115
|
+
"samp",
|
|
116
|
+
"small",
|
|
117
|
+
"span",
|
|
118
|
+
"strong",
|
|
119
|
+
"sub",
|
|
120
|
+
"sup",
|
|
121
|
+
"time",
|
|
122
|
+
"u",
|
|
123
|
+
"var",
|
|
124
|
+
"wbr",
|
|
125
|
+
"area",
|
|
126
|
+
"audio",
|
|
127
|
+
"img",
|
|
128
|
+
"map",
|
|
129
|
+
"track",
|
|
130
|
+
"video",
|
|
131
|
+
"embed",
|
|
132
|
+
"iframe",
|
|
133
|
+
"object",
|
|
134
|
+
"picture",
|
|
135
|
+
"portal",
|
|
136
|
+
"source",
|
|
137
|
+
"svg",
|
|
138
|
+
"math",
|
|
139
|
+
"canvas",
|
|
140
|
+
"noscript",
|
|
141
|
+
"script",
|
|
142
|
+
"del",
|
|
143
|
+
"ins",
|
|
144
|
+
"caption",
|
|
145
|
+
"col",
|
|
146
|
+
"colgroup",
|
|
147
|
+
"table",
|
|
148
|
+
"tbody",
|
|
149
|
+
"td",
|
|
150
|
+
"tfoot",
|
|
151
|
+
"th",
|
|
152
|
+
"thead",
|
|
153
|
+
"tr",
|
|
154
|
+
"button",
|
|
155
|
+
"datalist",
|
|
156
|
+
"fieldset",
|
|
157
|
+
"form",
|
|
158
|
+
"input",
|
|
159
|
+
"label",
|
|
160
|
+
"legend",
|
|
161
|
+
"meter",
|
|
162
|
+
"optgroup",
|
|
163
|
+
"option",
|
|
164
|
+
"output",
|
|
165
|
+
"progress",
|
|
166
|
+
"select",
|
|
167
|
+
"textarea",
|
|
168
|
+
"details",
|
|
169
|
+
"dialog",
|
|
170
|
+
"summary",
|
|
171
|
+
"slot",
|
|
172
|
+
"template",
|
|
173
|
+
"acronym",
|
|
174
|
+
"applet",
|
|
175
|
+
"basefont",
|
|
176
|
+
"bgsound",
|
|
177
|
+
"big",
|
|
178
|
+
"blink",
|
|
179
|
+
"center",
|
|
180
|
+
"content",
|
|
181
|
+
"dir",
|
|
182
|
+
"font",
|
|
183
|
+
"frame",
|
|
184
|
+
"frameset",
|
|
185
|
+
"hgroup",
|
|
186
|
+
"image",
|
|
187
|
+
"keygen",
|
|
188
|
+
"marquee",
|
|
189
|
+
"menuitem",
|
|
190
|
+
"nobr",
|
|
191
|
+
"noembed",
|
|
192
|
+
"noframes",
|
|
193
|
+
"param",
|
|
194
|
+
"plaintext",
|
|
195
|
+
"rb",
|
|
196
|
+
"rtc",
|
|
197
|
+
"shadow",
|
|
198
|
+
"spacer",
|
|
199
|
+
"strike",
|
|
200
|
+
"tt",
|
|
201
|
+
"xmp",
|
|
202
|
+
]);
|
|
203
|
+
|
|
64
204
|
function elem(tag: string, as: string[], bs: (HTMLElement | string)[], cs: string[]): HTMLElement {
|
|
65
205
|
assert(as.length > 0);
|
|
66
206
|
assert(as[0][0] === '<' && as[as.length - 1].slice(-1) === '>');
|
|
67
207
|
assert(cs.length === 1);
|
|
68
208
|
if (!tags.includes(tag)) return invalid('tag', `Invalid HTML tag <${tag}>`, as, bs, cs);
|
|
69
|
-
const attrs = attributes('html', [],
|
|
209
|
+
const attrs = attributes('html', [], attrspecs[tag], as.slice(1, -1));
|
|
70
210
|
return 'data-invalid-syntax' in attrs
|
|
71
211
|
? invalid('attribute', 'Invalid HTML attribute', as, bs, cs)
|
|
72
212
|
: h(tag as 'span', attrs, defrag(bs));
|
|
73
213
|
}
|
|
214
|
+
|
|
74
215
|
function invalid(type: string, message: string, as: (HTMLElement | string)[], bs: (HTMLElement | string)[], cs: (HTMLElement | string)[]): HTMLElement {
|
|
75
216
|
return h('span', {
|
|
76
217
|
class: 'invalid',
|
|
@@ -103,7 +244,7 @@ export function attributes(
|
|
|
103
244
|
? param.slice(name.length + 2, -1).replace(/\\(.?)/g, '$1')
|
|
104
245
|
: undefined;
|
|
105
246
|
invalid ||= !spec || name in attrs;
|
|
106
|
-
if (spec &&
|
|
247
|
+
if (spec && name in spec && !spec[name]) continue;
|
|
107
248
|
spec?.[name]?.includes(value) || value !== undefined && spec?.[name]?.length === 0
|
|
108
249
|
? attrs[name] = value ?? ''
|
|
109
250
|
: invalid ||= !!spec;
|
|
@@ -43,7 +43,7 @@ describe('Unit: parser/inline/strong', () => {
|
|
|
43
43
|
assert.deepStrictEqual(inspect(parser('**a*b*c**')), [['<strong>a<em>b</em>c</strong>'], '']);
|
|
44
44
|
assert.deepStrictEqual(inspect(parser('**a*b*c**d')), [['<strong>a<em>b</em>c</strong>'], 'd']);
|
|
45
45
|
assert.deepStrictEqual(inspect(parser('**`a`**')), [['<strong><code data-src="`a`">a</code></strong>'], '']);
|
|
46
|
-
assert.deepStrictEqual(inspect(parser('**<
|
|
46
|
+
assert.deepStrictEqual(inspect(parser('**<bdi>**')), [['<strong><bdi></strong>'], '']);
|
|
47
47
|
assert.deepStrictEqual(inspect(parser('**(*a*)**')), [['<strong><span class="paren">(<em>a</em>)</span></strong>'], '']);
|
|
48
48
|
assert.deepStrictEqual(inspect(parser('**(**a**)**')), [['<strong><span class="paren">(<strong>a</strong>)</span></strong>'], '']);
|
|
49
49
|
});
|
|
@@ -99,8 +99,8 @@ describe('Unit: parser/inline', () => {
|
|
|
99
99
|
assert.deepStrictEqual(inspect(parser('*++ ++*')), [['<em><ins> </ins></em>'], '']);
|
|
100
100
|
assert.deepStrictEqual(inspect(parser('*++ a ++*')), [['<em><ins> a </ins></em>'], '']);
|
|
101
101
|
assert.deepStrictEqual(inspect(parser('*++ a ++*')), [['<em><ins> a </ins></em>'], '']);
|
|
102
|
-
assert.deepStrictEqual(inspect(parser('*<
|
|
103
|
-
assert.deepStrictEqual(inspect(parser('<
|
|
102
|
+
assert.deepStrictEqual(inspect(parser('*<bdi>`a`</bdi>*')), [['<em><bdi><code data-src="`a`">a</code></bdi></em>'], '']);
|
|
103
|
+
assert.deepStrictEqual(inspect(parser('<bdi>*<bdi>a</bdi>*</bdi>')), [['<bdi><em><bdi>a</bdi></em></bdi>'], '']);
|
|
104
104
|
assert.deepStrictEqual(inspect(parser('<bdi>((<bdi>((a))</bdi>))</bdi>')), [['<bdi><sup class="annotation"><span><bdi><span class="paren">((a))</span></bdi></span></sup></bdi>'], '']);
|
|
105
105
|
assert.deepStrictEqual(inspect(parser('<bdi>[[<bdi>[[a]]</bdi>]]</bdi>')), [['<bdi><sup class="reference"><span><bdi>[[a]]</bdi></span></sup></bdi>'], '']);
|
|
106
106
|
assert.deepStrictEqual(inspect(parser('*[*]')), [['*', '[', '*', ']'], '']);
|
|
@@ -155,9 +155,8 @@ describe('Unit: parser/inline', () => {
|
|
|
155
155
|
assert.deepStrictEqual(inspect(parser('[(([a]{#}))]{#}')), [['<a href="#"><span class="paren">(<span class="paren">([a]{#})</span>)</span></a>'], '']);
|
|
156
156
|
assert.deepStrictEqual(inspect(parser('"[[""]]')), [['"', '<sup class="reference"><span>""</span></sup>'], '']);
|
|
157
157
|
assert.deepStrictEqual(inspect(parser('<http://host>')), [['<', '<a href="http://host" target="_blank">http://host</a>', '>'], '']);
|
|
158
|
-
assert.deepStrictEqual(inspect(parser('<<
|
|
159
|
-
assert.deepStrictEqual(inspect(parser('
|
|
160
|
-
assert.deepStrictEqual(inspect(parser('*<small>*`</small>`')), [['<em><small></em>', '<code data-src="`</small>`"></small></code>'], '']);
|
|
158
|
+
assert.deepStrictEqual(inspect(parser('<<bdi>a<</bdi>')), [['<', '<bdi>a<</bdi>'], '']);
|
|
159
|
+
assert.deepStrictEqual(inspect(parser('*<bdi>*`</bdi>`')), [['<em><bdi></em>', '<code data-src="`</bdi>`"></bdi></code>'], '']);
|
|
161
160
|
assert.deepStrictEqual(inspect(parser('[~http://host')), [['[', '~', '<a href="http://host" target="_blank">http://host</a>'], '']);
|
|
162
161
|
assert.deepStrictEqual(inspect(parser('[~a@b')), [['[', '~', '<a class="email" href="mailto:a@b">a@b</a>'], '']);
|
|
163
162
|
assert.deepStrictEqual(inspect(parser('[~~a~~]')), [['[', '<del>a</del>', ']'], '']);
|
|
@@ -29,7 +29,7 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
29
29
|
assert.deepStrictEqual(
|
|
30
30
|
[...target.children].map(el => el.outerHTML),
|
|
31
31
|
[
|
|
32
|
-
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="1" id="label:test-a"><figcaption><span class="figindex">Test 1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
32
|
+
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="1" id="label:test-a"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
33
33
|
'<p><a class="label" data-label="test-a" href="#label:test-a">Test 1</a></p>',
|
|
34
34
|
'<p><a class="label invalid" data-label="test-b" data-invalid-syntax="label" data-invalid-type="reference" data-invalid-message="Missing the target figure">$test-b</a></p>',
|
|
35
35
|
'<p><a class="label" data-label="test-a" href="#label:test-a">Test 1</a></p>',
|
|
@@ -51,12 +51,12 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
51
51
|
assert.deepStrictEqual(
|
|
52
52
|
[...target.children].map(el => el.outerHTML),
|
|
53
53
|
[
|
|
54
|
-
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="1" id="label:test-a"><figcaption><span class="figindex">Test 1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
54
|
+
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="1" id="label:test-a"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
55
55
|
'<h2 id="index:0">0</h2>',
|
|
56
|
-
'<figure data-type="quote" data-label="test-b" data-group="test" data-number="2" id="label:test-b"><figcaption><span class="figindex">Test 2. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
57
|
-
'<figure data-type="quote" data-label="quote-a" data-group="quote" data-number="1" id="label:quote-a"><figcaption><span class="figindex">Quote 1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
58
|
-
'<figure data-type="quote" data-label="test-b" data-group="test" data-number="3" class="invalid" data-invalid-syntax="figure" data-invalid-type="argument" data-invalid-message="Duplicate label"><figcaption><span class="figindex">Test 3. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
59
|
-
'<figure data-type="quote" data-label="test-c" data-group="test" data-number="4" id="label:test-c"><figcaption><span class="figindex">Test 4. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
56
|
+
'<figure data-type="quote" data-label="test-b" data-group="test" data-number="2" id="label:test-b"><figcaption><span class="figindex">Test 2. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
57
|
+
'<figure data-type="quote" data-label="quote-a" data-group="quote" data-number="1" id="label:quote-a"><figcaption><span class="figindex">Quote 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
58
|
+
'<figure data-type="quote" data-label="test-b" data-group="test" data-number="3" class="invalid" data-invalid-syntax="figure" data-invalid-type="argument" data-invalid-message="Duplicate label"><figcaption><span class="figindex">Test 3. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
59
|
+
'<figure data-type="quote" data-label="test-c" data-group="test" data-number="4" id="label:test-c"><figcaption><span class="figindex">Test 4. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
60
60
|
]);
|
|
61
61
|
}
|
|
62
62
|
});
|
|
@@ -71,7 +71,7 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
71
71
|
assert.deepStrictEqual(
|
|
72
72
|
[...target.children].map(el => el.outerHTML),
|
|
73
73
|
[
|
|
74
|
-
'<figure data-type="math" data-label="$-a" data-group="$" data-number="1" id="label:$-a"><figcaption><span class="figindex">(1)</span></figcaption><div><div class="math" translate="no">$$\n$$</div></div></figure>',
|
|
74
|
+
'<figure data-type="math" data-label="$-a" data-group="$" data-number="1" id="label:$-a"><figcaption><span class="figindex">(1)</span><span class="figtext"></span></figcaption><div><div class="math" translate="no">$$\n$$</div></div></figure>',
|
|
75
75
|
'<p><a class="label" data-label="$-a" href="#label:$-a">(1)</a></p>',
|
|
76
76
|
]);
|
|
77
77
|
}
|
|
@@ -93,11 +93,11 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
93
93
|
assert.deepStrictEqual(
|
|
94
94
|
[...target.children].map(el => el.outerHTML),
|
|
95
95
|
[
|
|
96
|
-
'<figure data-type="quote" data-label="test-2" data-group="test" data-number="2" id="label:test-2"><figcaption><span class="figindex">Test 2. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
97
|
-
'<figure data-type="quote" data-label="test-3.1" data-group="test" data-number="3.1" id="label:test-3.1"><figcaption><span class="figindex">Test 3.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
98
|
-
'<figure data-type="math" data-label="$-4.1.1" data-group="$" data-number="4.1.1" id="label:$-4.1.1"><figcaption><span class="figindex">(4.1.1)</span></figcaption><div><div class="math" translate="no">$$\n$$</div></div></figure>',
|
|
99
|
-
'<figure data-type="math" data-label="$-a" data-group="$" data-number="1" id="label:$-a"><figcaption><span class="figindex">(1)</span></figcaption><div><div class="math" translate="no">$$\n$$</div></div></figure>',
|
|
100
|
-
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="1" id="label:test-a"><figcaption><span class="figindex">Test 1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
96
|
+
'<figure data-type="quote" data-label="test-2" data-group="test" data-number="2" id="label:test-2"><figcaption><span class="figindex">Test 2. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
97
|
+
'<figure data-type="quote" data-label="test-3.1" data-group="test" data-number="3.1" id="label:test-3.1"><figcaption><span class="figindex">Test 3.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
98
|
+
'<figure data-type="math" data-label="$-4.1.1" data-group="$" data-number="4.1.1" id="label:$-4.1.1"><figcaption><span class="figindex">(4.1.1)</span><span class="figtext"></span></figcaption><div><div class="math" translate="no">$$\n$$</div></div></figure>',
|
|
99
|
+
'<figure data-type="math" data-label="$-a" data-group="$" data-number="1" id="label:$-a"><figcaption><span class="figindex">(1)</span><span class="figtext"></span></figcaption><div><div class="math" translate="no">$$\n$$</div></div></figure>',
|
|
100
|
+
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="1" id="label:test-a"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
101
101
|
'<p><a class="label" data-label="test-2" href="#label:test-2">Test 2</a></p>',
|
|
102
102
|
'<p><a class="label" data-label="$-4.1.1" href="#label:$-4.1.1">(4.1.1)</a></p>',
|
|
103
103
|
'<p><a class="label invalid" data-label="test-1" data-invalid-syntax="label" data-invalid-type="reference" data-invalid-message="Missing the target figure">$test-1</a></p>',
|
|
@@ -117,10 +117,10 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
117
117
|
assert.deepStrictEqual(
|
|
118
118
|
[...target.children].map(el => el.outerHTML),
|
|
119
119
|
[
|
|
120
|
-
'<blockquote><blockquote><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span></figcaption><div><blockquote></blockquote></div></figure><ol class="references"></ol></section></blockquote><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span></figcaption><div><blockquote></blockquote></div></figure><ol class="references"></ol></section></blockquote>',
|
|
121
|
-
'<aside class="example" data-type="markdown"><pre translate="no">~~~figure $test-a\n> \n\n~~~\n\n$test-a</pre><hr><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span></figcaption><div><blockquote></blockquote></div></figure><p><a class="label disabled" data-label="test-a">Test 1</a></p><ol class="references"></ol></section></aside>',
|
|
122
|
-
'<figure data-type="quote" data-label="test-b" data-group="test" data-number="1" id="label:test-b"><figcaption><span class="figindex">Test 1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
123
|
-
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="2" id="label:test-a"><figcaption><span class="figindex">Test 2. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
120
|
+
'<blockquote><blockquote><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure><ol class="references"></ol></section></blockquote><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure><ol class="references"></ol></section></blockquote>',
|
|
121
|
+
'<aside class="example" data-type="markdown"><pre translate="no">~~~figure $test-a\n> \n\n~~~\n\n$test-a</pre><hr><section><figure data-type="quote" data-label="test-a" data-group="test" data-number="1"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure><p><a class="label disabled" data-label="test-a">Test 1</a></p><ol class="references"></ol></section></aside>',
|
|
122
|
+
'<figure data-type="quote" data-label="test-b" data-group="test" data-number="1" id="label:test-b"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
123
|
+
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="2" id="label:test-a"><figcaption><span class="figindex">Test 2. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
124
124
|
]);
|
|
125
125
|
}
|
|
126
126
|
});
|
|
@@ -171,18 +171,18 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
171
171
|
'<h1 id="index:0">0</h1>',
|
|
172
172
|
'<figure data-label="$-0.0" data-group="$" hidden="" data-number="0.0"></figure>',
|
|
173
173
|
'<h2 id="index:0">0</h2>',
|
|
174
|
-
'<figure data-type="quote" data-label="test-1" data-group="test" data-number="1" id="label:test-1"><figcaption><span class="figindex">Test 1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
174
|
+
'<figure data-type="quote" data-label="test-1" data-group="test" data-number="1" id="label:test-1"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
175
175
|
'<h2 id="index:0">0</h2>',
|
|
176
176
|
'<blockquote><section><h2>0</h2><ol class="references"></ol></section></blockquote>',
|
|
177
|
-
'<figure data-type="quote" data-label="test-b" data-group="test" data-number="2.1" id="label:test-b"><figcaption><span class="figindex">Test 2.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
177
|
+
'<figure data-type="quote" data-label="test-b" data-group="test" data-number="2.1" id="label:test-b"><figcaption><span class="figindex">Test 2.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
178
178
|
'<h2 id="index:0">0</h2>',
|
|
179
179
|
'<figure data-label="$-0.0.0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="argument" data-invalid-message="Base index must be $-x.0 format"></figure>',
|
|
180
180
|
'<h3 id="index:0">0</h3>',
|
|
181
181
|
'<figure data-label="$-0.0" data-group="$" hidden="" data-number="3.0"></figure>',
|
|
182
|
-
'<figure data-type="quote" data-label="test-c" data-group="test" data-number="3.1" id="label:test-c"><figcaption><span class="figindex">Test 3.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
182
|
+
'<figure data-type="quote" data-label="test-c" data-group="test" data-number="3.1" id="label:test-c"><figcaption><span class="figindex">Test 3.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
183
183
|
'<h2 id="index:0">0</h2>',
|
|
184
184
|
'<figure data-label="$-0.1.0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="argument" data-invalid-message="Base index must be $-x.0 format"></figure>',
|
|
185
|
-
'<figure data-type="quote" data-label="test-d" data-group="test" data-number="4.1" id="label:test-d"><figcaption><span class="figindex">Test 4.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
185
|
+
'<figure data-type="quote" data-label="test-d" data-group="test" data-number="4.1" id="label:test-d"><figcaption><span class="figindex">Test 4.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
186
186
|
'<figure data-label="$-0.0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="position" data-invalid-message="Base index declarations must be after level 1 to 6 headings"></figure>',
|
|
187
187
|
'<figure data-label="$-0.1.0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="argument" data-invalid-message="Base index must be $-x.0 format"></figure>',
|
|
188
188
|
'<figure data-label="$-0.4.0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="argument" data-invalid-message="Base index must be $-x.0 format"></figure>',
|
|
@@ -190,19 +190,19 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
190
190
|
'<h2 id="index:0">0</h2>',
|
|
191
191
|
'<h2 id="index:0">0</h2>',
|
|
192
192
|
'<figure data-label="$-0.0" data-group="$" hidden="" data-number="6.0"></figure>',
|
|
193
|
-
'<figure data-type="quote" data-label="test-e" data-group="test" data-number="6.1" id="label:test-e"><figcaption><span class="figindex">Test 6.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
193
|
+
'<figure data-type="quote" data-label="test-e" data-group="test" data-number="6.1" id="label:test-e"><figcaption><span class="figindex">Test 6.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
194
194
|
'<h2 id="index:0">0</h2>',
|
|
195
195
|
'<figure data-label="$-5.0" data-group="$" hidden="" data-number="5.0"></figure>',
|
|
196
|
-
'<figure data-type="quote" data-label="test-f" data-group="test" data-number="5.1" id="label:test-f"><figcaption><span class="figindex">Test 5.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
196
|
+
'<figure data-type="quote" data-label="test-f" data-group="test" data-number="5.1" id="label:test-f"><figcaption><span class="figindex">Test 5.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
197
197
|
'<figure data-label="$-0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="argument" data-invalid-message="Invalid base index"></figure>',
|
|
198
|
-
'<figure data-type="quote" data-label="test-g" data-group="test" data-number="5.2" id="label:test-g"><figcaption><span class="figindex">Test 5.2. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
198
|
+
'<figure data-type="quote" data-label="test-g" data-group="test" data-number="5.2" id="label:test-g"><figcaption><span class="figindex">Test 5.2. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
199
199
|
'<h3 id="index:0">0</h3>',
|
|
200
200
|
'<figure data-label="$-0.0.0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="argument" data-invalid-message="Base index must be $-x.0 format"></figure>',
|
|
201
|
-
'<figure data-type="quote" data-label="test-h" data-group="test" data-number="5.3" id="label:test-h"><figcaption><span class="figindex">Test 5.3. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
201
|
+
'<figure data-type="quote" data-label="test-h" data-group="test" data-number="5.3" id="label:test-h"><figcaption><span class="figindex">Test 5.3. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
202
202
|
'<h3 id="index:0">0</h3>',
|
|
203
|
-
'<figure data-type="quote" data-label="test-i" data-group="test" data-number="5.4" id="label:test-i"><figcaption><span class="figindex">Test 5.4. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
203
|
+
'<figure data-type="quote" data-label="test-i" data-group="test" data-number="5.4" id="label:test-i"><figcaption><span class="figindex">Test 5.4. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
204
204
|
'<h1 id="index:0">0</h1>',
|
|
205
|
-
'<figure data-type="quote" data-label="test-j" data-group="test" data-number="6.1" id="label:test-j"><figcaption><span class="figindex">Test 6.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
205
|
+
'<figure data-type="quote" data-label="test-j" data-group="test" data-number="6.1" id="label:test-j"><figcaption><span class="figindex">Test 6.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
206
206
|
]);
|
|
207
207
|
}
|
|
208
208
|
});
|
|
@@ -237,22 +237,22 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
237
237
|
'<figure data-label="$-0.0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="position" data-invalid-message="Base index declarations must be after level 1 to 6 headings"></figure>',
|
|
238
238
|
'<h2 id="index:0">0</h2>',
|
|
239
239
|
'<figure data-label="$-0.0" data-group="$" hidden="" data-number="0.0"></figure>',
|
|
240
|
-
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="0.1" id="label:test-a"><figcaption><span class="figindex">Test 0.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
240
|
+
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="0.1" id="label:test-a"><figcaption><span class="figindex">Test 0.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
241
241
|
'<figure data-label="$-0.0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="position" data-invalid-message="Base index declarations must be after level 1 to 6 headings"></figure>',
|
|
242
242
|
'<h2 id="index:0">0</h2>',
|
|
243
|
-
'<figure data-type="quote" data-label="test-b" data-group="test" data-number="1.1" id="label:test-b"><figcaption><span class="figindex">Test 1.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
243
|
+
'<figure data-type="quote" data-label="test-b" data-group="test" data-number="1.1" id="label:test-b"><figcaption><span class="figindex">Test 1.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
244
244
|
'<figure data-label="$-0.0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="position" data-invalid-message="Base index declarations must be after level 1 to 6 headings"></figure>',
|
|
245
245
|
'<h3 id="index:0">0</h3>',
|
|
246
|
-
'<figure data-type="quote" data-label="test-c" data-group="test" data-number="1.2" id="label:test-c"><figcaption><span class="figindex">Test 1.2. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
246
|
+
'<figure data-type="quote" data-label="test-c" data-group="test" data-number="1.2" id="label:test-c"><figcaption><span class="figindex">Test 1.2. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
247
247
|
'<figure data-label="$-1.0" data-group="$" class="invalid" data-invalid-syntax="figure" data-invalid-type="position" data-invalid-message="Base index declarations must be after level 1 to 6 headings"></figure>',
|
|
248
248
|
'<h2 id="index:0">0</h2>',
|
|
249
249
|
'<figure data-label="$-0.0" data-group="$" hidden="" data-number="2.0"></figure>',
|
|
250
|
-
'<figure data-type="quote" data-label="test-d" data-group="test" data-number="2.1" id="label:test-d"><figcaption><span class="figindex">Test 2.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
250
|
+
'<figure data-type="quote" data-label="test-d" data-group="test" data-number="2.1" id="label:test-d"><figcaption><span class="figindex">Test 2.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
251
251
|
'<h3 id="index:0">0</h3>',
|
|
252
252
|
'<figure data-label="$-0.0" data-group="$" hidden="" data-number="2.0"></figure>',
|
|
253
253
|
'<h2 id="index:0">0</h2>',
|
|
254
254
|
'<figure data-label="$-9.0" data-group="$" hidden="" data-number="9.0"></figure>',
|
|
255
|
-
'<figure data-type="quote" data-label="test-e" data-group="test" data-number="9.1" id="label:test-e"><figcaption><span class="figindex">Test 9.1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
255
|
+
'<figure data-type="quote" data-label="test-e" data-group="test" data-number="9.1" id="label:test-e"><figcaption><span class="figindex">Test 9.1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
256
256
|
]);
|
|
257
257
|
}
|
|
258
258
|
});
|
|
@@ -268,7 +268,7 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
268
268
|
assert.deepStrictEqual(
|
|
269
269
|
[...target.children].map(el => el.outerHTML),
|
|
270
270
|
[
|
|
271
|
-
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="1" id="label:test-a"><figcaption><span class="figindex">Test 1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
271
|
+
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="1" id="label:test-a"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
272
272
|
'<p><a class="label" data-label="test-a" href="#label:test-a">Test 1</a></p>',
|
|
273
273
|
'<p><a class="label" data-label="test-a" href="#label:test-a">Test 1</a></p>',
|
|
274
274
|
]);
|
|
@@ -285,7 +285,7 @@ describe('Unit: parser/processor/figure', () => {
|
|
|
285
285
|
assert.deepStrictEqual(
|
|
286
286
|
[...target.children].map(el => el.outerHTML),
|
|
287
287
|
[
|
|
288
|
-
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="1" id="label:0:test-a"><figcaption><span class="figindex">Test 1. </span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
288
|
+
'<figure data-type="quote" data-label="test-a" data-group="test" data-number="1" id="label:0:test-a"><figcaption><span class="figindex">Test 1. </span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>',
|
|
289
289
|
'<p><a class="label" data-label="test-a" href="#label:0:test-a">Test 1</a></p>',
|
|
290
290
|
]);
|
|
291
291
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { annotation, reference } from './footnote';
|
|
1
|
+
import { footnote, annotation, reference } from './footnote';
|
|
2
2
|
import { parse as parse_ } from '../../parser';
|
|
3
3
|
import { html } from 'typed-dom/dom';
|
|
4
4
|
|
|
@@ -190,7 +190,7 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
190
190
|
it('split', () => {
|
|
191
191
|
const target = parse('((1))\n\n## a\n\n## b\n\n((2))((3))\n\n## c\n\n((4))');
|
|
192
192
|
for (let i = 0; i < 3; ++i) {
|
|
193
|
-
[...
|
|
193
|
+
[...footnote(target)];
|
|
194
194
|
assert.deepStrictEqual(
|
|
195
195
|
[...target.children].map(el => el.outerHTML),
|
|
196
196
|
[
|
|
@@ -10,6 +10,9 @@ export function* footnote(
|
|
|
10
10
|
opts: { readonly id?: string; } = {},
|
|
11
11
|
bottom: Node | null = null,
|
|
12
12
|
): Generator<HTMLAnchorElement | HTMLLIElement | undefined, undefined, undefined> {
|
|
13
|
+
// Bug: Firefox
|
|
14
|
+
//target.querySelectorAll(`:scope > .annotations`).forEach(el => el.remove());
|
|
15
|
+
target.querySelectorAll(`.annotations`).forEach(el => el.parentNode === target && el.remove());
|
|
13
16
|
yield* reference(target, footnotes?.references, opts, bottom);
|
|
14
17
|
yield* annotation(target, footnotes?.annotations, opts, bottom);
|
|
15
18
|
return;
|
|
@@ -39,10 +42,8 @@ function build(
|
|
|
39
42
|
//const splitters = push([], target.querySelectorAll(`:scope > :is(${splitter ?? '_'})`));
|
|
40
43
|
const splitters = push([], target.querySelectorAll(splitter ?? '_'))
|
|
41
44
|
.filter(el => el.parentNode === target);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
target.querySelectorAll(`.${syntax}s`).forEach(el => el.parentNode === target && el.remove());
|
|
45
|
-
let offset = 0;
|
|
45
|
+
let count = 0;
|
|
46
|
+
let total = 0;
|
|
46
47
|
let style: 'count' | 'abbr';
|
|
47
48
|
for (
|
|
48
49
|
let refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`),
|
|
@@ -51,12 +52,11 @@ function build(
|
|
|
51
52
|
const ref = refs[i];
|
|
52
53
|
while (+splitters[0]?.compareDocumentPosition(ref) & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
53
54
|
if (defs.size > 0) {
|
|
54
|
-
|
|
55
|
+
total += defs.size;
|
|
55
56
|
yield* proc(defs, target.insertBefore(html('ol', { class: `${syntax}s` }), splitters[0] ?? null));
|
|
56
57
|
}
|
|
57
58
|
splitters.shift();
|
|
58
59
|
}
|
|
59
|
-
if (syntax === 'annotation' && ref.closest('#annotations, .annotations, #references, .references')) continue;
|
|
60
60
|
const identifier = `${+!ref.querySelector('.label')}:${ref.getAttribute('data-abbr') || '_' + ref.firstElementChild!.innerHTML}`;
|
|
61
61
|
const abbr = ref.getAttribute('data-abbr') || undefined;
|
|
62
62
|
const content = frag(ref.firstElementChild!.cloneNode(true).childNodes);
|
|
@@ -95,7 +95,7 @@ function build(
|
|
|
95
95
|
: buffer.set(identifier, ref);
|
|
96
96
|
assert(syntax !== 'annotation' || !buffer.has(identifier));
|
|
97
97
|
const blank = !!abbr && !content.firstChild;
|
|
98
|
-
const refIndex =
|
|
98
|
+
const refIndex = ++count;
|
|
99
99
|
const refId = opts.id !== ''
|
|
100
100
|
? ref.id || `${syntax}:${opts.id ? `${opts.id}:` : ''}ref:${refIndex}`
|
|
101
101
|
: undefined;
|
|
@@ -103,8 +103,8 @@ function build(
|
|
|
103
103
|
|| defs.get(identifier)
|
|
104
104
|
|| defs.set(identifier, html('li',
|
|
105
105
|
{
|
|
106
|
-
id: opts.id !== '' ? `${syntax}:${opts.id ? `${opts.id}:` : ''}def:${defs.size +
|
|
107
|
-
'data-marker': !footnote ? marker(defs.size +
|
|
106
|
+
id: opts.id !== '' ? `${syntax}:${opts.id ? `${opts.id}:` : ''}def:${total + defs.size + 1}` : undefined,
|
|
107
|
+
'data-marker': !footnote ? marker(total + defs.size + 1, abbr) : undefined,
|
|
108
108
|
},
|
|
109
109
|
[content.cloneNode(true), html('sup')]))
|
|
110
110
|
.get(identifier)!;
|
|
@@ -123,7 +123,7 @@ function build(
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
const defIndex = +def.id.slice(def.id.lastIndexOf(':') + 1) || defs.size
|
|
126
|
+
const defIndex = +def.id.slice(def.id.lastIndexOf(':') + 1) || total + defs.size;
|
|
127
127
|
const defId = def.id || undefined;
|
|
128
128
|
define(ref, {
|
|
129
129
|
id: refId,
|