securemark 0.269.0 → 0.269.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/index.js +6 -4
- package/package.json +6 -6
- package/src/parser/api/bind.test.ts +3 -3
- package/src/parser/api/parse.test.ts +3 -3
- package/src/parser/block/blockquote.test.ts +1 -1
- package/src/parser/block/extension/example.test.ts +1 -1
- package/src/parser/inline/extension/indexee.ts +3 -2
- package/src/parser/processor/footnote.test.ts +17 -17
- package/src/parser/processor/footnote.ts +6 -5
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.269.
|
|
1
|
+
/*! securemark v0.269.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("Prism"), require("DOMPurify"));
|
|
@@ -6146,6 +6146,7 @@ function identity(id, text, name = 'index') {
|
|
|
6146
6146
|
case 'index':
|
|
6147
6147
|
return `${name}:${id ?? ''}:${cs.slice(0, 97).join('')}...`;
|
|
6148
6148
|
case 'mark':
|
|
6149
|
+
case 'note':
|
|
6149
6150
|
return `${name}:${id ?? ''}:${cs.slice(0, 50).join('')}...${cs.slice(-47).join('')}`;
|
|
6150
6151
|
}
|
|
6151
6152
|
}
|
|
@@ -7085,7 +7086,9 @@ function build(syntax, marker, splitter = '_') {
|
|
|
7085
7086
|
const ref = refs[i];
|
|
7086
7087
|
const identifier = ref.getAttribute('data-abbr') || ` ${ref.firstElementChild.innerHTML}`;
|
|
7087
7088
|
if (titles.has(identifier)) continue;
|
|
7088
|
-
const content = (0, dom_1.
|
|
7089
|
+
const content = (0, dom_1.html)('span', {
|
|
7090
|
+
id: (0, indexee_1.identity)(opts.id, (0, indexee_1.text)(ref.firstElementChild), 'note')
|
|
7091
|
+
}, ref.firstElementChild.cloneNode(true).childNodes);
|
|
7089
7092
|
const title = (0, indexee_1.text)(content).trim();
|
|
7090
7093
|
if (!title) continue;
|
|
7091
7094
|
titles.set(identifier, title);
|
|
@@ -7131,7 +7134,6 @@ function build(syntax, marker, splitter = '_') {
|
|
|
7131
7134
|
ref.lastChild?.remove();
|
|
7132
7135
|
}
|
|
7133
7136
|
const title = titles.get(identifier);
|
|
7134
|
-
const content = (0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes);
|
|
7135
7137
|
const refIndex = ++count;
|
|
7136
7138
|
const refId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:ref:${refIndex}` : undefined;
|
|
7137
7139
|
const def = false || defs.get(identifier) || defs.set(identifier, (0, dom_1.html)('li', {
|
|
@@ -7157,7 +7159,7 @@ function build(syntax, marker, splitter = '_') {
|
|
|
7157
7159
|
}, marker(defIndex, abbr)));
|
|
7158
7160
|
def.lastChild.appendChild((0, dom_1.html)('a', {
|
|
7159
7161
|
href: refId && `#${refId}`,
|
|
7160
|
-
title: abbr && (0, indexee_1.text)(
|
|
7162
|
+
title: abbr && (0, indexee_1.text)((0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes)).trim() || undefined
|
|
7161
7163
|
}, `^${refIndex}`));
|
|
7162
7164
|
}
|
|
7163
7165
|
if (defs.size > 0 || footnote) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securemark",
|
|
3
|
-
"version": "0.269.
|
|
3
|
+
"version": "0.269.1",
|
|
4
4
|
"description": "Secure markdown renderer working on browsers for user input data.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/falsandtru/securemark",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"LICENSE"
|
|
29
29
|
],
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/dompurify": "
|
|
31
|
+
"@types/dompurify": "3.0.0",
|
|
32
32
|
"@types/jquery": "3.5.16",
|
|
33
33
|
"@types/mathjax": "0.0.37",
|
|
34
34
|
"@types/mocha": "10.0.1",
|
|
35
35
|
"@types/power-assert": "1.5.8",
|
|
36
36
|
"@types/prismjs": "1.26.0",
|
|
37
|
-
"@typescript-eslint/parser": "^5.
|
|
37
|
+
"@typescript-eslint/parser": "^5.55.0",
|
|
38
38
|
"babel-loader": "^9.1.2",
|
|
39
39
|
"babel-plugin-unassert": "^3.2.0",
|
|
40
40
|
"concurrently": "^7.6.0",
|
|
41
|
-
"eslint": "^8.
|
|
41
|
+
"eslint": "^8.36.0",
|
|
42
42
|
"eslint-plugin-redos": "^4.4.5",
|
|
43
43
|
"eslint-webpack-plugin": "^4.0.0",
|
|
44
44
|
"glob": "^8.1.0",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"karma-mocha": "^2.0.1",
|
|
50
50
|
"karma-power-assert": "^1.0.0",
|
|
51
51
|
"mocha": "^10.2.0",
|
|
52
|
-
"npm-check-updates": "^16.7.
|
|
52
|
+
"npm-check-updates": "^16.7.12",
|
|
53
53
|
"semver": "^7.3.8",
|
|
54
54
|
"spica": "0.0.719",
|
|
55
55
|
"ts-loader": "^9.4.2",
|
|
56
56
|
"typed-dom": "^0.0.317",
|
|
57
57
|
"typescript": "4.9.5",
|
|
58
|
-
"webpack": "^5.
|
|
58
|
+
"webpack": "^5.76.1",
|
|
59
59
|
"webpack-cli": "^5.0.1",
|
|
60
60
|
"webpack-merge": "^5.8.0"
|
|
61
61
|
},
|
|
@@ -214,15 +214,15 @@ describe('Unit: parser/api/bind', () => {
|
|
|
214
214
|
cfgs.footnotes.references?.outerHTML,
|
|
215
215
|
html('ol', [
|
|
216
216
|
html('li', { id: 'reference::def:1' }, [
|
|
217
|
-
'1',
|
|
217
|
+
html('span', { id: 'note::1' }, '1'),
|
|
218
218
|
html('sup', [html('a', { href: '#reference::ref:1' }, '^1')]),
|
|
219
219
|
]),
|
|
220
220
|
html('li', { id: 'reference::def:2' }, [
|
|
221
|
-
'2',
|
|
221
|
+
html('span', { id: 'note::2' }, '2'),
|
|
222
222
|
html('sup', [html('a', { href: '#reference::ref:2' }, '^2')]),
|
|
223
223
|
]),
|
|
224
224
|
html('li', { id: 'reference::def:3' }, [
|
|
225
|
-
'3',
|
|
225
|
+
html('span', { id: 'note::3' }, '3'),
|
|
226
226
|
html('sup', [html('a', { href: '#reference::ref:3' }, '^3')]),
|
|
227
227
|
]),
|
|
228
228
|
]).outerHTML);
|
|
@@ -135,7 +135,7 @@ describe('Unit: parser/api/parse', () => {
|
|
|
135
135
|
'<p><a href="https://source/x/a" target="_blank"><img class="media" data-src="https://source/x/a" alt=""></a></p>',
|
|
136
136
|
'<p><a href="/z/a" target="_blank"><img class="media" data-src="/z/a" alt=""></a></p>',
|
|
137
137
|
'<p><a href="https://source/a" target="_blank"><img class="media" data-src="https://source/a" alt=""></a></p>',
|
|
138
|
-
'<ol class="annotations"><li id="annotation::def:1" data-marker="*1">a
|
|
138
|
+
'<ol class="annotations"><li id="annotation::def:1" data-marker="*1"><span id="note::a">a</span><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>',
|
|
139
139
|
]);
|
|
140
140
|
assert.deepStrictEqual(
|
|
141
141
|
[...parse([
|
|
@@ -208,11 +208,11 @@ describe('Unit: parser/api/parse', () => {
|
|
|
208
208
|
[
|
|
209
209
|
'<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>',
|
|
210
210
|
'<p><sup class="annotation" id="annotation::ref:1" title="(1)"><span hidden=""><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" id="reference::ref:1" title="b"><span hidden="">b</span><a href="#reference::def:1">[1]</a></sup><sup class="reference" id="reference::ref:2" title="cd"><span hidden="">c<em>d</em></span><a href="#reference::def:2">[2]</a></sup></span><a href="#annotation::def:1">*1</a></sup></p>',
|
|
211
|
-
'<ol class="annotations"><li id="annotation::def:1" data-marker="*1"><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" id="reference::ref:1" title="b"><span hidden="">b</span><a href="#reference::def:1">[1]</a></sup><sup class="reference" id="reference::ref:2" title="cd"><span hidden="">c<em>d</em></span><a href="#reference::def:2">[2]</a></sup><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>',
|
|
211
|
+
'<ol class="annotations"><li id="annotation::def:1" data-marker="*1"><span id="note::(1)"><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" id="reference::ref:1" title="b"><span hidden="">b</span><a href="#reference::def:1">[1]</a></sup><sup class="reference" id="reference::ref:2" title="cd"><span hidden="">c<em>d</em></span><a href="#reference::def:2">[2]</a></sup></span><sup><a href="#annotation::ref:1">^1</a></sup></li></ol>',
|
|
212
212
|
]);
|
|
213
213
|
assert.deepStrictEqual(
|
|
214
214
|
footnotes.references.outerHTML,
|
|
215
|
-
'<ol><li id="reference::def:1">b
|
|
215
|
+
'<ol><li id="reference::def:1"><span id="note::b">b</span><sup><a href="#reference::ref:1">^1</a></sup></li><li id="reference::def:2"><span id="note::cd">c<em>d</em></span><sup><a href="#reference::ref:2">^2</a></sup></li></ol>');
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
it('normalize', () => {
|
|
@@ -96,7 +96,7 @@ describe('Unit: parser/block/blockquote', () => {
|
|
|
96
96
|
assert.deepStrictEqual(inspect(parser('!>> ## a\n> ## a')), [['<blockquote><blockquote><section><h2>a</h2><h2>References</h2><ol class="references"></ol></section></blockquote><section><h2>a</h2><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
97
97
|
assert.deepStrictEqual(inspect(parser('!>> ~ a\n> ~ a')), [['<blockquote><blockquote><section><dl><dt>a</dt><dd></dd></dl><h2>References</h2><ol class="references"></ol></section></blockquote><section><dl><dt>a</dt><dd></dd></dl><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
98
98
|
assert.deepStrictEqual(inspect(parser('!>> ~~~figure $test-a\n>> > \n>>\n~~~\n> ~~~figure $test-a\n> > \n>\n[#a]\n~~~')), [['<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><h2>References</h2><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"><a class="index">a</a></span></figcaption><div><blockquote></blockquote></div></figure><h2>References</h2><ol class="references"></ol></section></blockquote>'], '']);
|
|
99
|
-
assert.deepStrictEqual(inspect(parser('!>> ((a))\n> ((a))')), [['<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">a
|
|
99
|
+
assert.deepStrictEqual(inspect(parser('!>> ((a))\n> ((a))')), [['<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></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>'], '']);
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
});
|
|
@@ -23,7 +23,7 @@ describe('Unit: parser/block/extension/example', () => {
|
|
|
23
23
|
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n[$fig-a]\n!https://host\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">[$fig-a]\n!https://host</pre><hr><section><figure data-type="media" data-label="fig-a" data-group="fig" data-number="1"><figcaption><span class="figindex">Fig. 1. </span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
24
24
|
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n## a\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">## a</pre><hr><section><h2>a</h2><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
25
25
|
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n~ a\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">~ a</pre><hr><section><dl><dt>a</dt><dd></dd></dl><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
26
|
-
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n((a))[[b]]\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">((a))[[b]]</pre><hr><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup><sup class="reference disabled" title="b"><span hidden="">b</span><a>[1]</a></sup></p><ol class="annotations"><li data-marker="*1">a
|
|
26
|
+
assert.deepStrictEqual(inspect(parser('~~~example/markdown\n((a))[[b]]\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">((a))[[b]]</pre><hr><section><p><sup class="annotation disabled" title="a"><span hidden="">a</span><a>*1</a></sup><sup class="reference disabled" title="b"><span hidden="">b</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"><li><span>b</span><sup><a>^1</a></sup></li></ol></section></aside>'], '']);
|
|
27
27
|
assert.deepStrictEqual(inspect(parser('~~~~example/markdown\na\n~~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">a</pre><hr><section><p>a</p><h2>References</h2><ol class="references"></ol></section></aside>'], '']);
|
|
28
28
|
assert.deepStrictEqual(inspect(parser('~~~example/math\na\n~~~')), [['<aside class="example" data-type="math"><pre translate="no">a</pre><hr><div class="math" translate="no">$$\na\n$$</div></aside>'], '']);
|
|
29
29
|
assert.deepStrictEqual(inspect(parser(`~~~example/math\n0${'\n'.repeat(100)}~~~`), '>'), [['<aside class="example" data-type="math">'], '']);
|
|
@@ -8,7 +8,7 @@ export function indexee(parser: Parser<HTMLElement, MarkdownParser.Context>, opt
|
|
|
8
8
|
return fmap(parser, ([el], _, { id }) => [define(el, { id: identity(id, text(el, optional)) })]);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function identity(id: string | undefined, text: string, name: 'index' | 'mark' = 'index'): string | undefined {
|
|
11
|
+
export function identity(id: string | undefined, text: string, name: 'index' | 'mark' | 'note' = 'index'): string | undefined {
|
|
12
12
|
assert(!id?.match(/[^0-9a-z/-]/i));
|
|
13
13
|
assert(!text.includes('\n'));
|
|
14
14
|
if (id === '') return undefined;
|
|
@@ -20,6 +20,7 @@ export function identity(id: string | undefined, text: string, name: 'index' | '
|
|
|
20
20
|
case 'index':
|
|
21
21
|
return `${name}:${id ?? ''}:${cs.slice(0, 97).join('')}...`;
|
|
22
22
|
case 'mark':
|
|
23
|
+
case 'note':
|
|
23
24
|
return `${name}:${id ?? ''}:${cs.slice(0, 50).join('')}...${cs.slice(-47).join('')}`;
|
|
24
25
|
}
|
|
25
26
|
assert(false);
|
|
@@ -31,7 +32,7 @@ assert(identity(undefined, '0'.repeat(100 - 1) + 1, 'mark')!.slice(6) === '0'.re
|
|
|
31
32
|
assert(identity(undefined, '0'.repeat(100) + 1, 'mark')!.slice(6) === '0'.repeat(50) + '...' + '0'.repeat(47 - 1) + 1);
|
|
32
33
|
assert(identity(undefined, '0'.repeat(200) + 1, 'mark')!.slice(6) === '0'.repeat(50) + '...' + '0'.repeat(47 - 1) + 1);
|
|
33
34
|
|
|
34
|
-
export function text(source:
|
|
35
|
+
export function text(source: Element | DocumentFragment, optional = false): string {
|
|
35
36
|
assert(source instanceof DocumentFragment || !source.matches('.indexer'));
|
|
36
37
|
assert(source.querySelectorAll(':scope > .indexer').length <= 1);
|
|
37
38
|
if (!source.firstChild) return '';
|
|
@@ -37,7 +37,7 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
37
37
|
footnote.outerHTML,
|
|
38
38
|
html('ol', [
|
|
39
39
|
html('li', { id: 'annotation::def:1' }, [
|
|
40
|
-
'a b',
|
|
40
|
+
html('span', { id: 'note::a_b' }, 'a b'),
|
|
41
41
|
html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
|
|
42
42
|
]),
|
|
43
43
|
]).outerHTML);
|
|
@@ -67,11 +67,11 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
67
67
|
footnote.outerHTML,
|
|
68
68
|
html('ol', [
|
|
69
69
|
html('li', { id: 'annotation::def:1' }, [
|
|
70
|
-
'1',
|
|
70
|
+
html('span', { id: 'note::1' }, '1'),
|
|
71
71
|
html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
|
|
72
72
|
]),
|
|
73
73
|
html('li', { id: 'annotation::def:2' }, [
|
|
74
|
-
'12345678901234567890',
|
|
74
|
+
html('span', { id: 'note::12345678901234567890' }, '12345678901234567890'),
|
|
75
75
|
html('sup', [html('a', { href: '#annotation::ref:2' }, '^2')])
|
|
76
76
|
]),
|
|
77
77
|
]).outerHTML);
|
|
@@ -113,22 +113,22 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
113
113
|
footnote.outerHTML,
|
|
114
114
|
html('ol', [
|
|
115
115
|
html('li', { id: 'annotation::def:1' }, [
|
|
116
|
-
'1',
|
|
116
|
+
html('span', { id: 'note::1' }, '1'),
|
|
117
117
|
html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
|
|
118
118
|
]),
|
|
119
119
|
html('li', { id: 'annotation::def:2' }, [
|
|
120
|
-
'2',
|
|
120
|
+
html('span', { id: 'note::2' }, '2'),
|
|
121
121
|
html('sup', [
|
|
122
122
|
html('a', { href: '#annotation::ref:2' }, '^2'),
|
|
123
123
|
html('a', { href: '#annotation::ref:4' }, '^4'),
|
|
124
124
|
]),
|
|
125
125
|
]),
|
|
126
126
|
html('li', { id: 'annotation::def:3' }, [
|
|
127
|
-
'3',
|
|
127
|
+
html('span', { id: 'note::3' }, '3'),
|
|
128
128
|
html('sup', [html('a', { href: '#annotation::ref:3' }, '^3')])
|
|
129
129
|
]),
|
|
130
130
|
html('li', { id: 'annotation::def:4' }, [
|
|
131
|
-
'4',
|
|
131
|
+
html('span', { id: 'note::4' }, '4'),
|
|
132
132
|
html('sup', [html('a', { href: '#annotation::ref:5' }, '^5')])
|
|
133
133
|
]),
|
|
134
134
|
]).outerHTML);
|
|
@@ -151,13 +151,13 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
151
151
|
assert.deepStrictEqual(
|
|
152
152
|
[...target.children].map(el => el.outerHTML),
|
|
153
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">a
|
|
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">a
|
|
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
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
157
|
]);
|
|
158
158
|
assert.deepStrictEqual(
|
|
159
159
|
footnote.outerHTML,
|
|
160
|
-
'<ol><li id="annotation::def:1">a
|
|
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
161
|
}
|
|
162
162
|
});
|
|
163
163
|
|
|
@@ -180,7 +180,7 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
180
180
|
footnote.outerHTML,
|
|
181
181
|
html('ol', [
|
|
182
182
|
html('li', { id: 'annotation:0:def:1' }, [
|
|
183
|
-
'a b',
|
|
183
|
+
html('span', { id: 'note:0:a_b' }, 'a b'),
|
|
184
184
|
html('sup', [html('a', { href: '#annotation:0:ref:1' }, '^1')])
|
|
185
185
|
]),
|
|
186
186
|
]).outerHTML);
|
|
@@ -202,7 +202,7 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
202
202
|
]).outerHTML,
|
|
203
203
|
html('ol', { class: 'annotations' }, [
|
|
204
204
|
html('li', { id: 'annotation::def:1', 'data-marker': '*1' }, [
|
|
205
|
-
'1',
|
|
205
|
+
html('span', { id: 'note::1' }, '1'),
|
|
206
206
|
html('sup', [html('a', { href: '#annotation::ref:1' }, '^1')])
|
|
207
207
|
]),
|
|
208
208
|
]).outerHTML,
|
|
@@ -220,11 +220,11 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
220
220
|
]).outerHTML,
|
|
221
221
|
html('ol', { class: 'annotations' }, [
|
|
222
222
|
html('li', { id: 'annotation::def:2', 'data-marker': '*2' }, [
|
|
223
|
-
'2',
|
|
223
|
+
html('span', { id: 'note::2' }, '2'),
|
|
224
224
|
html('sup', [html('a', { href: '#annotation::ref:2' }, '^2')])
|
|
225
225
|
]),
|
|
226
226
|
html('li', { id: 'annotation::def:3', 'data-marker': '*3' }, [
|
|
227
|
-
'3',
|
|
227
|
+
html('span', { id: 'note::3' }, '3'),
|
|
228
228
|
html('sup', [html('a', { href: '#annotation::ref:3' }, '^3')])
|
|
229
229
|
]),
|
|
230
230
|
]).outerHTML,
|
|
@@ -237,7 +237,7 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
237
237
|
]).outerHTML,
|
|
238
238
|
html('ol', { class: 'annotations' }, [
|
|
239
239
|
html('li', { id: 'annotation::def:4', 'data-marker': '*4' }, [
|
|
240
|
-
'4',
|
|
240
|
+
html('span', { id: 'note::4' }, '4'),
|
|
241
241
|
html('sup', [html('a', { href: '#annotation::ref:4' }, '^4')])
|
|
242
242
|
]),
|
|
243
243
|
]).outerHTML,
|
|
@@ -267,7 +267,7 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
267
267
|
footnote.outerHTML,
|
|
268
268
|
html('ol', [
|
|
269
269
|
html('li', { id: 'reference::def:1' }, [
|
|
270
|
-
'a b',
|
|
270
|
+
html('span', { id: 'note::a_b' }, 'a b'),
|
|
271
271
|
html('sup', [html('a', { href: '#reference::ref:1' }, '^1')])
|
|
272
272
|
]),
|
|
273
273
|
]).outerHTML);
|
|
@@ -301,7 +301,7 @@ describe('Unit: parser/processor/footnote', () => {
|
|
|
301
301
|
footnote.outerHTML,
|
|
302
302
|
html('ol', [
|
|
303
303
|
html('li', { id: 'reference::def:1' }, [
|
|
304
|
-
'b',
|
|
304
|
+
html('span', { id: 'note::b' }, 'b'),
|
|
305
305
|
html('sup', [
|
|
306
306
|
html('a', { href: '#reference::ref:1' }, '^1'),
|
|
307
307
|
html('a', { href: '#reference::ref:2', title: 'b' }, '^2'),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { text } from '../inline/extension/indexee';
|
|
1
|
+
import { identity, text } from '../inline/extension/indexee';
|
|
2
2
|
import { frag, html, define } from 'typed-dom/dom';
|
|
3
3
|
|
|
4
4
|
export function* footnote(
|
|
@@ -44,13 +44,15 @@ function build(
|
|
|
44
44
|
}
|
|
45
45
|
const refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`);
|
|
46
46
|
const titles = new Map<string, string>();
|
|
47
|
-
const contents = new Map<string,
|
|
47
|
+
const contents = new Map<string, HTMLSpanElement>();
|
|
48
48
|
for (let len = refs.length, i = 0; i < len; ++i) {
|
|
49
49
|
if (i % 10 === 9) yield;
|
|
50
50
|
const ref = refs[i];
|
|
51
51
|
const identifier = ref.getAttribute('data-abbr') || ` ${ref.firstElementChild!.innerHTML}`;
|
|
52
52
|
if (titles.has(identifier)) continue;
|
|
53
|
-
const content =
|
|
53
|
+
const content = html('span',
|
|
54
|
+
{ id: identity(opts.id, text(ref.firstElementChild!), 'note') },
|
|
55
|
+
ref.firstElementChild!.cloneNode(true).childNodes);
|
|
54
56
|
const title = text(content).trim();
|
|
55
57
|
if (!title) continue;
|
|
56
58
|
titles.set(identifier, title);
|
|
@@ -100,7 +102,6 @@ function build(
|
|
|
100
102
|
const title = titles.get(identifier);
|
|
101
103
|
assert(title !== '');
|
|
102
104
|
assert(syntax !== 'annotation' || title);
|
|
103
|
-
const content = frag(ref.firstElementChild!.cloneNode(true).childNodes);
|
|
104
105
|
const refIndex = ++count;
|
|
105
106
|
const refId = opts.id !== ''
|
|
106
107
|
? `${syntax}:${opts.id ?? ''}:ref:${refIndex}`
|
|
@@ -134,7 +135,7 @@ function build(
|
|
|
134
135
|
html('a',
|
|
135
136
|
{
|
|
136
137
|
href: refId && `#${refId}`,
|
|
137
|
-
title: abbr && text(
|
|
138
|
+
title: abbr && text(frag(ref.firstElementChild!.cloneNode(true).childNodes)).trim() || undefined,
|
|
138
139
|
},
|
|
139
140
|
`^${refIndex}`));
|
|
140
141
|
}
|