@amermathsoc/texml-to-html 16.1.1 → 17.0.1
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 +18 -0
- package/lib/elements/cite-detail.js +30 -0
- package/lib/elements/cite-group.js +31 -0
- package/lib/helpers/extractContribGroups.js +4 -4
- package/lib/transformer.js +4 -2
- package/package.json +1 -1
- package/test/article--alttitle.xml +3 -3
- package/test/article.xml +8 -2
- package/test/book.xml +4 -4
- package/test/element-inline-formula-disp-formula-tex-math.js +3 -1
- package/test/element-sec-meta.js +1 -1
- package/test/hacks.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [17.0.1](https://github.com/AmerMathSoc/texml-to-html/compare/v17.0.0...v17.0.1) (2024-06-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* handle cite-group, cite-detail inside tex-math ([0df8528](https://github.com/AmerMathSoc/texml-to-html/commit/0df85280d892ee33572f0923f6e56197bbb26a34)), closes [#450](https://github.com/AmerMathSoc/texml-to-html/issues/450)
|
|
11
|
+
|
|
12
|
+
## [17.0.0](https://github.com/AmerMathSoc/texml-to-html/compare/v16.1.1...v17.0.0) (2024-06-07)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### ⚠ BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
* Expects role instead author-comment
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* adjust to texml renaming author-comment to role ([c46822b](https://github.com/AmerMathSoc/texml-to-html/commit/c46822b9e6cbd96de1893c8e138f3f14df48492c)), closes [#449](https://github.com/AmerMathSoc/texml-to-html/issues/449)
|
|
22
|
+
|
|
5
23
|
### [16.1.1](https://github.com/AmerMathSoc/texml-to-html/compare/v16.1.0...v16.1.1) (2024-06-03)
|
|
6
24
|
|
|
7
25
|
|
|
@@ -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
|
+
* sc element
|
|
19
|
+
* @param {HTMLElement} htmlParentNode
|
|
20
|
+
* @param {Element} xmlnode
|
|
21
|
+
*/
|
|
22
|
+
export default function (htmlParentNode, xmlnode) {
|
|
23
|
+
if (xmlnode.closest('tex-math')) {
|
|
24
|
+
this.passThrough(htmlParentNode, xmlnode);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const citeGroup = this.createNode('cite-detail');
|
|
28
|
+
htmlParentNode.appendChild(citeGroup);
|
|
29
|
+
this.passThrough(citeGroup, xmlnode);
|
|
30
|
+
};
|
|
@@ -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
|
+
* sc element
|
|
19
|
+
* @param {HTMLElement} htmlParentNode
|
|
20
|
+
* @param {Element} xmlnode
|
|
21
|
+
*/
|
|
22
|
+
export default function (htmlParentNode, xmlnode) {
|
|
23
|
+
if (xmlnode.closest('tex-math')) {
|
|
24
|
+
this.passThrough(htmlParentNode, xmlnode);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const citeGroup = this.createNode('cite-group');
|
|
28
|
+
htmlParentNode.appendChild(citeGroup);
|
|
29
|
+
this.passThrough(citeGroup, xmlnode);
|
|
30
|
+
|
|
31
|
+
};
|
|
@@ -75,14 +75,14 @@ export function extractContribGroups(articleMetaNode) {
|
|
|
75
75
|
contributor.orcid = contrib.querySelector('contrib-id[contrib-id-type="orcid"]')?.textContent;
|
|
76
76
|
|
|
77
77
|
contributor.uri = contrib.querySelector('uri')?.textContent;
|
|
78
|
-
//
|
|
79
|
-
const
|
|
80
|
-
if (index === 0 &&
|
|
78
|
+
// role (NOTE: child of contrib-group but it's easier if we copy it to each contributor)
|
|
79
|
+
const role = contrib.parentNode.querySelector('role')?.textContent;
|
|
80
|
+
if (index === 0 && role) contributor.byline = role;
|
|
81
81
|
contributorsArray.push(contributor);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
const extractContribGroup = function (contributors, contribGroup) {
|
|
85
|
-
contributors[contribGroup.getAttribute('content-type')] ??= []; // NOTE: jams410 has 2 contrib-groups with content-type=contributors (but different
|
|
85
|
+
contributors[contribGroup.getAttribute('content-type')] ??= []; // NOTE: jams410 has 2 contrib-groups with content-type=contributors (but different roles); cf. #408
|
|
86
86
|
contribGroup.querySelectorAll('contrib').forEach(extractContrib.bind(this, contributors[contribGroup.getAttribute('content-type')]));
|
|
87
87
|
};
|
|
88
88
|
|
package/lib/transformer.js
CHANGED
|
@@ -80,6 +80,8 @@ import * as algorithm from './elements/algorithm.js';
|
|
|
80
80
|
import Tag from './elements/tag.js';
|
|
81
81
|
import Xrefgroup from './elements/xref-group.js';
|
|
82
82
|
import TexMath from './elements/tex-math.js';
|
|
83
|
+
import CiteGroup from './elements/cite-group.js';
|
|
84
|
+
import CiteDetail from './elements/cite-detail.js';
|
|
83
85
|
|
|
84
86
|
import copyElement from './helpers/copyElement.js';
|
|
85
87
|
import { extractContribGroups } from './helpers/extractContribGroups.js';
|
|
@@ -126,8 +128,6 @@ export class Transformer {
|
|
|
126
128
|
'td',
|
|
127
129
|
'pre',
|
|
128
130
|
'hr',
|
|
129
|
-
'cite-group',
|
|
130
|
-
'cite-detail',
|
|
131
131
|
].forEach(mapTag.bind(null, this.copyElement));
|
|
132
132
|
// passThrough elements
|
|
133
133
|
[
|
|
@@ -275,6 +275,8 @@ export class Transformer {
|
|
|
275
275
|
tag = Tag.bind(this)
|
|
276
276
|
'xref-group' = Xrefgroup.bind(this)
|
|
277
277
|
'tex-math' = TexMath.bind(this)
|
|
278
|
+
'cite-group' = CiteGroup.bind(this)
|
|
279
|
+
'cite-detail' = CiteDetail.bind(this)
|
|
278
280
|
|
|
279
281
|
// one-off reuse of imported elements
|
|
280
282
|
// NOTE if RHS gets re-used more than once, use mapTag in the constructor
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<bio>Some biographical info with <email>email</email></bio>
|
|
19
19
|
</contrib>
|
|
20
20
|
<aff id="aff">aff</aff>
|
|
21
|
-
<
|
|
21
|
+
<role>comment</role>
|
|
22
22
|
</contrib-group>
|
|
23
23
|
<contrib-group content-type="contribBs">
|
|
24
24
|
<contrib contrib-type="contribB">
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
</contrib>
|
|
37
37
|
<aff id="aff1" specific-use="current">Aff1</aff>
|
|
38
38
|
<aff id="aff2">Aff2</aff>
|
|
39
|
-
<
|
|
39
|
+
<role>comment</role>
|
|
40
40
|
</contrib-group>
|
|
41
41
|
<funding-group>
|
|
42
42
|
<funding-statement/>
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
</contrib>
|
|
119
119
|
</contrib-group>
|
|
120
120
|
<contrib-group content-type="contributors">
|
|
121
|
-
<
|
|
121
|
+
<role>with</role>
|
|
122
122
|
<contrib contrib-type="contributor">
|
|
123
123
|
<string-name>Author 2</string-name>
|
|
124
124
|
<bio>Author 2 Bio</bio>
|
package/test/article.xml
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
<uri>uri</uri>
|
|
48
48
|
</contrib>
|
|
49
49
|
<aff id="aff">aff</aff>
|
|
50
|
-
<
|
|
50
|
+
<role>comment</role>
|
|
51
51
|
</contrib-group>
|
|
52
52
|
<contrib-group content-type="contribBs">
|
|
53
53
|
<contrib contrib-type="contribB">
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
</contrib>
|
|
67
67
|
<aff id="aff1" specific-use="current">Aff1</aff>
|
|
68
68
|
<aff id="aff2">Aff2</aff>
|
|
69
|
-
<
|
|
69
|
+
<role>comment</role>
|
|
70
70
|
</contrib-group>
|
|
71
71
|
<funding-group>
|
|
72
72
|
<funding-statement>Funding 1</funding-statement>
|
|
@@ -419,6 +419,12 @@
|
|
|
419
419
|
<tag parens="yes">T</tag>
|
|
420
420
|
</target>
|
|
421
421
|
</disp-formula>
|
|
422
|
+
<!-- Formula with cite-group and cite-detail -->
|
|
423
|
+
<disp-formula>
|
|
424
|
+
<tex-math>
|
|
425
|
+
<cite-group><x>[</x><xref ref-type="bibr" rid="bibr-AEG0" specific-use="cite">AEG08<cite-detail><x>, </x>Section 5</cite-detail></xref><x></cite-group>
|
|
426
|
+
</tex-math>
|
|
427
|
+
</disp-formula>
|
|
422
428
|
</sec>
|
|
423
429
|
<!-- citegroup, cite-detail-->
|
|
424
430
|
<sec disp-level="1" id="citegroup" specific-use="section">
|
package/test/book.xml
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
<uri>uri</uri>
|
|
52
52
|
</contrib>
|
|
53
53
|
<aff id="aff1">aff</aff>
|
|
54
|
-
<
|
|
54
|
+
<role>comment</role>
|
|
55
55
|
</contrib-group>
|
|
56
56
|
<contrib-group content-type="contrib-group-type2">
|
|
57
57
|
<contrib contrib-type="contrib-type2">
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
</contrib>
|
|
63
63
|
</contrib-group>
|
|
64
64
|
<contrib-group content-type="contrib-group-type3">
|
|
65
|
-
<
|
|
65
|
+
<role>comment</role>
|
|
66
66
|
<contrib contrib-type="contrib-type3">
|
|
67
67
|
<name name-style="given-only">
|
|
68
68
|
<given-names>should be ignored</given-names>
|
|
@@ -218,9 +218,9 @@
|
|
|
218
218
|
<sec-meta>
|
|
219
219
|
<contrib-group>
|
|
220
220
|
<!-- NOTE: this contrib-group example is for MCL 1, 14 only; intentionally broken via #254 -->
|
|
221
|
-
<
|
|
221
|
+
<role>
|
|
222
222
|
comment
|
|
223
|
-
</
|
|
223
|
+
</role>
|
|
224
224
|
</contrib-group>
|
|
225
225
|
<abstract>
|
|
226
226
|
<title>Abstract</title>
|
|
@@ -18,7 +18,7 @@ import { article } from './helper.js';
|
|
|
18
18
|
import tape from 'tape';
|
|
19
19
|
|
|
20
20
|
tape('inline-formula, disp-formula, tex-math', async function (t) {
|
|
21
|
-
t.plan(
|
|
21
|
+
t.plan(20);
|
|
22
22
|
const document = article;
|
|
23
23
|
const inlineformula = document.querySelector(
|
|
24
24
|
'#equations [data-ams-doc="math inline"]'
|
|
@@ -93,4 +93,6 @@ tape('inline-formula, disp-formula, tex-math', async function (t) {
|
|
|
93
93
|
t.ok(document.querySelector('div[data-ams-doc="math text"]'), 'Display Formula of content-type=text');
|
|
94
94
|
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');
|
|
95
95
|
|
|
96
|
+
// formula with cite-group and cite-detail
|
|
97
|
+
t.equal(dispWithText[9].innerHTML, ' \\xhref[bibr]{#bibr-AEG0}{AEG08, Section 5} ', 'Formula with cite-group, cite-detail')
|
|
96
98
|
});
|
package/test/element-sec-meta.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { article, articleAlttitle, book } from './helper.js';
|
|
18
18
|
import tape from 'tape';
|
|
19
19
|
|
|
20
|
-
tape('Template: sec-meta => contrib-group,
|
|
20
|
+
tape('Template: sec-meta => contrib-group, role, abstract/title', async function (t) {
|
|
21
21
|
t.plan(10);
|
|
22
22
|
|
|
23
23
|
const document = book;
|
package/test/hacks.js
CHANGED
|
@@ -34,8 +34,6 @@ tape('Hacks', async function (t) {
|
|
|
34
34
|
|
|
35
35
|
t.equal(document.querySelectorAll('#hacks > p').length, 1, 'If paragraph is empty after postprocessing, it is removed.')
|
|
36
36
|
|
|
37
|
-
console.log(article.querySelector('cite-group').parentNode.outerHTML)
|
|
38
|
-
|
|
39
37
|
t.equal(document.querySelector('cite-group').parentNode.tagName, 'P', 'Custom elements remain in paragraph');
|
|
40
38
|
});
|
|
41
39
|
|