@amermathsoc/texml-to-html 17.0.1 → 17.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 CHANGED
@@ -2,6 +2,13 @@
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
+ ## [17.1.0](https://github.com/AmerMathSoc/texml-to-html/compare/v17.0.1...v17.1.0) (2024-07-04)
6
+
7
+
8
+ ### Features
9
+
10
+ * **toc-entry.js:** add label/title wrappers ([2165072](https://github.com/AmerMathSoc/texml-to-html/commit/2165072dc60ff9fd7c40ad6f65221eaa6f0924a2)), closes [#451](https://github.com/AmerMathSoc/texml-to-html/issues/451)
11
+
5
12
  ### [17.0.1](https://github.com/AmerMathSoc/texml-to-html/compare/v17.0.0...v17.0.1) (2024-06-07)
6
13
 
7
14
 
@@ -27,13 +27,14 @@ export default function (htmlParentNode, xmlnode) {
27
27
  "data-ams-ref": xmlnode.getAttribute('specific-use') // NOTE: specific-use contains `ref@ref-type`-like information (e.g., 'chapter', 'section')
28
28
  });
29
29
  li.appendChild(anchor);
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
31
- // NOTE [...].find() HACK for bug with ':scope > ...', jsdom/jsdom#2998
30
+ // NOTE: label/title handling must stay aligned with other cases
32
31
  const label = xmlnode.querySelector(':scope>label');
33
32
  const title = xmlnode.querySelector(':scope>title');
34
33
  const altTitle = xmlnode.querySelector(':scope>alt-title');
35
34
  if (label && label.innerHTML.trim() !== '') {
36
- this.passThrough(anchor, label);
35
+ const labelSpan = this.createNode('span', '', { 'data-ams-doc': 'label' });
36
+ anchor.appendChild(labelSpan);
37
+ this.passThrough(labelSpan, label);
37
38
  anchor.insertAdjacentText('beforeend', '. ');
38
39
  }
39
40
  if (altTitle) {
@@ -43,7 +44,11 @@ export default function (htmlParentNode, xmlnode) {
43
44
  anchor.textContent + altTitleContent
44
45
  );
45
46
  }
46
- if (title) this.passThrough(anchor, title);
47
+ if (title) {
48
+ const titleSpan = this.createNode('span', '', { 'data-ams-doc': 'title' });
49
+ anchor.appendChild(titleSpan);
50
+ this.passThrough(titleSpan, title);
51
+ }
47
52
  // NOTE we expect very simple markup: one contrib group, string-names only
48
53
  const contribGroup = xmlnode.querySelector(':scope>contrib-group');
49
54
  if (contribGroup) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amermathsoc/texml-to-html",
3
- "version": "17.0.1",
3
+ "version": "17.1.0",
4
4
  "type": "module",
5
5
  "description": "A NodeJS library for converting AMS-style JATS XML to HTML",
6
6
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  import { book } from './helper.js';
18
18
  import tape from 'tape';
19
19
 
20
- tape('Template: (book) toc, toc-entry', async function(t) {
20
+ tape('Template: (book) toc, toc-entry', async function (t) {
21
21
  t.plan(14);
22
22
  const document = book;
23
23
 
@@ -30,28 +30,28 @@ tape('Template: (book) toc, toc-entry', async function(t) {
30
30
  t.equal(list.children.length, 6, 'Nested toc-entries remain nested')
31
31
  t.equal(
32
32
  list.querySelector('li a[href="#tocid1"][data-ams-ref="chapter"]').innerHTML,
33
- 'Chunk',
33
+ '<span data-ams-doc="title">Chunk</span>',
34
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,
38
- '2. Chunk',
38
+ '<span data-ams-doc="label">2</span>. <span data-ams-doc="title">Chunk</span>',
39
39
  'toc-entry, label, nav-pointer'
40
40
  );
41
41
  t.equal(list.querySelector('ol').children.length, 1, 'Doubly nested toc-entries remain nested');
42
42
  t.equal(
43
43
  list.querySelector('li a[href="#tocid2"]+ol li a[href="#tocid3"]').innerHTML,
44
- '1. SubChunk',
44
+ '<span data-ams-doc="label">1</span>. <span data-ams-doc="title">SubChunk</span>',
45
45
  'Nested toc-entry, label, nav-pointer'
46
46
  );
47
47
  t.equal(
48
48
  list.querySelector('li a[href="#tocid4"]').innerHTML,
49
- '1. SubSubChunk with <span data-ams-href="chapter">Link</span>',
49
+ '<span data-ams-doc="label">1</span>. <span data-ams-doc="title">SubSubChunk with <span data-ams-href="chapter">Link</span></span>',
50
50
  'toc-entry with xref in title'
51
51
  );
52
52
  t.equal(
53
53
  list.querySelector('li a[href="#tocid5"]').innerHTML,
54
- 'Chunk with alt title',
54
+ '<span data-ams-doc="title">Chunk with alt title</span>',
55
55
  'toc-entry with alt-title: content'
56
56
  );
57
57
  t.equal(
@@ -61,7 +61,7 @@ tape('Template: (book) toc, toc-entry', async function(t) {
61
61
  );
62
62
  t.equal(
63
63
  list.querySelector('li a[href="#tocid6"]').innerHTML,
64
- 'Chunk without label but subchunk with label',
64
+ '<span data-ams-doc="title">Chunk without label but subchunk with label</span>',
65
65
  'toc-entry without label but sub-entry with label'
66
66
  );
67
67
  t.equal(