@amermathsoc/texml-to-html 17.1.0 → 18.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 +46 -1
- package/README.md +1 -1
- package/lib/elements/algorithm.js +1 -1
- package/lib/elements/cite-detail.js +0 -4
- package/lib/elements/fig.js +18 -0
- package/lib/elements/fn.js +11 -1
- package/lib/elements/label.js +2 -34
- package/lib/elements/ref.js +1 -1
- package/lib/elements/sec.js +1 -4
- package/lib/elements/secheading.js +2 -4
- package/lib/elements/toc-entry.js +1 -1
- package/lib/elements/x.js +4 -4
- package/lib/elements/xref-group.js +0 -4
- package/lib/transformer.js +0 -2
- package/out.html +696 -0
- package/out2.html +707 -0
- package/package.json +3 -3
- package/test/article.xml +9 -2
- package/test/book.xml +3 -3
- package/test/element-algorithm.js +6 -2
- package/test/element-cite-detail.js +1 -1
- package/test/element-cite-group.js +2 -2
- package/test/element-fig-subfig-label.js +6 -6
- package/test/element-inline-formula-disp-formula-tex-math.js +1 -1
- package/test/element-sec-app-front-matter-part-dedication-title-label.js +8 -9
- package/test/element-statement-label-title.js +7 -7
- package/test/element-stripEmptyLabel.js +1 -1
- package/test/element-table-wrap-group.js +2 -2
- package/test/element-table-wrap.js +1 -1
- package/test/element-toc-toc-entry.js +3 -3
- package/test/element-x.js +3 -6
- package/test/element-xref-group.js +4 -2
- package/lib/elements/caption.js +0 -52
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amermathsoc/texml-to-html",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A NodeJS library for converting AMS-style JATS XML to HTML",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"coverage": "c8 npm run test && c8 report --reporter html",
|
|
8
|
-
"release": "
|
|
8
|
+
"release": "commit-and-tag-version",
|
|
9
9
|
"test": "tape test/*.js"
|
|
10
10
|
},
|
|
11
11
|
"main": "./texml-to-html.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"homepage": "https://github.com/AmerMathSoc/texml-to-html#readme",
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"c8": "8.0.1",
|
|
33
|
-
"
|
|
33
|
+
"commit-and-tag-version": "12.4.1",
|
|
34
34
|
"tape": "5.7.2"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
package/test/article.xml
CHANGED
|
@@ -321,7 +321,7 @@
|
|
|
321
321
|
</statement>
|
|
322
322
|
<statement content-type="proof proof" has-qed-box="true" id="statement6">
|
|
323
323
|
<secheading id="statement6secheading" disp-level="3" specific-use="subsection">
|
|
324
|
-
<label>Label 6
|
|
324
|
+
<label>Label 6<x>.</x></label>
|
|
325
325
|
<title>secheading</title>
|
|
326
326
|
</secheading>
|
|
327
327
|
</statement>
|
|
@@ -346,7 +346,7 @@
|
|
|
346
346
|
<!-- fig, fig-group, caption, label -->
|
|
347
347
|
<sec disp-level="1" id="figures" specific-use="section">
|
|
348
348
|
<fig position="anchor" id="position">
|
|
349
|
-
<label>Label 1
|
|
349
|
+
<label>Label 1<x>.</x></label>
|
|
350
350
|
<caption>Caption 1</caption>
|
|
351
351
|
</fig>
|
|
352
352
|
<fig-group specific-use="special">
|
|
@@ -517,6 +517,12 @@
|
|
|
517
517
|
<alg:line><alg:statement><bold>Procedure</bold> <sc>Do</sc></alg:line>
|
|
518
518
|
</alg:procedure>
|
|
519
519
|
</alg:algorithm>
|
|
520
|
+
<alg:algorithm>
|
|
521
|
+
<alg:line lineno="1">
|
|
522
|
+
<alg:statement>
|
|
523
|
+
no line delim</alg:statement>
|
|
524
|
+
</alg:line>
|
|
525
|
+
</alg:algorithm>
|
|
520
526
|
</sec>
|
|
521
527
|
<sec disp-level="1">
|
|
522
528
|
<p>Email <email>email</email> in content, not metadata.</p>
|
|
@@ -546,6 +552,7 @@
|
|
|
546
552
|
</sec>
|
|
547
553
|
<sec id="xrefgroup">
|
|
548
554
|
<p>See groups <xref-group first="xrefgroup1" last="xrefgroup4" middle="xrefgroup2 xrefgroup3" ref-subtype="group" ref-type="grp"><x>(</x><xref ref-subtype="group" ref-type="grp" rid="xrefgroup1" specific-use="ref">2</xref><x>)</x>–<xref ref-subtype="group" ref-type="grp" rid="xrefgroup4" specific-use="ref">5</xref></xref-group></p>
|
|
555
|
+
<p>Groups in math-mode <inline-formula content-type="math/tex"><tex-math><xref-group first="xrefgroup1" last="xrefgroup4" middle="xrefgroup2 xrefgroup3" ref-subtype="group" ref-type="grp"><x>(</x><xref ref-subtype="group" ref-type="grp" rid="xrefgroup1" specific-use="ref">2</xref><x>)</x>–<xref ref-subtype="group" ref-type="grp" rid="xrefgroup4" specific-use="ref">5</xref></xref-group></inline-formula></tex-math></p>
|
|
549
556
|
</sec>
|
|
550
557
|
</body>
|
|
551
558
|
<back>
|
package/test/book.xml
CHANGED
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
<nav-pointer rid="tocid1"/>
|
|
92
92
|
</toc-entry>
|
|
93
93
|
<toc-entry>
|
|
94
|
-
<label>2
|
|
94
|
+
<label>2<x>.</x></label>
|
|
95
95
|
<title>Chunk</title>
|
|
96
96
|
<nav-pointer rid="tocid2"/>
|
|
97
97
|
<toc-entry>
|
|
@@ -255,7 +255,7 @@
|
|
|
255
255
|
|
|
256
256
|
<!-- alt-title -->
|
|
257
257
|
<sec disp-level="1" id="alttitle" specific-use="chapter">
|
|
258
|
-
<label>Label
|
|
258
|
+
<label>Label<x>.</x></label>
|
|
259
259
|
<title>Title</title>
|
|
260
260
|
<alt-title>Alt title</alt-title>
|
|
261
261
|
</sec>
|
|
@@ -278,7 +278,7 @@
|
|
|
278
278
|
<book-back>
|
|
279
279
|
<book-app-group id="book-app-group">
|
|
280
280
|
<book-app id="applabeltitle" disp-level="1" specific-use="chapter">
|
|
281
|
-
<label>Label
|
|
281
|
+
<label>Label<x>.</x></label>
|
|
282
282
|
<title>Title</title>
|
|
283
283
|
</book-app>
|
|
284
284
|
<book-app id="applabel" disp-level="1" specific-use="chapter">
|
|
@@ -20,10 +20,11 @@ import tape from 'tape';
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
tape('Element: alg:* elements', async function (t) {
|
|
23
|
-
t.plan(
|
|
23
|
+
t.plan(15);
|
|
24
24
|
const document = article;
|
|
25
25
|
// alg:algorithm
|
|
26
|
-
const
|
|
26
|
+
const algorithms = document.querySelectorAll('alg-algorithm');
|
|
27
|
+
const algorithm = algorithms[0];
|
|
27
28
|
t.ok(algorithm, 'alg-algorithm element');
|
|
28
29
|
t.equal(algorithm.getAttribute('data-ams-alg-linenodelimiter'), ':', 'alg-algorithm element');
|
|
29
30
|
// alg:line
|
|
@@ -52,5 +53,8 @@ tape('Element: alg:* elements', async function (t) {
|
|
|
52
53
|
t.ok(func, 'alg:function pass through');
|
|
53
54
|
const proc = [...algorithm.querySelectorAll('alg-line > alg-statement > *:first-of-type')].find(node => node.textContent === 'Procedure');
|
|
54
55
|
t.ok(proc, 'alg:procedure pass through');
|
|
56
|
+
|
|
57
|
+
// algorithm with no/empty line delimiter attribute
|
|
58
|
+
t.equal(algorithms[1].querySelector('alg-lineno').innerHTML, '1', 'alg-lineno without line number delimiter on algorithm root');
|
|
55
59
|
});
|
|
56
60
|
|
|
@@ -21,5 +21,5 @@ import tape from 'tape';
|
|
|
21
21
|
tape('Template: cite-detail', async function(t) {
|
|
22
22
|
t.plan(1);
|
|
23
23
|
|
|
24
|
-
t.equal(article.querySelector('cite-detail').outerHTML, '<cite-detail>, Section 5</cite-detail>', 'cite-detail');
|
|
24
|
+
t.equal(article.querySelector('cite-detail').outerHTML, '<cite-detail><ams-x>, </ams-x>Section 5</cite-detail>', 'cite-detail');
|
|
25
25
|
});
|
|
@@ -21,7 +21,7 @@ import tape from 'tape';
|
|
|
21
21
|
tape('Template: cite-group', async function (t) {
|
|
22
22
|
t.plan(2);
|
|
23
23
|
|
|
24
|
-
t.equal(article.querySelector('cite-group').outerHTML, '<cite-group><cite><a role="doc-biblioref" data-ams-ref="bibr" href="#bibr-AEG0">AEG08<cite-detail>, Section 5</cite-detail></a></cite><cite><a role="doc-biblioref" data-ams-ref="bibr" href="#bibr-AEG0">AEG08</a></cite></cite-group>', 'cite-group in article');
|
|
25
|
-
t.equal(book.querySelector('cite-group').outerHTML, '<cite-group>[
|
|
24
|
+
t.equal(article.querySelector('cite-group').outerHTML, '<cite-group><ams-x>[</ams-x><cite><a role="doc-biblioref" data-ams-ref="bibr" href="#bibr-AEG0">AEG08<cite-detail><ams-x>, </ams-x>Section 5</cite-detail></a></cite><ams-x>; </ams-x><cite><a role="doc-biblioref" data-ams-ref="bibr" href="#bibr-AEG0">AEG08</a></cite><ams-x>]</ams-x></cite-group>', 'cite-group in article');
|
|
25
|
+
t.equal(book.querySelector('cite-group').outerHTML, '<cite-group><ams-x>[</ams-x><cite><a role="doc-biblioref" data-ams-ref="bibr" href="#bibr-AEG0">AEG08<cite-detail><ams-x>, </ams-x>Section 5</cite-detail></a></cite><ams-x>; </ams-x><cite><a role="doc-biblioref" data-ams-ref="bibr" href="#bibr-AEG0">AEG08</a></cite><ams-x>]</ams-x></cite-group>', 'cite-group in book');
|
|
26
26
|
|
|
27
27
|
});
|
|
@@ -26,12 +26,12 @@ tape('Template: fig, fig-group, caption, label', async function(t) {
|
|
|
26
26
|
t.equal(figurePosition.getAttribute('data-ams-position'), 'anchor', 'Figure with data-ams-position attribute');
|
|
27
27
|
t.notOk(figurePosition.getAttribute('role'), 'Figure has no explicit role');
|
|
28
28
|
const labels = document.querySelectorAll('#figures figure strong');
|
|
29
|
-
t.equal(labels[0].innerHTML, 'Label 1
|
|
30
|
-
t.equal(labels[1].innerHTML, 'Grouplabel 1
|
|
31
|
-
t.equal(labels[2].innerHTML,'
|
|
32
|
-
t.equal(labels[3].innerHTML,'Label 2
|
|
33
|
-
t.equal(labels[4].innerHTML, 'Grouplabel 2
|
|
34
|
-
t.equal(labels[5].innerHTML, '
|
|
29
|
+
t.equal(labels[0].innerHTML, 'Label 1<ams-x>.</ams-x>', 'Fig label with caption gets period');
|
|
30
|
+
t.equal(labels[1].innerHTML, 'Grouplabel 1', 'Fig-group label with caption gets period');
|
|
31
|
+
t.equal(labels[2].innerHTML,'Sublabel 1', 'Subfigure label with caption gets parentheses');
|
|
32
|
+
t.equal(labels[3].innerHTML,'Label 2', 'Fig label without caption gets period');
|
|
33
|
+
t.equal(labels[4].innerHTML, 'Grouplabel 2', 'Fig-group label without caption gets period');
|
|
34
|
+
t.equal(labels[5].innerHTML, 'Sublabel 2', 'Subfigure label without caption gets parentheses');
|
|
35
35
|
t.notOk(figurePosition.nextElementSibling.hasAttribute('id'), 'Fig without id does not create a (bad) id');
|
|
36
36
|
t.notOk(figurePosition.nextElementSibling.getAttribute('data-ams-position'), 'Fig without position does not create a (bad) data attribute');
|
|
37
37
|
t.equal(figurePosition.nextElementSibling.getAttribute('data-ams-specific-use'), 'special', 'Fig with specific-use');
|
|
@@ -94,5 +94,5 @@ tape('inline-formula, disp-formula, tex-math', async function (t) {
|
|
|
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
96
|
// formula with cite-group and cite-detail
|
|
97
|
-
t.equal(dispWithText[9].innerHTML, '
|
|
97
|
+
t.equal(dispWithText[9].innerHTML, ' <ams-x>[</ams-x>\\xhref[bibr]{#bibr-AEG0}{AEG08<cite-detail><ams-x>, </ams-x>Section 5</cite-detail>}<ams-x></ams-x> ', 'Formula with cite-group, cite-detail')
|
|
98
98
|
});
|
|
@@ -18,8 +18,8 @@ import { article, articleAlttitle, articleNometa, book } from './helper.js';
|
|
|
18
18
|
import tape from 'tape';
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
tape('sec, app, front-matter-part, dedication, title, label', async function(t) {
|
|
22
|
-
t.plan(
|
|
21
|
+
tape('sec, app, front-matter-part, dedication, title, label', async function (t) {
|
|
22
|
+
t.plan(43);
|
|
23
23
|
const document = article;
|
|
24
24
|
|
|
25
25
|
t.ok(document.querySelector('#ack1[role="doc-acknowledgments"][data-ams-doc-level="1"]'), 'ack to role doc-acknowledgments with data-ams-doc-level');
|
|
@@ -31,10 +31,10 @@ tape('sec, app, front-matter-part, dedication, title, label', async function(t)
|
|
|
31
31
|
|
|
32
32
|
t.equal(document.querySelector('#subsec h3').innerHTML, '<span data-ams-doc="label">Subsection</span>', 'subsection without wrapping section gets correct level');
|
|
33
33
|
|
|
34
|
-
t.equal(document.querySelector('#seclabeltitle h2').innerHTML, '<span data-ams-doc="label">Label
|
|
34
|
+
t.equal(document.querySelector('#seclabeltitle h2').innerHTML, '<span data-ams-doc="label">Label</span> <span data-ams-doc="title">Title</span>', 'sec with label+title: heading level and content');
|
|
35
35
|
t.equal(document.querySelector('#sectitle h2').innerHTML, '<span data-ams-doc="title">Title</span>', 'sec with title: heading level and content');
|
|
36
36
|
t.equal(document.querySelector('#seclabel h2').innerHTML, '<span data-ams-doc="label">Label</span>', 'sec with label: heading level and content');
|
|
37
|
-
t.equal(document.querySelector('#applabeltitle h2').innerHTML, '<span data-ams-doc="label">Label
|
|
37
|
+
t.equal(document.querySelector('#applabeltitle h2').innerHTML, '<span data-ams-doc="label">Label</span> <span data-ams-doc="title">Title</span>', 'app with label+title: heading level and content');
|
|
38
38
|
t.equal(document.querySelector('#apptitle h2').innerHTML, '<span data-ams-doc="title">Title</span>', 'app with title: heading level and content');
|
|
39
39
|
t.equal(document.querySelector('#applabel h2').innerHTML, '<span data-ams-doc="label">Label</span>', 'app with label: heading level and content');
|
|
40
40
|
|
|
@@ -52,13 +52,13 @@ tape('sec, app, front-matter-part, dedication, title, label', async function(t)
|
|
|
52
52
|
const document2 = book;
|
|
53
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
54
|
|
|
55
|
-
t.equal(document2.querySelector('#seclabeltitle h2').innerHTML, '<span data-ams-doc="label">Label
|
|
55
|
+
t.equal(document2.querySelector('#seclabeltitle h2').innerHTML, '<span data-ams-doc="label">Label</span> <span data-ams-doc="title">Title</span>', 'sec with label+title: heading level and content');
|
|
56
56
|
t.equal(document2.querySelector('#sectitle h2').innerHTML, '<span data-ams-doc="title">Title</span>', 'sec with title: heading level and content');
|
|
57
57
|
t.equal(document2.querySelector('#seclabel h2').innerHTML, '<span data-ams-doc="label">Label</span>', 'sec with label: heading level and content');
|
|
58
|
-
t.equal(document2.querySelector('#fmlabeltitle h1').innerHTML, '<span data-ams-doc="label">Label
|
|
58
|
+
t.equal(document2.querySelector('#fmlabeltitle h1').innerHTML, '<span data-ams-doc="label">Label</span> <span data-ams-doc="title">Title</span>', 'front-matter-part with label+title: heading level and content');
|
|
59
59
|
t.equal(document2.querySelector('#fmtitle h1').innerHTML, '<span data-ams-doc="title">Title</span>', 'front-matter-part with title: heading level and content');
|
|
60
60
|
t.equal(document2.querySelector('#fmlabel h1').innerHTML, '<span data-ams-doc="label">Label</span>', 'front-matter-part with label: heading level and content');
|
|
61
|
-
t.equal(document2.querySelector('#applabeltitle h1').innerHTML, '<span data-ams-doc="label">Label
|
|
61
|
+
t.equal(document2.querySelector('#applabeltitle h1').innerHTML, '<span data-ams-doc="label">Label<ams-x>.</ams-x></span> <span data-ams-doc="title">Title</span>', 'app with label+title: heading level and content');
|
|
62
62
|
t.equal(document2.querySelector('#apptitle h1').innerHTML, '<span data-ams-doc="title">Title</span>', 'app with title: heading level and content');
|
|
63
63
|
t.equal(document2.querySelector('#applabel h1').innerHTML, '<span data-ams-doc="label">Label</span>', 'app with label: heading level and content');
|
|
64
64
|
|
|
@@ -73,8 +73,7 @@ tape('sec, app, front-matter-part, dedication, title, label', async function(t)
|
|
|
73
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
74
|
|
|
75
75
|
const bookAppGroup = document2.querySelector('#book-app-group');
|
|
76
|
-
t.equal(bookAppGroup.getAttribute('
|
|
77
|
-
t.equal(bookAppGroup.getAttribute('data-ams-doc'), 'part', 'book-app-group data-ams-doc');
|
|
76
|
+
t.equal(bookAppGroup.getAttribute('data-ams-doc'), 'app-group', 'book-app-group data-ams-doc');
|
|
78
77
|
t.equal(bookAppGroup.getAttribute('data-ams-doc-level'), '0', 'book-app-group data-ams-level');
|
|
79
78
|
t.equal(document2.querySelector('#applabeltitle').getAttribute('role'), 'doc-appendix', 'book-app role');
|
|
80
79
|
|
|
@@ -29,7 +29,7 @@ tape('Template: statement, label, title', async function(t) {
|
|
|
29
29
|
t.ok(statement1Heading, 'statement heading level in article');
|
|
30
30
|
t.equal(
|
|
31
31
|
statement1Heading.innerHTML,
|
|
32
|
-
'<span data-ams-doc="label">Label 1
|
|
32
|
+
'<span data-ams-doc="label">Label 1</span> <span data-ams-doc="title">Title 1</span>',
|
|
33
33
|
'statement with label+title creates space before and period after title'
|
|
34
34
|
);
|
|
35
35
|
const statement2 = document.querySelector(
|
|
@@ -38,7 +38,7 @@ tape('Template: statement, label, title', async function(t) {
|
|
|
38
38
|
t.ok(statement2, 'statement 2');
|
|
39
39
|
t.equal(
|
|
40
40
|
statement2.querySelector('figcaption').innerHTML,
|
|
41
|
-
'<span data-ams-doc="label">Label 2</span
|
|
41
|
+
'<span data-ams-doc="label">Label 2</span>',
|
|
42
42
|
'statement with label creates period after'
|
|
43
43
|
);
|
|
44
44
|
const statement3 = document.querySelector(
|
|
@@ -47,7 +47,7 @@ tape('Template: statement, label, title', async function(t) {
|
|
|
47
47
|
t.ok(statement3, 'statement 3');
|
|
48
48
|
t.equal(
|
|
49
49
|
statement3.querySelector('figcaption').innerHTML,
|
|
50
|
-
'<span data-ams-doc="title">Title 3</span
|
|
50
|
+
'<span data-ams-doc="title">Title 3</span>',
|
|
51
51
|
'statement with title creates period after'
|
|
52
52
|
);
|
|
53
53
|
const statementTitlePeriod = document.querySelector(
|
|
@@ -55,7 +55,7 @@ tape('Template: statement, label, title', async function(t) {
|
|
|
55
55
|
);
|
|
56
56
|
t.equal(
|
|
57
57
|
statementTitlePeriod.querySelector('figcaption').innerHTML,
|
|
58
|
-
'<span data-ams-doc="title">Title 4.</span>
|
|
58
|
+
'<span data-ams-doc="title">Title 4.</span>',
|
|
59
59
|
'statement with title with period does not have extra period after'
|
|
60
60
|
);
|
|
61
61
|
const statement4 = document.querySelector(
|
|
@@ -64,7 +64,7 @@ tape('Template: statement, label, title', async function(t) {
|
|
|
64
64
|
t.ok(statement4, 'statement 4');
|
|
65
65
|
t.equal(
|
|
66
66
|
statement4.querySelector('figcaption').innerHTML,
|
|
67
|
-
'<span data-ams-doc="title">Proof</span
|
|
67
|
+
'<span data-ams-doc="title">Proof</span>',
|
|
68
68
|
'title in proof statement now also gets extra period'
|
|
69
69
|
);
|
|
70
70
|
const statement5 = document.querySelector(
|
|
@@ -73,7 +73,7 @@ tape('Template: statement, label, title', async function(t) {
|
|
|
73
73
|
t.ok(statement5, 'statement 5');
|
|
74
74
|
t.equal(
|
|
75
75
|
statement5.querySelector('figcaption').innerHTML,
|
|
76
|
-
'<span data-ams-doc="label">Label 5
|
|
76
|
+
'<span data-ams-doc="label">Label 5</span> <span data-ams-doc="title">Proof</span>',
|
|
77
77
|
'proof statement with label+title'
|
|
78
78
|
);
|
|
79
79
|
t.equal(
|
|
@@ -87,7 +87,7 @@ tape('Template: statement, label, title', async function(t) {
|
|
|
87
87
|
t.ok(statement6, 'statement 6');
|
|
88
88
|
t.equal(
|
|
89
89
|
statement6.querySelector('[data-ams-doc="secheading"]').innerHTML,
|
|
90
|
-
'Label 6
|
|
90
|
+
'Label 6<ams-x>.</ams-x> secheading',
|
|
91
91
|
'secheading with title+label within statement'
|
|
92
92
|
);
|
|
93
93
|
|
|
@@ -22,5 +22,5 @@ tape('Empty Labels should be stripped', async function(t) {
|
|
|
22
22
|
t.plan(2);
|
|
23
23
|
const document = article;
|
|
24
24
|
t.equal(document.querySelector('#emptyLabel').innerHTML.trim(), '', 'Statement with no title and empty label');
|
|
25
|
-
t.equal(document.querySelector('#titleEmptyLabel').innerHTML.trim(), '<figcaption><span data-ams-doc="title">Title</span
|
|
25
|
+
t.equal(document.querySelector('#titleEmptyLabel').innerHTML.trim(), '<figcaption><span data-ams-doc="title">Title</span></figcaption>', 'Statement with no title and empty label');
|
|
26
26
|
});
|
|
@@ -23,8 +23,8 @@ tape('table-wrap-group element', async function (t) {
|
|
|
23
23
|
const document = article;
|
|
24
24
|
const tableWrapGroup = document.querySelector('figure[data-ams-doc="table-wrap-group"]');
|
|
25
25
|
t.ok(tableWrapGroup, 'table-wrap element as figure');
|
|
26
|
-
t.equal(tableWrapGroup.querySelector('figcaption > strong').innerHTML, 'Table with subtables
|
|
26
|
+
t.equal(tableWrapGroup.querySelector('figcaption > strong').innerHTML, 'Table with subtables', 'table-wrap-group caption');
|
|
27
27
|
t.equal(
|
|
28
|
-
tableWrapGroup.querySelector('figure[data-ams-doc="table-wrap"] > figcaption > strong').innerHTML, '
|
|
28
|
+
tableWrapGroup.querySelector('figure[data-ams-doc="table-wrap"] > figcaption > strong').innerHTML, 'a', 'table-wrap label'
|
|
29
29
|
);
|
|
30
30
|
});
|
|
@@ -35,18 +35,18 @@ tape('Template: (book) toc, toc-entry', async function (t) {
|
|
|
35
35
|
);
|
|
36
36
|
t.equal(
|
|
37
37
|
list.querySelector('li a[href="#tocid2"]').innerHTML,
|
|
38
|
-
'<span data-ams-doc="label">2
|
|
38
|
+
'<span data-ams-doc="label">2<ams-x>.</ams-x></span> <span data-ams-doc="title">Chunk</span>',
|
|
39
39
|
'toc-entry, label, nav-pointer'
|
|
40
40
|
);
|
|
41
41
|
t.equal(list.querySelector('ol').children.length, 1, 'Doubly nested toc-entries remain nested');
|
|
42
42
|
t.equal(
|
|
43
43
|
list.querySelector('li a[href="#tocid2"]+ol li a[href="#tocid3"]').innerHTML,
|
|
44
|
-
'<span data-ams-doc="label">1</span
|
|
44
|
+
'<span data-ams-doc="label">1</span> <span data-ams-doc="title">SubChunk</span>',
|
|
45
45
|
'Nested toc-entry, label, nav-pointer'
|
|
46
46
|
);
|
|
47
47
|
t.equal(
|
|
48
48
|
list.querySelector('li a[href="#tocid4"]').innerHTML,
|
|
49
|
-
'<span data-ams-doc="label">1</span
|
|
49
|
+
'<span data-ams-doc="label">1</span> <span data-ams-doc="title">SubSubChunk with <span data-ams-href="chapter">Link</span></span>',
|
|
50
50
|
'toc-entry with xref in title'
|
|
51
51
|
);
|
|
52
52
|
t.equal(
|
package/test/element-x.js
CHANGED
|
@@ -20,11 +20,8 @@ import tape from 'tape';
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
tape('Template: x', async function(t) {
|
|
23
|
-
t.plan(
|
|
23
|
+
t.plan(2);
|
|
24
24
|
const document = article;
|
|
25
|
-
t.equal(document.querySelector('
|
|
26
|
-
t.equal(document.
|
|
27
|
-
t.equal(document.querySelector('p#pwithx').innerHTML, 'Is ignored.', 'x in article is ignored');
|
|
28
|
-
const document2 = book;
|
|
29
|
-
t.equal(document2.querySelector('p#pwithx').innerHTML, 'Is not ignored.', 'x in book is preserved');
|
|
25
|
+
t.equal(document.querySelector('ams-x').innerHTML, ',', 'x tags renamed to ams-x');
|
|
26
|
+
t.equal(document.querySelectorAll('ams-x').length, 16, 'All x elements are preserved');
|
|
30
27
|
});
|
|
@@ -20,7 +20,9 @@ import tape from 'tape';
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
tape('Template: xref-group', async function (t) {
|
|
23
|
-
t.plan(
|
|
23
|
+
t.plan(2);
|
|
24
24
|
const xrefGroup = article.querySelector('#xrefgroup [data-ams-doc="refgroup"]');
|
|
25
|
-
t.equal(xrefGroup.outerHTML, '<span data-ams-refrange="xrefgroup2 xrefgroup3" data-ams-ref="grp" data-ams-doc="refgroup"><a data-ams-ref="grp" href="#xrefgroup1">2</a>–<a data-ams-ref="grp" href="#xrefgroup4">5</a></span>', 'xrefgroup snapshot test')
|
|
25
|
+
t.equal(xrefGroup.outerHTML, '<span data-ams-refrange="xrefgroup2 xrefgroup3" data-ams-ref="grp" data-ams-doc="refgroup"><ams-x>(</ams-x><a data-ams-ref="grp" href="#xrefgroup1">2</a><ams-x>)</ams-x>–<a data-ams-ref="grp" href="#xrefgroup4">5</a></span>', 'xrefgroup snapshot test')
|
|
26
|
+
const xrefGroupMath = article.querySelector('#xrefgroup tex-math [data-ams-doc="refgroup"]');
|
|
27
|
+
t.equal(xrefGroupMath.outerHTML, '<span data-ams-refrange="xrefgroup2 xrefgroup3" data-ams-ref="grp" data-ams-doc="refgroup"><ams-x>(</ams-x>\\xhref[grp]{#xrefgroup1}{2}<ams-x>)</ams-x>–\\xhref[grp]{#xrefgroup4}{5}</span>', 'xrefgroup in math mode snapshot test')
|
|
26
28
|
});
|
package/lib/elements/caption.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
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
|
-
};
|