@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.
- package/CHANGELOG.md +1414 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +16 -0
- package/examples/cli.js +6 -0
- package/ldom.js +6 -0
- package/lib/doms.js +30 -0
- package/lib/elements/abstract.js +34 -0
- package/lib/elements/algorithm.js +78 -0
- package/lib/elements/app.js +35 -0
- package/lib/elements/article-metadata-json.js +167 -0
- package/lib/elements/article-title.js +26 -0
- package/lib/elements/article.js +28 -0
- package/lib/elements/attrib.js +41 -0
- package/lib/elements/bold.js +32 -0
- package/lib/elements/book-meta-json.js +134 -0
- package/lib/elements/book-meta.js +33 -0
- package/lib/elements/book-title.js +26 -0
- package/lib/elements/boxed-text.js +31 -0
- package/lib/elements/break.js +25 -0
- package/lib/elements/caption.js +52 -0
- package/lib/elements/compound-kwd.js +27 -0
- package/lib/elements/def-item.js +26 -0
- package/lib/elements/def-list.js +30 -0
- package/lib/elements/def.js +29 -0
- package/lib/elements/disp-formula-group.js +30 -0
- package/lib/elements/disp-quote.js +33 -0
- package/lib/elements/email.js +28 -0
- package/lib/elements/ext-link.js +38 -0
- package/lib/elements/fig.js +32 -0
- package/lib/elements/fn.js +42 -0
- package/lib/elements/formula.js +51 -0
- package/lib/elements/front.js +64 -0
- package/lib/elements/funding-group.js +26 -0
- package/lib/elements/graphic.js +49 -0
- package/lib/elements/img.js +28 -0
- package/lib/elements/italic.js +33 -0
- package/lib/elements/kwd-group.js +29 -0
- package/lib/elements/kwd.js +26 -0
- package/lib/elements/label.js +101 -0
- package/lib/elements/line.js +31 -0
- package/lib/elements/meta-name.js +29 -0
- package/lib/elements/meta-value.js +27 -0
- package/lib/elements/mixed-citation.js +35 -0
- package/lib/elements/monospace.js +35 -0
- package/lib/elements/notes.js +36 -0
- package/lib/elements/p.js +29 -0
- package/lib/elements/preface.js +33 -0
- package/lib/elements/ref-list.js +50 -0
- package/lib/elements/ref.js +28 -0
- package/lib/elements/roman.js +34 -0
- package/lib/elements/sans-serif.js +34 -0
- package/lib/elements/sc.js +35 -0
- package/lib/elements/sec-meta.js +35 -0
- package/lib/elements/sec.js +89 -0
- package/lib/elements/secheading.js +43 -0
- package/lib/elements/simpletabbing.js +29 -0
- package/lib/elements/statement.js +31 -0
- package/lib/elements/string-name.js +28 -0
- package/lib/elements/styled-content.js +32 -0
- package/lib/elements/subj-group.js +29 -0
- package/lib/elements/subject.js +26 -0
- package/lib/elements/subtitle.js +29 -0
- package/lib/elements/table.js +28 -0
- package/lib/elements/tag.js +50 -0
- package/lib/elements/target.js +39 -0
- package/lib/elements/term.js +31 -0
- package/lib/elements/tex-math.js +34 -0
- package/lib/elements/text.js +29 -0
- package/lib/elements/toc-entry.js +63 -0
- package/lib/elements/toc.js +35 -0
- package/lib/elements/underline.js +26 -0
- package/lib/elements/x.js +27 -0
- package/lib/elements/xref-group.js +36 -0
- package/lib/elements/xref.js +89 -0
- package/lib/hacks.js +43 -0
- package/lib/head.js +38 -0
- package/lib/helpers/copyElement.js +29 -0
- package/lib/helpers/extractContribGroups.js +94 -0
- package/lib/helpers/generateByline.js +35 -0
- package/lib/helpers/getParentLevel.js +24 -0
- package/lib/helpers/helpers-tex.js +54 -0
- package/lib/helpers/mapAttributes.js +54 -0
- package/lib/helpers/mapColorAttributes.js +36 -0
- package/lib/helpers/unnest.js +34 -0
- package/lib/transformer.js +311 -0
- package/out.html +550 -0
- package/package.json +39 -0
- package/test/article--alttitle.xml +146 -0
- package/test/article--nometa.xml +40 -0
- package/test/article-alttitle-meta-snapshot.json +94 -0
- package/test/article-meta-snapshot.json +129 -0
- package/test/article-nometa-meta-snapshot.json +46 -0
- package/test/article.xml +593 -0
- package/test/attribute-content-type.js +26 -0
- package/test/attribute-has-qed-box.js +28 -0
- package/test/attribute-hidden.js +27 -0
- package/test/attribute-rowspan-colspan.js +27 -0
- package/test/attribute-specific-use.js +27 -0
- package/test/attribute-style.js +27 -0
- package/test/book-meta-snapshot.json +78 -0
- package/test/book.xml +292 -0
- package/test/copyElement.js +38 -0
- package/test/element-abstract-title.js +27 -0
- package/test/element-algorithm.js +56 -0
- package/test/element-article.js +24 -0
- package/test/element-attrib.js +27 -0
- package/test/element-back-app-group-app.js +28 -0
- package/test/element-bold.js +26 -0
- package/test/element-book-meta.js +37 -0
- package/test/element-book-preface.js +29 -0
- package/test/element-book-ref-list.js +32 -0
- package/test/element-book.js +33 -0
- package/test/element-boxed-text.js +28 -0
- package/test/element-break.js +27 -0
- package/test/element-citegroup.js +25 -0
- package/test/element-compound-kwd.js +24 -0
- package/test/element-def-list-def-item-def-term.js +43 -0
- package/test/element-disp-formula-group.js +27 -0
- package/test/element-disp-quote.js +31 -0
- package/test/element-email.js +26 -0
- package/test/element-ext-link.js +30 -0
- package/test/element-fig-subfig-label.js +38 -0
- package/test/element-fn.js +40 -0
- package/test/element-front.js +45 -0
- package/test/element-funding-group.js +29 -0
- package/test/element-graphic-inline-graphic.js +40 -0
- package/test/element-img.js +30 -0
- package/test/element-inline-formula-disp-formula-tex-math.js +91 -0
- package/test/element-italic.js +28 -0
- package/test/element-kwd-group.js +28 -0
- package/test/element-kwd.js +27 -0
- package/test/element-mixed-citation.js +32 -0
- package/test/element-monospace.js +27 -0
- package/test/element-notes.js +42 -0
- package/test/element-p-p.js +27 -0
- package/test/element-ref-list-ref-label.js +40 -0
- package/test/element-roman.js +27 -0
- package/test/element-sans-serif.js +27 -0
- package/test/element-sc.js +27 -0
- package/test/element-sec-app-front-matter-part-dedication-title-label.js +87 -0
- package/test/element-sec-meta.js +43 -0
- package/test/element-secheading.js +28 -0
- package/test/element-simpletabbing-line.js +31 -0
- package/test/element-statement-label-title.js +120 -0
- package/test/element-string-name.js +27 -0
- package/test/element-stripEmptyLabel.js +26 -0
- package/test/element-styled-content.js +28 -0
- package/test/element-subtitle.js +36 -0
- package/test/element-table-wrap-group.js +30 -0
- package/test/element-table-wrap.js +51 -0
- package/test/element-table.js +34 -0
- package/test/element-tag.js +38 -0
- package/test/element-target.js +33 -0
- package/test/element-toc-toc-entry.js +77 -0
- package/test/element-underline.js +27 -0
- package/test/element-verse-group.js +28 -0
- package/test/element-x.js +30 -0
- package/test/element-xref-group.js +26 -0
- package/test/element-xref.js +32 -0
- package/test/hacks.js +37 -0
- package/test/helper-mapColorAttributes.js +27 -0
- package/test/helper.js +26 -0
- package/test/setHead.js +32 -0
- package/test/unit/abstract.js +35 -0
- package/texml-to-html.js +32 -0
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
* attrib element
|
|
19
|
+
* @param {HTMLElement} htmlParentNode
|
|
20
|
+
* @param {Element} xmlnode
|
|
21
|
+
*/
|
|
22
|
+
export default function (htmlParentNode, xmlnode) {
|
|
23
|
+
let actualParent = htmlParentNode;
|
|
24
|
+
if (xmlnode.parentNode.tagName === 'disp-quote') {
|
|
25
|
+
const footer = this.createNode('footer');
|
|
26
|
+
htmlParentNode.appendChild(footer);
|
|
27
|
+
actualParent = footer;
|
|
28
|
+
}
|
|
29
|
+
if (
|
|
30
|
+
xmlnode.parentNode.tagName === 'fig' ||
|
|
31
|
+
xmlnode.parentNode.tagName === 'fig-group'
|
|
32
|
+
) {
|
|
33
|
+
// NOTE there should be a figcaption element (cf. caption())
|
|
34
|
+
// NOTE so far this only occurs in mbk103, clrm067 to attribute graphics in figures
|
|
35
|
+
actualParent = htmlParentNode.querySelector(':scope>figcaption');
|
|
36
|
+
}
|
|
37
|
+
const span = this.createNode('span');
|
|
38
|
+
actualParent.insertAdjacentText('beforeend', ' '); // NOTE needed inside fig-caption
|
|
39
|
+
actualParent.appendChild(span);
|
|
40
|
+
this.passThrough(span, xmlnode);
|
|
41
|
+
};
|
|
@@ -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
|
+
import { node2macro } from '../helpers/helpers-tex.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* bold 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, 'textbf', true]);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const node = this.createNode('strong');
|
|
30
|
+
htmlParentNode.appendChild(node);
|
|
31
|
+
this.passThrough(node, xmlnode);
|
|
32
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
const bookMetaJson =
|
|
18
|
+
{
|
|
19
|
+
book: {
|
|
20
|
+
identifiers: {
|
|
21
|
+
AMS: { // book-id
|
|
22
|
+
publKey: '',
|
|
23
|
+
volumeId: '',
|
|
24
|
+
volumeNr: '', // book-volume-number
|
|
25
|
+
},
|
|
26
|
+
crossref: { // book-id
|
|
27
|
+
doi: ''
|
|
28
|
+
},
|
|
29
|
+
issn: {
|
|
30
|
+
// print: '',
|
|
31
|
+
},
|
|
32
|
+
isbn: {
|
|
33
|
+
// electronic: '',
|
|
34
|
+
// google: '',
|
|
35
|
+
// print: '',
|
|
36
|
+
// softcover: '',
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
title: '', // NOTE might contain math (but no use case yet)
|
|
40
|
+
// alttitle: '', // NOTE once we have math mode, we should have alttitle
|
|
41
|
+
// subtitle: '',
|
|
42
|
+
// history: '', // html output drops history, too
|
|
43
|
+
},
|
|
44
|
+
publishers:
|
|
45
|
+
[
|
|
46
|
+
// {
|
|
47
|
+
// name: '',
|
|
48
|
+
// location: ''
|
|
49
|
+
// },
|
|
50
|
+
]
|
|
51
|
+
,
|
|
52
|
+
contributors: {
|
|
53
|
+
// contributor groups (editors, translators, illustrators)
|
|
54
|
+
// NOTE should have at least have 1 author or 1 editor
|
|
55
|
+
// e.g.
|
|
56
|
+
// authors: [
|
|
57
|
+
// {
|
|
58
|
+
// // name: '',
|
|
59
|
+
// // affiliations: [],
|
|
60
|
+
// // email: [],
|
|
61
|
+
// // homepage: [],
|
|
62
|
+
|
|
63
|
+
// }
|
|
64
|
+
// ],
|
|
65
|
+
// ...
|
|
66
|
+
},
|
|
67
|
+
permissions: {
|
|
68
|
+
// NOTE we only use the statement downstream
|
|
69
|
+
// copyrightYear: '',
|
|
70
|
+
// copyrightHolder: ''
|
|
71
|
+
copyrightStatement: '',
|
|
72
|
+
|
|
73
|
+
},
|
|
74
|
+
// collection: {
|
|
75
|
+
// title: '',
|
|
76
|
+
// subseries: '',
|
|
77
|
+
// },
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* NOTE: `this` bound via call
|
|
81
|
+
* @param {Node} bookMetaNode book-meta XML element node
|
|
82
|
+
* @returns {String} JSON string with metadata
|
|
83
|
+
*/
|
|
84
|
+
export function generateBookJson(bookMetaNode) {
|
|
85
|
+
|
|
86
|
+
// identifiers
|
|
87
|
+
bookMetaJson.book.identifiers.AMS.publKey = bookMetaNode.querySelector('book-id[assigning-authority="AMS"][book-id-type="publisher"]')?.textContent;
|
|
88
|
+
bookMetaJson.book.identifiers.AMS.volumeId = bookMetaNode.querySelector('book-id[assigning-authority="AMS"][book-id-type="volume_id"]')?.textContent;
|
|
89
|
+
bookMetaJson.book.identifiers.crossref.doi = bookMetaNode.querySelector('book-id[assigning-authority="crossref"][book-id-type="doi"]')?.textContent;
|
|
90
|
+
|
|
91
|
+
// Volume number
|
|
92
|
+
bookMetaJson.book.identifiers.AMS.volumeNr = bookMetaNode.querySelector('book-volume-number')?.textContent;
|
|
93
|
+
|
|
94
|
+
// basename
|
|
95
|
+
bookMetaJson.book.identifiers.basename = bookMetaJson.book.identifiers.AMS.publKey + bookMetaJson.book.identifiers.AMS.volumeNr
|
|
96
|
+
|
|
97
|
+
bookMetaJson.contributors = this.extractContribGroups(bookMetaNode);
|
|
98
|
+
|
|
99
|
+
bookMetaNode.querySelectorAll('publisher').forEach(publisher => {
|
|
100
|
+
const publisherData = { name: publisher.querySelector('publisher-name').textContent };
|
|
101
|
+
if (publisher.querySelector('publisher-loc')) publisherData.location = publisher.querySelector('publisher-loc').textContent;
|
|
102
|
+
bookMetaJson.publishers.push(publisherData);
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
bookMetaJson.permissions.copyrightStatement = bookMetaNode.querySelector('copyright-statement')?.textContent;
|
|
106
|
+
bookMetaNode.querySelectorAll('isbn').forEach(isbn => {
|
|
107
|
+
bookMetaJson.book.identifiers.isbn[isbn.getAttribute('publication-format')] = isbn.textContent;
|
|
108
|
+
})
|
|
109
|
+
bookMetaNode.querySelectorAll('issn').forEach(issn => {
|
|
110
|
+
bookMetaJson.book.identifiers.issn[issn.getAttribute('publication-format')] = issn.textContent;
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
// book-title-group
|
|
114
|
+
const title = bookMetaNode.querySelector('book-title-group > book-title'); // NOTE title might contain math-mode (no use case yet)
|
|
115
|
+
const subtitle = bookMetaNode.querySelector('book-title-group > subtitle'); // NOTE subtitle might contain math-mode (no use case yet)
|
|
116
|
+
const alttitle = bookMetaNode.querySelector('book-title-group > alt-title') || title;
|
|
117
|
+
bookMetaJson.book.title = this.passthroughIntoHTMLString(title);
|
|
118
|
+
if (subtitle) bookMetaJson.book.subtitle = this.passthroughIntoHTMLString(subtitle);
|
|
119
|
+
if (alttitle) bookMetaJson.book.alttitle = alttitle.textContent;
|
|
120
|
+
|
|
121
|
+
// collection-meta
|
|
122
|
+
const collectionMeta = bookMetaNode.ownerDocument.querySelector('collection-meta');
|
|
123
|
+
if (collectionMeta) {
|
|
124
|
+
bookMetaJson.collection = {};
|
|
125
|
+
bookMetaJson.collection.title = collectionMeta.querySelector('title-group > title').textContent;
|
|
126
|
+
collectionMeta.querySelectorAll('custom-meta').forEach(customMeta => {
|
|
127
|
+
// NOTE custom-meta should have exactly two children - meta-name and meta-value
|
|
128
|
+
bookMetaJson.collection[customMeta.querySelector('meta-name').textContent] = customMeta.querySelector('meta-value').textContent;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return JSON.stringify(bookMetaJson);
|
|
133
|
+
};
|
|
134
|
+
|
|
@@ -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 { generateBookJson } from './book-meta-json.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* book-meta element
|
|
21
|
+
* @param {HTMLElement} htmlParentNode
|
|
22
|
+
* @param {Element} xmlnode
|
|
23
|
+
*/
|
|
24
|
+
export default function (htmlParentNode, xmlnode) {
|
|
25
|
+
const titlepage = this.createNode('section', '', {
|
|
26
|
+
'data-ams-doc': 'titlepage'
|
|
27
|
+
});
|
|
28
|
+
htmlParentNode.appendChild(titlepage);
|
|
29
|
+
|
|
30
|
+
const script = this.createNode('script', '', { type: "application/json" });
|
|
31
|
+
titlepage.append(script);
|
|
32
|
+
script.textContent = generateBookJson.call(this, xmlnode);
|
|
33
|
+
};
|
|
@@ -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
|
+
* book-title element
|
|
19
|
+
* @param {HTMLElement} htmlParentNode
|
|
20
|
+
* @param {Element} xmlnode
|
|
21
|
+
*/
|
|
22
|
+
export default function (htmlParentNode, xmlnode) {
|
|
23
|
+
const heading = this.createNode('h1');
|
|
24
|
+
htmlParentNode.appendChild(heading);
|
|
25
|
+
this.passThrough(heading, xmlnode);
|
|
26
|
+
};
|
|
@@ -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
|
+
import mapAttributes from '../helpers/mapAttributes.js';
|
|
18
|
+
import { mapColorAttributes } from '../helpers/mapColorAttributes.js';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* boxed-text element
|
|
22
|
+
* @param {HTMLElement} htmlParentNode
|
|
23
|
+
* @param {Element} xmlnode
|
|
24
|
+
*/
|
|
25
|
+
export default function (htmlParentNode, xmlnode) {
|
|
26
|
+
const node = this.createNode('div', '', { 'data-ams-style': 'boxed' });
|
|
27
|
+
htmlParentNode.appendChild(node);
|
|
28
|
+
mapAttributes(node, xmlnode);
|
|
29
|
+
mapColorAttributes(node, xmlnode);
|
|
30
|
+
this.passThrough(node, xmlnode);
|
|
31
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
* break element
|
|
19
|
+
* @param {HTMLElement} htmlParentNode
|
|
20
|
+
* @param {Element} xmlnode
|
|
21
|
+
*/
|
|
22
|
+
export default function (htmlParentNode) {
|
|
23
|
+
const br = this.createNode('br');
|
|
24
|
+
htmlParentNode.appendChild(br);
|
|
25
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
* caption element; also used for label element (when inside fig, table etc. - cf. label.js)
|
|
19
|
+
* @param {HTMLElement} htmlParentNode
|
|
20
|
+
* @param {Element} xmlnode
|
|
21
|
+
*/
|
|
22
|
+
export default function (htmlParentNode, xmlnode) {
|
|
23
|
+
const isLabel = xmlnode.tagName === 'label';
|
|
24
|
+
if (
|
|
25
|
+
isLabel &&
|
|
26
|
+
xmlnode.nextElementSibling &&
|
|
27
|
+
xmlnode.nextElementSibling.tagName === 'caption'
|
|
28
|
+
) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const isSubfigure =
|
|
32
|
+
(xmlnode.parentNode.tagName === 'fig' &&
|
|
33
|
+
xmlnode.parentNode.parentNode.tagName === 'fig-group') ||
|
|
34
|
+
(xmlnode.parentNode.tagName === 'table-wrap' &&
|
|
35
|
+
xmlnode.parentNode.parentNode.tagName === 'table-wrap-group') ;
|
|
36
|
+
const previousSibling = xmlnode.previousElementSibling;
|
|
37
|
+
const hasLabel = previousSibling && previousSibling.tagName === 'label';
|
|
38
|
+
|
|
39
|
+
const figcaption = this.createNode('figcaption');
|
|
40
|
+
htmlParentNode.appendChild(figcaption);
|
|
41
|
+
|
|
42
|
+
if (isLabel || hasLabel) {
|
|
43
|
+
const label = isLabel ? xmlnode : previousSibling;
|
|
44
|
+
const strong = this.createNode('strong');
|
|
45
|
+
figcaption.appendChild(strong);
|
|
46
|
+
if (isSubfigure) strong.insertAdjacentText('afterbegin', '(');
|
|
47
|
+
this.passThrough(strong, label);
|
|
48
|
+
strong.insertAdjacentText('beforeend', isSubfigure ? ') ' : '. ');
|
|
49
|
+
}
|
|
50
|
+
if (isLabel) return;
|
|
51
|
+
this.passThrough(figcaption, xmlnode);
|
|
52
|
+
};
|
|
@@ -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
|
+
* compound-kwd element
|
|
19
|
+
* NOTE: left in document because compound-kwd-part[content-type="text"] can contain tex-math
|
|
20
|
+
* @param {HTMLElement} htmlParentNode
|
|
21
|
+
* @param {Element} xmlnode
|
|
22
|
+
*/
|
|
23
|
+
export default function (htmlParentNode, xmlnode) {
|
|
24
|
+
const li = this.createNode('li', '', { 'data-msc-role': xmlnode.getAttribute('content-type'), 'data-msc-key': xmlnode.querySelector('compound-kwd-part[content-type="code"]').textContent });
|
|
25
|
+
htmlParentNode.appendChild(li);
|
|
26
|
+
this.passThrough(li, xmlnode.querySelector('compound-kwd-part[content-type="text"]'));
|
|
27
|
+
};
|
|
@@ -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
|
+
* def-item element
|
|
19
|
+
* @param {HTMLElement} htmlParentNode
|
|
20
|
+
* @param {Element} xmlnode
|
|
21
|
+
*/
|
|
22
|
+
export default function (htmlParentNode, xmlnode) {
|
|
23
|
+
const div = this.createNode('div');
|
|
24
|
+
htmlParentNode.appendChild(div);
|
|
25
|
+
this.passThrough(div, xmlnode);
|
|
26
|
+
};
|
|
@@ -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
|
+
import mapAttributes from '../helpers/mapAttributes.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* def-list element
|
|
21
|
+
* @param {HTMLElement} htmlParentNode
|
|
22
|
+
* @param {Element} xmlnode
|
|
23
|
+
*/
|
|
24
|
+
export default function (htmlParentNode, xmlnode) {
|
|
25
|
+
const dl = this.createNode('dl');
|
|
26
|
+
mapAttributes(dl, xmlnode);
|
|
27
|
+
// NOTE DOM let's us insert DL in p, which is invalid
|
|
28
|
+
htmlParentNode.appendChild(dl);
|
|
29
|
+
this.passThrough(dl, xmlnode);
|
|
30
|
+
};
|
|
@@ -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
|
+
import mapAttributes from '../helpers/mapAttributes.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* def element
|
|
21
|
+
* @param {HTMLElement} htmlParentNode
|
|
22
|
+
* @param {Element} xmlnode
|
|
23
|
+
*/
|
|
24
|
+
export default function (htmlParentNode, xmlnode) {
|
|
25
|
+
const dd = this.createNode('dd');
|
|
26
|
+
mapAttributes(dd, xmlnode);
|
|
27
|
+
htmlParentNode.appendChild(dd);
|
|
28
|
+
this.passThrough(dd, xmlnode);
|
|
29
|
+
};
|
|
@@ -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
|
+
* disp-formula-group element
|
|
19
|
+
* @param {HTMLElement} htmlParentNode
|
|
20
|
+
* @param {Element} xmlnode
|
|
21
|
+
*/
|
|
22
|
+
export default function (htmlParentNode, xmlnode) {
|
|
23
|
+
const figure = this.createNode('figure', '', {
|
|
24
|
+
'data-ams-doc': 'statement',
|
|
25
|
+
'data-ams-content-type': 'disp-formula-group',
|
|
26
|
+
id: xmlnode.id,
|
|
27
|
+
});
|
|
28
|
+
htmlParentNode.appendChild(figure);
|
|
29
|
+
this.passThrough(figure, xmlnode);
|
|
30
|
+
};
|
|
@@ -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
|
+
/**
|
|
18
|
+
* disp-quote element
|
|
19
|
+
* @param {HTMLElement} htmlParentNode
|
|
20
|
+
* @param {Element} xmlnode
|
|
21
|
+
*/
|
|
22
|
+
export default function (htmlParentNode, xmlnode) {
|
|
23
|
+
const specificUse = xmlnode.getAttribute('specific-use');
|
|
24
|
+
const contentType = xmlnode.getAttribute('content-type');
|
|
25
|
+
const blockquote = this.createNode('blockquote');
|
|
26
|
+
if (contentType === 'epigraph')
|
|
27
|
+
blockquote.setAttribute('role', 'doc-epigraph');
|
|
28
|
+
else blockquote.setAttribute('data-ams-style', specificUse);
|
|
29
|
+
if (htmlParentNode.tagName === 'P')
|
|
30
|
+
htmlParentNode.insertAdjacentElement('afterend', blockquote);
|
|
31
|
+
else htmlParentNode.appendChild(blockquote);
|
|
32
|
+
this.passThrough(blockquote, xmlnode);
|
|
33
|
+
};
|
|
@@ -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
|
+
* email element
|
|
19
|
+
* NOTE: only for email within content; within metadata see the json generation.
|
|
20
|
+
* @param {HTMLElement} htmlParentNode
|
|
21
|
+
* @param {Element} xmlnode
|
|
22
|
+
*/
|
|
23
|
+
export default function (htmlParentNode, xmlnode) {
|
|
24
|
+
const text = xmlnode.textContent;
|
|
25
|
+
htmlParentNode.appendChild(
|
|
26
|
+
this.createNode('a', text, { href: `mailto://${text}` })
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { unnestLinks } from '../helpers/unnest.js';
|
|
18
|
+
import { node2macro } from '../helpers/helpers-tex.js';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* ext-link element
|
|
22
|
+
* @param {HTMLElement} htmlParentNode
|
|
23
|
+
* @param {Element} xmlnode
|
|
24
|
+
*/
|
|
25
|
+
export default function (htmlParentNode, xmlnode) {
|
|
26
|
+
if (xmlnode.closest('tex-math')) {
|
|
27
|
+
node2macro.apply(this, [htmlParentNode, xmlnode, `href{${xmlnode.getAttribute('xlink:href')}}`, true]); // NOTE href works in both math and text mode; `\href`'s first argument does not need escaping
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const anchor = this.createNode('a', '', {
|
|
31
|
+
href: xmlnode.getAttribute('xlink:href')
|
|
32
|
+
});
|
|
33
|
+
htmlParentNode.appendChild(anchor);
|
|
34
|
+
// handle nested links
|
|
35
|
+
const linkChild = xmlnode.childNodes.find(node => node.tagName === 'xref' || node.tagName === 'ext-link');
|
|
36
|
+
if (linkChild) unnestLinks(this.recurseTheDom, this.createNode, xmlnode, anchor, linkChild)
|
|
37
|
+
else this.passThrough(anchor, xmlnode);
|
|
38
|
+
};
|
|
@@ -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
|
+
import mapAttributes from '../helpers/mapAttributes.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* fig element, also used for fig-group, verse-group, table-wrap, table-wrap-group
|
|
21
|
+
* @param {HTMLElement} htmlParentNode
|
|
22
|
+
* @param {Element} xmlnode
|
|
23
|
+
*/
|
|
24
|
+
export default function (htmlParentNode, xmlnode) {
|
|
25
|
+
const figure = this.createNode('figure', '', {
|
|
26
|
+
'data-ams-doc': xmlnode.tagName
|
|
27
|
+
});
|
|
28
|
+
if (xmlnode.getAttribute('position')) figure.setAttribute('data-ams-position', xmlnode.getAttribute('position'));
|
|
29
|
+
mapAttributes(figure, xmlnode);
|
|
30
|
+
htmlParentNode.appendChild(figure);
|
|
31
|
+
this.passThrough(figure, xmlnode);
|
|
32
|
+
};
|