@amermathsoc/texml-to-html 15.2.1 → 16.1.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 +25 -0
- package/README.md +2 -0
- package/lib/elements/book-meta-json.js +4 -0
- package/lib/elements/ext-link.js +11 -8
- package/lib/elements/toc-entry.js +1 -0
- package/lib/elements/x.js +1 -1
- package/lib/elements/xref.js +25 -19
- package/lib/transformer.js +3 -2
- package/package.json +1 -1
- package/test/article.xml +2 -2
- package/test/book-meta-snapshot.json +3 -0
- package/test/book.xml +7 -1
- package/test/{element-citegroup.js → element-cite-detail.js} +3 -3
- package/test/element-cite-group.js +27 -0
- package/test/element-ext-link.js +2 -3
- package/test/element-toc-toc-entry.js +3 -3
- package/test/element-xref.js +2 -3
- package/lib/helpers/unnest.js +0 -34
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [16.1.0](https://github.com/AmerMathSoc/texml-to-html/compare/v16.0.0...v16.1.0) (2024-06-03)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **book-meta.json.js:** preserve LCCN if present ([4426d63](https://github.com/AmerMathSoc/texml-to-html/commit/4426d632aa0e804ac516b39aea62186aa2c32751)), closes [#440](https://github.com/AmerMathSoc/texml-to-html/issues/440)
|
|
11
|
+
* support cite-group and cite-detail ([dc832cf](https://github.com/AmerMathSoc/texml-to-html/commit/dc832cf7a4b002a8c6dc3725df34b814a306239a)), closes [#443](https://github.com/AmerMathSoc/texml-to-html/issues/443)
|
|
12
|
+
* **toc-entry.js:** support specific-use attribute ([b11a3c9](https://github.com/AmerMathSoc/texml-to-html/commit/b11a3c955bc1601b425612a0a9ede0213e163bdd)), closes [#444](https://github.com/AmerMathSoc/texml-to-html/issues/444)
|
|
13
|
+
|
|
14
|
+
## [16.0.0](https://github.com/AmerMathSoc/texml-to-html/compare/v15.2.1...v16.0.0) (2024-04-29)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### ⚠ BREAKING CHANGES
|
|
18
|
+
|
|
19
|
+
* Nested `a` are now "flattened" to `span`.
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* revise treatment of nested links ([cdc63a9](https://github.com/AmerMathSoc/texml-to-html/commit/cdc63a970cc14c87ae6faa115ae2484bb03fe339)), closes [#442](https://github.com/AmerMathSoc/texml-to-html/issues/442)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* **xref.js:** warn on nested link not inside toc-entry ([a59b69e](https://github.com/AmerMathSoc/texml-to-html/commit/a59b69e205cc9296d65668e364040995144e564e)), closes [#442](https://github.com/AmerMathSoc/texml-to-html/issues/442)
|
|
29
|
+
|
|
5
30
|
### [15.2.1](https://github.com/AmerMathSoc/texml-to-html/compare/v15.2.0...v15.2.1) (2024-03-29)
|
|
6
31
|
|
|
7
32
|
## [15.2.0](https://github.com/AmerMathSoc/texml-to-html/compare/v15.1.1...v15.2.0) (2024-03-29)
|
package/README.md
CHANGED
|
@@ -149,6 +149,8 @@ Beyond HTML element and attributes, texml-to-html stores data in custom `data-*`
|
|
|
149
149
|
- graphic | inline-graphic @height
|
|
150
150
|
- data-ams-doc-alttitle
|
|
151
151
|
- alt-title (book only, for sectioning content only)
|
|
152
|
+
- data-ams-href
|
|
153
|
+
- stores href for span that avoids a nested link (cf. xref, ext-link)
|
|
152
154
|
|
|
153
155
|
##### downstream `data-*` attributes
|
|
154
156
|
|
|
@@ -34,6 +34,9 @@ const bookMetaJson =
|
|
|
34
34
|
// google: '',
|
|
35
35
|
// print: '',
|
|
36
36
|
// softcover: '',
|
|
37
|
+
},
|
|
38
|
+
loc: {
|
|
39
|
+
// llcn
|
|
37
40
|
}
|
|
38
41
|
},
|
|
39
42
|
title: '', // NOTE might contain math (but no use case yet)
|
|
@@ -87,6 +90,7 @@ export function generateBookJson(bookMetaNode) {
|
|
|
87
90
|
bookMetaJson.book.identifiers.AMS.publKey = bookMetaNode.querySelector('book-id[assigning-authority="AMS"][book-id-type="publisher"]')?.textContent;
|
|
88
91
|
bookMetaJson.book.identifiers.AMS.volumeId = bookMetaNode.querySelector('book-id[assigning-authority="AMS"][book-id-type="volume_id"]')?.textContent;
|
|
89
92
|
bookMetaJson.book.identifiers.crossref.doi = bookMetaNode.querySelector('book-id[assigning-authority="crossref"][book-id-type="doi"]')?.textContent;
|
|
93
|
+
bookMetaJson.book.identifiers.loc.lccn = bookMetaNode.querySelector('book-id[assigning-authority="Library of Congress"][book-id-type="lccn"]')?.textContent;
|
|
90
94
|
|
|
91
95
|
// Volume number
|
|
92
96
|
bookMetaJson.book.identifiers.AMS.volumeNr = bookMetaNode.querySelector('book-volume-number')?.textContent;
|
package/lib/elements/ext-link.js
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { unnestLinks } from '../helpers/unnest.js';
|
|
18
17
|
import { node2macro } from '../helpers/helpers-tex.js';
|
|
19
18
|
|
|
20
19
|
/**
|
|
@@ -27,12 +26,16 @@ export default function (htmlParentNode, xmlnode) {
|
|
|
27
26
|
node2macro.apply(this, [htmlParentNode, xmlnode, `href{${xmlnode.getAttribute('xlink:href')}}`, true]); // NOTE href works in both math and text mode; `\href`'s first argument does not need escaping
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const isNestedLink = htmlParentNode.closest('a');
|
|
30
|
+
if (isNestedLink) console.log('Warning: texml-to-html: Nested ext-link', xmlnode.outerHTML);
|
|
31
|
+
const anchor = isNestedLink ?
|
|
32
|
+
this.createNode('span', '', {
|
|
33
|
+
'data-ams-href': xmlnode.getAttribute('xlink:href')
|
|
34
|
+
})
|
|
35
|
+
: this.createNode('a', '', {
|
|
36
|
+
href: xmlnode.getAttribute('xlink:href')
|
|
37
|
+
});
|
|
33
38
|
htmlParentNode.appendChild(anchor);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (linkChild) unnestLinks(this.recurseTheDom, this.createNode, xmlnode, anchor, linkChild)
|
|
37
|
-
else this.passThrough(anchor, xmlnode);
|
|
39
|
+
|
|
40
|
+
this.passThrough(anchor, xmlnode);
|
|
38
41
|
};
|
|
@@ -24,6 +24,7 @@ export default function (htmlParentNode, xmlnode) {
|
|
|
24
24
|
htmlParentNode.appendChild(li);
|
|
25
25
|
const anchor = this.createNode('a', '', {
|
|
26
26
|
href: `#${xmlnode.querySelector('nav-pointer').getAttribute('rid')}`,
|
|
27
|
+
"data-ams-ref": xmlnode.getAttribute('specific-use') // NOTE: specific-use contains `ref@ref-type`-like information (e.g., 'chapter', 'section')
|
|
27
28
|
});
|
|
28
29
|
li.appendChild(anchor);
|
|
29
30
|
// NOTE unify label/title processing with label() - requires some form of new wrapper around content in lieu of heading (or have it add the anchor but then the nav-pointer will be odd to pull in). See #398
|
package/lib/elements/x.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
export default function (htmlParentNode, xmlnode) {
|
|
23
23
|
// ignore if not xref/x or isBook
|
|
24
|
-
if ('xref'
|
|
24
|
+
if (!xmlnode.closest('xref') && xmlnode.closest('article'))
|
|
25
25
|
return;
|
|
26
26
|
this.passThrough(htmlParentNode, xmlnode);
|
|
27
27
|
};
|
package/lib/elements/xref.js
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { unnestLinks } from '../helpers/unnest.js';
|
|
18
17
|
import { replaceTeXCharactersInNodes } from '../helpers/helpers-tex.js';
|
|
19
18
|
|
|
20
19
|
/**
|
|
@@ -23,10 +22,28 @@ import { replaceTeXCharactersInNodes } from '../helpers/helpers-tex.js';
|
|
|
23
22
|
* @param {Element} xmlnode
|
|
24
23
|
*/
|
|
25
24
|
export default function (htmlParentNode, xmlnode) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const rid = xmlnode.getAttribute('rid');
|
|
26
|
+
|
|
27
|
+
// case: no RID
|
|
28
|
+
if (!rid) {
|
|
29
|
+
const span = this.createNode('span', '', {
|
|
30
|
+
'data-ams-ref': 'notrid'
|
|
31
|
+
});
|
|
32
|
+
htmlParentNode.appendChild(span);
|
|
33
|
+
this.passThrough(span, xmlnode);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// case nested links
|
|
38
|
+
const isNestedLink = htmlParentNode.closest('a');
|
|
39
|
+
if (isNestedLink) {
|
|
40
|
+
const anchor =
|
|
41
|
+
this.createNode('span', '', {
|
|
42
|
+
'data-ams-href': rid,
|
|
43
|
+
})
|
|
44
|
+
htmlParentNode.appendChild(anchor);
|
|
45
|
+
this.passThrough(anchor, xmlnode);
|
|
46
|
+
if (!xmlnode.closest('toc-entry')) console.log('Warning: texml-to-html: Nested xref', xmlnode.outerHTML);
|
|
30
47
|
return;
|
|
31
48
|
}
|
|
32
49
|
const refType = xmlnode.getAttribute('ref-type');
|
|
@@ -41,7 +58,6 @@ export default function (htmlParentNode, xmlnode) {
|
|
|
41
58
|
[...texmathAncestor.querySelectorAll('*')].includes(foonoteAncestor)
|
|
42
59
|
)
|
|
43
60
|
) {
|
|
44
|
-
const rid = xmlnode.getAttribute('rid');
|
|
45
61
|
htmlParentNode.insertAdjacentText(
|
|
46
62
|
'beforeend',
|
|
47
63
|
`\\xhref[${refType}]{#${rid}}{`
|
|
@@ -53,15 +69,7 @@ export default function (htmlParentNode, xmlnode) {
|
|
|
53
69
|
htmlParentNode.insertAdjacentText('beforeend', `}`);
|
|
54
70
|
return;
|
|
55
71
|
}
|
|
56
|
-
|
|
57
|
-
if (!rid) {
|
|
58
|
-
const span = this.createNode('span', '', {
|
|
59
|
-
'data-ams-ref': 'notrid'
|
|
60
|
-
});
|
|
61
|
-
htmlParentNode.appendChild(span);
|
|
62
|
-
this.passThrough(span, xmlnode);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
72
|
+
// the "regular" case: a cross-reference
|
|
65
73
|
const anchor = this.createNode('a', '', {
|
|
66
74
|
href: `#${rid}`,
|
|
67
75
|
'data-ams-ref': refType
|
|
@@ -78,10 +86,8 @@ export default function (htmlParentNode, xmlnode) {
|
|
|
78
86
|
} else {
|
|
79
87
|
htmlParentNode.appendChild(anchor);
|
|
80
88
|
}
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
if (linkChild) unnestLinks(this.recurseTheDom, this.createNode, xmlnode, anchor, linkChild)
|
|
84
|
-
else this.passThrough(anchor, xmlnode);
|
|
89
|
+
// Recursion
|
|
90
|
+
this.passThrough(anchor, xmlnode);
|
|
85
91
|
// footonote ref gets wrapped in <sup>
|
|
86
92
|
if (isFootnoteRef) {
|
|
87
93
|
anchor.innerHTML = `<sup>${anchor.innerHTML}</sup>`;
|
package/lib/transformer.js
CHANGED
|
@@ -126,6 +126,8 @@ export class Transformer {
|
|
|
126
126
|
'td',
|
|
127
127
|
'pre',
|
|
128
128
|
'hr',
|
|
129
|
+
'cite-group',
|
|
130
|
+
'cite-detail',
|
|
129
131
|
].forEach(mapTag.bind(null, this.copyElement));
|
|
130
132
|
// passThrough elements
|
|
131
133
|
[
|
|
@@ -144,7 +146,6 @@ export class Transformer {
|
|
|
144
146
|
'back',
|
|
145
147
|
'alternatives',
|
|
146
148
|
'title-group',
|
|
147
|
-
'cite-group',
|
|
148
149
|
'app-group',
|
|
149
150
|
'book-title-group',
|
|
150
151
|
'private-char',
|
|
@@ -201,7 +202,7 @@ export class Transformer {
|
|
|
201
202
|
this.passThrough(span, xmlnode);
|
|
202
203
|
return span.innerHTML.trim();
|
|
203
204
|
}
|
|
204
|
-
|
|
205
|
+
|
|
205
206
|
// extract contrib-groups into json data
|
|
206
207
|
extractContribGroups = extractContribGroups.bind(this);
|
|
207
208
|
|
package/package.json
CHANGED
package/test/article.xml
CHANGED
|
@@ -420,9 +420,9 @@
|
|
|
420
420
|
</target>
|
|
421
421
|
</disp-formula>
|
|
422
422
|
</sec>
|
|
423
|
-
<!--
|
|
423
|
+
<!-- citegroup, cite-detail-->
|
|
424
424
|
<sec disp-level="1" id="citegroup" specific-use="section">
|
|
425
|
-
|
|
425
|
+
<cite-group><x>[</x><xref ref-type="bibr" rid="bibr-AEG0" specific-use="cite">AEG08<cite-detail><x>, </x>Section 5</cite-detail></xref><x>; </x><xref ref-type="bibr" rid="bibr-AEG0" specific-use="cite">AEG08</xref><x>]</x></cite-group>
|
|
426
426
|
</sec>
|
|
427
427
|
|
|
428
428
|
<!-- alt-title -->
|
package/test/book.xml
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
<book-id assigning-authority="AMS" book-id-type="publisher">series</book-id>
|
|
25
25
|
<book-id assigning-authority="AMS" book-id-type="volume_id">volume</book-id>
|
|
26
26
|
<book-id assigning-authority="crossref" book-id-type="doi">doi</book-id>
|
|
27
|
+
<book-id assigning-authority="Library of Congress" book-id-type="lccn">0123456789</book-id>
|
|
27
28
|
<book-title-group>
|
|
28
29
|
<book-title>title</book-title>
|
|
29
30
|
<subtitle>subtitle</subtitle>
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
<title-group>
|
|
86
87
|
<title>Contents</title>
|
|
87
88
|
</title-group>
|
|
88
|
-
<toc-entry>
|
|
89
|
+
<toc-entry specific-use="chapter">
|
|
89
90
|
<title>Chunk</title>
|
|
90
91
|
<nav-pointer rid="tocid1"/>
|
|
91
92
|
</toc-entry>
|
|
@@ -266,6 +267,11 @@
|
|
|
266
267
|
<line indent="1">Indented line.</line>
|
|
267
268
|
</simpletabbing>
|
|
268
269
|
</sec>
|
|
270
|
+
<!-- citegroup, cite-detail-->
|
|
271
|
+
<sec disp-level="1" id="citegroup" specific-use="section">
|
|
272
|
+
<cite-group><x>[</x><xref ref-type="bibr" rid="bibr-AEG0" specific-use="cite">AEG08<cite-detail><x>, </x>Section 5</cite-detail></xref><x>; </x><xref ref-type="bibr" rid="bibr-AEG0" specific-use="cite">AEG08</xref><x>]</x></cite-group>
|
|
273
|
+
</sec>
|
|
274
|
+
|
|
269
275
|
</body>
|
|
270
276
|
</book-part>
|
|
271
277
|
</book-body>
|
|
@@ -18,8 +18,8 @@ import { article } from './helper.js';
|
|
|
18
18
|
import tape from 'tape';
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
tape('Template: cite-
|
|
21
|
+
tape('Template: cite-detail', async function(t) {
|
|
22
22
|
t.plan(1);
|
|
23
|
-
|
|
24
|
-
t.equal(
|
|
23
|
+
|
|
24
|
+
t.equal(article.querySelector('cite-detail').outerHTML, '<cite-detail>, Section 5</cite-detail>', 'cite-detail');
|
|
25
25
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2023 American Mathematical Society
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { article, book } from './helper.js';
|
|
18
|
+
import tape from 'tape';
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
tape('Template: cite-group', async function (t) {
|
|
22
|
+
t.plan(2);
|
|
23
|
+
|
|
24
|
+
t.equal(article.querySelector('cite-group').outerHTML, '<cite-group><cite><a role="doc-biblioref" data-ams-ref="bibr" href="#bibr-AEG0">AEG08<cite-detail>, Section 5</cite-detail></a></cite><cite><a role="doc-biblioref" data-ams-ref="bibr" href="#bibr-AEG0">AEG08</a></cite></cite-group>', 'cite-group in article');
|
|
25
|
+
t.equal(book.querySelector('cite-group').outerHTML, '<cite-group>[<cite><a role="doc-biblioref" data-ams-ref="bibr" href="#bibr-AEG0">AEG08<cite-detail>, Section 5</cite-detail></a></cite>; <cite><a role="doc-biblioref" data-ams-ref="bibr" href="#bibr-AEG0">AEG08</a></cite>]</cite-group>', 'cite-group in book');
|
|
26
|
+
|
|
27
|
+
});
|
package/test/element-ext-link.js
CHANGED
|
@@ -20,11 +20,10 @@ import tape from 'tape';
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
tape('Template: ext-link', async function (t) {
|
|
23
|
-
t.plan(
|
|
23
|
+
t.plan(2);
|
|
24
24
|
const document = article;
|
|
25
25
|
const extlink = document.querySelector('a[href="https://"]');
|
|
26
26
|
t.ok(extlink, 'Element ext-link becomes a with href');
|
|
27
|
-
t.
|
|
28
|
-
t.ok(document.querySelector('a[href="https://nested2"]+span').querySelector('a[data-ams-ref="nested"]'), 'xref inside ext-link moved after ext-link');
|
|
27
|
+
t.equal(document.querySelector('a[href="https://nested2"]').outerHTML, '<a href="https://nested2"><span data-ams-href="rid6"></span></a>', 'xref inside ext-link flattened');
|
|
29
28
|
});
|
|
30
29
|
|
|
@@ -29,9 +29,9 @@ tape('Template: (book) toc, toc-entry', async function(t) {
|
|
|
29
29
|
t.ok(list, 'toc: ordered list');
|
|
30
30
|
t.equal(list.children.length, 6, 'Nested toc-entries remain nested')
|
|
31
31
|
t.equal(
|
|
32
|
-
list.querySelector('li a[href="#tocid1"]').innerHTML,
|
|
32
|
+
list.querySelector('li a[href="#tocid1"][data-ams-ref="chapter"]').innerHTML,
|
|
33
33
|
'Chunk',
|
|
34
|
-
'toc-entry and nav-pointer'
|
|
34
|
+
'toc-entry and nav-pointer with href and data-ams-ref'
|
|
35
35
|
);
|
|
36
36
|
t.equal(
|
|
37
37
|
list.querySelector('li a[href="#tocid2"]').innerHTML,
|
|
@@ -46,7 +46,7 @@ tape('Template: (book) toc, toc-entry', async function(t) {
|
|
|
46
46
|
);
|
|
47
47
|
t.equal(
|
|
48
48
|
list.querySelector('li a[href="#tocid4"]').innerHTML,
|
|
49
|
-
'1. SubSubChunk with Link',
|
|
49
|
+
'1. SubSubChunk with <span data-ams-href="chapter">Link</span>',
|
|
50
50
|
'toc-entry with xref in title'
|
|
51
51
|
);
|
|
52
52
|
t.equal(
|
package/test/element-xref.js
CHANGED
|
@@ -20,13 +20,12 @@ import tape from 'tape';
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
tape('Template: xref', async function(t) {
|
|
23
|
-
t.plan(
|
|
23
|
+
t.plan(6);
|
|
24
24
|
const document = article;
|
|
25
25
|
t.ok(document.querySelector('a[href="#rid1"][data-ams-ref="type"]'), 'xref as anchor with href, data-ams-ref');
|
|
26
26
|
t.ok(document.querySelector('a[href="#rid2"][data-ams-ref="fn"][role="doc-noteref"]'), 'xref with ref-type fn has role doc-noteref');
|
|
27
27
|
t.equal(document.querySelector('a[data-ams-ref="fn"]').firstElementChild.tagName, 'SUP', 'xref with ref-type fn has firstChild sup');
|
|
28
28
|
t.ok(document.querySelector('cite a[href="#rid3"][data-ams-ref="bibr"][role="doc-biblioref"]'), 'xref with ref-type bibr a cite with anchor with href, data-ams-ref, role doc-biblioref');
|
|
29
29
|
t.ok(document.querySelector('span[data-ams-ref="notrid"]'), 'xref without rid as span with data-ams-ref notrid');
|
|
30
|
-
t.
|
|
31
|
-
t.ok(document.querySelector('a[data-ams-ref="nested"]+span').querySelector('a[href="https://nested"]'), 'ext-link inside xref moved after xref');
|
|
30
|
+
t.equal(document.querySelector('a[data-ams-ref="nested"]').outerHTML, '<a data-ams-ref="nested" href="#rid6"><span data-ams-href="https://nested"></span></a>', 'xref with ext-link inside: nested link flattened');
|
|
32
31
|
});
|
package/lib/helpers/unnest.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2023 American Mathematical Society
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* moves links into subsequent span
|
|
19
|
-
* @param {Function} recurseTheDom
|
|
20
|
-
* @param {Function} createNode
|
|
21
|
-
* @param {Node} xmlnode XML DOM node
|
|
22
|
-
* @param {Node} htmlnode HTML Dom Node
|
|
23
|
-
* @param {Node} linkChild XML Dom Node, child of xmlnode
|
|
24
|
-
* @returns {Boolean}
|
|
25
|
-
*/
|
|
26
|
-
export const unnestLinks = (recurseTheDom, createNode, xmlnode, htmlnode, linkChild) => {
|
|
27
|
-
const siblings = [...xmlnode.childNodes];
|
|
28
|
-
const precedingSiblings = siblings.slice(0, siblings.indexOf(linkChild));
|
|
29
|
-
const followingSiblings = siblings.slice(siblings.indexOf(linkChild));
|
|
30
|
-
const span = createNode('span');
|
|
31
|
-
htmlnode.insertAdjacentElement('afterend', span);
|
|
32
|
-
precedingSiblings.forEach(recurseTheDom.bind(null, htmlnode));
|
|
33
|
-
followingSiblings.forEach(recurseTheDom.bind(null, span));
|
|
34
|
-
}
|