@amermathsoc/texml-to-html 15.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.
Files changed (166) hide show
  1. package/CHANGELOG.md +1414 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +5 -0
  4. package/README.md +16 -0
  5. package/examples/cli.js +6 -0
  6. package/ldom.js +6 -0
  7. package/lib/doms.js +30 -0
  8. package/lib/elements/abstract.js +34 -0
  9. package/lib/elements/algorithm.js +78 -0
  10. package/lib/elements/app.js +35 -0
  11. package/lib/elements/article-metadata-json.js +167 -0
  12. package/lib/elements/article-title.js +26 -0
  13. package/lib/elements/article.js +28 -0
  14. package/lib/elements/attrib.js +41 -0
  15. package/lib/elements/bold.js +32 -0
  16. package/lib/elements/book-meta-json.js +134 -0
  17. package/lib/elements/book-meta.js +33 -0
  18. package/lib/elements/book-title.js +26 -0
  19. package/lib/elements/boxed-text.js +31 -0
  20. package/lib/elements/break.js +25 -0
  21. package/lib/elements/caption.js +52 -0
  22. package/lib/elements/compound-kwd.js +27 -0
  23. package/lib/elements/def-item.js +26 -0
  24. package/lib/elements/def-list.js +30 -0
  25. package/lib/elements/def.js +29 -0
  26. package/lib/elements/disp-formula-group.js +30 -0
  27. package/lib/elements/disp-quote.js +33 -0
  28. package/lib/elements/email.js +28 -0
  29. package/lib/elements/ext-link.js +38 -0
  30. package/lib/elements/fig.js +32 -0
  31. package/lib/elements/fn.js +42 -0
  32. package/lib/elements/formula.js +51 -0
  33. package/lib/elements/front.js +64 -0
  34. package/lib/elements/funding-group.js +26 -0
  35. package/lib/elements/graphic.js +49 -0
  36. package/lib/elements/img.js +28 -0
  37. package/lib/elements/italic.js +33 -0
  38. package/lib/elements/kwd-group.js +29 -0
  39. package/lib/elements/kwd.js +26 -0
  40. package/lib/elements/label.js +101 -0
  41. package/lib/elements/line.js +31 -0
  42. package/lib/elements/meta-name.js +29 -0
  43. package/lib/elements/meta-value.js +27 -0
  44. package/lib/elements/mixed-citation.js +35 -0
  45. package/lib/elements/monospace.js +35 -0
  46. package/lib/elements/notes.js +36 -0
  47. package/lib/elements/p.js +29 -0
  48. package/lib/elements/preface.js +33 -0
  49. package/lib/elements/ref-list.js +50 -0
  50. package/lib/elements/ref.js +28 -0
  51. package/lib/elements/roman.js +34 -0
  52. package/lib/elements/sans-serif.js +34 -0
  53. package/lib/elements/sc.js +35 -0
  54. package/lib/elements/sec-meta.js +35 -0
  55. package/lib/elements/sec.js +89 -0
  56. package/lib/elements/secheading.js +43 -0
  57. package/lib/elements/simpletabbing.js +29 -0
  58. package/lib/elements/statement.js +31 -0
  59. package/lib/elements/string-name.js +28 -0
  60. package/lib/elements/styled-content.js +32 -0
  61. package/lib/elements/subj-group.js +29 -0
  62. package/lib/elements/subject.js +26 -0
  63. package/lib/elements/subtitle.js +29 -0
  64. package/lib/elements/table.js +28 -0
  65. package/lib/elements/tag.js +50 -0
  66. package/lib/elements/target.js +39 -0
  67. package/lib/elements/term.js +31 -0
  68. package/lib/elements/tex-math.js +34 -0
  69. package/lib/elements/text.js +29 -0
  70. package/lib/elements/toc-entry.js +63 -0
  71. package/lib/elements/toc.js +35 -0
  72. package/lib/elements/underline.js +26 -0
  73. package/lib/elements/x.js +27 -0
  74. package/lib/elements/xref-group.js +36 -0
  75. package/lib/elements/xref.js +89 -0
  76. package/lib/hacks.js +43 -0
  77. package/lib/head.js +38 -0
  78. package/lib/helpers/copyElement.js +29 -0
  79. package/lib/helpers/extractContribGroups.js +94 -0
  80. package/lib/helpers/generateByline.js +35 -0
  81. package/lib/helpers/getParentLevel.js +24 -0
  82. package/lib/helpers/helpers-tex.js +54 -0
  83. package/lib/helpers/mapAttributes.js +54 -0
  84. package/lib/helpers/mapColorAttributes.js +36 -0
  85. package/lib/helpers/unnest.js +34 -0
  86. package/lib/transformer.js +311 -0
  87. package/out.html +550 -0
  88. package/package.json +39 -0
  89. package/test/article--alttitle.xml +146 -0
  90. package/test/article--nometa.xml +40 -0
  91. package/test/article-alttitle-meta-snapshot.json +94 -0
  92. package/test/article-meta-snapshot.json +129 -0
  93. package/test/article-nometa-meta-snapshot.json +46 -0
  94. package/test/article.xml +593 -0
  95. package/test/attribute-content-type.js +26 -0
  96. package/test/attribute-has-qed-box.js +28 -0
  97. package/test/attribute-hidden.js +27 -0
  98. package/test/attribute-rowspan-colspan.js +27 -0
  99. package/test/attribute-specific-use.js +27 -0
  100. package/test/attribute-style.js +27 -0
  101. package/test/book-meta-snapshot.json +78 -0
  102. package/test/book.xml +292 -0
  103. package/test/copyElement.js +38 -0
  104. package/test/element-abstract-title.js +27 -0
  105. package/test/element-algorithm.js +56 -0
  106. package/test/element-article.js +24 -0
  107. package/test/element-attrib.js +27 -0
  108. package/test/element-back-app-group-app.js +28 -0
  109. package/test/element-bold.js +26 -0
  110. package/test/element-book-meta.js +37 -0
  111. package/test/element-book-preface.js +29 -0
  112. package/test/element-book-ref-list.js +32 -0
  113. package/test/element-book.js +33 -0
  114. package/test/element-boxed-text.js +28 -0
  115. package/test/element-break.js +27 -0
  116. package/test/element-citegroup.js +25 -0
  117. package/test/element-compound-kwd.js +24 -0
  118. package/test/element-def-list-def-item-def-term.js +43 -0
  119. package/test/element-disp-formula-group.js +27 -0
  120. package/test/element-disp-quote.js +31 -0
  121. package/test/element-email.js +26 -0
  122. package/test/element-ext-link.js +30 -0
  123. package/test/element-fig-subfig-label.js +38 -0
  124. package/test/element-fn.js +40 -0
  125. package/test/element-front.js +45 -0
  126. package/test/element-funding-group.js +29 -0
  127. package/test/element-graphic-inline-graphic.js +40 -0
  128. package/test/element-img.js +30 -0
  129. package/test/element-inline-formula-disp-formula-tex-math.js +91 -0
  130. package/test/element-italic.js +28 -0
  131. package/test/element-kwd-group.js +28 -0
  132. package/test/element-kwd.js +27 -0
  133. package/test/element-mixed-citation.js +32 -0
  134. package/test/element-monospace.js +27 -0
  135. package/test/element-notes.js +42 -0
  136. package/test/element-p-p.js +27 -0
  137. package/test/element-ref-list-ref-label.js +40 -0
  138. package/test/element-roman.js +27 -0
  139. package/test/element-sans-serif.js +27 -0
  140. package/test/element-sc.js +27 -0
  141. package/test/element-sec-app-front-matter-part-dedication-title-label.js +87 -0
  142. package/test/element-sec-meta.js +43 -0
  143. package/test/element-secheading.js +28 -0
  144. package/test/element-simpletabbing-line.js +31 -0
  145. package/test/element-statement-label-title.js +120 -0
  146. package/test/element-string-name.js +27 -0
  147. package/test/element-stripEmptyLabel.js +26 -0
  148. package/test/element-styled-content.js +28 -0
  149. package/test/element-subtitle.js +36 -0
  150. package/test/element-table-wrap-group.js +30 -0
  151. package/test/element-table-wrap.js +51 -0
  152. package/test/element-table.js +34 -0
  153. package/test/element-tag.js +38 -0
  154. package/test/element-target.js +33 -0
  155. package/test/element-toc-toc-entry.js +77 -0
  156. package/test/element-underline.js +27 -0
  157. package/test/element-verse-group.js +28 -0
  158. package/test/element-x.js +30 -0
  159. package/test/element-xref-group.js +26 -0
  160. package/test/element-xref.js +32 -0
  161. package/test/hacks.js +37 -0
  162. package/test/helper-mapColorAttributes.js +27 -0
  163. package/test/helper.js +26 -0
  164. package/test/setHead.js +32 -0
  165. package/test/unit/abstract.js +35 -0
  166. package/texml-to-html.js +32 -0
@@ -0,0 +1,42 @@
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 mapAttributes from '../helpers/mapAttributes.js';
18
+
19
+ /**
20
+ * Recursively check siblings of maybeBadAncestor node if they are footnotes (so as to insert after all earlier footnotes from the same maybeBadAncestor, i.e., keep order of footnotes correct).
21
+ *
22
+ * @param {HTMLElement} maybeBadAncestor
23
+ * @returns {HTMLElement}
24
+ */
25
+ const getElementToInsertAfter = maybeBadAncestor => (maybeBadAncestor.nextElementSibling && maybeBadAncestor.nextElementSibling.getAttribute('role') === 'doc-footnote') ? getElementToInsertAfter(maybeBadAncestor.nextElementSibling) : maybeBadAncestor;
26
+
27
+ /**
28
+ *
29
+ * @param {HTMLElement} htmlParentNode
30
+ * @param {Element} xmlnode
31
+ */
32
+ export default function (htmlParentNode, xmlnode) {
33
+ if (xmlnode.closest('tex-math')) xmlnode.remove();
34
+ const div = this.createNode('div', '', { role: 'doc-footnote', 'aria-label': `Footnote ${xmlnode.querySelector('label').textContent}` });
35
+ // NOTE AmerMathSoc/texml-to-html#336 analyzed where fn occurs in publications; might need revisions
36
+ // Essentially, we can assume fn occurs inside elements (that turn into) p, h1, and span (from formula markup)
37
+ // Since a span ancestor can be inside p (e.g., from inline-formula) we check for the others first.
38
+ const maybeBadAncestor = htmlParentNode.closest('p, h1') || htmlParentNode.closest('span');
39
+ maybeBadAncestor ? getElementToInsertAfter(maybeBadAncestor).insertAdjacentElement('afterend', div) : htmlParentNode.appendChild(div);
40
+ mapAttributes(div, xmlnode);
41
+ this.passThrough(div, xmlnode);
42
+ };
@@ -0,0 +1,51 @@
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
+ * inline-formula and disp-formula element
19
+ * @param {HTMLElement} htmlParentNode
20
+ * @param {Element} xmlnode
21
+ */
22
+ export default function (htmlParentNode, xmlnode) {
23
+ // unwrap nested formula elements and return; cf. tex-math.js
24
+ if (xmlnode.parentNode.closest('tex-math')) {
25
+ this.passThrough(htmlParentNode, xmlnode);
26
+ return;
27
+ }
28
+ if (xmlnode.getAttribute('content-type') === 'text') {
29
+ const div = this.createNode('div', '', {
30
+ 'data-ams-doc': `math text`
31
+ });
32
+ htmlParentNode.appendChild(div);
33
+ this.passThrough(div, xmlnode);
34
+ return
35
+ }
36
+ // Otherwise
37
+ const mathMode = xmlnode.tagName === 'inline-formula' ? 'inline' : 'block';
38
+ const span = this.createNode('span', '', {
39
+ 'data-ams-doc': `math ${mathMode}`
40
+ });
41
+ htmlParentNode.appendChild(span);
42
+ const hasLinkedTag = xmlnode.querySelector('target tag');
43
+ const tagContainer = `<span hidden data-ams-doc="tags"></span>`; //NOTE we store copies of tags for easier re-use downstream (cf. tags.js) except for text equations
44
+ if (hasLinkedTag) span.insertAdjacentHTML('afterbegin', tagContainer)
45
+ if (mathMode === 'block' && xmlnode.querySelector('tex-math[has-qed-box]'))
46
+ span.setAttribute('data-ams-qed-box', 'true');
47
+ this.passThrough(span, xmlnode);
48
+ // NOTE we (sometimes?) get extra whitespace from childnodes; needs test
49
+ const text = span.innerHTML;
50
+ span.innerHTML = text.replace(/[ \n]+/g, ' ');
51
+ };
@@ -0,0 +1,64 @@
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 { generateArticleJson } from './article-metadata-json.js';
18
+
19
+ /**
20
+ * front element => data-ams-doc="frontmatter"
21
+ * @param {HTMLElement} htmlParentNode
22
+ * @param {Element} xmlnode
23
+ */
24
+ export default function (htmlParentNode, xmlnode) {
25
+ const frontmatterSection = this.createNode('section', '', {
26
+ 'data-ams-doc': 'frontmatter',
27
+ });
28
+ htmlParentNode.appendChild(frontmatterSection);
29
+
30
+ // NOTE: we DO NOT recurse into the front element.
31
+ // Most of the metadata-like descendants are stored in a JSON blob (for easier use downstream).
32
+ // In addition to the JSON blob, we process specific elements so that they remain in HTML. The main reasons are:
33
+ // - document content (e.g., title, abstract, dedication)
34
+ // - elements with tex-math content (to more easily process it downstream)
35
+
36
+ // JSON metadata - handles (most of) article-meta, journal-meta
37
+ const script = this.createNode('script', '', { type: "application/json" });
38
+ frontmatterSection.append(script);
39
+ script.textContent = generateArticleJson.call(this, xmlnode);
40
+
41
+ // title-group (title, subtitle); may have tex-math
42
+ this.recurseTheDom(
43
+ frontmatterSection,
44
+ xmlnode.querySelector('front>article-meta>title-group')
45
+ );
46
+
47
+ // notes (e.g., dedication); may have tex-math
48
+ xmlnode.querySelectorAll('notes').forEach(this.recurseTheDom.bind(null, frontmatterSection));
49
+
50
+
51
+ // abstract; may have tex-math
52
+ this.recurseTheDom(
53
+ frontmatterSection,
54
+ xmlnode.querySelector('front>article-meta>abstract')
55
+ );
56
+
57
+ // kwd-groups (MSC, keywords); may have tex-math
58
+ xmlnode.querySelectorAll('article-meta>kwd-group').forEach(this.recurseTheDom.bind(null, frontmatterSection));
59
+
60
+ // funding-groups; may have tex-math
61
+ xmlnode.querySelectorAll('article-meta>funding-group').forEach(this.recurseTheDom.bind(null, frontmatterSection));
62
+
63
+ // NOTE: we DO NOT recurse into front - see the earlier comments
64
+ }
@@ -0,0 +1,26 @@
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
+ * funding-group element
19
+ * @param {HTMLElement} htmlParentNode
20
+ * @param {Element} xmlnode
21
+ */
22
+ export default function (htmlParentNode, xmlnode) {
23
+ const div = this.createNode('div', '', { 'data-ams-doc': 'funding-group' });
24
+ htmlParentNode.appendChild(div);
25
+ this.passThrough(div, xmlnode);
26
+ };
@@ -0,0 +1,49 @@
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 path from 'path';
18
+
19
+ /**
20
+ * graphic and inline-graphic element
21
+ * @param {HTMLElement} htmlParentNode
22
+ * @param {Element} xmlnode
23
+ */
24
+ export default function (htmlParentNode, xmlnode) {
25
+ const filename = xmlnode.getAttribute('xlink:href');
26
+ // texml sometimes generates unitless dimensions; we add px then
27
+ let width = xmlnode.getAttribute('width');
28
+ if (width.search(/[^0-9]/) === -1) width = width + 'px';
29
+ let height = xmlnode.getAttribute('height');
30
+ if (height.search(/[^0-9]/) === -1) height = height + 'px';
31
+ const alttext = this.imageAltDictionary[path.basename(filename)] || 'Graphic without alt text';
32
+ if (xmlnode.closest('tex-math')) {
33
+ htmlParentNode.insertAdjacentText('beforeend', `\\vcenter{\\img[][${width}][${height}][{${alttext}}]{${filename}}}`);
34
+ return;
35
+ }
36
+ const img = this.createNode('img', '', {
37
+ 'data-ams-doc': xmlnode.tagName,
38
+ src: filename,
39
+ 'data-ams-style': xmlnode.getAttribute('specific-use'),
40
+ 'data-ams-width': width,
41
+ 'data-ams-height': height,
42
+ alt: alttext
43
+ });
44
+ htmlParentNode.appendChild(img);
45
+ if (xmlnode.parentNode.tagName !== 'fig') return;
46
+ // NOTE We assume alt-text appears only in figures; cf. AmerMathSoc/texml#55
47
+ const altText = xmlnode.parentNode.querySelector('alt-text');
48
+ if (altText) img.setAttribute('alt', altText.textContent);
49
+ };
@@ -0,0 +1,28 @@
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
+ * img element
19
+ * @param {HTMLElement} htmlParentNode
20
+ * @param {Element} xmlnode
21
+ */
22
+ export default function (htmlParentNode, xmlnode) {
23
+ const img = this.createNode('img', '', {
24
+ src: xmlnode.getAttribute('src'),
25
+ alt: xmlnode.getAttribute('alt') || ''
26
+ });
27
+ htmlParentNode.appendChild(img);
28
+ };
@@ -0,0 +1,33 @@
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 { node2macro } from '../helpers/helpers-tex.js';
18
+
19
+ /**
20
+ * italic element
21
+ * @param {HTMLElement} htmlParentNode
22
+ * @param {Element} xmlnode
23
+ */
24
+ export default function (htmlParentNode, xmlnode) {
25
+ if (xmlnode.closest('tex-math')) {
26
+ node2macro.apply(this, [htmlParentNode, xmlnode, 'textit', true]);
27
+ return;
28
+ }
29
+ const tagname = xmlnode.getAttribute('toggle') === 'yes' ? 'em' : 'i';
30
+ const node = this.createNode(tagname);
31
+ htmlParentNode.appendChild(node);
32
+ this.passThrough(node, xmlnode);
33
+ };
@@ -0,0 +1,29 @@
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
+ * kwd-group element
19
+ * @param {HTMLElement} htmlParentNode
20
+ * @param {Element} xmlnode
21
+ */
22
+ export default function (htmlParentNode, xmlnode) {
23
+ // NOTE: we have only 2 types of kwd-group elements
24
+ // - with @vocab (MSC 2010/20)
25
+ // - with @type="author" (keywords)
26
+ const list = this.createNode('ul', '', { 'data-ams-doc': xmlnode.getAttribute('vocab') || 'keywords' });
27
+ htmlParentNode.appendChild(list);
28
+ this.passThrough(list, xmlnode);
29
+ };
@@ -0,0 +1,26 @@
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
+ * kwd element
19
+ * @param {HTMLElement} htmlParentNode
20
+ * @param {Element} xmlnode
21
+ */
22
+ export default function (htmlParentNode, xmlnode) {
23
+ const li = this.createNode('li');
24
+ htmlParentNode.appendChild(li);
25
+ this.passThrough(li, xmlnode);
26
+ };
@@ -0,0 +1,101 @@
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 getParentLevel from '../helpers/getParentLevel.js';
18
+
19
+ /**
20
+ * label and title elements
21
+ * @param {HTMLElement} htmlParentNode
22
+ * @param {Element} xmlnode
23
+ */
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
+ // CASE label followed by a title -- we skip (and pull in the label later on when processing title)
55
+ if (xmlnode.nextElementSibling?.tagName === 'title') return;
56
+ // CASE empty label
57
+ if (xmlnode.tagName === 'label' && xmlnode.innerHTML.trim() === '') return;
58
+
59
+ // complex cases
60
+
61
+ // Decide output markup (h* or figcaption; wrapping header for subtitles)
62
+ const isStatement = xmlnode.parentNode.tagName === 'statement';
63
+ const isDispFormulaGroup = xmlnode.parentNode.tagName === 'disp-formula-group';
64
+ const level = getParentLevel(htmlParentNode) + 1;
65
+ const heading = (isStatement || isDispFormulaGroup) ? this.createNode('figcaption', '') : this.createNode(`h${level}`, '');
66
+ htmlParentNode.appendChild(heading);
67
+
68
+ // subtitle handling (assumes heading is not figcaption)
69
+ const subtitleSibling = xmlnode.parentNode.querySelector(':scope>subtitle');
70
+ if (subtitleSibling && subtitleSibling.innerHTML.trim() !== '') {
71
+ // wrap heading in header
72
+ const header = this.createNode('header');
73
+ htmlParentNode.appendChild(header);
74
+ header.appendChild(heading);
75
+ // recurse subtitle
76
+ this.recurseTheDom(header, subtitleSibling);
77
+ }
78
+
79
+ // Pull in label (if title+label and we're processing title)
80
+ const previousSibling = xmlnode.previousElementSibling;
81
+ if (previousSibling?.tagName === 'label' && previousSibling.innerHTML.trim() !== '') {
82
+ const labelSpan = this.createNode('span', '', { 'data-ams-doc': 'label' });
83
+ heading.appendChild(labelSpan);
84
+ this.passThrough(labelSpan, previousSibling);
85
+ const labelSeparatorString = isStatement ? ' ' : '. ';
86
+ labelSpan.insertAdjacentText('beforeend', labelSeparatorString);
87
+ }
88
+
89
+ // CASE Book
90
+ const altTitle = xmlnode.parentNode.querySelector(':scope>alt-title');
91
+ const hasAltTitle = altTitle && altTitle.innerHTML !== xmlnode.innerHTML;
92
+ if (this.isBook && hasAltTitle) {
93
+ heading.setAttribute('data-ams-doc-alttitle', heading.textContent + altTitle.innerHTML); // NOTE assumes previousSibling handled first
94
+ }
95
+
96
+ // recurse main node
97
+ this.passThrough(heading, xmlnode);
98
+
99
+ // faking TeX's punctutation-at-end logic
100
+ if (isStatement) heading.insertAdjacentText('beforeend', heading.textContent.endsWith('.') ? ' ' : '. ');
101
+ };
@@ -0,0 +1,31 @@
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
+ * line element
19
+ * @param {HTMLElement} htmlParentNode
20
+ * @param {Element} xmlnode
21
+ */
22
+ export default function (htmlParentNode, xmlnode) {
23
+ const paragraph = this.createNode('p', '', {
24
+ 'data-ams-doc': xmlnode.tagName,
25
+ });
26
+ if (xmlnode.hasAttribute('id')) paragraph.id = xmlnode.getAttribute('id');
27
+ if (xmlnode.hasAttribute('indent'))
28
+ paragraph.setAttribute('data-ams-indent', xmlnode.getAttribute('indent'));
29
+ htmlParentNode.appendChild(paragraph);
30
+ this.passThrough(paragraph, xmlnode);
31
+ };
@@ -0,0 +1,29 @@
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
+ * meta-name element
19
+ * @param {HTMLElement} htmlParentNode
20
+ * @param {Element} xmlnode
21
+ */
22
+ export default function (htmlParentNode, xmlnode) {
23
+ // NOTE currently, we only have custom-meta[@specific-use='communicated-by']>meta-name; future publications might need more here
24
+ const dt = this.createNode('dt');
25
+ const specificUse = xmlnode.parentNode.getAttribute('specific-use');
26
+ if (specificUse) dt.setAttribute('data-ams-specific-use', specificUse);
27
+ htmlParentNode.appendChild(dt);
28
+ this.passThrough(dt, xmlnode);
29
+ };
@@ -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
+ /**
18
+ * meta-value element
19
+ * @param {HTMLElement} htmlParentNode
20
+ * @param {Element} xmlnode
21
+ */
22
+ export default function (htmlParentNode, xmlnode) {
23
+ // NOTE currently, we only have custom-meta[@specific-use='communicated-by']>meta-value; future publications might need more here
24
+ const dd = this.createNode('dd');
25
+ htmlParentNode.appendChild(dd);
26
+ this.passThrough(dd, xmlnode);
27
+ };
@@ -0,0 +1,35 @@
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
+ * mixed-citation element
19
+ * @param {HTMLElement} htmlParentNode
20
+ * @param {Element} xmlnode
21
+ */
22
+ export default function (htmlParentNode, xmlnode) {
23
+ const dd = this.createNode('dd');
24
+ htmlParentNode.appendChild(dd);
25
+ const div = this.createNode('div', '', { 'data-ams-doc': 'biblioentry' });
26
+ dd.appendChild(div);
27
+ // NOTE xslt would map attributes but we have no content with attributes on mixed-citations
28
+ this.passThrough(div, xmlnode);
29
+ const rawCitation = xmlnode.parentNode.querySelector('raw-citation');
30
+ if (!rawCitation) return;
31
+ const code = this.createNode('code', rawCitation.textContent, {
32
+ 'data-ams-doc': 'amsref'
33
+ });
34
+ div.appendChild(code);
35
+ };
@@ -0,0 +1,35 @@
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 { node2macro } from '../helpers/helpers-tex.js';
18
+
19
+ /**
20
+ * monospace element
21
+ * @param {HTMLElement} htmlParentNode
22
+ * @param {Element} xmlnode
23
+ */
24
+ export default function (htmlParentNode, xmlnode) {
25
+ if (xmlnode.closest('tex-math')) {
26
+ node2macro.apply(this, [htmlParentNode, xmlnode, 'texttt', true]);
27
+
28
+ return;
29
+ }
30
+ const span = this.createNode('span', '', {
31
+ 'data-ams-style': xmlnode.tagName
32
+ });
33
+ htmlParentNode.appendChild(span);
34
+ this.passThrough(span, xmlnode);
35
+ };
@@ -0,0 +1,36 @@
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 mapAttributes from '../helpers/mapAttributes.js';
18
+
19
+ /**
20
+ * notes element
21
+ * @param {HTMLElement} htmlParentNode
22
+ * @param {Element} xmlnode
23
+ */
24
+ export default function (htmlParentNode, xmlnode) {
25
+ const section = this.createNode('section');
26
+ mapAttributes(section, xmlnode);
27
+ const notesType = xmlnode.getAttribute('notes-type');
28
+ section.setAttribute('data-ams-doc', 'notes');
29
+ section.setAttribute('data-ams-content-type', notesType);
30
+ if (notesType === 'dedication')
31
+ section.setAttribute('role', 'doc-dedication');
32
+ htmlParentNode.appendChild(section);
33
+ if (this.isBook) section.setAttribute('data-ams-doc-level', '0');
34
+
35
+ this.passThrough(section, xmlnode);
36
+ };