@pretextbook/pretext-html 0.1.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.
Files changed (110) hide show
  1. package/README.md +160 -0
  2. package/assets/preview-html.xsl +230 -0
  3. package/assets/upstream.json +7 -0
  4. package/assets/xsl/README.md +31 -0
  5. package/assets/xsl/entities.ent +154 -0
  6. package/assets/xsl/extract-asymptote.xsl +68 -0
  7. package/assets/xsl/extract-biblio-csl.xsl +327 -0
  8. package/assets/xsl/extract-datafile.xsl +71 -0
  9. package/assets/xsl/extract-dynamic.xsl +139 -0
  10. package/assets/xsl/extract-identity.xsl +136 -0
  11. package/assets/xsl/extract-interactive.xsl +81 -0
  12. package/assets/xsl/extract-latex-image.xsl +118 -0
  13. package/assets/xsl/extract-mermaid.xsl +58 -0
  14. package/assets/xsl/extract-mom.xsl +63 -0
  15. package/assets/xsl/extract-pg.xsl +2897 -0
  16. package/assets/xsl/extract-prefigure.xsl +157 -0
  17. package/assets/xsl/extract-qrcode.xsl +100 -0
  18. package/assets/xsl/extract-runestone-page-template.xsl +139 -0
  19. package/assets/xsl/extract-sageplot.xsl +166 -0
  20. package/assets/xsl/extract-stack.xsl +56 -0
  21. package/assets/xsl/extract-trace.xsl +134 -0
  22. package/assets/xsl/extract-youtube.xsl +63 -0
  23. package/assets/xsl/html-symbols.xsl +3344 -0
  24. package/assets/xsl/latex/pretext-latex-AIM.xsl +56 -0
  25. package/assets/xsl/latex/pretext-latex-CLP.xsl +148 -0
  26. package/assets/xsl/latex/pretext-latex-chaos.xsl +317 -0
  27. package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +76 -0
  28. package/assets/xsl/latex/pretext-latex-guide.xsl +104 -0
  29. package/assets/xsl/latex/pretext-latex-texstyle.xsl +862 -0
  30. package/assets/xsl/localizations/README.md +56 -0
  31. package/assets/xsl/localizations/af-ZA.xml +276 -0
  32. package/assets/xsl/localizations/bg-BG.xml +276 -0
  33. package/assets/xsl/localizations/ca-ES.xml +285 -0
  34. package/assets/xsl/localizations/cs-CZ.xml +280 -0
  35. package/assets/xsl/localizations/de-DE.xml +281 -0
  36. package/assets/xsl/localizations/en-US.xml +427 -0
  37. package/assets/xsl/localizations/es-ES.xml +287 -0
  38. package/assets/xsl/localizations/fi-FI.xml +275 -0
  39. package/assets/xsl/localizations/fr-CA.xml +276 -0
  40. package/assets/xsl/localizations/fr-FR.xml +280 -0
  41. package/assets/xsl/localizations/hu-HU.xml +280 -0
  42. package/assets/xsl/localizations/it-IT.xml +276 -0
  43. package/assets/xsl/localizations/ku-CKB.xml +275 -0
  44. package/assets/xsl/localizations/localizations.xml +48 -0
  45. package/assets/xsl/localizations/nl-NL.xml +275 -0
  46. package/assets/xsl/localizations/pt-BR.xml +288 -0
  47. package/assets/xsl/localizations/pt-PT.xml +292 -0
  48. package/assets/xsl/localizations/zh-HANS.xml +269 -0
  49. package/assets/xsl/pretext-assembly.xsl +4795 -0
  50. package/assets/xsl/pretext-basic-html.xsl +86 -0
  51. package/assets/xsl/pretext-beamer.xsl +662 -0
  52. package/assets/xsl/pretext-braille-preprint.xsl +2249 -0
  53. package/assets/xsl/pretext-common.xsl +12018 -0
  54. package/assets/xsl/pretext-dynamic.xsl +65 -0
  55. package/assets/xsl/pretext-epub.xsl +1483 -0
  56. package/assets/xsl/pretext-fo.xsl +4593 -0
  57. package/assets/xsl/pretext-html.xsl +14791 -0
  58. package/assets/xsl/pretext-json-manifest.xsl +150 -0
  59. package/assets/xsl/pretext-jupyter.xsl +868 -0
  60. package/assets/xsl/pretext-latex-classic.xsl +952 -0
  61. package/assets/xsl/pretext-latex-common.xsl +11563 -0
  62. package/assets/xsl/pretext-latex.xsl +47 -0
  63. package/assets/xsl/pretext-litprog.xsl +105 -0
  64. package/assets/xsl/pretext-merge.xsl +41 -0
  65. package/assets/xsl/pretext-numbers.xsl +875 -0
  66. package/assets/xsl/pretext-revealjs.xsl +522 -0
  67. package/assets/xsl/pretext-runestone-fitb.xsl +1233 -0
  68. package/assets/xsl/pretext-runestone-static.xsl +1438 -0
  69. package/assets/xsl/pretext-runestone.xsl +3083 -0
  70. package/assets/xsl/pretext-sage-doctest.xsl +289 -0
  71. package/assets/xsl/pretext-smc.xsl +492 -0
  72. package/assets/xsl/pretext-solution-manual-latex.xsl +323 -0
  73. package/assets/xsl/pretext-text-utilities.xsl +1217 -0
  74. package/assets/xsl/pretext-text.xsl +392 -0
  75. package/assets/xsl/pretext-units.xsl +195 -0
  76. package/assets/xsl/pretext-view-source.xsl +157 -0
  77. package/assets/xsl/pretext-ww-problem-sets.xsl +391 -0
  78. package/assets/xsl/publisher-variables.xsl +4756 -0
  79. package/assets/xsl/support/README.md +22 -0
  80. package/assets/xsl/support/extract-math.xsl +256 -0
  81. package/assets/xsl/support/package-math.xsl +141 -0
  82. package/assets/xsl/support/play-button/README.md +46 -0
  83. package/assets/xsl/support/play-button/play-button.png +0 -0
  84. package/assets/xsl/support/play-button/play-button.svg +3 -0
  85. package/assets/xsl/support/pretext-pg-macros.xsl +110 -0
  86. package/assets/xsl/support/webpack_static_imports.xml +14 -0
  87. package/assets/xsl/tests/README.md +24 -0
  88. package/assets/xsl/tests/null.xml +4 -0
  89. package/assets/xsl/tests/pretext-text-utilities-test.xsl +334 -0
  90. package/assets/xsl/utilities/README.md +31 -0
  91. package/assets/xsl/utilities/author-report.xsl +107 -0
  92. package/assets/xsl/utilities/deprecate-autoname.sed +18 -0
  93. package/assets/xsl/utilities/deprecate-index.sed +33 -0
  94. package/assets/xsl/utilities/fix-deprecations.xsl +663 -0
  95. package/assets/xsl/utilities/pretext-enhanced-source.xsl +112 -0
  96. package/assets/xsl/utilities/report-publisher-variables.xsl +162 -0
  97. package/assets/xsl/xml-to-json.xsl +326 -0
  98. package/assets/xsl/xml-to-string.xsl +328 -0
  99. package/cli.mjs +29 -0
  100. package/dist/cli-C6tfAVvi.js +553 -0
  101. package/dist/cli.d.ts +10 -0
  102. package/dist/cli.js +7 -0
  103. package/dist/index.d.ts +6 -0
  104. package/dist/index.js +10 -0
  105. package/dist/mounts.d.ts +23 -0
  106. package/dist/publication.d.ts +16 -0
  107. package/dist/renderer.d.ts +84 -0
  108. package/dist/sourcemap.d.ts +41 -0
  109. package/dist/xinclude.d.ts +45 -0
  110. package/package.json +52 -0
@@ -0,0 +1,157 @@
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 <prefigure> elements and copies them for processing -->
23
+
24
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
25
+ xmlns:xml="http://www.w3.org/XML/1998/namespace"
26
+ xmlns:exsl="http://exslt.org/common"
27
+ xmlns:pf="https://prefigure.org"
28
+ extension-element-prefixes="exsl"
29
+ >
30
+
31
+ <!-- Get internal ID's for filenames, etc -->
32
+ <!-- Standard conversion groundwork -->
33
+ <xsl:import href="./publisher-variables.xsl"/>
34
+ <xsl:import href="./pretext-assembly.xsl"/>
35
+ <xsl:import href="./pretext-common.xsl"/>
36
+
37
+ <!-- Get a "subtree" xml:id value -->
38
+ <!-- Then walk the XML source tree -->
39
+ <!-- applying specializations below -->
40
+ <xsl:import href="./extract-identity.xsl" />
41
+
42
+ <!-- Output PreFigure XML -->
43
+ <xsl:output method="xml" encoding="UTF-8"/>
44
+
45
+ <!-- PreFigure graphics to standalone file -->
46
+ <!-- NB: don't match the empty element that is a text -->
47
+ <!-- generator. Once PreFigure has a namespace, then -->
48
+ <!-- it should be used here instead. -->
49
+ <xsl:template match="pf:prefigure[node()]" mode="extraction">
50
+ <xsl:variable name="filebase">
51
+ <xsl:apply-templates select="." mode="image-source-basename"/>
52
+ </xsl:variable>
53
+ <!-- Do not use directories here, as Windows paths will get mangled -->
54
+ <!-- Instead, set working directory before applying stylesheet -->
55
+ <exsl:document href="{$filebase}.xml" method="xml">
56
+ <!-- xerox the "prefigure" element, but with modifications -->
57
+ <xsl:apply-templates select="." mode="prefigure-edit"/>
58
+ </exsl:document>
59
+ </xsl:template>
60
+
61
+ <!-- Identity template, with a mode, so we can edit a diagram -->
62
+ <!-- NB: it does not seem the "pf:" is necessary here -->
63
+ <xsl:template match="node()|@*" mode="prefigure-edit">
64
+ <xsl:copy>
65
+ <xsl:apply-templates select="node()|@*" mode="prefigure-edit"/>
66
+ </xsl:copy>
67
+ </xsl:template>
68
+
69
+ <!-- Raison d'etre for "prefigure-edit": insert a PF "caption" with -->
70
+ <!-- a type-name/number pair and a document-wide serial number -->
71
+ <xsl:template match="pf:diagram" mode="prefigure-edit">
72
+ <xsl:copy>
73
+ <xsl:apply-templates select="@*" mode="prefigure-edit"/>
74
+ <!-- insert a PF "caption", hopefully with helpful content -->
75
+ <!-- duplicate indentation of first child of "diagram" to -->
76
+ <!-- make insertion of the first new children look good -->
77
+ <xsl:value-of select="text()[1]"/>
78
+ <xsl:comment> Reference to containing ancestor comes from PreTeXt context </xsl:comment>
79
+ <xsl:value-of select="text()[1]"/>
80
+ <xsl:comment> Serial number is from document-wide count of PreFigure diagrams </xsl:comment>
81
+ <xsl:value-of select="text()[1]"/>
82
+ <xsl:element name="caption" namespace="https://prefigure.org">
83
+ <!-- pf:diagram, pf:prefigure, and "image" all lack meaningful -->
84
+ <!-- numbers, so start searching for a [location with a number] -->
85
+ <!-- from the parent of the "image" -->
86
+ <xsl:apply-templates select="parent::pf:prefigure/parent::image/parent::*" mode="prefigure-container"/>
87
+ <!-- previous template supplies a space, if it provides a type/number pair -->
88
+ <!-- Serial number, just document-wide for pf:prefigure -->
89
+ <!-- NB: implement this as part of the overall numbering -->
90
+ <!-- scheme, so it comes through as an attribute. -->
91
+ <xsl:text>(</xsl:text>
92
+ <!-- pf:diagram is current context, no danger that an empty "pretext" -->
93
+ <!-- generator will be mistakenly used for the @from pattern -->
94
+ <xsl:number count="pf:prefigure" from="pretext" level="any"/>
95
+ <xsl:text>)</xsl:text>
96
+ </xsl:element>
97
+ <!-- xerox remaining elements -->
98
+ <xsl:apply-templates select="node()" mode="prefigure-edit"/>
99
+ </xsl:copy>
100
+ </xsl:template>
101
+
102
+ <!-- Recurse up the tree, looking for the first element with a -->
103
+ <!-- non-empty number. Produce type-name and a serial number. -->
104
+ <xsl:template match="*" mode="prefigure-container">
105
+ <!-- Will test on non-empty number strings. This can be -->
106
+ <!-- fooled by elements with un-implemented numbers such -->
107
+ <!-- as a pure container like a "sidebyside". -->
108
+ <xsl:variable name="the-number">
109
+ <xsl:apply-templates select="." mode="number"/>
110
+ </xsl:variable>
111
+
112
+ <xsl:choose>
113
+ <!-- this is the safety-valve halting condition -->
114
+ <xsl:when test="self::pretext"/>
115
+ <!-- Test here for useless containers that have better parents. -->
116
+ <!-- Examples might be a "case" in a "proof" or a "task" in an -->
117
+ <!-- "exercise" or an "li" in an "ol". -->
118
+ <!-- Then recurse with the parent, as below. -->
119
+ <xsl:when test="not($the-number = '')">
120
+ <xsl:apply-templates select="." mode="type-name" />
121
+ <xsl:text> </xsl:text>
122
+ <xsl:value-of select="$the-number"/>
123
+ <!-- will always follow with a serial number, -->
124
+ <!-- so add a space here, since conditional -->
125
+ <xsl:text> </xsl:text>
126
+ <!-- mission accomplished, no more recursion -->
127
+ </xsl:when>
128
+ <xsl:otherwise>
129
+ <!-- step-up (recurse) to the parent -->
130
+ <xsl:apply-templates select="parent::*" mode="prefigure-container"/>
131
+ </xsl:otherwise>
132
+ </xsl:choose>
133
+ </xsl:template>
134
+
135
+ <!-- PreFigure publication file -->
136
+ <!-- We need a one-off generation of a PreFigure publication -->
137
+ <!-- file, dumped in the same directory as the extracted source -->
138
+ <!-- diagrams. So we match the *only* guaranteed node and let -->
139
+ <!-- it do its thing, and then create the necessary file. -->
140
+ <xsl:template match="/">
141
+ <xsl:apply-imports/>
142
+ <exsl:document href="pf_publication.xml" method="xml">
143
+ <xsl:element name="prefigure" namespace="https://prefigure.org">
144
+ <!-- No "prefigure-preamble" => nothing produced -->
145
+ <xsl:copy-of select="$docinfo/pf:prefigure-preamble/*"/>
146
+ <!-- $latex-macros is never empty (<, >, &) so always a "macros" -->
147
+ <xsl:element name="macros" namespace="https://prefigure.org">
148
+ <!-- move to a new line for minimal readability -->
149
+ <xsl:text>&#xa;</xsl:text>
150
+ <!-- global variable in -common, includes \lt, \gt, \amp -->
151
+ <xsl:value-of select="$latex-macros"/>
152
+ </xsl:element>
153
+ </xsl:element>
154
+ </exsl:document>
155
+ </xsl:template>
156
+
157
+ </xsl:stylesheet>
@@ -0,0 +1,100 @@
1
+ <?xml version='1.0'?>
2
+
3
+ <!--********************************************************************
4
+ Copyright 2014-2016 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
+ <!-- This stylesheet extracts URL information for audio, video, -->
23
+ <!-- and interactive elements. For each, it writes a sidecar -->
24
+ <!-- XML file (via exsl:document) containing a standalone URL -->
25
+ <!-- and an in-context URL, used later for QR code generation -->
26
+ <!-- (Python) and for links in static representations -->
27
+ <!-- (pretext-assembly.xsl). -->
28
+ <!-- -->
29
+ <!-- It is hard to get a link into chunked HTML while actually -->
30
+ <!-- building generic PreTeXt for a static representation. The -->
31
+ <!-- chunking level and file extension are format-specific, but -->
32
+ <!-- assembly must remain format-neutral. So we set HTML- -->
33
+ <!-- specific variables ($chunk-level, $file-extension) here in -->
34
+ <!-- the extraction stylesheet, which has the highest import -->
35
+ <!-- precedence. Assembly then reads the pre-computed URLs from -->
36
+ <!-- the sidecar files rather than computing them itself. -->
37
+
38
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
39
+ xmlns:xml="http://www.w3.org/XML/1998/namespace"
40
+ xmlns:exsl="http://exslt.org/common"
41
+ xmlns:str="http://exslt.org/strings"
42
+ xmlns:pi="http://pretextbook.org/2020/pretext/internal"
43
+ extension-element-prefixes="exsl"
44
+ >
45
+
46
+ <!-- Get internal ID's for filenames, etc -->
47
+ <!-- Standard conversion groundwork -->
48
+ <xsl:import href="./publisher-variables.xsl"/>
49
+ <xsl:import href="./pretext-assembly.xsl"/>
50
+ <xsl:import href="./pretext-common.xsl"/>
51
+
52
+ <!-- Get a "subtree" xml:id value -->
53
+ <!-- Then walk the XML source tree -->
54
+ <!-- applying specializations below -->
55
+ <xsl:import href="./extract-identity.xsl" />
56
+
57
+ <xsl:output method="text" encoding="UTF-8"/>
58
+
59
+ <!-- Avoid Catch-22: default assembly/pre-processor provides output -->
60
+ <!-- for a conversion to a static format, but that format will -->
61
+ <!-- *replace* "audio", "video", "interactive" by a static version -->
62
+ <!-- (a "sidebyside") and it will not be available for extraction. -->
63
+ <xsl:variable name="exercise-style" select="'dynamic'"/>
64
+
65
+ <!-- In "normal" circumstances, this variable is -->
66
+ <!-- set to "false()", but when employing this -->
67
+ <!-- specialized stylesheet, we override to "true" -->
68
+ <xsl:variable name="b-extracting-qrcode" select="true()"/>
69
+
70
+ <!-- Set HTML-specific variables so that "containing-filename" -->
71
+ <!-- (used by "context-url") produces correct HTML filenames. -->
72
+ <!-- These override the abstract defaults in pretext-common.xsl -->
73
+ <!-- by virtue of this stylesheet's higher import precedence. -->
74
+ <xsl:variable name="chunk-level" select="$html-chunk-level"/>
75
+ <xsl:variable name="file-extension" select="'.html'"/>
76
+
77
+ <xsl:template match="audio[@source|@href]|video[@source|@href|@youtube|@youtubeplaylist|@vimeo]|interactive" mode="extraction">
78
+ <!-- Sidecar XML file with pre-computed URLs for use -->
79
+ <!-- by pretext-assembly.xsl when building static -->
80
+ <!-- representations, and by the Python script when -->
81
+ <!-- generating QR code images. -->
82
+ <xsl:variable name="the-id">
83
+ <xsl:apply-templates select="." mode="visible-id"/>
84
+ </xsl:variable>
85
+ <exsl:document href="{$the-id}-url.xml" method="xml">
86
+ <pi:qrcode-urls>
87
+ <pi:standalone-url>
88
+ <xsl:apply-templates select="." mode="static-url"/>
89
+ </pi:standalone-url>
90
+ <pi:context-url>
91
+ <xsl:apply-templates select="." mode="context-url"/>
92
+ </pi:context-url>
93
+ <pi:embed-iframe-url>
94
+ <xsl:apply-templates select="." mode="embed-iframe-url"/>
95
+ </pi:embed-iframe-url>
96
+ </pi:qrcode-urls>
97
+ </exsl:document>
98
+ </xsl:template>
99
+
100
+ </xsl:stylesheet>
@@ -0,0 +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 %}&#xa;</xsl:text>
44
+ <!-- Call the original template -->
45
+ <xsl:apply-imports/>
46
+ <xsl:text>{% endraw %}&#xa;</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>
@@ -0,0 +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, '&#xa;'))">
107
+ <xsl:text>&#xa;</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="'&#xa;'" />
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="'&#xa;'" />
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>&#xa;</xsl:text>
140
+ <xsl:value-of select="$plot-name" />
141
+ <xsl:text> = </xsl:text>
142
+ <xsl:value-of select="$plotcmd" />
143
+ <xsl:text>&#xa;</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>)&#xa;</xsl:text>
162
+ </exsl:document>
163
+ </xsl:if>
164
+ </xsl:template>
165
+
166
+ </xsl:stylesheet>
@@ -0,0 +1,56 @@
1
+ <?xml version='1.0'?>
2
+
3
+ <!--********************************************************************
4
+ Copyright 2014-2016 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
+ <!-- This stylesheet locates all exercise/stack elements and -->
23
+ <!-- writes out a single file listing the @source attribute value -->
24
+ <!-- for eaCh one (the files with these names will be sent to a -->
25
+ <!-- server for conversion to static forms) -->
26
+
27
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
28
+ xmlns:xml="http://www.w3.org/XML/1998/namespace"
29
+ xmlns:exsl="http://exslt.org/common"
30
+ extension-element-prefixes="exsl"
31
+ >
32
+
33
+ <!-- Get internal ID's for filenames, etc -->
34
+ <!-- Standard conversion groundwork -->
35
+ <xsl:import href="./publisher-variables.xsl"/>
36
+ <xsl:import href="./pretext-assembly.xsl"/>
37
+ <xsl:import href="./pretext-common.xsl"/>
38
+
39
+ <!-- Get a "subtree" xml:id value -->
40
+ <!-- Then walk the XML source tree -->
41
+ <!-- applying specializations below -->
42
+ <xsl:import href="./extract-identity.xsl" />
43
+
44
+ <xsl:output method="text" encoding="UTF-8"/>
45
+
46
+ <!-- Flag an extraction pass, so pretext-assembly does not get confused -->
47
+ <xsl:variable name="b-extracting-stack" select="true()"/>
48
+
49
+ <xsl:template match="exercise/stack" mode="extraction">
50
+ <xsl:value-of select="@source"/>
51
+ <xsl:text> </xsl:text>
52
+ <xsl:apply-templates select="." mode="assembly-id"/>
53
+ <xsl:text>&#xa;</xsl:text>
54
+ </xsl:template>
55
+
56
+ </xsl:stylesheet>