@amermathsoc/texml-to-html 17.1.0 → 18.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
@@ -1,6 +1,51 @@
1
1
  # Changelog
2
2
 
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.
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
+
5
+ ## [18.0.0](https://github.com/AmerMathSoc/texml-to-html/compare/v18.0.0-0...v18.0.0) (2024-08-16)
6
+
7
+ ## [18.0.0-0](https://github.com/AmerMathSoc/texml-to-html/compare/v17.1.0...v18.0.0-0) (2024-08-13)
8
+
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+
12
+ * label.js no longer generates
13
+ punctuation&space in label (with title) but adds space
14
+ between label and title (if both present); also no longer adds
15
+ space and possible punctuation after theorem title.
16
+ * secheading no longer generates
17
+ punctuation+space in label, but spaces after label&title.
18
+ * caption.js no longer generates
19
+ punctuation after label nor parentheses around subfigure
20
+ labels.
21
+ * toc-entry no longer generates
22
+ punctuation after label.
23
+ * xref-group now preserved in tex-math
24
+ * cite-detail no longer unwrapped in tex-math
25
+ * book-app-groups are no longer
26
+ forcibly marked as parts and level.
27
+ * all x elements are now preserved as
28
+ ams-x, i.e. downstream will need to remove unwanted ones.
29
+
30
+ * feat!(label.js): stop adding "generated text" ([4b9543d](https://github.com/AmerMathSoc/texml-to-html/commit/4b9543d0d04ffb1d0b79f3046b95fc180fa13d92)), closes [#454](https://github.com/AmerMathSoc/texml-to-html/issues/454)
31
+ * feat!(secheading.js): stop adding "generated text" ([d98265e](https://github.com/AmerMathSoc/texml-to-html/commit/d98265e57560690a3f793c49493e74751d9202f9)), closes [#454](https://github.com/AmerMathSoc/texml-to-html/issues/454)
32
+ * feat!(caption.js): stop adding "generated text" ([3d17ff1](https://github.com/AmerMathSoc/texml-to-html/commit/3d17ff1b52ba459d9facda1c01b6ad301b046992)), closes [#454](https://github.com/AmerMathSoc/texml-to-html/issues/454)
33
+ * feat!(toc-entry.js): stop adding "generated text" ([1981ae3](https://github.com/AmerMathSoc/texml-to-html/commit/1981ae371bc1c7770903381c2c22966858b452dd)), closes [#454](https://github.com/AmerMathSoc/texml-to-html/issues/454)
34
+ * feat!(xref-groupl.js): preserve in tex-math ([133d8a5](https://github.com/AmerMathSoc/texml-to-html/commit/133d8a529446fa47d75f3a02bab0ee42c26aba23)), closes [#456](https://github.com/AmerMathSoc/texml-to-html/issues/456)
35
+ * feat!(cite-detail.js): preserve in tex-math ([0a570fe](https://github.com/AmerMathSoc/texml-to-html/commit/0a570feb05678164db0e7834c32977b2fa74182a)), closes [#455](https://github.com/AmerMathSoc/texml-to-html/issues/455)
36
+ * feat!(sec.js): revise book-app-group output ([2f4e06a](https://github.com/AmerMathSoc/texml-to-html/commit/2f4e06a117a62a49489b413c6cc26436773b0a36)), closes [#436](https://github.com/AmerMathSoc/texml-to-html/issues/436)
37
+ * feat!(x.js): preserve all x elements as ams-x ([5b77a86](https://github.com/AmerMathSoc/texml-to-html/commit/5b77a8642fe78bfd56fb5bfc753d67e9bbd3d719)), closes [#445](https://github.com/AmerMathSoc/texml-to-html/issues/445)
38
+
39
+
40
+ ### Features
41
+
42
+ * **algorithm.js:** support missing line no. delimiter ([0ef3047](https://github.com/AmerMathSoc/texml-to-html/commit/0ef3047623af712c11bae148c372d623ee611b10)), closes [#453](https://github.com/AmerMathSoc/texml-to-html/issues/453)
43
+
44
+
45
+ ### Bug Fixes
46
+
47
+ * **package.json:** replace standard-version ([5db8c62](https://github.com/AmerMathSoc/texml-to-html/commit/5db8c62ccbb441b4902b0bb30db8e568d1a486d2)), closes [#458](https://github.com/AmerMathSoc/texml-to-html/issues/458)
48
+ * secheading, toc-entry should match label.js ([4e9d7ef](https://github.com/AmerMathSoc/texml-to-html/commit/4e9d7eff09e3c481dbb4c917f8e31ac23a6db03e)), closes [#454](https://github.com/AmerMathSoc/texml-to-html/issues/454)
4
49
 
5
50
  ## [17.1.0](https://github.com/AmerMathSoc/texml-to-html/compare/v17.0.1...v17.1.0) (2024-07-04)
6
51
 
package/README.md CHANGED
@@ -117,6 +117,7 @@ Beyond HTML element and attributes, texml-to-html stores data in custom `data-*`
117
117
  - tags - container for (duplicated) equation tags
118
118
  - container is inside data-ams-doc="math block" elements
119
119
  - ams-html uses these to generate the math panel DTs for equations
120
+ - app-group [from book-app-group]
120
121
  - data-ams-doc-contrib
121
122
  - {@content-type} [expected: "authors", "editors", "translators", "contributors"]
122
123
  - {@contrib-type} [expected: "author", "editor", "translator", "contributor"]
@@ -187,7 +188,6 @@ The following [ARIA-DPUB](https://w3c.github.io/dpub-aria/) role attribute value
187
188
  - doc-abstract
188
189
  - doc-toc
189
190
  - doc-footnote
190
- - doc-appendix
191
191
 
192
192
  #### texml XML to `data-*` mappings
193
193
 
@@ -35,7 +35,7 @@ export function algLine(htmlParentNode, xmlnode) {
35
35
  const spansLineNo = ['alg:require', 'alg:ensure'].includes(xmlnode.firstElementChild.tagName); // NOTE if texml generated a suitable attribute, we wouldn't need an allowlist
36
36
  const lineNo = this.createNode('alg-lineno');
37
37
  htmlParentNode.appendChild(lineNo);
38
- if (!spansLineNo && xmlnode.getAttribute('lineno')) lineNo.innerHTML = `${xmlnode.getAttribute('lineno')}${xmlnode.closest('[linenodelimiter]').getAttribute('linenodelimiter')}`;
38
+ if (!spansLineNo && xmlnode.getAttribute('lineno')) lineNo.innerHTML = `${xmlnode.getAttribute('lineno')}${xmlnode.closest('[linenodelimiter]')?.getAttribute('linenodelimiter') || ''}`;
39
39
  const node = this.createNode('alg-line');
40
40
  if (spansLineNo) node.setAttribute('data-ams-alg-spanslineno');
41
41
  htmlParentNode.appendChild(node);
@@ -20,10 +20,6 @@
20
20
  * @param {Element} xmlnode
21
21
  */
22
22
  export default function (htmlParentNode, xmlnode) {
23
- if (xmlnode.closest('tex-math')) {
24
- this.passThrough(htmlParentNode, xmlnode);
25
- return;
26
- }
27
23
  const citeGroup = this.createNode('cite-detail');
28
24
  htmlParentNode.appendChild(citeGroup);
29
25
  this.passThrough(citeGroup, xmlnode);
@@ -28,5 +28,23 @@ export default function (htmlParentNode, xmlnode) {
28
28
  if (xmlnode.getAttribute('position')) figure.setAttribute('data-ams-position', xmlnode.getAttribute('position'));
29
29
  mapAttributes(figure, xmlnode);
30
30
  htmlParentNode.appendChild(figure);
31
+
32
+ const label = xmlnode.querySelector(':scope>label');
33
+ const caption = xmlnode.querySelector(':scope>caption');
34
+
35
+ if (label || caption) {
36
+ const figcaption = this.createNode('figcaption');
37
+ figure.appendChild(figcaption);
38
+ if (label) {
39
+ const strong = this.createNode('strong');//TODO: cf. & unify with label.js; NOTE: no space after label necessary (since downstream rewrites things); but space shouldn't be harmful if we unify with label.js.
40
+ figcaption.appendChild(strong);
41
+ this.passThrough(strong, label);
42
+ label.remove();//NOTE: prevent duplicate processing later on
43
+ }
44
+ if (caption) {
45
+ this.passThrough(figcaption, caption);
46
+ }
47
+ }
48
+ // process remaining children
31
49
  this.passThrough(figure, xmlnode);
32
50
  };
@@ -31,12 +31,22 @@ const getElementToInsertAfter = maybeBadAncestor => (maybeBadAncestor.nextElemen
31
31
  */
32
32
  export default function (htmlParentNode, xmlnode) {
33
33
  if (xmlnode.closest('tex-math')) xmlnode.remove();
34
- const div = this.createNode('div', '', { role: 'doc-footnote', 'aria-label': `Footnote ${xmlnode.querySelector('label').textContent}` });
34
+ const label = xmlnode.querySelector('label');
35
+ const div = this.createNode('div', '', { role: 'doc-footnote', 'aria-label': `Footnote ${label.textContent}` });
35
36
  // NOTE AmerMathSoc/texml-to-html#336 analyzed where fn occurs in publications; might need revisions
36
37
  // Essentially, we can assume fn occurs inside elements (that turn into) p, h1, and span (from formula markup)
37
38
  // Since a span ancestor can be inside p (e.g., from inline-formula) we check for the others first.
38
39
  const maybeBadAncestor = htmlParentNode.closest('p, h1') || htmlParentNode.closest('span');
39
40
  maybeBadAncestor ? getElementToInsertAfter(maybeBadAncestor).insertAdjacentElement('afterend', div) : htmlParentNode.appendChild(div);
40
41
  mapAttributes(div, xmlnode);
42
+ // label
43
+ const span = this.createNode('span', '<sup></sup>', {
44
+ 'data-ams-doc': 'label'
45
+ });
46
+ div.appendChild(span);
47
+ const superscript = span.firstElementChild;
48
+ this.passThrough(superscript, label);
49
+ label.remove(); //NOTE: prevent duplicate processing later on
50
+
41
51
  this.passThrough(div, xmlnode);
42
52
  };
@@ -22,35 +22,6 @@ import getParentLevel from '../helpers/getParentLevel.js';
22
22
  * @param {Element} xmlnode
23
23
  */
24
24
  export default function (htmlParentNode, xmlnode) {
25
- const caption = this.caption;
26
-
27
- // simple cases
28
- // CASE fn
29
- if (xmlnode.parentNode.tagName === 'fn') {
30
- const span = this.createNode('span', '<sup></sup>', {
31
- 'data-ams-doc': 'label'
32
- });
33
- htmlParentNode.appendChild(span);
34
- const superscript = span.firstElementChild;
35
- this.passThrough(superscript, xmlnode);
36
- return;
37
- }
38
- // CASE ref
39
- if (xmlnode.parentNode.tagName === 'ref') {
40
- // NOTE the DT created in ref.js serves as wrapper
41
- this.passThrough(htmlParentNode, xmlnode);
42
- return;
43
- }
44
- // CASE fig, fig-group, table-wrap, table-wrap-group via caption
45
- if (
46
- xmlnode.parentNode.tagName === 'table-wrap' ||
47
- xmlnode.parentNode.tagName === 'table-wrap-group' ||
48
- xmlnode.parentNode.tagName === 'fig' ||
49
- xmlnode.parentNode.tagName === 'fig-group'
50
- ) {
51
- caption(htmlParentNode, xmlnode);
52
- return;
53
- }
54
25
  // CASE label followed by a title -- we skip (and pull in the label later on when processing title)
55
26
  if (xmlnode.nextElementSibling?.tagName === 'title') return;
56
27
  // CASE empty label
@@ -82,8 +53,7 @@ export default function (htmlParentNode, xmlnode) {
82
53
  const labelSpan = this.createNode('span', '', { 'data-ams-doc': 'label' });
83
54
  container.appendChild(labelSpan);
84
55
  this.passThrough(labelSpan, previousSibling);
85
- const labelSeparatorString = isStatement ? ' ' : '. ';
86
- labelSpan.insertAdjacentText('beforeend', labelSeparatorString);
56
+ labelSpan.insertAdjacentText('afterend', ' '); // NOTE: adding (in HTML meaningful) space after label & before title to avoid them from smashing together.
87
57
  }
88
58
 
89
59
  // CASE Book
@@ -96,8 +66,6 @@ export default function (htmlParentNode, xmlnode) {
96
66
  // add main node and recurse
97
67
  const actualSpan = this.createNode('span', '', { 'data-ams-doc': xmlnode.tagName });
98
68
  container.appendChild(actualSpan);
69
+ // NOTE: no space after title/label if there's only one. Downstream might insert some (e.g., with inlined headings).
99
70
  this.passThrough(actualSpan, xmlnode);
100
-
101
- // faking TeX's punctutation-at-end logic
102
- if (isStatement) container.insertAdjacentText('beforeend', container.textContent.endsWith('.') ? ' ' : '. ');
103
71
  };
@@ -23,6 +23,6 @@ export default function (htmlParentNode, xmlnode) {
23
23
  const dt = this.createNode('dt');
24
24
  dt.id = xmlnode.id;
25
25
  htmlParentNode.appendChild(dt);
26
- this.recurseTheDom(dt, xmlnode.querySelector('label'));
26
+ this.passThrough(dt, xmlnode.querySelector('label'));
27
27
  this.recurseTheDom(htmlParentNode, xmlnode.querySelector('mixed-citation'));
28
28
  };
@@ -78,10 +78,7 @@ export default function (htmlParentNode, xmlnode) {
78
78
 
79
79
  // book appendices
80
80
  if (tagName === 'book-app-group') {
81
- // NOTE might become redundant if book-app-group gets specific-use=part
82
- section.setAttribute('role', 'doc-part');
83
- section.setAttribute('data-ams-doc', 'part');
84
- section.setAttribute('data-ams-doc-level', '0');
81
+ section.setAttribute('data-ams-doc', 'app-group');
85
82
  }
86
83
  if (tagName === 'book-app') section.setAttribute('role', 'doc-appendix');
87
84
 
@@ -34,10 +34,8 @@ export default function (htmlParentNode, xmlnode) {
34
34
  const title = xmlnode.querySelector('title');
35
35
  if (label) {
36
36
  this.passThrough(span, label);
37
+ if (title) span.insertAdjacentText('beforeend', ' '); //TODO: cf. & unify with label.js
37
38
  }
38
- if (title && label) {
39
- span.insertAdjacentText('beforeend', '. ');
40
- // NOTE this does not match label/title punctuation where a title without label would get a period.
41
- }
39
+ if (!title) return;
42
40
  this.passThrough(span, title);
43
41
  };
@@ -35,7 +35,7 @@ export default function (htmlParentNode, xmlnode) {
35
35
  const labelSpan = this.createNode('span', '', { 'data-ams-doc': 'label' });
36
36
  anchor.appendChild(labelSpan);
37
37
  this.passThrough(labelSpan, label);
38
- anchor.insertAdjacentText('beforeend', '. ');
38
+ if (title) labelSpan.insertAdjacentText('afterend', ' '); //TODO: cf. & unify with label.js
39
39
  }
40
40
  if (altTitle) {
41
41
  const altTitleContent = altTitle.textContent;
package/lib/elements/x.js CHANGED
@@ -20,8 +20,8 @@
20
20
  * @param {Element} xmlnode
21
21
  */
22
22
  export default function (htmlParentNode, xmlnode) {
23
- // ignore if not xref/x or isBook
24
- if (!xmlnode.closest('xref') && xmlnode.closest('article'))
25
- return;
26
- this.passThrough(htmlParentNode, xmlnode);
23
+ // NOTE: downstream will (sometimes) strip (some) of these out later
24
+ const amsx = this.createNode('ams-x');
25
+ htmlParentNode.appendChild(amsx);
26
+ this.passThrough(amsx, xmlnode);
27
27
  };
@@ -22,10 +22,6 @@
22
22
  export default function (htmlParentNode, xmlnode) {
23
23
  const refType = xmlnode.getAttribute('ref-type');
24
24
  const refrange = xmlnode.getAttribute('middle');
25
- if (xmlnode.parentNode.closest('tex-math')) {
26
- // NOTE: no use case so far; cf. #428 for code example
27
- return;
28
- }
29
25
  const span = this.createNode('span', '', {
30
26
  'data-ams-doc': 'refgroup',
31
27
  'data-ams-ref': refType,
@@ -56,7 +56,6 @@ import SecMeta from './elements/sec-meta.js';
56
56
  import Graphic from './elements/graphic.js';
57
57
  import Img from './elements/img.js';
58
58
  import Fig from './elements/fig.js';
59
- import Caption from './elements/caption.js';
60
59
  import Toc from './elements/toc.js';
61
60
  import TocEntry from './elements/toc-entry.js';
62
61
  import Formula from './elements/formula.js';
@@ -252,7 +251,6 @@ export class Transformer {
252
251
  graphic = Graphic.bind(this)
253
252
  img = Img.bind(this)
254
253
  fig = Fig.bind(this)
255
- caption = Caption.bind(this)
256
254
  toc = Toc.bind(this)
257
255
  'toc-entry' = TocEntry.bind(this)
258
256
  'inline-formula' = Formula.bind(this)