securemark 0.271.0 → 0.273.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.js +99 -100
- package/index.d.ts +2 -2
- package/package.json +16 -16
- package/src/parser/api/bind.test.ts +5 -5
- package/src/parser/api/bind.ts +4 -4
- package/src/parser/api/parse.test.ts +9 -9
- package/src/parser/api/parse.ts +4 -4
- package/src/parser/block/blockquote.ts +1 -1
- package/src/parser/block/extension/aside.ts +4 -4
- package/src/parser/block/extension/example.ts +1 -1
- package/src/parser/inline/autolink/url.ts +2 -2
- package/src/parser/inline/autolink.ts +3 -3
- package/src/parser/inline/extension/indexee.ts +9 -5
- package/src/parser/inline/media.ts +2 -2
- package/src/parser/inline.ts +3 -3
- package/src/parser/processor/figure.ts +2 -2
- package/src/parser/processor/note.test.ts +369 -0
- package/src/parser/processor/{footnote.ts → note.ts} +38 -43
- package/tsconfig.json +2 -1
- package/webpack.config.js +4 -4
- package/src/parser/processor/footnote.test.ts +0 -317
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import { footnote, annotation, reference } from './footnote';
|
|
2
|
-
import { parse as parse_ } from '../../parser';
|
|
3
|
-
import { html } from 'typed-dom/dom';
|
|
4
|
-
|
|
5
|
-
const parse = (s: string) => parse_(s, { test: true });
|
|
6
|
-
|
|
7
|
-
describe('Unit: parser/processor/footnote', () => {
|
|
8
|
-
describe('annotation', () => {
|
|
9
|
-
it('empty', () => {
|
|
10
|
-
const target = parse('');
|
|
11
|
-
const footnote = html('ol');
|
|
12
|
-
[...annotation(target, footnote)];
|
|
13
|
-
assert.deepStrictEqual(
|
|
14
|
-
[...target.children].map(el => el.outerHTML),
|
|
15
|
-
[]);
|
|
16
|
-
assert.deepStrictEqual(
|
|
17
|
-
footnote.outerHTML,
|
|
18
|
-
html('ol').outerHTML);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('1', () => {
|
|
22
|
-
const target = parse('((a b))');
|
|
23
|
-
const footnote = html('ol');
|
|
24
|
-
for (let i = 0; i < 3; ++i) {
|
|
25
|
-
assert.deepStrictEqual([...annotation(target, footnote)].length, i === 0 ? 2 : 1);
|
|
26
|
-
assert.deepStrictEqual(
|
|
27
|
-
[...target.children].map(el => el.outerHTML),
|
|
28
|
-
[
|
|
29
|
-
html('p', [
|
|
30
|
-
html('sup', { class: "annotation", id: "annotation::ref:1", title: "a b" }, [
|
|
31
|
-
html('span', { hidden: '' }, 'a b'),
|
|
32
|
-
html('a', { href: "#annotation::def:1" }, '*1')
|
|
33
|
-
]),
|
|
34
|
-
]).outerHTML,
|
|
35
|
-
]);
|
|
36
|
-
assert.deepStrictEqual(
|
|
37
|
-
footnote.outerHTML,
|
|
38
|
-
html('ol', [
|
|
39
|
-
html('li', { id: 'annotation::def:1' }, [
|
|
40
|
-
html('span', { id: 'note::a_b' }, 'a b'),
|
|
41
|
-
html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
|
|
42
|
-
]),
|
|
43
|
-
]).outerHTML);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('2', () => {
|
|
48
|
-
const target = parse('((1))((12345678901234567890))');
|
|
49
|
-
const footnote = html('ol');
|
|
50
|
-
for (let i = 0; i < 3; ++i) {
|
|
51
|
-
assert.deepStrictEqual([...annotation(target, footnote)].length, i === 0 ? 4 : 2);
|
|
52
|
-
assert.deepStrictEqual(
|
|
53
|
-
[...target.children].map(el => el.outerHTML),
|
|
54
|
-
[
|
|
55
|
-
html('p', [
|
|
56
|
-
html('sup', { class: "annotation", id: "annotation::ref:1", title: "1" }, [
|
|
57
|
-
html('span', { hidden: '' }, '1'),
|
|
58
|
-
html('a', { href: "#annotation::def:1" }, '*1')
|
|
59
|
-
]),
|
|
60
|
-
html('sup', { class: "annotation", id: "annotation::ref:2", title: "12345678901234567890" }, [
|
|
61
|
-
html('span', { hidden: '' }, '12345678901234567890'),
|
|
62
|
-
html('a', { href: "#annotation::def:2" }, '*2')
|
|
63
|
-
]),
|
|
64
|
-
]).outerHTML,
|
|
65
|
-
]);
|
|
66
|
-
assert.deepStrictEqual(
|
|
67
|
-
footnote.outerHTML,
|
|
68
|
-
html('ol', [
|
|
69
|
-
html('li', { id: 'annotation::def:1' }, [
|
|
70
|
-
html('span', { id: 'note::1' }, '1'),
|
|
71
|
-
html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
|
|
72
|
-
]),
|
|
73
|
-
html('li', { id: 'annotation::def:2' }, [
|
|
74
|
-
html('span', { id: 'note::12345678901234567890' }, '12345678901234567890'),
|
|
75
|
-
html('sup', [html('a', { href: '#annotation::ref:2' }, '^2')])
|
|
76
|
-
]),
|
|
77
|
-
]).outerHTML);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('unify', () => {
|
|
82
|
-
const target = parse('((1))((2))((3))((2))((4))');
|
|
83
|
-
const footnote = html('ol');
|
|
84
|
-
for (let i = 0; i < 3; ++i) {
|
|
85
|
-
[...annotation(target, footnote)];
|
|
86
|
-
assert.deepStrictEqual(
|
|
87
|
-
[...target.children].map(el => el.outerHTML),
|
|
88
|
-
[
|
|
89
|
-
html('p', [
|
|
90
|
-
html('sup', { class: "annotation", id: "annotation::ref:1", title: "1" }, [
|
|
91
|
-
html('span', { hidden: '' }, '1'),
|
|
92
|
-
html('a', { href: "#annotation::def:1" }, '*1')
|
|
93
|
-
]),
|
|
94
|
-
html('sup', { class: "annotation", id: "annotation::ref:2", title: "2" }, [
|
|
95
|
-
html('span', { hidden: '' }, '2'),
|
|
96
|
-
html('a', { href: "#annotation::def:2" }, '*2')
|
|
97
|
-
]),
|
|
98
|
-
html('sup', { class: "annotation", id: "annotation::ref:3", title: "3" }, [
|
|
99
|
-
html('span', { hidden: '' }, '3'),
|
|
100
|
-
html('a', { href: "#annotation::def:3" }, '*3')
|
|
101
|
-
]),
|
|
102
|
-
html('sup', { class: "annotation", id: "annotation::ref:4", title: "2" }, [
|
|
103
|
-
html('span', { hidden: '' }, '2'),
|
|
104
|
-
html('a', { href: "#annotation::def:2" }, '*2')
|
|
105
|
-
]),
|
|
106
|
-
html('sup', { class: "annotation", id: "annotation::ref:5", title: "4" }, [
|
|
107
|
-
html('span', { hidden: '' }, '4'),
|
|
108
|
-
html('a', { href: "#annotation::def:4" }, '*4')
|
|
109
|
-
]),
|
|
110
|
-
]).outerHTML,
|
|
111
|
-
]);
|
|
112
|
-
assert.deepStrictEqual(
|
|
113
|
-
footnote.outerHTML,
|
|
114
|
-
html('ol', [
|
|
115
|
-
html('li', { id: 'annotation::def:1' }, [
|
|
116
|
-
html('span', { id: 'note::1' }, '1'),
|
|
117
|
-
html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
|
|
118
|
-
]),
|
|
119
|
-
html('li', { id: 'annotation::def:2' }, [
|
|
120
|
-
html('span', { id: 'note::2' }, '2'),
|
|
121
|
-
html('sup', [
|
|
122
|
-
html('a', { href: '#annotation::ref:2' }, '^2'),
|
|
123
|
-
html('a', { href: '#annotation::ref:4' }, '^4'),
|
|
124
|
-
]),
|
|
125
|
-
]),
|
|
126
|
-
html('li', { id: 'annotation::def:3' }, [
|
|
127
|
-
html('span', { id: 'note::3' }, '3'),
|
|
128
|
-
html('sup', [html('a', { href: '#annotation::ref:3' }, '^3')])
|
|
129
|
-
]),
|
|
130
|
-
html('li', { id: 'annotation::def:4' }, [
|
|
131
|
-
html('span', { id: 'note::4' }, '4'),
|
|
132
|
-
html('sup', [html('a', { href: '#annotation::ref:5' }, '^5')])
|
|
133
|
-
]),
|
|
134
|
-
]).outerHTML);
|
|
135
|
-
}
|
|
136
|
-
[...annotation(parse(''), footnote)];
|
|
137
|
-
assert.deepStrictEqual(
|
|
138
|
-
footnote.outerHTML,
|
|
139
|
-
html('ol').outerHTML);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('separation', () => {
|
|
143
|
-
const target = html('blockquote', parse([
|
|
144
|
-
'!>> ((a))\n> ((a))\n~~~',
|
|
145
|
-
'~~~~example/markdown\n((a))\n~~~~',
|
|
146
|
-
'((a))',
|
|
147
|
-
].join('\n\n')).children);
|
|
148
|
-
const footnote = html('ol');
|
|
149
|
-
for (let i = 0; i < 3; ++i) {
|
|
150
|
-
[...annotation(target, footnote)];
|
|
151
|
-
assert.deepStrictEqual(
|
|
152
|
-
[...target.children].map(el => el.outerHTML),
|
|
153
|
-
[
|
|
154
|
-
'<blockquote><blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1"><span>a</span><sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup><br>~~~</p><ol class="annotations"><li data-marker="*1"><span>a</span><sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></blockquote>',
|
|
155
|
-
'<aside class="example" data-type="markdown"><pre translate="no">((a))</pre><hr><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup></p><ol class="annotations"><li data-marker="*1"><span>a</span><sup><a>^1</a></sup></li></ol><h2>References</h2><ol class="references"></ol></section></aside>',
|
|
156
|
-
'<p><sup class="annotation" id="annotation::ref:1" title="a"><span hidden="">a</span><a href="#annotation::def:1">*1</a></sup></p>',
|
|
157
|
-
]);
|
|
158
|
-
assert.deepStrictEqual(
|
|
159
|
-
footnote.outerHTML,
|
|
160
|
-
'<ol><li id="annotation::def:1"><span id="note::a">a</span><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>');
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('id', () => {
|
|
165
|
-
const target = parse('((a b))');
|
|
166
|
-
const footnote = html('ol');
|
|
167
|
-
for (let i = 0; i < 3; ++i) {
|
|
168
|
-
assert.deepStrictEqual([...annotation(target, footnote, { id: '0' })].length, i === 0 ? 2 : 1);
|
|
169
|
-
assert.deepStrictEqual(
|
|
170
|
-
[...target.children].map(el => el.outerHTML),
|
|
171
|
-
[
|
|
172
|
-
html('p', [
|
|
173
|
-
html('sup', { class: "annotation", id: "annotation:0:ref:1", title: "a b" }, [
|
|
174
|
-
html('span', { hidden: '' }, 'a b'),
|
|
175
|
-
html('a', { href: "#annotation:0:def:1" }, '*1')
|
|
176
|
-
]),
|
|
177
|
-
]).outerHTML,
|
|
178
|
-
]);
|
|
179
|
-
assert.deepStrictEqual(
|
|
180
|
-
footnote.outerHTML,
|
|
181
|
-
html('ol', [
|
|
182
|
-
html('li', { id: 'annotation:0:def:1' }, [
|
|
183
|
-
html('span', { id: 'note:0:a_b' }, 'a b'),
|
|
184
|
-
html('sup', [html('a', { href: '#annotation:0:ref:1' }, '^1')])
|
|
185
|
-
]),
|
|
186
|
-
]).outerHTML);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it('split', () => {
|
|
191
|
-
const target = parse('((1))\n\n## a\n\n## b\n\n((2))((3))\n\n## c\n\n((4))');
|
|
192
|
-
for (let i = 0; i < 3; ++i) {
|
|
193
|
-
[...footnote(target)];
|
|
194
|
-
assert.deepStrictEqual(
|
|
195
|
-
[...target.children].map(el => el.outerHTML),
|
|
196
|
-
[
|
|
197
|
-
html('p', [
|
|
198
|
-
html('sup', { class: "annotation", id: "annotation::ref:1", title: "1" }, [
|
|
199
|
-
html('span', { hidden: '' }, '1'),
|
|
200
|
-
html('a', { href: "#annotation::def:1" }, '*1')
|
|
201
|
-
]),
|
|
202
|
-
]).outerHTML,
|
|
203
|
-
html('ol', { class: 'annotations' }, [
|
|
204
|
-
html('li', { id: 'annotation::def:1', 'data-marker': '*1' }, [
|
|
205
|
-
html('span', { id: 'note::1' }, '1'),
|
|
206
|
-
html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
|
|
207
|
-
]),
|
|
208
|
-
]).outerHTML,
|
|
209
|
-
html('h2', { id: 'index::a' }, 'a').outerHTML,
|
|
210
|
-
html('h2', { id: 'index::b' }, 'b').outerHTML,
|
|
211
|
-
html('p', [
|
|
212
|
-
html('sup', { class: "annotation", id: "annotation::ref:2", title: "2" }, [
|
|
213
|
-
html('span', { hidden: '' }, '2'),
|
|
214
|
-
html('a', { href: "#annotation::def:2" }, '*2')
|
|
215
|
-
]),
|
|
216
|
-
html('sup', { class: "annotation", id: "annotation::ref:3", title: "3" }, [
|
|
217
|
-
html('span', { hidden: '' }, '3'),
|
|
218
|
-
html('a', { href: "#annotation::def:3" }, '*3')
|
|
219
|
-
]),
|
|
220
|
-
]).outerHTML,
|
|
221
|
-
html('ol', { class: 'annotations' }, [
|
|
222
|
-
html('li', { id: 'annotation::def:2', 'data-marker': '*2' }, [
|
|
223
|
-
html('span', { id: 'note::2' }, '2'),
|
|
224
|
-
html('sup', [html('a', { href: '#annotation::ref:2' }, '^2')])
|
|
225
|
-
]),
|
|
226
|
-
html('li', { id: 'annotation::def:3', 'data-marker': '*3' }, [
|
|
227
|
-
html('span', { id: 'note::3' }, '3'),
|
|
228
|
-
html('sup', [html('a', { href: '#annotation::ref:3' }, '^3')])
|
|
229
|
-
]),
|
|
230
|
-
]).outerHTML,
|
|
231
|
-
html('h2', { id: 'index::c' }, 'c').outerHTML,
|
|
232
|
-
html('p', [
|
|
233
|
-
html('sup', { class: "annotation", id: "annotation::ref:4", title: "4" }, [
|
|
234
|
-
html('span', { hidden: '' }, '4'),
|
|
235
|
-
html('a', { href: "#annotation::def:4" }, '*4')
|
|
236
|
-
]),
|
|
237
|
-
]).outerHTML,
|
|
238
|
-
html('ol', { class: 'annotations' }, [
|
|
239
|
-
html('li', { id: 'annotation::def:4', 'data-marker': '*4' }, [
|
|
240
|
-
html('span', { id: 'note::4' }, '4'),
|
|
241
|
-
html('sup', [html('a', { href: '#annotation::ref:4' }, '^4')])
|
|
242
|
-
]),
|
|
243
|
-
]).outerHTML,
|
|
244
|
-
]);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
describe('reference', () => {
|
|
251
|
-
it('1', () => {
|
|
252
|
-
const target = parse('[[a b]]');
|
|
253
|
-
const footnote = html('ol');
|
|
254
|
-
for (let i = 0; i < 3; ++i) {
|
|
255
|
-
[...reference(target, footnote)];
|
|
256
|
-
assert.deepStrictEqual(
|
|
257
|
-
[...target.children].map(el => el.outerHTML),
|
|
258
|
-
[
|
|
259
|
-
html('p', [
|
|
260
|
-
html('sup', { class: "reference", id: "reference::ref:1", title: "a b" }, [
|
|
261
|
-
html('span', { hidden: '' }, 'a b'),
|
|
262
|
-
html('a', { href: "#reference::def:1" }, '[1]')
|
|
263
|
-
]),
|
|
264
|
-
]).outerHTML,
|
|
265
|
-
]);
|
|
266
|
-
assert.deepStrictEqual(
|
|
267
|
-
footnote.outerHTML,
|
|
268
|
-
html('ol', [
|
|
269
|
-
html('li', { id: 'reference::def:1' }, [
|
|
270
|
-
html('span', { id: 'note::a_b' }, 'a b'),
|
|
271
|
-
html('sup', [html('a', { href: '#reference::ref:1' }, '^1')])
|
|
272
|
-
]),
|
|
273
|
-
]).outerHTML);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('abbr', () => {
|
|
278
|
-
const target = parse('[[^a]][[^a| b]][[^a]]');
|
|
279
|
-
const footnote = html('ol');
|
|
280
|
-
for (let i = 0; i < 3; ++i) {
|
|
281
|
-
[...reference(target, footnote)];
|
|
282
|
-
assert.deepStrictEqual(
|
|
283
|
-
[...target.children].map(el => el.outerHTML),
|
|
284
|
-
[
|
|
285
|
-
html('p', [
|
|
286
|
-
html('sup', { class: "reference", 'data-abbr': "a", id: "reference::ref:1", title: "b" }, [
|
|
287
|
-
html('span', { hidden: '' }),
|
|
288
|
-
html('a', { href: "#reference::def:1" }, '[a]')
|
|
289
|
-
]),
|
|
290
|
-
html('sup', { class: "reference", 'data-abbr': "a", id: "reference::ref:2", title: "b" }, [
|
|
291
|
-
html('span', { hidden: '' }, 'b'),
|
|
292
|
-
html('a', { href: "#reference::def:1" }, '[a]')
|
|
293
|
-
]),
|
|
294
|
-
html('sup', { class: "reference", 'data-abbr': "a", id: "reference::ref:3", title: "b" }, [
|
|
295
|
-
html('span', { hidden: '' }),
|
|
296
|
-
html('a', { href: "#reference::def:1" }, '[a]')
|
|
297
|
-
]),
|
|
298
|
-
]).outerHTML,
|
|
299
|
-
]);
|
|
300
|
-
assert.deepStrictEqual(
|
|
301
|
-
footnote.outerHTML,
|
|
302
|
-
html('ol', [
|
|
303
|
-
html('li', { id: 'reference::def:1' }, [
|
|
304
|
-
html('span', { id: 'note::b' }, 'b'),
|
|
305
|
-
html('sup', [
|
|
306
|
-
html('a', { href: '#reference::ref:1' }, '^1'),
|
|
307
|
-
html('a', { href: '#reference::ref:2', title: 'b' }, '^2'),
|
|
308
|
-
html('a', { href: '#reference::ref:3' }, '^3'),
|
|
309
|
-
])
|
|
310
|
-
]),
|
|
311
|
-
]).outerHTML);
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
});
|