@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,30 @@
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
+ import { article } from './helper.js';
19
+ import tape from 'tape';
20
+
21
+
22
+ tape('Template: img', async function(t) {
23
+ t.plan(3);
24
+ const document = article;
25
+ const img = document.querySelector('section[data-ams-doc="article"] img');
26
+ t.ok(img, 'img element in article');
27
+ t.equal(img.getAttribute('src'), 'file', 'img source');
28
+ t.equal(img.getAttribute('alt'), 'text', 'img alt-text');
29
+ });
30
+
@@ -0,0 +1,91 @@
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 } from './helper.js';
18
+ import tape from 'tape';
19
+
20
+ tape('inline-formula, disp-formula, tex-math', async function (t) {
21
+ t.plan(18);
22
+ const document = article;
23
+ const inlineformula = document.querySelector(
24
+ '#equations [data-ams-doc="math inline"]'
25
+ );
26
+ t.ok(inlineformula, 'Inline formula');
27
+ const tex = inlineformula.innerHTML;
28
+ t.ok(
29
+ tex.includes('\\text{Te\\#t }'),
30
+ 'tex-math/text (with unicode spacing characters)'
31
+ );
32
+ t.ok(
33
+ tex.includes('\\xhref[fn]{#fnid1}{{}^{1}}'),
34
+ 'tex-math/xref@ref-type="fn"'
35
+ );
36
+ t.ok(
37
+ tex.includes('\\xhref[other]{#otherid1}{}'),
38
+ 'tex-math/xref@ref-type="other"'
39
+ );
40
+ const footnote = document.querySelector('#fnid');
41
+ t.ok(
42
+ footnote.getAttribute('role'),
43
+ 'doc-footnote',
44
+ 'Inline-formula Footnote'
45
+ );
46
+ t.notOk(footnote.closest('p, span'), 'footnote moved out of span and paragraph');
47
+ t.ok(footnote.querySelector('a'), 'xref in footnote within tex-math not rewritten to TeX macro')
48
+
49
+ const displayformula = document.querySelector(
50
+ '#equations [data-ams-doc="math block"]'
51
+ );
52
+ t.ok(displayformula, 'Display formula');
53
+ t.equal(
54
+ displayformula.getAttribute('data-ams-qed-box'),
55
+ 'true',
56
+ 'has-qed-box'
57
+ );
58
+ t.ok(
59
+ displayformula.innerHTML.includes('\\xhref[fn]{#fnid2}{{}^{2}}'),
60
+ 'tex-math/xref@ref-type="fn"'
61
+ );
62
+ t.ok(
63
+ displayformula.nextElementSibling.getAttribute('role'),
64
+ 'doc-footnote',
65
+ 'Display-formula Footnote'
66
+ );
67
+ const disptex = displayformula.lastElementChild.innerHTML;
68
+ // NOTE JS implementation removed extra space between the two strings
69
+ t.equal(
70
+ disptex, '\\xhref[fn]{#fnid2}{{}^{2}}\\text{Start\\xhref[other]{#otherid2}{\\$}End}',
71
+ 'tex-math/text/xref'
72
+ );
73
+ const formulaNestedTeX = document.querySelectorAll('#equations [data-ams-doc="math inline"] > tex-math')[1];
74
+ t.equal(formulaNestedTeX.innerHTML, '\\text{Te\\$t$x^2$}');
75
+
76
+ // text-mode text styling
77
+ const dispWithText = document.querySelectorAll(
78
+ '#equations [data-ams-doc="math block"] > tex-math'
79
+ );
80
+ t.equal(dispWithText[1].innerHTML, ' \\text{\\textrm{roman\\#} $\\mathsc{sc\\$}$ \\textit{italic\\_} \\textbf{bold\\$} \\textsf{sans-serif\\&} \\texttt{monospace} \\href{https://ext~}{ext-link\\unicode{x7E}} inside text} ', 'Text markup inside text + escaping active characters');
81
+
82
+ // formula in footnote in formula not treated as nested formula
83
+ t.equal(document.querySelector('#fnid5').innerHTML, '<span data-ams-doc="label"><sup></sup></span><span data-ams-doc="math inline"><tex-math>x</tex-math></span>', 'Formula with footnote with formula');
84
+ // formula in formula at implicit text mode
85
+ t.equal(dispWithText[5].innerHTML, '\\tag{$x$}', 'Formula with with formula in implicit text mode');
86
+
87
+ // formula of type text (aka "thingy" environment)
88
+ t.ok(document.querySelector('div[data-ams-doc="math text"]'), 'Display Formula of content-type=text');
89
+ t.equal(document.querySelector('div[data-ams-doc="math text"] > span[data-ams-doc="label"]#textEquation+p').previousElementSibling.innerHTML, '(T)', 'Display Formula of content-type=text, label and paragraph');
90
+
91
+ });
@@ -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
+ import { article } from './helper.js';
19
+ import tape from 'tape';
20
+
21
+
22
+ tape('Template: italic', async function(t) {
23
+ t.plan(2);
24
+ const document = article;
25
+ t.ok(document.querySelector('i'), 'Italic as i');
26
+ t.ok(document.querySelector('em'), 'Italic with toggle=yes as em');
27
+ });
28
+
@@ -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
+ import { article } from './helper.js';
19
+ import tape from 'tape';
20
+
21
+
22
+ tape('Template: kwd-group', async function(t) {
23
+ t.plan(2);
24
+ const document = article;
25
+ t.ok(document.querySelector('section[data-ams-doc="frontmatter"] ul[data-ams-doc="keywords"]'), 'keywords kwd-group to ul');
26
+ t.ok(document.querySelector('section[data-ams-doc="frontmatter"] ul[data-ams-doc="MSC scheme"]'), 'MSC kwd-group to ul');
27
+ });
28
+
@@ -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
+ import { article } from './helper.js';
19
+ import tape from 'tape';
20
+
21
+
22
+ tape('Template: kwd', async function(t) {
23
+ t.plan(1);
24
+ const document = article;
25
+ t.equal(document.querySelector('section[data-ams-doc="frontmatter"] ul[data-ams-doc="keywords"] li').innerHTML, 'keyword', 'kwd to li with content');
26
+ });
27
+
@@ -0,0 +1,32 @@
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
+ import { article } from './helper.js';
19
+ import tape from 'tape';
20
+
21
+ tape('Template: mixed-citation', async function(t) {
22
+ t.plan(2);
23
+ const document = article;
24
+ const mixedCitation = document.querySelector(
25
+ 'dd > div[data-ams-doc="biblioentry"]'
26
+ );
27
+ const rawCitation = mixedCitation.querySelector(
28
+ 'code[data-ams-doc="amsref"]'
29
+ );
30
+ t.ok(mixedCitation, 'Element mixed-citation');
31
+ t.ok(rawCitation, 'Element raw-citation');
32
+ });
@@ -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
+ import { article } from './helper.js';
19
+ import tape from 'tape';
20
+
21
+
22
+ tape('Template: monospace', async function(t) {
23
+ t.plan(1);
24
+ const document = article;
25
+ t.ok(document.querySelector('span[data-ams-style="monospace"]'), 'Monospace as span with data-ams-style attribute');
26
+ });
27
+
@@ -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 { article, articleAlttitle, book } from './helper.js';
18
+ import tape from 'tape';
19
+
20
+ tape('Template: front/notes@notes-type=dedication', async function (t) {
21
+ t.plan(3);
22
+
23
+ const document = article;
24
+ t.ok(
25
+ document.querySelector('section[role="doc-dedication"]'),
26
+ 'notes with notes-type dedication creates section with role doc-dedication'
27
+ );
28
+
29
+ const document2 = book;
30
+ t.ok(
31
+ document2.querySelector(
32
+ 'section[data-ams-specific-use="epub-opening-page"][data-ams-content-type="publishers-note"][data-ams-doc-level="0"]'
33
+ ),
34
+ 'notes creates section with data-ams attributes'
35
+ );
36
+
37
+ const document3 = articleAlttitle;
38
+ t.ok(
39
+ document3.querySelector('section[data-ams-doc="notes"][data-ams-content-type="article"]'),
40
+ 'notes with notes-type article'
41
+ );
42
+ });
@@ -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
+ import { article } from './helper.js';
19
+ import tape from 'tape';
20
+
21
+
22
+ tape('Template: p, nested paragraphs', async function(t) {
23
+ t.plan(1);
24
+ const document = article;
25
+ t.ok(document.querySelector('dl#pid2 > div > dd > p'), 'paragraph inside def-list stays paragraph')
26
+ });
27
+
@@ -0,0 +1,40 @@
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, articleAlttitle } from './helper.js';
18
+ import tape from 'tape';
19
+
20
+
21
+ tape('ref-list, ref-list/title, ref, ref/label', async function (t) {
22
+ t.plan(10);
23
+ const document = article;
24
+ const bibliography = document.querySelector('section[role="doc-bibliography"]');
25
+ t.ok(bibliography, 'Section with role doc-bibliography');
26
+ t.ok(bibliography.querySelector('h2'), 'Bibliography heading in article');
27
+ t.ok(bibliography.querySelector('dl dt#ref'), 'Reference as DT with ID');
28
+ t.equal(bibliography.querySelector('dl dt#ref').innerHTML, 'Label', 'Reference label in DT');
29
+
30
+ t.ok(bibliography.querySelector('dl dt#refnolabel+dd'), 'Reference without label');
31
+
32
+ const document2 = articleAlttitle;
33
+ const bib = document2.querySelector('section[role="doc-bibliography"]');
34
+ t.ok(bib, 'Outer ref-list Section with role doc-bibliography');
35
+ t.ok(bib.querySelector('h2'), 'Outer ref-list heading');
36
+ t.notOk(bib.querySelector(':scope>DL'), 'Outer ref-list does not have a DL child');
37
+ const nestedBib = bib.querySelector('section');
38
+ t.ok(nestedBib.querySelector('h3'), 'Inner ref-list heading');
39
+ t.ok(nestedBib.querySelector('dl'), 'Inner ref-list has DL');
40
+ });
@@ -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
+ import { article } from './helper.js';
19
+ import tape from 'tape';
20
+
21
+
22
+ tape('Template: roman', async function(t) {
23
+ t.plan(1);
24
+ const document = article;
25
+ t.ok(document.querySelector('span[data-ams-style="roman"]'), 'Roman as span with data-ams-style attribute');
26
+ });
27
+
@@ -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
+ import { article } from './helper.js';
19
+ import tape from 'tape';
20
+
21
+
22
+ tape('Template: sans-serif', async function(t) {
23
+ t.plan(1);
24
+ const document = article;
25
+ t.ok(document.querySelector('span[data-ams-style="sans-serif"]'), 'Sans-serif as span with data-ams-style attribute');
26
+ });
27
+
@@ -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
+ import { article } from './helper.js';
19
+ import tape from 'tape';
20
+
21
+
22
+ tape('Template: sc', async function(t) {
23
+ t.plan(1);
24
+ const document = article;
25
+ t.ok(document.querySelector('span[data-ams-style="sc"]'), 'SC as span with data-ams-style attribute');
26
+ });
27
+
@@ -0,0 +1,87 @@
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, articleAlttitle, articleNometa, book } from './helper.js';
18
+ import tape from 'tape';
19
+
20
+
21
+ tape('sec, app, front-matter-part, dedication, title, label', async function(t) {
22
+ t.plan(44);
23
+ const document = article;
24
+
25
+ t.ok(document.querySelector('#ack1[role="doc-acknowledgments"][data-ams-doc-level="1"]'), 'ack to role doc-acknowledgments with data-ams-doc-level');
26
+ t.ok(document.querySelector('#ack2[role="doc-acknowledgments"]'), 'front-matter-part with matching title text to role doc-acknowledgments');
27
+ t.ok(document.querySelector('#ack3[role="doc-acknowledgments"]'), 'sec with matching title text to role doc-acknowledgments');
28
+ t.ok(document.querySelector('#intro1[role="doc-introduction"]'), 'front-matter-part with matching title text to role doc-introduction');
29
+ t.ok(document.querySelector('#intro2[role="doc-introduction"]'), 'sec with matching title text to role doc-introduction');
30
+ t.ok(document.querySelector('#ded[role="doc-dedication"]'), 'dedication to role doc-dedication');
31
+
32
+ t.equal(document.querySelector('#subsec h3').innerHTML, 'Subsection', 'subsection without wrapping section gets correct level');
33
+
34
+ t.equal(document.querySelector('#seclabeltitle h2').innerHTML, '<span data-ams-doc="label">Label. </span>Title', 'sec with label+title: heading level and content');
35
+ t.equal(document.querySelector('#sectitle h2').innerHTML, 'Title', 'sec with title: heading level and content');
36
+ t.equal(document.querySelector('#seclabel h2').innerHTML, 'Label', 'sec with label: heading level and content');
37
+ t.equal(document.querySelector('#applabeltitle h2').innerHTML, '<span data-ams-doc="label">Label. </span>Title', 'app with label+title: heading level and content');
38
+ t.equal(document.querySelector('#apptitle h2').innerHTML, 'Title', 'app with title: heading level and content');
39
+ t.equal(document.querySelector('#applabel h2').innerHTML, 'Label', 'app with label: heading level and content');
40
+
41
+ t.ok(document.querySelector('#sectitle header p[data-ams-doc="subtitle"]'), 'sec with title: subtitle to p with data-ams-doc');
42
+ t.ok(document.querySelector('#seclabel header p[data-ams-doc="subtitle"]'), 'sec with title: subtitle to p with data-ams-doc');
43
+ t.ok(document.querySelector('#apptitle header p[data-ams-doc="subtitle"]'), 'sec with title: subtitle to p with data-ams-doc');
44
+ t.ok(document.querySelector('#applabel header p[data-ams-doc="subtitle"]'), 'sec with title: subtitle to p with data-ams-doc');
45
+
46
+ t.notOk(document.querySelector('#alttitle h2').hasAttribute('data-ams-doc-alttitle'), 'sec with title: subtitle to p with data-ams-doc');
47
+
48
+ t.equal(document.querySelector('#appack').getAttribute('role'), 'doc-acknowledgments', 'appendix with title "Acknowledg": role');
49
+
50
+ t.ok(document.querySelector('#refhead h2'), 'refhead heading level');
51
+
52
+ const document2 = book;
53
+ t.ok(document2.querySelector('#chapter[role="doc-chapter"]'), 'sec with specific-use chapter to role doc-chapter'); // NOTE so far, chapters only occur in books but the xslt doesn't check for it
54
+
55
+ t.equal(document2.querySelector('#seclabeltitle h2').innerHTML, '<span data-ams-doc="label">Label. </span>Title', 'sec with label+title: heading level and content');
56
+ t.equal(document2.querySelector('#sectitle h2').innerHTML, 'Title', 'sec with title: heading level and content');
57
+ t.equal(document2.querySelector('#seclabel h2').innerHTML, 'Label', 'sec with label: heading level and content');
58
+ t.equal(document2.querySelector('#fmlabeltitle h1').innerHTML, '<span data-ams-doc="label">Label. </span>Title', 'front-matter-part with label+title: heading level and content');
59
+ t.equal(document2.querySelector('#fmtitle h1').innerHTML, 'Title', 'front-matter-part with title: heading level and content');
60
+ t.equal(document2.querySelector('#fmlabel h1').innerHTML, 'Label', 'front-matter-part with label: heading level and content');
61
+ t.equal(document2.querySelector('#applabeltitle h1').innerHTML, '<span data-ams-doc="label">Label. </span>Title', 'app with label+title: heading level and content');
62
+ t.equal(document2.querySelector('#apptitle h1').innerHTML, 'Title', 'app with title: heading level and content');
63
+ t.equal(document2.querySelector('#applabel h1').innerHTML, 'Label', 'app with label: heading level and content');
64
+
65
+ t.equal(document2.querySelector('#part').getAttribute('role'), 'doc-part', 'part role');
66
+ t.ok(document2.querySelector('#inparttitle h2'), 'sec with title in chapter in part: heading level reduced');
67
+ t.ok(document2.querySelector('#inpartlabel h2'), 'sec with label in chapter in part: heading level reduced');
68
+
69
+ t.ok(document2.querySelector('#fmtitle header p[data-ams-doc="subtitle"]'), 'sec with title: subtitle to p with data-ams-doc');
70
+ t.ok(document2.querySelector('#fmlabel header p[data-ams-doc="subtitle"]'), 'sec with title: subtitle to p with data-ams-doc');
71
+ t.ok(document2.querySelector('#ack1[role="doc-acknowledgments"] h1'), 'ack to role doc-acknowledgments with data-ams-doc-level'); // NOTE should be testing doc-level but they differ in XSL vs JS
72
+
73
+ t.equal(document2.querySelector('#alttitle h1').getAttribute('data-ams-doc-alttitle'), 'Label. Alt title', 'sec with title: subtitle to p with data-ams-doc');
74
+
75
+ const bookAppGroup = document2.querySelector('#book-app-group');
76
+ t.equal(bookAppGroup.getAttribute('role'), 'doc-part', 'book-app-group role');
77
+ t.equal(bookAppGroup.getAttribute('data-ams-doc'), 'part', 'book-app-group data-ams-doc');
78
+ t.equal(bookAppGroup.getAttribute('data-ams-doc-level'), '0', 'book-app-group data-ams-level');
79
+ t.equal(document2.querySelector('#applabeltitle').getAttribute('role'), 'doc-appendix', 'book-app role');
80
+
81
+ const document3 = articleAlttitle;
82
+ t.ok(document3.querySelector('section[data-ams-doc-level="1"]'), 'Article with part gets increased doc-levels');
83
+ t.ok(document3.querySelector('section[data-ams-doc-level="2"]'), 'Article with part gets increased doc-levels');
84
+
85
+ const document4 = articleNometa;
86
+ t.equal(document4.querySelector('#sec').getAttribute('role'), 'doc-part', 'part in article: role');
87
+ });
@@ -0,0 +1,43 @@
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, articleAlttitle, book } from './helper.js';
18
+ import tape from 'tape';
19
+
20
+ tape('Template: sec-meta => contrib-group, author-comment, abstract/title', async function (t) {
21
+ t.plan(10);
22
+
23
+ const document = book;
24
+ const section = document.querySelector('#secmeta');
25
+ const secMeta = section.querySelector('section[data-ams-doc="sec-meta"]');
26
+ t.equal(secMeta.getAttribute('data-ams-contributors'), '{"null":[]}', 'book sec-meta');
27
+ t.ok(section.querySelector('h1'), 'title becomes h1');
28
+ t.equal(section.querySelector('h1').innerHTML, 'Title', 'title content in heading');
29
+ t.ok(section.querySelector('[role="doc-abstract"] h2'), 'abstract title becomes h2');
30
+
31
+ const document2 = article;
32
+ const secmeta = document2.querySelector('#secmeta section[data-ams-doc="sec-meta"]');
33
+ t.ok(secmeta, 'article sec-meta creates section data attribute');
34
+ t.equal(secmeta.getAttribute('data-ams-contributors'), '{"authors":[{"name":"GivenName Surname","bio":"","affiliations":[],"emails":[]}]}', 'article sec-meta');
35
+ t.equal(secmeta.getAttribute('data-ams-byline'), 'GivenName Surname', 'article sec-meta');
36
+
37
+ const document3 = articleAlttitle;
38
+ const secmeta3 = document3.querySelector('#secmeta section[data-ams-doc="sec-meta"]');
39
+ t.equal(secmeta3.getAttribute('data-ams-contributors'), '{"authors":[{"name":"Author 1","bio":"Author 1 Bio","affiliations":[],"emails":[]}],"contributors":[{"name":"Author 2","bio":"Author 2 Bio","affiliations":[],"emails":[],"byline":"with"}]}', 'article--alttitle sec-meta');
40
+ t.equal(secmeta3.getAttribute('data-ams-byline'), 'Author 1, with Author 2', 'article sec-meta');
41
+
42
+ t.ok(secmeta3.querySelector('section[data-ams-doc="notes"]'), 'sec-meta (non-contrib-group) child content');
43
+ });
@@ -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
+ import { article } from './helper.js';
18
+ import tape from 'tape';
19
+
20
+ tape('Template: statement, label, title', async function (t) {
21
+ t.plan(1);
22
+
23
+ t.equal(
24
+ article.querySelector('[data-ams-doc="secheading"][id="statement4secheading"][data-ams-specific-use="subsection"][data-ams-doc-level="2"]').innerHTML,
25
+ 'secheading',
26
+ 'secheading with title within statement'
27
+ );
28
+ });