@pretextbook/pretext-html 0.1.0 → 0.1.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/README.md +42 -3
- package/assets/preview-html.xsl +230 -230
- package/assets/upstream.json +7 -7
- package/assets/xsl/README.md +0 -0
- package/assets/xsl/entities.ent +154 -154
- package/assets/xsl/extract-asymptote.xsl +68 -68
- package/assets/xsl/extract-biblio-csl.xsl +327 -327
- package/assets/xsl/extract-datafile.xsl +71 -71
- package/assets/xsl/extract-dynamic.xsl +139 -139
- package/assets/xsl/extract-identity.xsl +136 -136
- package/assets/xsl/extract-interactive.xsl +81 -81
- package/assets/xsl/extract-latex-image.xsl +118 -118
- package/assets/xsl/extract-mermaid.xsl +58 -58
- package/assets/xsl/extract-mom.xsl +63 -63
- package/assets/xsl/extract-pg.xsl +2897 -2897
- package/assets/xsl/extract-prefigure.xsl +157 -157
- package/assets/xsl/extract-qrcode.xsl +100 -100
- package/assets/xsl/extract-runestone-page-template.xsl +139 -139
- package/assets/xsl/extract-sageplot.xsl +166 -166
- package/assets/xsl/extract-stack.xsl +56 -56
- package/assets/xsl/extract-trace.xsl +134 -134
- package/assets/xsl/extract-youtube.xsl +63 -63
- package/assets/xsl/html-symbols.xsl +3344 -3344
- package/assets/xsl/latex/pretext-latex-AIM.xsl +56 -56
- package/assets/xsl/latex/pretext-latex-CLP.xsl +148 -148
- package/assets/xsl/latex/pretext-latex-chaos.xsl +317 -317
- package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +76 -76
- package/assets/xsl/latex/pretext-latex-guide.xsl +104 -104
- package/assets/xsl/latex/pretext-latex-texstyle.xsl +862 -862
- package/assets/xsl/localizations/README.md +0 -0
- package/assets/xsl/localizations/af-ZA.xml +276 -276
- package/assets/xsl/localizations/bg-BG.xml +276 -276
- package/assets/xsl/localizations/ca-ES.xml +285 -285
- package/assets/xsl/localizations/cs-CZ.xml +280 -280
- package/assets/xsl/localizations/de-DE.xml +281 -281
- package/assets/xsl/localizations/en-US.xml +427 -427
- package/assets/xsl/localizations/es-ES.xml +287 -287
- package/assets/xsl/localizations/fi-FI.xml +275 -275
- package/assets/xsl/localizations/fr-CA.xml +276 -276
- package/assets/xsl/localizations/fr-FR.xml +280 -280
- package/assets/xsl/localizations/hu-HU.xml +280 -280
- package/assets/xsl/localizations/it-IT.xml +276 -276
- package/assets/xsl/localizations/ku-CKB.xml +275 -275
- package/assets/xsl/localizations/localizations.xml +48 -48
- package/assets/xsl/localizations/nl-NL.xml +275 -275
- package/assets/xsl/localizations/pt-BR.xml +288 -288
- package/assets/xsl/localizations/pt-PT.xml +292 -292
- package/assets/xsl/localizations/zh-HANS.xml +269 -269
- package/assets/xsl/pretext-assembly.xsl +4795 -4795
- package/assets/xsl/pretext-basic-html.xsl +86 -86
- package/assets/xsl/pretext-beamer.xsl +662 -662
- package/assets/xsl/pretext-braille-preprint.xsl +2249 -2249
- package/assets/xsl/pretext-common.xsl +12018 -12018
- package/assets/xsl/pretext-dynamic.xsl +65 -65
- package/assets/xsl/pretext-epub.xsl +1483 -1483
- package/assets/xsl/pretext-fo.xsl +4593 -4593
- package/assets/xsl/pretext-html.xsl +14791 -14791
- package/assets/xsl/pretext-json-manifest.xsl +150 -150
- package/assets/xsl/pretext-jupyter.xsl +868 -868
- package/assets/xsl/pretext-latex-classic.xsl +952 -952
- package/assets/xsl/pretext-latex-common.xsl +11563 -11563
- package/assets/xsl/pretext-latex.xsl +47 -47
- package/assets/xsl/pretext-litprog.xsl +105 -105
- package/assets/xsl/pretext-merge.xsl +41 -41
- package/assets/xsl/pretext-numbers.xsl +875 -875
- package/assets/xsl/pretext-revealjs.xsl +522 -522
- package/assets/xsl/pretext-runestone-fitb.xsl +1233 -1233
- package/assets/xsl/pretext-runestone-static.xsl +1438 -1438
- package/assets/xsl/pretext-runestone.xsl +3083 -3083
- package/assets/xsl/pretext-sage-doctest.xsl +289 -289
- package/assets/xsl/pretext-smc.xsl +492 -492
- package/assets/xsl/pretext-solution-manual-latex.xsl +323 -323
- package/assets/xsl/pretext-text-utilities.xsl +1217 -1217
- package/assets/xsl/pretext-text.xsl +392 -392
- package/assets/xsl/pretext-units.xsl +195 -195
- package/assets/xsl/pretext-view-source.xsl +157 -157
- package/assets/xsl/pretext-ww-problem-sets.xsl +391 -391
- package/assets/xsl/publisher-variables.xsl +4756 -4756
- package/assets/xsl/support/README.md +0 -0
- package/assets/xsl/support/extract-math.xsl +256 -256
- package/assets/xsl/support/package-math.xsl +141 -141
- package/assets/xsl/support/play-button/README.md +0 -0
- package/assets/xsl/support/play-button/play-button.png +0 -0
- package/assets/xsl/support/play-button/play-button.svg +3 -3
- package/assets/xsl/support/pretext-pg-macros.xsl +110 -110
- package/assets/xsl/support/webpack_static_imports.xml +14 -14
- package/assets/xsl/tests/README.md +0 -0
- package/assets/xsl/tests/null.xml +3 -3
- package/assets/xsl/tests/pretext-text-utilities-test.xsl +333 -333
- package/assets/xsl/utilities/README.md +0 -0
- package/assets/xsl/utilities/author-report.xsl +107 -107
- package/assets/xsl/utilities/deprecate-autoname.sed +18 -18
- package/assets/xsl/utilities/deprecate-index.sed +33 -33
- package/assets/xsl/utilities/fix-deprecations.xsl +663 -663
- package/assets/xsl/utilities/pretext-enhanced-source.xsl +112 -112
- package/assets/xsl/utilities/report-publisher-variables.xsl +162 -162
- package/assets/xsl/xml-to-json.xsl +326 -326
- package/assets/xsl/xml-to-string.xsl +328 -328
- package/dist/{cli-C6tfAVvi.js → cli-BQizBK0N.js} +74 -72
- package/dist/cli.d.ts +0 -0
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -6
- package/dist/mounts.d.ts +0 -0
- package/dist/publication.d.ts +0 -0
- package/dist/renderer.d.ts +10 -0
- package/dist/sourcemap.d.ts +0 -0
- package/dist/theme.d.ts +68 -0
- package/dist/theme.js +93 -0
- package/dist/xinclude.d.ts +0 -0
- package/package.json +14 -2
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
<?xml version='1.0'?>
|
|
2
|
-
|
|
3
|
-
<!--********************************************************************
|
|
4
|
-
Copyright 2026 Robert A. Beezer
|
|
5
|
-
|
|
6
|
-
This file is part of PreTeXt.
|
|
7
|
-
|
|
8
|
-
PreTeXt is free software: you can redistribute it and/or modify
|
|
9
|
-
it under the terms of the GNU General Public License as published by
|
|
10
|
-
the Free Software Foundation, either version 2 or version 3 of the
|
|
11
|
-
License (at your option).
|
|
12
|
-
|
|
13
|
-
PreTeXt is distributed in the hope that it will be useful,
|
|
14
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
GNU General Public License for more details.
|
|
17
|
-
|
|
18
|
-
You should have received a copy of the GNU General Public License
|
|
19
|
-
along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
*********************************************************************-->
|
|
21
|
-
|
|
22
|
-
<!-- Empty shell page that Runestone can use to display content on a page -->
|
|
23
|
-
<!-- that looks like it belongs to the book. -->
|
|
24
|
-
|
|
25
|
-
<xsl:stylesheet
|
|
26
|
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
27
|
-
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
|
28
|
-
>
|
|
29
|
-
|
|
30
|
-
<!-- Import the HTML conversion for file wrapping and page-part templates, -->
|
|
31
|
-
<!-- but override its entry point so this extraction only writes _base.html. -->
|
|
32
|
-
<xsl:import href="./pretext-html.xsl"/>
|
|
33
|
-
|
|
34
|
-
<!-- Override the variable open and close to use normal Jinga syntax -->
|
|
35
|
-
<!-- This will be used as a template to insert other Jinga content into -->
|
|
36
|
-
<!-- and that content uses normal variable delimeters. -->
|
|
37
|
-
<!-- We are not worried about LaTeX content we don't directly control. -->
|
|
38
|
-
<xsl:variable name="rso" select="'{{'"/>
|
|
39
|
-
<xsl:variable name="rsc" select="'}}'"/>
|
|
40
|
-
|
|
41
|
-
<!-- Override latex-macros so we can escape them in bulk -->
|
|
42
|
-
<xsl:template match="*" mode="latex-macros">
|
|
43
|
-
<xsl:text>{% raw %}
</xsl:text>
|
|
44
|
-
<!-- Call the original template -->
|
|
45
|
-
<xsl:apply-imports/>
|
|
46
|
-
<xsl:text>{% endraw %}
</xsl:text>
|
|
47
|
-
</xsl:template>
|
|
48
|
-
|
|
49
|
-
<!-- Overrride navigation template to prevent next button from being enabled -->
|
|
50
|
-
<xsl:template match="*" mode="next-linear-url"/>
|
|
51
|
-
|
|
52
|
-
<!-- Override the HTML default so file-wrap emits Runestone template hooks -->
|
|
53
|
-
<xsl:template match="*" mode="file-wrap-head-pre">
|
|
54
|
-
{% set using_ptx_base = "true" %}
|
|
55
|
-
<base>
|
|
56
|
-
<!-- avoid wonkiness with XSL {{ escaping. No spaces is important -->
|
|
57
|
-
<xsl:attribute name="href">{{base_url}}</xsl:attribute>
|
|
58
|
-
</base>
|
|
59
|
-
<!-- Call the original template just in case something is added there -->
|
|
60
|
-
<xsl:apply-imports/>
|
|
61
|
-
</xsl:template>
|
|
62
|
-
|
|
63
|
-
<!-- Override canonical link - don't want to generate the same value for -->
|
|
64
|
-
<!-- all pages and don't need to SEO the internal student pages -->
|
|
65
|
-
<xsl:template name="canonical-link"/>
|
|
66
|
-
|
|
67
|
-
<xsl:template match="*" mode="file-wrap-head-post">
|
|
68
|
-
<!-- Call the original template just in case something is added there -->
|
|
69
|
-
<xsl:apply-imports/>
|
|
70
|
-
<link href="/staticAssets/main-ptx-based.css" rel="stylesheet" />
|
|
71
|
-
<script>
|
|
72
|
-
window.addEventListener("DOMContentLoaded", () => {
|
|
73
|
-
const sidebar = document.getElementById("ptx-sidebar");
|
|
74
|
-
if (sidebar) {
|
|
75
|
-
sidebar.classList.add("hidden");
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
</script>
|
|
79
|
-
{% block css %}
|
|
80
|
-
{% endblock %}
|
|
81
|
-
</xsl:template>
|
|
82
|
-
|
|
83
|
-
<xsl:template match="*" mode="file-wrap-body-attr-extra">
|
|
84
|
-
<!-- Call the original template just in case something is added there -->
|
|
85
|
-
<xsl:apply-imports/>
|
|
86
|
-
<xsl:text> ptx-runestone-template</xsl:text>
|
|
87
|
-
</xsl:template>
|
|
88
|
-
|
|
89
|
-
<xsl:template match="*" mode="file-wrap-body-post">
|
|
90
|
-
<!-- Call the original template just in case something is added there -->
|
|
91
|
-
<xsl:apply-imports/>
|
|
92
|
-
<!-- rs footer -->
|
|
93
|
-
{% include 'footer.html' %}
|
|
94
|
-
<!-- scripts -->
|
|
95
|
-
<script>
|
|
96
|
-
<!-- hide sidebar by default in all themes -->
|
|
97
|
-
const sidebar = document.getElementById("ptx-sidebar");
|
|
98
|
-
if (sidebar) {
|
|
99
|
-
sidebar.classList.add("hidden");
|
|
100
|
-
}
|
|
101
|
-
</script>
|
|
102
|
-
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
|
|
103
|
-
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js"></script>
|
|
104
|
-
{% block js %}
|
|
105
|
-
{% endblock %}
|
|
106
|
-
</xsl:template>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
<xsl:output method="html" indent="yes" encoding="UTF-8" doctype-system="about:legacy-compat" />
|
|
110
|
-
|
|
111
|
-
<xsl:template match="/">
|
|
112
|
-
<xsl:call-template name="runestone-page-template"/>
|
|
113
|
-
</xsl:template>
|
|
114
|
-
|
|
115
|
-
<xsl:template name="runestone-page-template">
|
|
116
|
-
<xsl:if test="$b-host-runestone and ($b-is-book or $b-is-article)">
|
|
117
|
-
<xsl:apply-templates select="$document-root" mode="runestone-page-template"/>
|
|
118
|
-
</xsl:if>
|
|
119
|
-
</xsl:template>
|
|
120
|
-
|
|
121
|
-
<xsl:template match="book|article" mode="runestone-page-template">
|
|
122
|
-
<xsl:apply-templates select="." mode="file-wrap">
|
|
123
|
-
<xsl:with-param name="filename">
|
|
124
|
-
<xsl:text>_base.html</xsl:text>
|
|
125
|
-
</xsl:with-param>
|
|
126
|
-
<xsl:with-param name="title">
|
|
127
|
-
<xsl:text>{% block title %}</xsl:text>
|
|
128
|
-
<xsl:apply-templates select="." mode="title-plain" />
|
|
129
|
-
<xsl:text>{% endblock %}</xsl:text>
|
|
130
|
-
</xsl:with-param>
|
|
131
|
-
<xsl:with-param name="b-include-bottom-nav" select="false()"/>
|
|
132
|
-
<xsl:with-param name="content">
|
|
133
|
-
{% block content %}
|
|
134
|
-
{% endblock %}
|
|
135
|
-
</xsl:with-param>
|
|
136
|
-
</xsl:apply-templates>
|
|
137
|
-
</xsl:template>
|
|
138
|
-
|
|
139
|
-
</xsl:stylesheet>
|
|
1
|
+
<?xml version='1.0'?>
|
|
2
|
+
|
|
3
|
+
<!--********************************************************************
|
|
4
|
+
Copyright 2026 Robert A. Beezer
|
|
5
|
+
|
|
6
|
+
This file is part of PreTeXt.
|
|
7
|
+
|
|
8
|
+
PreTeXt is free software: you can redistribute it and/or modify
|
|
9
|
+
it under the terms of the GNU General Public License as published by
|
|
10
|
+
the Free Software Foundation, either version 2 or version 3 of the
|
|
11
|
+
License (at your option).
|
|
12
|
+
|
|
13
|
+
PreTeXt is distributed in the hope that it will be useful,
|
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
You should have received a copy of the GNU General Public License
|
|
19
|
+
along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*********************************************************************-->
|
|
21
|
+
|
|
22
|
+
<!-- Empty shell page that Runestone can use to display content on a page -->
|
|
23
|
+
<!-- that looks like it belongs to the book. -->
|
|
24
|
+
|
|
25
|
+
<xsl:stylesheet
|
|
26
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
27
|
+
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
|
28
|
+
>
|
|
29
|
+
|
|
30
|
+
<!-- Import the HTML conversion for file wrapping and page-part templates, -->
|
|
31
|
+
<!-- but override its entry point so this extraction only writes _base.html. -->
|
|
32
|
+
<xsl:import href="./pretext-html.xsl"/>
|
|
33
|
+
|
|
34
|
+
<!-- Override the variable open and close to use normal Jinga syntax -->
|
|
35
|
+
<!-- This will be used as a template to insert other Jinga content into -->
|
|
36
|
+
<!-- and that content uses normal variable delimeters. -->
|
|
37
|
+
<!-- We are not worried about LaTeX content we don't directly control. -->
|
|
38
|
+
<xsl:variable name="rso" select="'{{'"/>
|
|
39
|
+
<xsl:variable name="rsc" select="'}}'"/>
|
|
40
|
+
|
|
41
|
+
<!-- Override latex-macros so we can escape them in bulk -->
|
|
42
|
+
<xsl:template match="*" mode="latex-macros">
|
|
43
|
+
<xsl:text>{% raw %}
</xsl:text>
|
|
44
|
+
<!-- Call the original template -->
|
|
45
|
+
<xsl:apply-imports/>
|
|
46
|
+
<xsl:text>{% endraw %}
</xsl:text>
|
|
47
|
+
</xsl:template>
|
|
48
|
+
|
|
49
|
+
<!-- Overrride navigation template to prevent next button from being enabled -->
|
|
50
|
+
<xsl:template match="*" mode="next-linear-url"/>
|
|
51
|
+
|
|
52
|
+
<!-- Override the HTML default so file-wrap emits Runestone template hooks -->
|
|
53
|
+
<xsl:template match="*" mode="file-wrap-head-pre">
|
|
54
|
+
{% set using_ptx_base = "true" %}
|
|
55
|
+
<base>
|
|
56
|
+
<!-- avoid wonkiness with XSL {{ escaping. No spaces is important -->
|
|
57
|
+
<xsl:attribute name="href">{{base_url}}</xsl:attribute>
|
|
58
|
+
</base>
|
|
59
|
+
<!-- Call the original template just in case something is added there -->
|
|
60
|
+
<xsl:apply-imports/>
|
|
61
|
+
</xsl:template>
|
|
62
|
+
|
|
63
|
+
<!-- Override canonical link - don't want to generate the same value for -->
|
|
64
|
+
<!-- all pages and don't need to SEO the internal student pages -->
|
|
65
|
+
<xsl:template name="canonical-link"/>
|
|
66
|
+
|
|
67
|
+
<xsl:template match="*" mode="file-wrap-head-post">
|
|
68
|
+
<!-- Call the original template just in case something is added there -->
|
|
69
|
+
<xsl:apply-imports/>
|
|
70
|
+
<link href="/staticAssets/main-ptx-based.css" rel="stylesheet" />
|
|
71
|
+
<script>
|
|
72
|
+
window.addEventListener("DOMContentLoaded", () => {
|
|
73
|
+
const sidebar = document.getElementById("ptx-sidebar");
|
|
74
|
+
if (sidebar) {
|
|
75
|
+
sidebar.classList.add("hidden");
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
</script>
|
|
79
|
+
{% block css %}
|
|
80
|
+
{% endblock %}
|
|
81
|
+
</xsl:template>
|
|
82
|
+
|
|
83
|
+
<xsl:template match="*" mode="file-wrap-body-attr-extra">
|
|
84
|
+
<!-- Call the original template just in case something is added there -->
|
|
85
|
+
<xsl:apply-imports/>
|
|
86
|
+
<xsl:text> ptx-runestone-template</xsl:text>
|
|
87
|
+
</xsl:template>
|
|
88
|
+
|
|
89
|
+
<xsl:template match="*" mode="file-wrap-body-post">
|
|
90
|
+
<!-- Call the original template just in case something is added there -->
|
|
91
|
+
<xsl:apply-imports/>
|
|
92
|
+
<!-- rs footer -->
|
|
93
|
+
{% include 'footer.html' %}
|
|
94
|
+
<!-- scripts -->
|
|
95
|
+
<script>
|
|
96
|
+
<!-- hide sidebar by default in all themes -->
|
|
97
|
+
const sidebar = document.getElementById("ptx-sidebar");
|
|
98
|
+
if (sidebar) {
|
|
99
|
+
sidebar.classList.add("hidden");
|
|
100
|
+
}
|
|
101
|
+
</script>
|
|
102
|
+
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
|
|
103
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js"></script>
|
|
104
|
+
{% block js %}
|
|
105
|
+
{% endblock %}
|
|
106
|
+
</xsl:template>
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
<xsl:output method="html" indent="yes" encoding="UTF-8" doctype-system="about:legacy-compat" />
|
|
110
|
+
|
|
111
|
+
<xsl:template match="/">
|
|
112
|
+
<xsl:call-template name="runestone-page-template"/>
|
|
113
|
+
</xsl:template>
|
|
114
|
+
|
|
115
|
+
<xsl:template name="runestone-page-template">
|
|
116
|
+
<xsl:if test="$b-host-runestone and ($b-is-book or $b-is-article)">
|
|
117
|
+
<xsl:apply-templates select="$document-root" mode="runestone-page-template"/>
|
|
118
|
+
</xsl:if>
|
|
119
|
+
</xsl:template>
|
|
120
|
+
|
|
121
|
+
<xsl:template match="book|article" mode="runestone-page-template">
|
|
122
|
+
<xsl:apply-templates select="." mode="file-wrap">
|
|
123
|
+
<xsl:with-param name="filename">
|
|
124
|
+
<xsl:text>_base.html</xsl:text>
|
|
125
|
+
</xsl:with-param>
|
|
126
|
+
<xsl:with-param name="title">
|
|
127
|
+
<xsl:text>{% block title %}</xsl:text>
|
|
128
|
+
<xsl:apply-templates select="." mode="title-plain" />
|
|
129
|
+
<xsl:text>{% endblock %}</xsl:text>
|
|
130
|
+
</xsl:with-param>
|
|
131
|
+
<xsl:with-param name="b-include-bottom-nav" select="false()"/>
|
|
132
|
+
<xsl:with-param name="content">
|
|
133
|
+
{% block content %}
|
|
134
|
+
{% endblock %}
|
|
135
|
+
</xsl:with-param>
|
|
136
|
+
</xsl:apply-templates>
|
|
137
|
+
</xsl:template>
|
|
138
|
+
|
|
139
|
+
</xsl:stylesheet>
|
|
@@ -1,166 +1,166 @@
|
|
|
1
|
-
<?xml version='1.0'?>
|
|
2
|
-
|
|
3
|
-
<!--********************************************************************
|
|
4
|
-
Copyright 2014-2016 Robert A. Beezer
|
|
5
|
-
|
|
6
|
-
This file is part of MathBook XML.
|
|
7
|
-
|
|
8
|
-
MathBook XML is free software: you can redistribute it and/or modify
|
|
9
|
-
it under the terms of the GNU General Public License as published by
|
|
10
|
-
the Free Software Foundation, either version 2 or version 3 of the
|
|
11
|
-
License (at your option).
|
|
12
|
-
|
|
13
|
-
MathBook XML is distributed in the hope that it will be useful,
|
|
14
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
GNU General Public License for more details.
|
|
17
|
-
|
|
18
|
-
You should have received a copy of the GNU General Public License
|
|
19
|
-
along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
*********************************************************************-->
|
|
21
|
-
|
|
22
|
-
<!-- This stylesheet locates <sageplot> elements -->
|
|
23
|
-
<!-- and bundles them into a Sage/Python program -->
|
|
24
|
-
<!-- The program accepts one command-line parameter: -->
|
|
25
|
-
<!-- the file extension of the desired format -->
|
|
26
|
-
<!-- (i.e. svg, eps, pdf, png, etc) -->
|
|
27
|
-
<!-- N.B. 3D plots always render as PNG -->
|
|
28
|
-
|
|
29
|
-
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
30
|
-
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
|
31
|
-
xmlns:exsl="http://exslt.org/common"
|
|
32
|
-
extension-element-prefixes="exsl"
|
|
33
|
-
>
|
|
34
|
-
|
|
35
|
-
<!-- Get internal ID's for filenames, etc -->
|
|
36
|
-
<!-- Standard conversion groundwork -->
|
|
37
|
-
<xsl:import href="./publisher-variables.xsl"/>
|
|
38
|
-
<xsl:import href="./pretext-assembly.xsl"/>
|
|
39
|
-
<xsl:import href="./pretext-common.xsl"/>
|
|
40
|
-
|
|
41
|
-
<!-- Get a "subtree" xml:id value -->
|
|
42
|
-
<!-- Then walk the XML source tree -->
|
|
43
|
-
<!-- applying specializations below -->
|
|
44
|
-
<xsl:import href="./extract-identity.xsl" />
|
|
45
|
-
|
|
46
|
-
<!-- Output Sage code as text -->
|
|
47
|
-
<xsl:output method="text" encoding="UTF-8"/>
|
|
48
|
-
|
|
49
|
-
<!-- This stylesheet is parameterized by a requested file format to be -->
|
|
50
|
-
<!-- produced by Sage, which Sage picks up from file extensions in the -->
|
|
51
|
-
<!-- filename argument in a .save() method. We supply this from the -->
|
|
52
|
-
<!-- pretext/pretext script, so there is no error checking. Values -->
|
|
53
|
-
<!-- vary by the @variant of the "sageplot". *.png are low-quality -->
|
|
54
|
-
<!-- (not cropped tight), so even if possible for 2D graphics, we do -->
|
|
55
|
-
<!-- not build such a thing. Otherwise the formats are exclusive to -->
|
|
56
|
-
<!-- their variant (Sage capability). -->
|
|
57
|
-
<!-- -->
|
|
58
|
-
<!-- 2D variant: pdf (LaTeX), svg (HTML) formats -->
|
|
59
|
-
<!-- 3D variant: png (LaTeX), html (HTML) formats -->
|
|
60
|
-
|
|
61
|
-
<xsl:param name="sageplot.fileformat" select="'pdf'"/>
|
|
62
|
-
|
|
63
|
-
<!-- Sage graphics to standalone Sage/Python file -->
|
|
64
|
-
<xsl:template match="sageplot" mode="extraction">
|
|
65
|
-
<!-- Construct the file for Sage to execute -->
|
|
66
|
-
<!-- Convert final line to an assignment, so we can do save(s) -->
|
|
67
|
-
<!-- First, basename for the file (Sage input, image output) -->
|
|
68
|
-
<!-- Second, the (unique) name of the graphics object in Sage -->
|
|
69
|
-
<!-- (We do this first, so we can use "$filebase" below) -->
|
|
70
|
-
<xsl:variable name="filebase">
|
|
71
|
-
<xsl:apply-templates select="." mode="image-source-basename"/>
|
|
72
|
-
</xsl:variable>
|
|
73
|
-
<xsl:variable name="plot-name">
|
|
74
|
-
<xsl:text>plot_</xsl:text>
|
|
75
|
-
<xsl:value-of select="generate-id(.)" />
|
|
76
|
-
</xsl:variable>
|
|
77
|
-
<!-- Look to see if "sageplot" is building 2d or 3d -->
|
|
78
|
-
<xsl:variable name="variant">
|
|
79
|
-
<xsl:choose>
|
|
80
|
-
<!-- default is a 2d graphic -->
|
|
81
|
-
<xsl:when test="not(@variant)">
|
|
82
|
-
<xsl:text>2d</xsl:text>
|
|
83
|
-
</xsl:when>
|
|
84
|
-
<xsl:when test="@variant = '2d'">
|
|
85
|
-
<xsl:text>2d</xsl:text>
|
|
86
|
-
</xsl:when>
|
|
87
|
-
<xsl:when test="@variant = '3d'">
|
|
88
|
-
<xsl:text>3d</xsl:text>
|
|
89
|
-
</xsl:when>
|
|
90
|
-
<xsl:otherwise>
|
|
91
|
-
<xsl:message>PTX:ERROR: a "sageplot" has a @variant attribute ("<xsl:value-of select="@variant"/>") for "<xsl:value-of select="$filebase"/>" whose value is not "2d" nor "3d". The default ("2d") is being used, which could be incorrect</xsl:message>
|
|
92
|
-
<xsl:text>2d</xsl:text>
|
|
93
|
-
</xsl:otherwise>
|
|
94
|
-
</xsl:choose>
|
|
95
|
-
</xsl:variable>
|
|
96
|
-
<!-- has one trailing newline, which we ignore later (?) -->
|
|
97
|
-
<xsl:variable name="plot-code-sanitary">
|
|
98
|
-
<xsl:call-template name="sanitize-text">
|
|
99
|
-
<xsl:with-param name="text" select="." />
|
|
100
|
-
</xsl:call-template>
|
|
101
|
-
</xsl:variable>
|
|
102
|
-
<!-- remove the trailing newline provided by sanitization -->
|
|
103
|
-
<xsl:variable name="plot-code-trimmed" select="substring($plot-code-sanitary,1,string-length($plot-code-sanitary)-1)"/>
|
|
104
|
-
<!-- conditionally provide a breakpoint for single-line source -->
|
|
105
|
-
<xsl:variable name="plot-code">
|
|
106
|
-
<xsl:if test="not(contains($plot-code-trimmed, '
'))">
|
|
107
|
-
<xsl:text>
</xsl:text>
|
|
108
|
-
</xsl:if>
|
|
109
|
-
<xsl:value-of select="$plot-code-trimmed"/>
|
|
110
|
-
</xsl:variable>
|
|
111
|
-
<!-- split on last newline, which is first character for single-line source -->
|
|
112
|
-
<xsl:variable name="preamble">
|
|
113
|
-
<xsl:call-template name="substring-before-last">
|
|
114
|
-
<xsl:with-param name="input" select="$plot-code"/>
|
|
115
|
-
<xsl:with-param name="substr" select="'
'" />
|
|
116
|
-
</xsl:call-template>
|
|
117
|
-
</xsl:variable>
|
|
118
|
-
<xsl:variable name="plotcmd">
|
|
119
|
-
<xsl:call-template name="substring-after-last">
|
|
120
|
-
<xsl:with-param name="input" select="$plot-code"/>
|
|
121
|
-
<xsl:with-param name="substr" select="'
'" />
|
|
122
|
-
</xsl:call-template>
|
|
123
|
-
</xsl:variable>
|
|
124
|
-
<!-- NB: 2D PNG is not preferable, but needed for EPUB sent to Kindle -->
|
|
125
|
-
<xsl:variable name="b-legal-combination" select="($variant = '2d' and $sageplot.fileformat = 'pdf')
|
|
126
|
-
or ($variant = '2d' and $sageplot.fileformat = 'svg')
|
|
127
|
-
or ($variant = '2d' and $sageplot.fileformat = 'png')
|
|
128
|
-
or ($variant = '3d' and $sageplot.fileformat = 'png')
|
|
129
|
-
or ($variant = '3d' and $sageplot.fileformat = 'html')"/>
|
|
130
|
-
<!-- Only certain combinations are supported and only certain -->
|
|
131
|
-
<!-- combinations are needed in subsequent conversions. Yes, this -->
|
|
132
|
-
<!-- setup is all inefficient to just bail out now. -->
|
|
133
|
-
<!-- Do not use directories here, as Windows paths will get mangled -->
|
|
134
|
-
<!-- Instead, set working directory before applying stylesheet -->
|
|
135
|
-
<xsl:if test="$b-legal-combination">
|
|
136
|
-
<exsl:document href="{$filebase}.sage" method="text">
|
|
137
|
-
<!-- Duplicate most code, massage code at last line -->
|
|
138
|
-
<xsl:value-of select="$preamble" />
|
|
139
|
-
<xsl:text>
</xsl:text>
|
|
140
|
-
<xsl:value-of select="$plot-name" />
|
|
141
|
-
<xsl:text> = </xsl:text>
|
|
142
|
-
<xsl:value-of select="$plotcmd" />
|
|
143
|
-
<xsl:text>
</xsl:text>
|
|
144
|
-
<!-- We could build a try/except block here, where a ValueError -->
|
|
145
|
-
<!-- indicates a fileformat not supported, but we may have that -->
|
|
146
|
-
<!-- covered. Would need to get the exception out of the sage -->
|
|
147
|
-
<!-- executable invocation in the Python script to relay. -->
|
|
148
|
-
<xsl:value-of select="$plot-name" />
|
|
149
|
-
<xsl:text>.save('</xsl:text>
|
|
150
|
-
<xsl:value-of select="$filebase" />
|
|
151
|
-
<xsl:text>.</xsl:text>
|
|
152
|
-
<xsl:value-of select="$sageplot.fileformat"/>
|
|
153
|
-
<xsl:text>'</xsl:text>
|
|
154
|
-
<!-- Need to inform Sage display manager for 3d HTML that we -->
|
|
155
|
-
<!-- are not inside a notebook or the command-line and we -->
|
|
156
|
-
<!-- want self-contained threejs apllications with -->
|
|
157
|
-
<!-- Javascript coming from a CDN. -->
|
|
158
|
-
<xsl:if test="$sageplot.fileformat = 'html'">
|
|
159
|
-
<xsl:text>, online=True</xsl:text>
|
|
160
|
-
</xsl:if>
|
|
161
|
-
<xsl:text>)
</xsl:text>
|
|
162
|
-
</exsl:document>
|
|
163
|
-
</xsl:if>
|
|
164
|
-
</xsl:template>
|
|
165
|
-
|
|
166
|
-
</xsl:stylesheet>
|
|
1
|
+
<?xml version='1.0'?>
|
|
2
|
+
|
|
3
|
+
<!--********************************************************************
|
|
4
|
+
Copyright 2014-2016 Robert A. Beezer
|
|
5
|
+
|
|
6
|
+
This file is part of MathBook XML.
|
|
7
|
+
|
|
8
|
+
MathBook XML is free software: you can redistribute it and/or modify
|
|
9
|
+
it under the terms of the GNU General Public License as published by
|
|
10
|
+
the Free Software Foundation, either version 2 or version 3 of the
|
|
11
|
+
License (at your option).
|
|
12
|
+
|
|
13
|
+
MathBook XML is distributed in the hope that it will be useful,
|
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
You should have received a copy of the GNU General Public License
|
|
19
|
+
along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*********************************************************************-->
|
|
21
|
+
|
|
22
|
+
<!-- This stylesheet locates <sageplot> elements -->
|
|
23
|
+
<!-- and bundles them into a Sage/Python program -->
|
|
24
|
+
<!-- The program accepts one command-line parameter: -->
|
|
25
|
+
<!-- the file extension of the desired format -->
|
|
26
|
+
<!-- (i.e. svg, eps, pdf, png, etc) -->
|
|
27
|
+
<!-- N.B. 3D plots always render as PNG -->
|
|
28
|
+
|
|
29
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
30
|
+
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
|
31
|
+
xmlns:exsl="http://exslt.org/common"
|
|
32
|
+
extension-element-prefixes="exsl"
|
|
33
|
+
>
|
|
34
|
+
|
|
35
|
+
<!-- Get internal ID's for filenames, etc -->
|
|
36
|
+
<!-- Standard conversion groundwork -->
|
|
37
|
+
<xsl:import href="./publisher-variables.xsl"/>
|
|
38
|
+
<xsl:import href="./pretext-assembly.xsl"/>
|
|
39
|
+
<xsl:import href="./pretext-common.xsl"/>
|
|
40
|
+
|
|
41
|
+
<!-- Get a "subtree" xml:id value -->
|
|
42
|
+
<!-- Then walk the XML source tree -->
|
|
43
|
+
<!-- applying specializations below -->
|
|
44
|
+
<xsl:import href="./extract-identity.xsl" />
|
|
45
|
+
|
|
46
|
+
<!-- Output Sage code as text -->
|
|
47
|
+
<xsl:output method="text" encoding="UTF-8"/>
|
|
48
|
+
|
|
49
|
+
<!-- This stylesheet is parameterized by a requested file format to be -->
|
|
50
|
+
<!-- produced by Sage, which Sage picks up from file extensions in the -->
|
|
51
|
+
<!-- filename argument in a .save() method. We supply this from the -->
|
|
52
|
+
<!-- pretext/pretext script, so there is no error checking. Values -->
|
|
53
|
+
<!-- vary by the @variant of the "sageplot". *.png are low-quality -->
|
|
54
|
+
<!-- (not cropped tight), so even if possible for 2D graphics, we do -->
|
|
55
|
+
<!-- not build such a thing. Otherwise the formats are exclusive to -->
|
|
56
|
+
<!-- their variant (Sage capability). -->
|
|
57
|
+
<!-- -->
|
|
58
|
+
<!-- 2D variant: pdf (LaTeX), svg (HTML) formats -->
|
|
59
|
+
<!-- 3D variant: png (LaTeX), html (HTML) formats -->
|
|
60
|
+
|
|
61
|
+
<xsl:param name="sageplot.fileformat" select="'pdf'"/>
|
|
62
|
+
|
|
63
|
+
<!-- Sage graphics to standalone Sage/Python file -->
|
|
64
|
+
<xsl:template match="sageplot" mode="extraction">
|
|
65
|
+
<!-- Construct the file for Sage to execute -->
|
|
66
|
+
<!-- Convert final line to an assignment, so we can do save(s) -->
|
|
67
|
+
<!-- First, basename for the file (Sage input, image output) -->
|
|
68
|
+
<!-- Second, the (unique) name of the graphics object in Sage -->
|
|
69
|
+
<!-- (We do this first, so we can use "$filebase" below) -->
|
|
70
|
+
<xsl:variable name="filebase">
|
|
71
|
+
<xsl:apply-templates select="." mode="image-source-basename"/>
|
|
72
|
+
</xsl:variable>
|
|
73
|
+
<xsl:variable name="plot-name">
|
|
74
|
+
<xsl:text>plot_</xsl:text>
|
|
75
|
+
<xsl:value-of select="generate-id(.)" />
|
|
76
|
+
</xsl:variable>
|
|
77
|
+
<!-- Look to see if "sageplot" is building 2d or 3d -->
|
|
78
|
+
<xsl:variable name="variant">
|
|
79
|
+
<xsl:choose>
|
|
80
|
+
<!-- default is a 2d graphic -->
|
|
81
|
+
<xsl:when test="not(@variant)">
|
|
82
|
+
<xsl:text>2d</xsl:text>
|
|
83
|
+
</xsl:when>
|
|
84
|
+
<xsl:when test="@variant = '2d'">
|
|
85
|
+
<xsl:text>2d</xsl:text>
|
|
86
|
+
</xsl:when>
|
|
87
|
+
<xsl:when test="@variant = '3d'">
|
|
88
|
+
<xsl:text>3d</xsl:text>
|
|
89
|
+
</xsl:when>
|
|
90
|
+
<xsl:otherwise>
|
|
91
|
+
<xsl:message>PTX:ERROR: a "sageplot" has a @variant attribute ("<xsl:value-of select="@variant"/>") for "<xsl:value-of select="$filebase"/>" whose value is not "2d" nor "3d". The default ("2d") is being used, which could be incorrect</xsl:message>
|
|
92
|
+
<xsl:text>2d</xsl:text>
|
|
93
|
+
</xsl:otherwise>
|
|
94
|
+
</xsl:choose>
|
|
95
|
+
</xsl:variable>
|
|
96
|
+
<!-- has one trailing newline, which we ignore later (?) -->
|
|
97
|
+
<xsl:variable name="plot-code-sanitary">
|
|
98
|
+
<xsl:call-template name="sanitize-text">
|
|
99
|
+
<xsl:with-param name="text" select="." />
|
|
100
|
+
</xsl:call-template>
|
|
101
|
+
</xsl:variable>
|
|
102
|
+
<!-- remove the trailing newline provided by sanitization -->
|
|
103
|
+
<xsl:variable name="plot-code-trimmed" select="substring($plot-code-sanitary,1,string-length($plot-code-sanitary)-1)"/>
|
|
104
|
+
<!-- conditionally provide a breakpoint for single-line source -->
|
|
105
|
+
<xsl:variable name="plot-code">
|
|
106
|
+
<xsl:if test="not(contains($plot-code-trimmed, '
'))">
|
|
107
|
+
<xsl:text>
</xsl:text>
|
|
108
|
+
</xsl:if>
|
|
109
|
+
<xsl:value-of select="$plot-code-trimmed"/>
|
|
110
|
+
</xsl:variable>
|
|
111
|
+
<!-- split on last newline, which is first character for single-line source -->
|
|
112
|
+
<xsl:variable name="preamble">
|
|
113
|
+
<xsl:call-template name="substring-before-last">
|
|
114
|
+
<xsl:with-param name="input" select="$plot-code"/>
|
|
115
|
+
<xsl:with-param name="substr" select="'
'" />
|
|
116
|
+
</xsl:call-template>
|
|
117
|
+
</xsl:variable>
|
|
118
|
+
<xsl:variable name="plotcmd">
|
|
119
|
+
<xsl:call-template name="substring-after-last">
|
|
120
|
+
<xsl:with-param name="input" select="$plot-code"/>
|
|
121
|
+
<xsl:with-param name="substr" select="'
'" />
|
|
122
|
+
</xsl:call-template>
|
|
123
|
+
</xsl:variable>
|
|
124
|
+
<!-- NB: 2D PNG is not preferable, but needed for EPUB sent to Kindle -->
|
|
125
|
+
<xsl:variable name="b-legal-combination" select="($variant = '2d' and $sageplot.fileformat = 'pdf')
|
|
126
|
+
or ($variant = '2d' and $sageplot.fileformat = 'svg')
|
|
127
|
+
or ($variant = '2d' and $sageplot.fileformat = 'png')
|
|
128
|
+
or ($variant = '3d' and $sageplot.fileformat = 'png')
|
|
129
|
+
or ($variant = '3d' and $sageplot.fileformat = 'html')"/>
|
|
130
|
+
<!-- Only certain combinations are supported and only certain -->
|
|
131
|
+
<!-- combinations are needed in subsequent conversions. Yes, this -->
|
|
132
|
+
<!-- setup is all inefficient to just bail out now. -->
|
|
133
|
+
<!-- Do not use directories here, as Windows paths will get mangled -->
|
|
134
|
+
<!-- Instead, set working directory before applying stylesheet -->
|
|
135
|
+
<xsl:if test="$b-legal-combination">
|
|
136
|
+
<exsl:document href="{$filebase}.sage" method="text">
|
|
137
|
+
<!-- Duplicate most code, massage code at last line -->
|
|
138
|
+
<xsl:value-of select="$preamble" />
|
|
139
|
+
<xsl:text>
</xsl:text>
|
|
140
|
+
<xsl:value-of select="$plot-name" />
|
|
141
|
+
<xsl:text> = </xsl:text>
|
|
142
|
+
<xsl:value-of select="$plotcmd" />
|
|
143
|
+
<xsl:text>
</xsl:text>
|
|
144
|
+
<!-- We could build a try/except block here, where a ValueError -->
|
|
145
|
+
<!-- indicates a fileformat not supported, but we may have that -->
|
|
146
|
+
<!-- covered. Would need to get the exception out of the sage -->
|
|
147
|
+
<!-- executable invocation in the Python script to relay. -->
|
|
148
|
+
<xsl:value-of select="$plot-name" />
|
|
149
|
+
<xsl:text>.save('</xsl:text>
|
|
150
|
+
<xsl:value-of select="$filebase" />
|
|
151
|
+
<xsl:text>.</xsl:text>
|
|
152
|
+
<xsl:value-of select="$sageplot.fileformat"/>
|
|
153
|
+
<xsl:text>'</xsl:text>
|
|
154
|
+
<!-- Need to inform Sage display manager for 3d HTML that we -->
|
|
155
|
+
<!-- are not inside a notebook or the command-line and we -->
|
|
156
|
+
<!-- want self-contained threejs apllications with -->
|
|
157
|
+
<!-- Javascript coming from a CDN. -->
|
|
158
|
+
<xsl:if test="$sageplot.fileformat = 'html'">
|
|
159
|
+
<xsl:text>, online=True</xsl:text>
|
|
160
|
+
</xsl:if>
|
|
161
|
+
<xsl:text>)
</xsl:text>
|
|
162
|
+
</exsl:document>
|
|
163
|
+
</xsl:if>
|
|
164
|
+
</xsl:template>
|
|
165
|
+
|
|
166
|
+
</xsl:stylesheet>
|