@amermathsoc/texml-to-html 18.7.0 → 19.0.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,17 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [19.0.0](https://github.com/AmerMathSoc/texml-to-html/compare/v18.7.0...v19.0.0) (2025-11-26)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * Expects new texml TOC markup (toc-title-group).
11
+
12
+ ### Features
13
+
14
+ * adjust to new TOC markup ([b18f29a](https://github.com/AmerMathSoc/texml-to-html/commit/b18f29a831bd6a1943d8a05faf04f01d20f65167)), closes [#494](https://github.com/AmerMathSoc/texml-to-html/issues/494)
15
+
5
16
  ## [18.7.0](https://github.com/AmerMathSoc/texml-to-html/compare/v18.6.0...v18.7.0) (2025-07-02)
6
17
 
7
18
 
package/README.md CHANGED
@@ -162,7 +162,7 @@ Beyond HTML element and attributes, texml-to-html stores data in custom `data-*`
162
162
 
163
163
  ##### downstream `data-*` attributes
164
164
 
165
- While the vast majority of data attributes originate in texml-to-html, we have a few cases where downstream tooling introduces custom attributes.
165
+ While most data attributes originate in texml-to-html, we have a few cases where downstream tooling introduces custom attributes.
166
166
  We list the attribute names, the related tools and purpose:
167
167
 
168
168
  - [deprecated] data-eqn-tag-#
@@ -329,12 +329,16 @@ For books:
329
329
 
330
330
  **Note.** There is some overlap with other sections of this document. Ensure that updates are consistent across the document.
331
331
 
332
- For math mode, texml creates MathJax-optimized TeX strings that may contain XML markup; for content not supported by MathJax it falls back to SVG creation. This mix requires extra processing.
332
+ For math mode, texml creates MathJax-optimized TeX strings that may contain XML markup; for content not supported by MathJax it falls back to SVG creation. This mix requires additional processing.
333
+
334
+ For MathJax requirements, see the section below.
333
335
 
334
336
  #### xref
335
337
 
336
338
  Math mode output may contain xref elements. This gets turned into something like `\xhref[@ref-type]{#@rid}{...}`; the custom `xhref` MathJax macro works in both (MathJax's) text and math mode.
337
339
 
340
+ Furthermore, xref-group and cite-group will pass through and may need to be stripped for MathJax processing.
341
+
338
342
  #### text inside math mode
339
343
 
340
344
  In the case where math mode contains text mode, texml creates text elements possibly containing text XML markup. We turn this into MathJax-compatible TeX strings.
@@ -383,3 +387,38 @@ We convert the markup to HTML custom elements with attributes. Further processin
383
387
  - alg:repeat
384
388
  - alg:until
385
389
  - alg:loop
390
+
391
+ ### MathJax requirements
392
+
393
+ The output generated by texml and texml-to-html assumes the following MathJax extensions are available:
394
+
395
+ #### mathjax-src extensions
396
+
397
+ - Base
398
+ - Ams
399
+ - AmsCd
400
+ - Bbox
401
+ - Boldsymbol
402
+ - Braket
403
+ - Cancel
404
+ - Color
405
+ - ConfigMacros
406
+ - Enclose
407
+ - Extpfeil
408
+ - Html
409
+ - TagFormat
410
+ - TextMacros
411
+ - Unicode
412
+ - Verb
413
+ - Mathtools
414
+ - Cases
415
+ - Empheq
416
+ - Colortbl
417
+
418
+ #### third-party extensions
419
+
420
+ - [mathjax-xhref](https://github.com/AmerMathSoc/mathjax-xhref)
421
+ - [mathjax-img](https://github.com/pkra/mathjax-img)
422
+ - [mathjax-ams-macros](https://github.com/AmerMathSoc/mathjax-ams-macros)
423
+ - [mathjax-unicode-math](https://github.com/AmerMathSoc/mathjax-unicode-math)
424
+ - [mathjax-dbnsymb](https://github.com/AmerMathSoc/mathjax-dbnsymb)
@@ -82,7 +82,10 @@ export default function (htmlParentNode, xmlnode) {
82
82
  if (tagName === 'book-app-group') {
83
83
  section.setAttribute('data-ams-doc', 'app-group');
84
84
  }
85
- if (tagName === 'book-app' && !xmlnode.parentNode.closest('book-app')) section.setAttribute('role', 'doc-appendix'); // TODO: revisit after AmerMathSoc/texml#223
85
+ if (tagName === 'book-app' && !xmlnode.parentNode.closest('book-app')) {
86
+ section.setAttribute('role', 'doc-appendix'); // TODO: revisit after AmerMathSoc/texml#223
87
+ // section.setAttribute('data-ams-doc-level', '0')
88
+ }
86
89
 
87
90
  this.createHeading(section, xmlnode);
88
91
  this.passThrough(section, xmlnode);
@@ -26,7 +26,7 @@ export default function (htmlParentNode, xmlnode) {
26
26
  id: xmlnode.id,
27
27
  });
28
28
  htmlParentNode.appendChild(nav);
29
- this.recurseTheDom(nav, xmlnode.querySelector('title-group'));
29
+ this.recurseTheDom(nav, xmlnode.querySelector('toc-title-group'));
30
30
  const ol = this.createNode('ol');
31
31
  nav.appendChild(ol);
32
32
  [...xmlnode.childNodes]
@@ -208,6 +208,17 @@ export class Transformer {
208
208
  this.passThrough(span, xmlnode);
209
209
  return span.innerHTML.trim();
210
210
  }
211
+
212
+ /**
213
+ * Recursion hack for metadata generation
214
+ * @param {Node} xmlnode
215
+ * @returns {String}
216
+ */
217
+ recurseTheDomIntoHTMLString = xmlnode => {
218
+ const span = this.createNode('span');
219
+ this.recurseTheDom(span, xmlnode);
220
+ return span.innerHTML.trim();
221
+ }
211
222
 
212
223
  createHeading = (section, xmlnode) => { // create heading structure
213
224
  const label = xmlnode.querySelector(':scope>label:not(:empty)');
@@ -305,6 +316,7 @@ export class Transformer {
305
316
  'cite-group' = CiteGroup.bind(this)
306
317
  'cite-detail' = CiteDetail.bind(this)
307
318
  'title-group' = TitleGroup.bind(this)
319
+ 'toc-title-group' = TitleGroup.bind(this)
308
320
 
309
321
  // one-off reuse of imported elements
310
322
  // NOTE if RHS gets re-used more than once, use mapTag in the constructor
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@amermathsoc/texml-to-html",
3
- "version": "18.7.0",
3
+ "version": "19.0.0",
4
4
  "type": "module",
5
5
  "description": "A NodeJS library for converting AMS-style JATS XML to HTML",
6
6
  "scripts": {
7
7
  "coverage": "c8 npm run test && c8 report --reporter html",
8
8
  "release": "commit-and-tag-version",
9
- "texmlTests": "rm ./test/snapshots/texml-tests/* && find ../texml/tests/ -name *.xml -exec cp {} ./test/snapshots/texml-tests/. \\;",
9
+ "texmlTests": "rm -f ./test/snapshots/texml-tests/* && find ../texml/tests/ -name '*.xml' -exec cp {} ./test/snapshots/texml-tests/. \\;",
10
10
  "pretest": "node ./test/snapshots/updateTexmlSnapshots.js",
11
11
  "test": "tape test/*.js"
12
12
  },
@@ -123,9 +123,9 @@
123
123
  </book-meta>
124
124
  <front-matter>
125
125
  <toc id="toc">
126
- <title-group>
126
+ <toc-title-group>
127
127
  <title>Contents</title>
128
- </title-group>
128
+ </toc-title-group>
129
129
  <toc-entry specific-use="chapter">
130
130
  <title>Chunk</title>
131
131
  <nav-pointer rid="tocid1"/>
package/test/book.xml CHANGED
@@ -88,9 +88,9 @@
88
88
  </book-meta>
89
89
  <front-matter>
90
90
  <toc id="toc">
91
- <title-group>
91
+ <toc-title-group>
92
92
  <title>Contents</title>
93
- </title-group>
93
+ </toc-title-group>
94
94
  <toc-entry specific-use="chapter" style="custom">
95
95
  <title>Chunk</title>
96
96
  <nav-pointer rid="tocid1"/>
@@ -0,0 +1,74 @@
1
+ <!DOCTYPE html> <html dir="ltr" lang="en"><head><meta charset="utf-8"><meta content="width=device-width, initial-scale=1" name="viewport"><title>Sample book with appendix</title></head><body>
2
+ <section data-ams-doc="titlepage"><script type="application/json">{"book":{"identifiers":{"AMS":{},"crossref":{},"issn":{},"isbn":{},"loc":{},"basename":null},"title":"Sample book with appendix","alttitle":"Sample book with appendix"},"publishers":[],"contributors":{"authors":[{"name":"Jane Doe","bio":"","affiliations":[],"emails":[]}]},"permissions":{},"history":{}}</script></section>
3
+
4
+ <nav id="ltxid2" data-ams-doc-level="0" role="doc-toc"><h1><span data-ams-doc="title">Contents</span></h1><ol><li><a data-ams-ref="epub-opening-page" href="#ltxid3"><span data-ams-doc="title">Publisher’s Notice</span></a></li><li><a data-ams-ref="chapter" href="#ltxid5"><span data-ams-doc="label">Chapter 1<ams-x>.</ams-x></span> <span data-ams-doc="title">Chapter title</span></a><ol><li><a data-ams-ref="section" href="#ltxid6"><span data-ams-doc="label">1<ams-x>.</ams-x></span> <span data-ams-doc="title">Introduction</span></a></li></ol></li><li><a data-ams-ref="book-app" href="#ltxid9"><span data-ams-doc="label">Appendix A<ams-x>.</ams-x></span> <span data-ams-doc="title">Esoteric Secrets</span></a><ol><li><a data-ams-ref="section" href="#ltxid10"><span data-ams-doc="label">1<ams-x>.</ams-x></span> <span data-ams-doc="title">Appendix section</span></a></li></ol></li><li><a data-ams-ref="book-app" href="#ltxid12"><span data-ams-doc="title">Esotericer Secrets</span></a><ol><li><a data-ams-ref="section" href="#ltxid13"><span data-ams-doc="label">2<ams-x>.</ams-x></span> <span data-ams-doc="title">Another appendix section</span></a></li></ol></li><li><a data-ams-ref="book-app" href="#ltxid14"><span data-ams-doc="label">Appendix B<ams-x>.</ams-x></span> <span data-ams-doc="title">Esotericest Secrets</span></a><ol><li><a data-ams-ref="section" href="#ltxid15"><span data-ams-doc="title">Shout outs</span></a></li></ol></li></ol></nav>
5
+ <section data-ams-doc-level="0" data-ams-content-type="publishers-note" data-ams-doc="notes" data-ams-specific-use="epub-opening-page" id="ltxid3"><h1><span data-ams-doc="title">Publisher’s Notice</span></h1>
6
+
7
+ <p>The <a href="https://www.ams.org">American Mathematical Society</a> has provided this ebook to you without Digital Rights Management (DRM) software applied so that you can enjoy reading it on your personal devices. This ebook is for your personal use only and must not be made publicly available in any way. You may not copy, reproduce, or upload this ebook except to read it on your personal devices.</p>
8
+ </section>
9
+
10
+
11
+
12
+
13
+ <section role="doc-chapter" id="ltxid5" data-ams-doc="chapter" data-ams-doc-level="0"><h1><span data-ams-doc="label">Chapter 1</span> <span data-ams-doc="title">Chapter title</span></h1>
14
+
15
+
16
+ <section role="doc-introduction" id="ltxid6" data-ams-doc="section" data-ams-doc-level="1"><h2><span data-ams-doc="label">1<ams-x>.</ams-x></span> <span data-ams-doc="title">Introduction</span></h2>
17
+
18
+
19
+ <p>Here is some text.</p>
20
+ </section>
21
+ </section>
22
+
23
+
24
+
25
+
26
+ <section id="ltxid8" data-ams-doc="app-group" data-ams-doc-level="0">
27
+
28
+ <h1><span data-ams-doc="title">Appendixes</span></h1>
29
+
30
+ <section role="doc-appendix" id="ltxid9" data-ams-doc="null" data-ams-doc-level="5">
31
+
32
+ <h6><span data-ams-doc="label">Appendix A</span> <span data-ams-doc="title">Esoteric Secrets</span></h6>
33
+
34
+
35
+ <p>Some text.</p>
36
+ <section data-ams-specific-use="section" id="ltxid10" data-ams-doc-level="1" role="doc-appendix"><h2><span data-ams-doc="label">1<ams-x>.</ams-x></span> <span data-ams-doc="title">Appendix section</span></h2>
37
+
38
+
39
+ <p>Some text.</p>
40
+ <section id="ltxid11" data-ams-doc="subsection" data-ams-doc-level="2"><h3><span data-ams-doc="label">1.1<ams-x>.</ams-x></span> <span data-ams-doc="title">Appendix subsection<ams-x>.</ams-x></span></h3>
41
+
42
+
43
+ <p>Some text.</p>
44
+ </section>
45
+ </section>
46
+
47
+ </section>
48
+ <section role="doc-appendix" id="ltxid12" data-ams-doc="null" data-ams-doc-level="5">
49
+
50
+ <h6><span data-ams-doc="label">Appendix</span> <span data-ams-doc="title">Esotericer Secrets</span></h6>
51
+
52
+
53
+ <p>Some text.</p>
54
+ <section data-ams-specific-use="section" id="ltxid13" data-ams-doc-level="1" role="doc-appendix"><h2><span data-ams-doc="label">2<ams-x>.</ams-x></span> <span data-ams-doc="title">Another appendix section</span></h2>
55
+
56
+
57
+ <p>Some text.</p>
58
+ </section>
59
+
60
+ </section>
61
+ <section role="doc-appendix" id="ltxid14" data-ams-doc="null" data-ams-doc-level="5">
62
+
63
+ <h6><span data-ams-doc="label">Appendix B</span> <span data-ams-doc="title">Esotericest Secrets</span></h6>
64
+
65
+
66
+ <p>Here is the real truth.</p>
67
+
68
+ </section>
69
+ </section>
70
+ <section role="doc-acknowledgments" id="ltxid15" data-ams-doc="section" data-ams-doc-level="1"><h2><span data-ams-doc="title">Shout outs</span></h2>
71
+
72
+ </section>
73
+
74
+ </body></html>
@@ -0,0 +1,142 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE book PUBLIC "-//NLM//DTD BITS Book Interchange DTD v2.1 20180401//EN" "BITS-book2.dtd">
3
+ <book xmlns:xlink="http://www.w3.org/1999/xlink">
4
+ <book-meta>
5
+ <book-title-group>
6
+ <book-title>Sample book with appendix</book-title>
7
+ </book-title-group>
8
+ <contrib-group content-type="authors">
9
+ <contrib contrib-type="author">
10
+ <string-name>Jane Doe</string-name>
11
+ </contrib>
12
+ </contrib-group>
13
+ </book-meta>
14
+ <front-matter id="ltxid1">
15
+ <toc id="ltxid2">
16
+ <toc-title-group>
17
+ <title>Contents</title>
18
+ </toc-title-group>
19
+ <toc-entry specific-use="epub-opening-page">
20
+ <title>Publisher’s Notice</title>
21
+ <nav-pointer rid="ltxid3"/>
22
+ </toc-entry>
23
+ <toc-entry specific-use="chapter">
24
+ <label>Chapter 1<x>.</x></label>
25
+ <title>Chapter title</title>
26
+ <nav-pointer rid="ltxid5"/>
27
+ <toc-entry specific-use="section">
28
+ <label>1<x>.</x></label>
29
+ <title>Introduction</title>
30
+ <nav-pointer rid="ltxid6"/>
31
+ </toc-entry>
32
+ </toc-entry>
33
+ <toc-entry specific-use="book-app">
34
+ <label>Appendix A<x>.</x></label>
35
+ <title>Esoteric Secrets</title>
36
+ <nav-pointer rid="ltxid9"/>
37
+ <toc-entry specific-use="section">
38
+ <label>1<x>.</x></label>
39
+ <title>Appendix section</title>
40
+ <nav-pointer rid="ltxid10"/>
41
+ </toc-entry>
42
+ </toc-entry>
43
+ <toc-entry specific-use="book-app">
44
+ <title>Esotericer Secrets</title>
45
+ <nav-pointer rid="ltxid12"/>
46
+ <toc-entry specific-use="section">
47
+ <label>2<x>.</x></label>
48
+ <title>Another appendix section</title>
49
+ <nav-pointer rid="ltxid13"/>
50
+ </toc-entry>
51
+ </toc-entry>
52
+ <toc-entry specific-use="book-app">
53
+ <label>Appendix B<x>.</x></label>
54
+ <title>Esotericest Secrets</title>
55
+ <nav-pointer rid="ltxid14"/>
56
+ <toc-entry specific-use="section">
57
+ <title>Shout outs</title>
58
+ <nav-pointer rid="ltxid15"/>
59
+ </toc-entry>
60
+ </toc-entry>
61
+ </toc>
62
+ <notes id="ltxid3" notes-type="publishers-note" specific-use="epub-opening-page">
63
+ <title>Publisher’s Notice</title>
64
+ <p>The <ext-link xlink:href="https://www.ams.org">American Mathematical Society</ext-link> has provided this ebook to you without Digital Rights Management (DRM) software applied so that you can enjoy reading it on your personal devices. This ebook is for your personal use only and must not be made publicly available in any way. You may not copy, reproduce, or upload this ebook except to read it on your personal devices.</p>
65
+ </notes>
66
+ </front-matter>
67
+ <book-body id="ltxid4">
68
+ <book-part>
69
+ <body>
70
+ <sec disp-level="1" id="ltxid5" specific-use="chapter">
71
+ <label>Chapter 1</label>
72
+ <title>Chapter title</title>
73
+ <sec disp-level="2" id="ltxid6" specific-use="section">
74
+ <label>1<x>.</x></label>
75
+ <title>Introduction</title>
76
+ <p>Here is some text.</p>
77
+ </sec>
78
+ </sec>
79
+ </body>
80
+ </book-part>
81
+ </book-body>
82
+ <book-back id="ltxid7">
83
+ <book-app-group id="ltxid8">
84
+ <book-part-meta>
85
+ <title-group>
86
+ <title>Appendixes</title>
87
+ </title-group>
88
+ </book-part-meta>
89
+ <book-app id="ltxid9">
90
+ <book-part-meta>
91
+ <title-group>
92
+ <label>Appendix A</label>
93
+ <title>Esoteric Secrets</title>
94
+ </title-group>
95
+ </book-part-meta>
96
+ <body>
97
+ <p>Some text.</p>
98
+ <app disp-level="2" id="ltxid10" specific-use="section">
99
+ <label>1<x>.</x></label>
100
+ <title>Appendix section</title>
101
+ <p>Some text.</p>
102
+ <sec disp-level="3" id="ltxid11" specific-use="subsection">
103
+ <label>1.1<x>.</x></label>
104
+ <title>Appendix subsection<x>.</x></title>
105
+ <p>Some text.</p>
106
+ </sec>
107
+ </app>
108
+ </body>
109
+ </book-app>
110
+ <book-app id="ltxid12">
111
+ <book-part-meta>
112
+ <title-group>
113
+ <label>Appendix</label>
114
+ <title>Esotericer Secrets</title>
115
+ </title-group>
116
+ </book-part-meta>
117
+ <body>
118
+ <p>Some text.</p>
119
+ <app disp-level="2" id="ltxid13" specific-use="section">
120
+ <label>2<x>.</x></label>
121
+ <title>Another appendix section</title>
122
+ <p>Some text.</p>
123
+ </app>
124
+ </body>
125
+ </book-app>
126
+ <book-app id="ltxid14">
127
+ <book-part-meta>
128
+ <title-group>
129
+ <label>Appendix B</label>
130
+ <title>Esotericest Secrets</title>
131
+ </title-group>
132
+ </book-part-meta>
133
+ <body>
134
+ <p>Here is the real truth.</p>
135
+ </body>
136
+ </book-app>
137
+ </book-app-group>
138
+ <ack disp-level="2" id="ltxid15" specific-use="section">
139
+ <title>Shout outs</title>
140
+ </ack>
141
+ </book-back>
142
+ </book>