@amermathsoc/texml-to-html 15.2.1 → 16.1.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 CHANGED
@@ -2,6 +2,38 @@
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.1](https://github.com/AmerMathSoc/texml-to-html/compare/v16.1.0...v16.1.1) (2024-06-03)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **hacks.js:** treat custom elements like phrasing content ([ab7c158](https://github.com/AmerMathSoc/texml-to-html/commit/ab7c1583a635f095de6dc9c3315ceb4c3a50d63e)), closes [#447](https://github.com/AmerMathSoc/texml-to-html/issues/447)
11
+
12
+ ## [16.1.0](https://github.com/AmerMathSoc/texml-to-html/compare/v16.0.0...v16.1.0) (2024-06-03)
13
+
14
+
15
+ ### Features
16
+
17
+ * **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)
18
+ * 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)
19
+ * **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)
20
+
21
+ ## [16.0.0](https://github.com/AmerMathSoc/texml-to-html/compare/v15.2.1...v16.0.0) (2024-04-29)
22
+
23
+
24
+ ### ⚠ BREAKING CHANGES
25
+
26
+ * Nested `a` are now "flattened" to `span`.
27
+
28
+ ### Features
29
+
30
+ * 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)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * **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)
36
+
5
37
  ### [15.2.1](https://github.com/AmerMathSoc/texml-to-html/compare/v15.2.0...v15.2.1) (2024-03-29)
6
38
 
7
39
  ## [15.2.0](https://github.com/AmerMathSoc/texml-to-html/compare/v15.1.1...v15.2.0) (2024-03-29)
package/README.md CHANGED
@@ -46,6 +46,11 @@ Some elements in texml's XML output have the same name (and purpose) as in HTML.
46
46
  - tr
47
47
  - td
48
48
 
49
+ The following custom tag names are preserved:
50
+
51
+ - cite-group (wrapper around citations)
52
+ - cite-detail (wrapper for optional argument of `\cite`)
53
+
49
54
  ### preseved attributes
50
55
 
51
56
  Some attributes in texml's XML output have the same name (and purpose) in HTML.
@@ -132,6 +137,7 @@ Beyond HTML element and attributes, texml-to-html stores data in custom `data-*`
132
137
  - {@ref-type} [expected: bibr, fn, disp-formula, sec, fig, table, algorithm, list, statement]
133
138
  - notrid
134
139
  - fn-return [added in ams-html output]
140
+ - `toc-entry@specific-use` [expected: section, chapter, etc.]
135
141
  - data-ams-doc-level
136
142
  - [0-9]
137
143
  - data-ams-content-type
@@ -149,6 +155,8 @@ Beyond HTML element and attributes, texml-to-html stores data in custom `data-*`
149
155
  - graphic | inline-graphic @height
150
156
  - data-ams-doc-alttitle
151
157
  - alt-title (book only, for sectioning content only)
158
+ - data-ams-href
159
+ - stores href for span that avoids a nested link (cf. xref, ext-link)
152
160
 
153
161
  ##### downstream `data-*` attributes
154
162
 
@@ -238,6 +246,7 @@ The following provide a list from the reverse point of view.
238
246
  - notes => section with data-ams-doc="notes"
239
247
  - @notes-type => @data-ams-content-type (and role=dedication for dedications)
240
248
  - use cases: dedication (articles), article and section notes (NOTI only), drm notice & epub note (books)
249
+ - toc-entry@specific-use => data-ams-ref
241
250
  - attributes
242
251
  - @disp-level => data-ams-doc-level [data-ams-doc-level is also added to some elements that lack disp-level]
243
252
  - @content-type => data-ams-content-type
@@ -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;
@@ -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 anchor = this.createNode('a', '', {
31
- href: xmlnode.getAttribute('xlink:href')
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
- // handle nested links
35
- const linkChild = xmlnode.childNodes.find(node => node.tagName === 'xref' || node.tagName === 'ext-link');
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' !== xmlnode.parentNode.tagName && xmlnode.closest('article'))
24
+ if (!xmlnode.closest('xref') && xmlnode.closest('article'))
25
25
  return;
26
26
  this.passThrough(htmlParentNode, xmlnode);
27
27
  };
@@ -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
- // case toc-entry//xref
27
- const tocEntryAncestor = xmlnode.closest('toc-entry');
28
- if (tocEntryAncestor) {
29
- this.passThrough(htmlParentNode, xmlnode);
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
- const rid = xmlnode.getAttribute('rid');
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
- // handle nested xref
82
- const linkChild = xmlnode.childNodes.find(node => node.tagName === 'xref' || node.tagName === 'ext-link');
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/hacks.js CHANGED
@@ -23,7 +23,7 @@ const phrasingContentTags = ['abbr', 'audio', 'b', 'bdo', 'br', 'button', 'canva
23
23
  */
24
24
  const sanitizeParagraph = node => {
25
25
  const childrenArray = [...node.children];
26
- const maybeBadChild = childrenArray.find(child => !phrasingContentTags.includes(child.tagName.toLowerCase()));
26
+ const maybeBadChild = childrenArray.find(child => (!child.tagName.includes('-') && !phrasingContentTags.includes(child.tagName.toLowerCase()))); // check for content that is not phrasing conetnt and not a custom element name.
27
27
  if (!maybeBadChild) return;
28
28
  console.log(`Info: texml-to-html: fixing non-phrasing in paragraph, cf. texml#104, near ID ${node.closest('[id]')?.getAttribute('id')}`)
29
29
  const remainingChildren = childrenArray.slice(childrenArray.indexOf(maybeBadChild)).reverse();
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amermathsoc/texml-to-html",
3
- "version": "15.2.1",
3
+ "version": "16.1.1",
4
4
  "type": "module",
5
5
  "description": "A NodeJS library for converting AMS-style JATS XML to HTML",
6
6
  "scripts": {
package/test/article.xml CHANGED
@@ -420,9 +420,11 @@
420
420
  </target>
421
421
  </disp-formula>
422
422
  </sec>
423
- <!-- inline-formula, disp-formula, tex-math -->
423
+ <!-- citegroup, cite-detail-->
424
424
  <sec disp-level="1" id="citegroup" specific-use="section">
425
- <cite-group><x>[</x><xref ref-type="type" rid="rid1">ref</xref><x>, </x><xref ref-type="fn" rid="rid2">ref</xref><x>]</x></cite-group>
425
+ <p>
426
+ <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>
427
+ </p>
426
428
  </sec>
427
429
 
428
430
  <!-- alt-title -->
@@ -18,6 +18,9 @@
18
18
  "print": "isbn print",
19
19
  "epub": "isbn epub"
20
20
  },
21
+ "loc": {
22
+ "lccn": "0123456789"
23
+ },
21
24
  "basename": "seriesvolume"
22
25
  },
23
26
  "title": "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-group', async function(t) {
21
+ tape('Template: cite-detail', async function(t) {
22
22
  t.plan(1);
23
- const document = article;
24
- t.equal(document.querySelectorAll('section#citegroup a').length, 2, 'cite-group passed through, leaving two anchors');
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
+ });
@@ -20,11 +20,10 @@ import tape from 'tape';
20
20
 
21
21
 
22
22
  tape('Template: ext-link', async function (t) {
23
- t.plan(3);
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.notOk(document.querySelector('a[href="https://nested2"] a'), 'ext-link with xref inside does not produce nested link');
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(
@@ -20,13 +20,12 @@ import tape from 'tape';
20
20
 
21
21
 
22
22
  tape('Template: xref', async function(t) {
23
- t.plan(7);
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.notOk(document.querySelector('a[data-ams-ref="nested"] a'), 'xref with ext-link inside does not have nested link');
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/test/hacks.js CHANGED
@@ -19,7 +19,7 @@ import tape from 'tape';
19
19
 
20
20
 
21
21
  tape('Hacks', async function (t) {
22
- t.plan(4);
22
+ t.plan(5);
23
23
  const document = article;
24
24
 
25
25
  // moved from test/element-def-list-def-item-def-term.js (for the old def-list.js hack of "move DL after its P parent")
@@ -33,5 +33,9 @@ tape('Hacks', async function (t) {
33
33
  t.equal(firstDT.innerHTML, '1', 'DLs moved out of paragraph appear in the correct oder');
34
34
 
35
35
  t.equal(document.querySelectorAll('#hacks > p').length, 1, 'If paragraph is empty after postprocessing, it is removed.')
36
+
37
+ console.log(article.querySelector('cite-group').parentNode.outerHTML)
38
+
39
+ t.equal(document.querySelector('cite-group').parentNode.tagName, 'P', 'Custom elements remain in paragraph');
36
40
  });
37
41
 
@@ -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
- }