@amermathsoc/texml-to-html 17.0.0 → 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
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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
|
+
|
|
5
12
|
## [17.0.0](https://github.com/AmerMathSoc/texml-to-html/compare/v16.1.1...v17.0.0) (2024-06-07)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -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
|
+
};
|
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
package/test/article.xml
CHANGED
|
@@ -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">
|
|
@@ -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/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
|
|