@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.
- package/README.md +160 -0
- package/assets/preview-html.xsl +230 -0
- package/assets/upstream.json +7 -0
- package/assets/xsl/README.md +31 -0
- package/assets/xsl/entities.ent +154 -0
- package/assets/xsl/extract-asymptote.xsl +68 -0
- package/assets/xsl/extract-biblio-csl.xsl +327 -0
- package/assets/xsl/extract-datafile.xsl +71 -0
- package/assets/xsl/extract-dynamic.xsl +139 -0
- package/assets/xsl/extract-identity.xsl +136 -0
- package/assets/xsl/extract-interactive.xsl +81 -0
- package/assets/xsl/extract-latex-image.xsl +118 -0
- package/assets/xsl/extract-mermaid.xsl +58 -0
- package/assets/xsl/extract-mom.xsl +63 -0
- package/assets/xsl/extract-pg.xsl +2897 -0
- package/assets/xsl/extract-prefigure.xsl +157 -0
- package/assets/xsl/extract-qrcode.xsl +100 -0
- package/assets/xsl/extract-runestone-page-template.xsl +139 -0
- package/assets/xsl/extract-sageplot.xsl +166 -0
- package/assets/xsl/extract-stack.xsl +56 -0
- package/assets/xsl/extract-trace.xsl +134 -0
- package/assets/xsl/extract-youtube.xsl +63 -0
- package/assets/xsl/html-symbols.xsl +3344 -0
- package/assets/xsl/latex/pretext-latex-AIM.xsl +56 -0
- package/assets/xsl/latex/pretext-latex-CLP.xsl +148 -0
- package/assets/xsl/latex/pretext-latex-chaos.xsl +317 -0
- package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +76 -0
- package/assets/xsl/latex/pretext-latex-guide.xsl +104 -0
- package/assets/xsl/latex/pretext-latex-texstyle.xsl +862 -0
- package/assets/xsl/localizations/README.md +56 -0
- package/assets/xsl/localizations/af-ZA.xml +276 -0
- package/assets/xsl/localizations/bg-BG.xml +276 -0
- package/assets/xsl/localizations/ca-ES.xml +285 -0
- package/assets/xsl/localizations/cs-CZ.xml +280 -0
- package/assets/xsl/localizations/de-DE.xml +281 -0
- package/assets/xsl/localizations/en-US.xml +427 -0
- package/assets/xsl/localizations/es-ES.xml +287 -0
- package/assets/xsl/localizations/fi-FI.xml +275 -0
- package/assets/xsl/localizations/fr-CA.xml +276 -0
- package/assets/xsl/localizations/fr-FR.xml +280 -0
- package/assets/xsl/localizations/hu-HU.xml +280 -0
- package/assets/xsl/localizations/it-IT.xml +276 -0
- package/assets/xsl/localizations/ku-CKB.xml +275 -0
- package/assets/xsl/localizations/localizations.xml +48 -0
- package/assets/xsl/localizations/nl-NL.xml +275 -0
- package/assets/xsl/localizations/pt-BR.xml +288 -0
- package/assets/xsl/localizations/pt-PT.xml +292 -0
- package/assets/xsl/localizations/zh-HANS.xml +269 -0
- package/assets/xsl/pretext-assembly.xsl +4795 -0
- package/assets/xsl/pretext-basic-html.xsl +86 -0
- package/assets/xsl/pretext-beamer.xsl +662 -0
- package/assets/xsl/pretext-braille-preprint.xsl +2249 -0
- package/assets/xsl/pretext-common.xsl +12018 -0
- package/assets/xsl/pretext-dynamic.xsl +65 -0
- package/assets/xsl/pretext-epub.xsl +1483 -0
- package/assets/xsl/pretext-fo.xsl +4593 -0
- package/assets/xsl/pretext-html.xsl +14791 -0
- package/assets/xsl/pretext-json-manifest.xsl +150 -0
- package/assets/xsl/pretext-jupyter.xsl +868 -0
- package/assets/xsl/pretext-latex-classic.xsl +952 -0
- package/assets/xsl/pretext-latex-common.xsl +11563 -0
- package/assets/xsl/pretext-latex.xsl +47 -0
- package/assets/xsl/pretext-litprog.xsl +105 -0
- package/assets/xsl/pretext-merge.xsl +41 -0
- package/assets/xsl/pretext-numbers.xsl +875 -0
- package/assets/xsl/pretext-revealjs.xsl +522 -0
- package/assets/xsl/pretext-runestone-fitb.xsl +1233 -0
- package/assets/xsl/pretext-runestone-static.xsl +1438 -0
- package/assets/xsl/pretext-runestone.xsl +3083 -0
- package/assets/xsl/pretext-sage-doctest.xsl +289 -0
- package/assets/xsl/pretext-smc.xsl +492 -0
- package/assets/xsl/pretext-solution-manual-latex.xsl +323 -0
- package/assets/xsl/pretext-text-utilities.xsl +1217 -0
- package/assets/xsl/pretext-text.xsl +392 -0
- package/assets/xsl/pretext-units.xsl +195 -0
- package/assets/xsl/pretext-view-source.xsl +157 -0
- package/assets/xsl/pretext-ww-problem-sets.xsl +391 -0
- package/assets/xsl/publisher-variables.xsl +4756 -0
- package/assets/xsl/support/README.md +22 -0
- package/assets/xsl/support/extract-math.xsl +256 -0
- package/assets/xsl/support/package-math.xsl +141 -0
- package/assets/xsl/support/play-button/README.md +46 -0
- package/assets/xsl/support/play-button/play-button.png +0 -0
- package/assets/xsl/support/play-button/play-button.svg +3 -0
- package/assets/xsl/support/pretext-pg-macros.xsl +110 -0
- package/assets/xsl/support/webpack_static_imports.xml +14 -0
- package/assets/xsl/tests/README.md +24 -0
- package/assets/xsl/tests/null.xml +4 -0
- package/assets/xsl/tests/pretext-text-utilities-test.xsl +334 -0
- package/assets/xsl/utilities/README.md +31 -0
- package/assets/xsl/utilities/author-report.xsl +107 -0
- package/assets/xsl/utilities/deprecate-autoname.sed +18 -0
- package/assets/xsl/utilities/deprecate-index.sed +33 -0
- package/assets/xsl/utilities/fix-deprecations.xsl +663 -0
- package/assets/xsl/utilities/pretext-enhanced-source.xsl +112 -0
- package/assets/xsl/utilities/report-publisher-variables.xsl +162 -0
- package/assets/xsl/xml-to-json.xsl +326 -0
- package/assets/xsl/xml-to-string.xsl +328 -0
- package/cli.mjs +29 -0
- package/dist/cli-C6tfAVvi.js +553 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +10 -0
- package/dist/mounts.d.ts +23 -0
- package/dist/publication.d.ts +16 -0
- package/dist/renderer.d.ts +84 -0
- package/dist/sourcemap.d.ts +41 -0
- package/dist/xinclude.d.ts +45 -0
- package/package.json +52 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<?xml version='1.0'?> <!-- As XML file -->
|
|
2
|
+
|
|
3
|
+
<!--********************************************************************
|
|
4
|
+
Copyright 2019 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
|
+
<!-- http://pimpmyxslt.com/articles/entity-tricks-part2/ -->
|
|
23
|
+
<!DOCTYPE xsl:stylesheet [
|
|
24
|
+
<!ENTITY % entities SYSTEM "entities.ent">
|
|
25
|
+
%entities;
|
|
26
|
+
]>
|
|
27
|
+
|
|
28
|
+
<!-- Identify as a stylesheet -->
|
|
29
|
+
<!-- We choose to not include a default namespace -->
|
|
30
|
+
<!-- (in particular http://www.w3.org/1999/xhtml), -->
|
|
31
|
+
<!-- even if this complicates adding namespaces onto -->
|
|
32
|
+
<!-- derivatives, such as HTML destined for EPUB output -->
|
|
33
|
+
<!-- xmlns="http://www.w3.org/1999/xhtml" -->
|
|
34
|
+
<xsl:stylesheet
|
|
35
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
36
|
+
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
|
37
|
+
xmlns:exsl="http://exslt.org/common"
|
|
38
|
+
extension-element-prefixes="exsl"
|
|
39
|
+
>
|
|
40
|
+
|
|
41
|
+
<!-- IMPORTANT -->
|
|
42
|
+
<!-- The "sanitize-text" template can be called on sizeable -->
|
|
43
|
+
<!-- chunks of text, in a recursive manner, and then looks -->
|
|
44
|
+
<!-- like runaway recursion. "xsltproc" has a "-maxdepth" -->
|
|
45
|
+
<!-- argument. For the sample article, we increased it from -->
|
|
46
|
+
<!-- 3000 to 6000 to prevent a spurious error. -->
|
|
47
|
+
|
|
48
|
+
<!-- We assume the source is in great shape, typically having been -->
|
|
49
|
+
<!-- created by a pretty-printing tool. So we keep all the -->
|
|
50
|
+
<!-- whitespace as being of interest to human reader. This is -->
|
|
51
|
+
<!-- the beauty of a separate stylesheet here: -->
|
|
52
|
+
<!-- (a) we can override the strip-space declarations -->
|
|
53
|
+
<!-- of the main HTML stylesheet -->
|
|
54
|
+
<!-- (b) the election of the addition of source annotations -->
|
|
55
|
+
<!-- is made by simply using a different stylesheet -->
|
|
56
|
+
<xsl:preserve-space elements="*"/>
|
|
57
|
+
<!-- But whitespace in the root element gets regurgitated -->
|
|
58
|
+
<!-- outside/before/above any file writing and ends up on the -->
|
|
59
|
+
<!-- terminal. So we kill it with no loss. -->
|
|
60
|
+
<xsl:strip-space elements="pretext"/>
|
|
61
|
+
|
|
62
|
+
<!-- Below, we use a purpose-built attribute to match elements which -->
|
|
63
|
+
<!-- have been through the pre-proccessor with their (nearly-)original -->
|
|
64
|
+
<!-- progenitors. So we need this id here, late in the game, but we -->
|
|
65
|
+
<!-- don't want authors wondering if they should be authoring it in -->
|
|
66
|
+
<!-- their source. So at the last minute, while creating text versions -->
|
|
67
|
+
<!-- of source material, we kill it. Any similar leakage could be -->
|
|
68
|
+
<!-- handled the same way. -->
|
|
69
|
+
<xsl:template match="@original-id" mode="xml-to-string"/>
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
<!-- N.B.: the -assembly stylesheet first construct a "version" which -->
|
|
73
|
+
<!-- is the resolution of version support and customizations. Then -->
|
|
74
|
+
<!-- "original-id" are added in the next pass. These are solely for -->
|
|
75
|
+
<!-- the purpose of "going back" to this second pass to identify pieces -->
|
|
76
|
+
<!-- of a document before the assembly process perturbs them. So the -->
|
|
77
|
+
<!-- key tree this next template acts on is in the variable -->
|
|
78
|
+
<!-- $original-labeled. Just above we explain how these id's get -->
|
|
79
|
+
<!-- scrubbed before presenting source to the reader. -->
|
|
80
|
+
|
|
81
|
+
<!-- The template to place into the HTML stylesheet, which is -->
|
|
82
|
+
<!-- overriding a do-nothing stub in the HTML stylesheet. This is -->
|
|
83
|
+
<!-- a no-op unless the $b-view-source has been set to true() -->
|
|
84
|
+
<!-- electively. Not too much of a performance hit as bailing out -->
|
|
85
|
+
<!-- is quick, and use is limited to divisions and blocks (roughly). -->
|
|
86
|
+
<xsl:template match="*" mode="view-source-widget">
|
|
87
|
+
<!-- Footnotes are silly to annotate, and are also automatically -->
|
|
88
|
+
<!-- generated for URLs and hence have no original source, so we -->
|
|
89
|
+
<!-- kill them here. Careful experiments suggest these are the -->
|
|
90
|
+
<!-- only elements without source. -->
|
|
91
|
+
<xsl:variable name="b-banned" select="boolean(self::fn)"/>
|
|
92
|
+
<xsl:if test="$b-view-source and not($b-banned)">
|
|
93
|
+
<!-- Part 1: Serialize the source -->
|
|
94
|
+
<!-- Save off the id of the element being annotated -->
|
|
95
|
+
<xsl:variable name="the-element-id" select="@original-id"/>
|
|
96
|
+
<!-- Locate the element with the same id, but in a very early -->
|
|
97
|
+
<!-- pass of the assembly stylesheet, so with as little (no?) -->
|
|
98
|
+
<!-- extraneous manufactured markup as possible. -->
|
|
99
|
+
<xsl:variable name="original-element" select="$original-labeled//*[@original-id = $the-element-id]"/>
|
|
100
|
+
<!-- Just for convenience, capture highly sanitized text -->
|
|
101
|
+
<!-- version of the XML source within a variable. -->
|
|
102
|
+
<!-- -->
|
|
103
|
+
<!-- (1) Grab the node *just prior* to the element. -->
|
|
104
|
+
<!-- (2) This ends with a newline and then some -->
|
|
105
|
+
<!-- indentation, we grab this indentation. -->
|
|
106
|
+
<!-- (3) Serialize the element, a photocopy machine -->
|
|
107
|
+
<!-- which converts XML nodes into text (originally -->
|
|
108
|
+
<!-- built to put HTML into JSON for Jupyter). -->
|
|
109
|
+
<!-- (4) Run (2)+(3) through "sanitize-text" mainly to pull -->
|
|
110
|
+
<!-- the whole stanza left, since it may have a lot of -->
|
|
111
|
+
<!-- common indentation (which is why we caught -->
|
|
112
|
+
<!-- the preceding indentation). -->
|
|
113
|
+
<!-- (5) Run that through "sanitize-text" to deindent -->
|
|
114
|
+
<!-- NB: the $original-element is used *twice* below, in -->
|
|
115
|
+
<!-- order to have the right conteaxt for the manipulations -->
|
|
116
|
+
<xsl:variable name="serialized-html">
|
|
117
|
+
<xsl:variable name="serialized-html-raw">
|
|
118
|
+
<xsl:variable name="lead-in">
|
|
119
|
+
<xsl:apply-templates select="$original-element/preceding-sibling::node()[1]" mode="xml-to-string">
|
|
120
|
+
<xsl:with-param name="depth" select="1"/>
|
|
121
|
+
</xsl:apply-templates>
|
|
122
|
+
</xsl:variable>
|
|
123
|
+
<xsl:call-template name="substring-after-last">
|
|
124
|
+
<xsl:with-param name="input" select="$lead-in" />
|
|
125
|
+
<xsl:with-param name="substr" select="'
'" />
|
|
126
|
+
</xsl:call-template>
|
|
127
|
+
<xsl:apply-templates select="$original-element" mode="xml-to-string">
|
|
128
|
+
<xsl:with-param name="depth" select="1"/>
|
|
129
|
+
</xsl:apply-templates>
|
|
130
|
+
</xsl:variable>
|
|
131
|
+
<xsl:call-template name="sanitize-text">
|
|
132
|
+
<xsl:with-param name="text">
|
|
133
|
+
<xsl:value-of select="$serialized-html-raw"/>
|
|
134
|
+
</xsl:with-param>
|
|
135
|
+
</xsl:call-template>
|
|
136
|
+
</xsl:variable>
|
|
137
|
+
|
|
138
|
+
<!-- Part 2: drop the source into a details on the page -->
|
|
139
|
+
<details class="source-view">
|
|
140
|
+
<summary class="source-view__link" data-reveal-label="Open" data-close-label="Close">
|
|
141
|
+
<!-- TODO: internationalize me? -->
|
|
142
|
+
<xsl:text>View Source for </xsl:text><xsl:value-of select="name()"/>
|
|
143
|
+
</summary>
|
|
144
|
+
<!-- -->
|
|
145
|
+
<article class="view-source-view__content" >
|
|
146
|
+
<pre>
|
|
147
|
+
<code class="language-xml">
|
|
148
|
+
<xsl:value-of select="$serialized-html"/>
|
|
149
|
+
</code>
|
|
150
|
+
</pre>
|
|
151
|
+
</article>
|
|
152
|
+
</details>
|
|
153
|
+
|
|
154
|
+
</xsl:if>
|
|
155
|
+
</xsl:template>
|
|
156
|
+
|
|
157
|
+
</xsl:stylesheet>
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
|
|
3
|
+
<!-- ********************************************************************* -->
|
|
4
|
+
<!-- Copyright 2015-18 -->
|
|
5
|
+
<!-- Robert A. Beezer, Michael Gage, Geoff Goehle, Alex Jordan -->
|
|
6
|
+
<!-- -->
|
|
7
|
+
<!-- This file is part of PreTeXt. -->
|
|
8
|
+
<!-- -->
|
|
9
|
+
<!-- PreTeXt is free software: you can redistribute it and/or modify -->
|
|
10
|
+
<!-- it under the terms of the GNU General Public License as published by -->
|
|
11
|
+
<!-- the Free Software Foundation, either version 2 or version 3 of the -->
|
|
12
|
+
<!-- License (at your option). -->
|
|
13
|
+
<!-- -->
|
|
14
|
+
<!-- PreTeXt is distributed in the hope that it will be useful, -->
|
|
15
|
+
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
|
|
16
|
+
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
|
|
17
|
+
<!-- GNU General Public License for more details. -->
|
|
18
|
+
<!-- -->
|
|
19
|
+
<!-- You should have received a copy of the GNU General Public License -->
|
|
20
|
+
<!-- along with PreTeXt. If not, see <http://www.gnu.org/licenses/>. -->
|
|
21
|
+
<!-- ********************************************************************* -->
|
|
22
|
+
|
|
23
|
+
<!-- http://pimpmyxslt.com/articles/entity-tricks-part2/ -->
|
|
24
|
+
<!DOCTYPE xsl:stylesheet [
|
|
25
|
+
<!ENTITY % entities SYSTEM "entities.ent">
|
|
26
|
+
%entities;
|
|
27
|
+
]>
|
|
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
|
+
<!-- Apply this style sheet to to produce a folder tree of PG problem files -->
|
|
36
|
+
<!-- with set defintion and set header files. Compress into a .tgz and -->
|
|
37
|
+
<!-- upload into a WeBWorK course (perhaps in the templates/local folder); -->
|
|
38
|
+
<!-- or into a server's libraries folder and set up site-wide access. -->
|
|
39
|
+
|
|
40
|
+
<!-- Standard conversion groundwork -->
|
|
41
|
+
<xsl:import href="./publisher-variables.xsl"/>
|
|
42
|
+
<xsl:import href="./pretext-assembly.xsl"/>
|
|
43
|
+
<xsl:import href="./pretext-common.xsl"/>
|
|
44
|
+
<xsl:import href="./extract-pg.xsl"/>
|
|
45
|
+
|
|
46
|
+
<!-- Intend output to be a PG/PGML problem or a "def" file -->
|
|
47
|
+
<xsl:output method="text" />
|
|
48
|
+
|
|
49
|
+
<!-- ######### -->
|
|
50
|
+
<!-- Variables -->
|
|
51
|
+
<!-- ######### -->
|
|
52
|
+
|
|
53
|
+
<!-- This variable controls representations of interactive exercises -->
|
|
54
|
+
<!-- built in pretext-assembly.xsl. This is the one place we override -->
|
|
55
|
+
<!-- this variable to the value 'pg-problems' as a signal to only mine -->
|
|
56
|
+
<!-- PG representations from the multiple representations available. -->
|
|
57
|
+
<xsl:variable name="exercise-style" select="'pg-problems'"/>
|
|
58
|
+
|
|
59
|
+
<!-- We default to one massive def file -->
|
|
60
|
+
<xsl:variable name="chunk-level">
|
|
61
|
+
<xsl:choose>
|
|
62
|
+
<xsl:when test="$chunk-level-entered != ''">
|
|
63
|
+
<xsl:value-of select="$chunk-level-entered" />
|
|
64
|
+
</xsl:when>
|
|
65
|
+
<xsl:otherwise>
|
|
66
|
+
<xsl:text>0</xsl:text>
|
|
67
|
+
</xsl:otherwise>
|
|
68
|
+
</xsl:choose>
|
|
69
|
+
</xsl:variable>
|
|
70
|
+
|
|
71
|
+
<!-- ############## -->
|
|
72
|
+
<!-- Entry template -->
|
|
73
|
+
<!-- ############## -->
|
|
74
|
+
|
|
75
|
+
<!-- First, create the problem files in directories -->
|
|
76
|
+
<!-- Organized in directories as in the document tree, cut off at chunk level -->
|
|
77
|
+
<!-- Then chunk the document to write reasonable problem definition files -->
|
|
78
|
+
<xsl:template match="/">
|
|
79
|
+
<xsl:apply-templates select="$original" mode="generic-warnings"/>
|
|
80
|
+
<xsl:apply-templates select="$document-root//webwork[statement|task|text()]" mode="write-file"/>
|
|
81
|
+
<xsl:apply-templates select="$document-root" mode="chunking"/>
|
|
82
|
+
</xsl:template>
|
|
83
|
+
|
|
84
|
+
<!-- ################## -->
|
|
85
|
+
<!-- Filename Utilities -->
|
|
86
|
+
<!-- ################## -->
|
|
87
|
+
|
|
88
|
+
<xsl:template name="project-folder">
|
|
89
|
+
<xsl:apply-templates select="$document-root" mode="numbered-title-filesafe" />
|
|
90
|
+
</xsl:template>
|
|
91
|
+
|
|
92
|
+
<!-- Directory path, recursively climb structural nodes, -->
|
|
93
|
+
<!-- record names as pass up through chunk-level barrier -->
|
|
94
|
+
<!-- Includes root document node (book, article, etc) -->
|
|
95
|
+
<xsl:template match="*" mode="directory-path">
|
|
96
|
+
<xsl:variable name="structural">
|
|
97
|
+
<xsl:apply-templates select="." mode="is-structural"/>
|
|
98
|
+
</xsl:variable>
|
|
99
|
+
<xsl:variable name="current-level">
|
|
100
|
+
<xsl:choose>
|
|
101
|
+
<xsl:when test="$structural = 'true'">
|
|
102
|
+
<xsl:apply-templates select="." mode="level" />
|
|
103
|
+
</xsl:when>
|
|
104
|
+
<xsl:otherwise>
|
|
105
|
+
<xsl:text>undefined</xsl:text>
|
|
106
|
+
</xsl:otherwise>
|
|
107
|
+
</xsl:choose>
|
|
108
|
+
</xsl:variable>
|
|
109
|
+
<xsl:choose>
|
|
110
|
+
<xsl:when test="self::mathbook|self::pretext" /> <!-- done -->
|
|
111
|
+
<xsl:when test="$structural='false'"> <!-- skip up -->
|
|
112
|
+
<xsl:apply-templates select="parent::*" mode="directory-path" />
|
|
113
|
+
</xsl:when>
|
|
114
|
+
<!-- structural is true now, compare levels -->
|
|
115
|
+
<xsl:when test="$current-level > $chunk-level"> <!-- also skip up -->
|
|
116
|
+
<xsl:apply-templates select="parent::*" mode="directory-path" />
|
|
117
|
+
</xsl:when>
|
|
118
|
+
<xsl:otherwise> <!-- append current node name -->
|
|
119
|
+
<xsl:apply-templates select="parent::*" mode="directory-path" />
|
|
120
|
+
<xsl:apply-templates select="." mode="numbered-title-filesafe" />
|
|
121
|
+
<xsl:text>/</xsl:text>
|
|
122
|
+
</xsl:otherwise>
|
|
123
|
+
</xsl:choose>
|
|
124
|
+
</xsl:template>
|
|
125
|
+
|
|
126
|
+
<!-- Append a filename to the directory path -->
|
|
127
|
+
<xsl:template match="webwork[statement|task|text()]" mode="relative-filename">
|
|
128
|
+
<xsl:apply-templates select="." mode="directory-path" />
|
|
129
|
+
<xsl:if test="parent::*[&PROJECT-FILTER;]">
|
|
130
|
+
<xsl:apply-templates select="parent::*" mode="type-name"/>
|
|
131
|
+
<xsl:text>-</xsl:text>
|
|
132
|
+
</xsl:if>
|
|
133
|
+
<xsl:apply-templates select="parent::*" mode="numbered-title-filesafe" />
|
|
134
|
+
<xsl:text>.pg</xsl:text>
|
|
135
|
+
</xsl:template>
|
|
136
|
+
<xsl:template match="webwork[statement|task|text()]" mode="filename">
|
|
137
|
+
<xsl:apply-templates select="." mode="relative-filename"/>
|
|
138
|
+
</xsl:template>
|
|
139
|
+
|
|
140
|
+
<xsl:template match="webwork[@source|@local]" mode="filename">
|
|
141
|
+
<xsl:apply-templates select="." mode="relative-filename"/>
|
|
142
|
+
</xsl:template>
|
|
143
|
+
|
|
144
|
+
<!-- For problems from the OPL, just report the @source -->
|
|
145
|
+
<xsl:template match="webwork[@source]" mode="relative-filename">
|
|
146
|
+
<xsl:value-of select="@source"/>
|
|
147
|
+
</xsl:template>
|
|
148
|
+
|
|
149
|
+
<!-- For local, just report @local but inside external directory, and all -->
|
|
150
|
+
<!-- inside the project folder, with the expectation that a host WW course -->
|
|
151
|
+
<!-- will copy the external folder to the project folder in templates/ -->
|
|
152
|
+
<xsl:template match="webwork[@local]" mode="relative-filename">
|
|
153
|
+
<xsl:call-template name="project-folder"/>
|
|
154
|
+
<xsl:value-of select="concat('/',$external-directory,@local)"/>
|
|
155
|
+
</xsl:template>
|
|
156
|
+
|
|
157
|
+
<!-- For copied problems move to the problem that was copied -->
|
|
158
|
+
<xsl:template match="webwork[@copied-from]" mode="relative-filename">
|
|
159
|
+
<xsl:variable name="copied-from" select="@copied-from"/>
|
|
160
|
+
<xsl:apply-templates select="$document-root//webwork[@xml:id=$copied-from]" mode="relative-filename"/>
|
|
161
|
+
</xsl:template>
|
|
162
|
+
<xsl:template match="webwork[@copied-from]" mode="filename">
|
|
163
|
+
<xsl:variable name="copied-from" select="@copied-from"/>
|
|
164
|
+
<xsl:apply-templates select="$document-root//webwork[@xml:id=$copied-from]" mode="filename"/>
|
|
165
|
+
</xsl:template>
|
|
166
|
+
|
|
167
|
+
<!-- ################## -->
|
|
168
|
+
<!-- Problem Extraction -->
|
|
169
|
+
<!-- ################## -->
|
|
170
|
+
|
|
171
|
+
<!-- Extract an authored problem into its own file, flush left -->
|
|
172
|
+
<xsl:template match="webwork[statement|task|text()]" mode="write-file">
|
|
173
|
+
<xsl:variable name="filename">
|
|
174
|
+
<xsl:apply-templates select="." mode="filename" />
|
|
175
|
+
</xsl:variable>
|
|
176
|
+
<exsl:document href="{$filename}" method="text">
|
|
177
|
+
<xsl:choose>
|
|
178
|
+
<xsl:when test="statement|task">
|
|
179
|
+
<xsl:call-template name="sanitize-text">
|
|
180
|
+
<xsl:with-param name="text">
|
|
181
|
+
<xsl:call-template name="consolidate-empty-lines">
|
|
182
|
+
<xsl:with-param name="text">
|
|
183
|
+
<xsl:apply-templates select=".">
|
|
184
|
+
<xsl:with-param name="b-hint" select="true()" />
|
|
185
|
+
<xsl:with-param name="b-solution" select="true()" />
|
|
186
|
+
<xsl:with-param name="b-human-readable" select="true()" />
|
|
187
|
+
</xsl:apply-templates>
|
|
188
|
+
</xsl:with-param>
|
|
189
|
+
</xsl:call-template>
|
|
190
|
+
</xsl:with-param>
|
|
191
|
+
</xsl:call-template>
|
|
192
|
+
</xsl:when>
|
|
193
|
+
<xsl:otherwise>
|
|
194
|
+
<xsl:value-of select="."/>
|
|
195
|
+
</xsl:otherwise>
|
|
196
|
+
</xsl:choose>
|
|
197
|
+
</exsl:document>
|
|
198
|
+
</xsl:template>
|
|
199
|
+
|
|
200
|
+
<!-- We don't write a new file for a copied webwork exercise -->
|
|
201
|
+
<xsl:template match="webwork[@copied-from]" mode="write-file"/>
|
|
202
|
+
|
|
203
|
+
<!-- ################## -->
|
|
204
|
+
<!-- Chunking Def Files-->
|
|
205
|
+
<!-- ################## -->
|
|
206
|
+
|
|
207
|
+
<!-- A complete file for a structural subdivision -->
|
|
208
|
+
<xsl:template match="&STRUCTURAL;" mode="chunk">
|
|
209
|
+
<!-- Separate webwork within any exercises into their own set. -->
|
|
210
|
+
<xsl:apply-templates select="." mode="file-wrap">
|
|
211
|
+
<xsl:with-param name="content">
|
|
212
|
+
<xsl:apply-templates select=".//webwork[statement|task|text()|@source|@local|@copy and not(ancestor::exercises)]" mode="def-info-v2" />
|
|
213
|
+
</xsl:with-param>
|
|
214
|
+
</xsl:apply-templates>
|
|
215
|
+
<xsl:apply-templates select="." mode="file-wrap">
|
|
216
|
+
<xsl:with-param name="exercises" select="true()" />
|
|
217
|
+
<xsl:with-param name="content">
|
|
218
|
+
<xsl:apply-templates select=".//webwork[statement|task|text()|@source|@local|@copy and ancestor::exercises]" mode="def-info-v2" />
|
|
219
|
+
</xsl:with-param>
|
|
220
|
+
</xsl:apply-templates>
|
|
221
|
+
</xsl:template>
|
|
222
|
+
|
|
223
|
+
<!-- A summary file for a structural subdivision -->
|
|
224
|
+
<!-- Any webwork not in a subdivision (say, in an introduction) -->
|
|
225
|
+
<!-- The // is OK here (rather than descendant-or-self) since -->
|
|
226
|
+
<!-- there will at least be an intervening "exercise" wrapper -->
|
|
227
|
+
<xsl:template match="&STRUCTURAL;" mode="intermediate">
|
|
228
|
+
<xsl:apply-templates select="." mode="file-wrap">
|
|
229
|
+
<xsl:with-param name="content">
|
|
230
|
+
<xsl:apply-templates select="*[not(&STRUCTURAL-FILTER;)]//webwork[statement|task|text()|@source|@local|@copy]" mode="def-info-v2" />
|
|
231
|
+
</xsl:with-param>
|
|
232
|
+
</xsl:apply-templates>
|
|
233
|
+
</xsl:template>
|
|
234
|
+
|
|
235
|
+
<!-- ##################### -->
|
|
236
|
+
<!-- Def File Construction -->
|
|
237
|
+
<!-- ##################### -->
|
|
238
|
+
|
|
239
|
+
<!-- A *.def file for a structural subdivision -->
|
|
240
|
+
<xsl:template match="&STRUCTURAL;" mode="file-wrap">
|
|
241
|
+
<xsl:param name="content" />
|
|
242
|
+
<xsl:param name="exercises" select="false()" />
|
|
243
|
+
<!-- no problems, no def infos, then no file -->
|
|
244
|
+
<xsl:if test="not($content = '')">
|
|
245
|
+
<!-- filenames -->
|
|
246
|
+
<xsl:variable name="def-filename">
|
|
247
|
+
<xsl:call-template name="project-folder" />
|
|
248
|
+
<xsl:text>/def/</xsl:text>
|
|
249
|
+
<!-- mandatory filename initial string -->
|
|
250
|
+
<xsl:text>set</xsl:text>
|
|
251
|
+
<xsl:apply-templates select="." mode="numbered-title-filesafe" />
|
|
252
|
+
<xsl:if test="$exercises">
|
|
253
|
+
<xsl:text>_Exercises</xsl:text>
|
|
254
|
+
</xsl:if>
|
|
255
|
+
<xsl:text>.def</xsl:text>
|
|
256
|
+
</xsl:variable>
|
|
257
|
+
<xsl:variable name="relative-header-filename">
|
|
258
|
+
<xsl:call-template name="project-folder" />
|
|
259
|
+
<xsl:text>/header/</xsl:text>
|
|
260
|
+
<xsl:apply-templates select="." mode="numbered-title-filesafe" />
|
|
261
|
+
<xsl:if test="$exercises">
|
|
262
|
+
<xsl:text>_Exercises</xsl:text>
|
|
263
|
+
</xsl:if>
|
|
264
|
+
<xsl:text>.pg</xsl:text>
|
|
265
|
+
</xsl:variable>
|
|
266
|
+
<xsl:variable name="header-filename">
|
|
267
|
+
<xsl:value-of select="$relative-header-filename"/>
|
|
268
|
+
</xsl:variable>
|
|
269
|
+
<!-- set-definition file -->
|
|
270
|
+
<exsl:document href="{$def-filename}" method="text">
|
|
271
|
+
<!-- Fixed, obviously fictional placeholder dates so the file -->
|
|
272
|
+
<!-- is stable across regenerations. Earlier this used -->
|
|
273
|
+
<!-- "date:date-time()" + a six-month "date:add", which made -->
|
|
274
|
+
<!-- every regeneration churn the dates with no semantic -->
|
|
275
|
+
<!-- change. Authors using this output will edit the dates -->
|
|
276
|
+
<!-- to fit their course schedule anyway. -->
|
|
277
|
+
<xsl:text>openDate = 01/01/2027 at 12:00am
</xsl:text>
|
|
278
|
+
<xsl:text>dueDate = 12/31/2027 at 10:00pm
</xsl:text>
|
|
279
|
+
<xsl:text>answerDate = 12/31/2027 at 10:00pm
</xsl:text>
|
|
280
|
+
<xsl:text>paperHeaderFile = </xsl:text>
|
|
281
|
+
<xsl:value-of select="$relative-header-filename" />
|
|
282
|
+
<xsl:text>
</xsl:text>
|
|
283
|
+
<xsl:text>screenHeaderFile = </xsl:text>
|
|
284
|
+
<xsl:value-of select="$relative-header-filename" />
|
|
285
|
+
<xsl:text>
</xsl:text>
|
|
286
|
+
<xsl:text>description = </xsl:text>
|
|
287
|
+
<xsl:apply-templates select="." mode="title-simple" />
|
|
288
|
+
<xsl:text>
</xsl:text>
|
|
289
|
+
<!-- Version 2 problem list lead-in -->
|
|
290
|
+
<xsl:text>problemListV2
</xsl:text>
|
|
291
|
+
<xsl:copy-of select="$content" />
|
|
292
|
+
</exsl:document>
|
|
293
|
+
<!-- set-header file -->
|
|
294
|
+
<!-- a bit of a hack to write a second file here -->
|
|
295
|
+
<!-- but we avoid the entire $content used above -->
|
|
296
|
+
<exsl:document href="{$header-filename}" method="text">
|
|
297
|
+
<xsl:apply-templates select="." mode="header-content" />
|
|
298
|
+
</exsl:document>
|
|
299
|
+
</xsl:if>
|
|
300
|
+
</xsl:template>
|
|
301
|
+
|
|
302
|
+
<!-- Version 2 problem info -->
|
|
303
|
+
<!-- Each problem gets its own line in the problem set -->
|
|
304
|
+
<!-- definition file. Be careful to create no content if -->
|
|
305
|
+
<!-- there are no problems in a subdivision as we employ -->
|
|
306
|
+
<!-- non-emptieness up the wrapping chain to ensure -->
|
|
307
|
+
<!-- no trivial problem definition files are created. -->
|
|
308
|
+
<!-- http://webwork.maa.org/wiki/Set_Definition_Files#Version_2 -->
|
|
309
|
+
<xsl:template match="webwork" mode="def-info-v2">
|
|
310
|
+
<xsl:text>problem_start
</xsl:text>
|
|
311
|
+
<xsl:text>source_file = </xsl:text> <!-- PG file -->
|
|
312
|
+
<xsl:apply-templates select="." mode="relative-filename" />
|
|
313
|
+
<xsl:text>
</xsl:text>
|
|
314
|
+
<!--Much of the following commented out until we decide we should include them. -->
|
|
315
|
+
<!--WeBWorK provides good default values, customizable by sysadmin or instructor. -->
|
|
316
|
+
<!--<xsl:text>value = 1
</xsl:text>--> <!-- default problem weight -->
|
|
317
|
+
<!--<xsl:text>max_attempts = -1
</xsl:text>--> <!-- default max attempts is unlimited -->
|
|
318
|
+
<!--<xsl:text>showMeAnother = -1
</xsl:text>--> <!-- default SMA is off -->
|
|
319
|
+
<xsl:text>problem_id = </xsl:text>
|
|
320
|
+
<xsl:apply-templates select="ancestor::exercise" mode="serial-number" />
|
|
321
|
+
<xsl:text>
</xsl:text>
|
|
322
|
+
<!--<xsl:text>counts_parent_grade = 0
</xsl:text>--> <!-- for JIT sets only -->
|
|
323
|
+
<!--<xsl:text>att_to_open_children = 0
</xsl:text>--> <!-- for JIT sets only -->
|
|
324
|
+
<xsl:text>problem_end
</xsl:text>
|
|
325
|
+
</xsl:template>
|
|
326
|
+
|
|
327
|
+
<!-- Header file content -->
|
|
328
|
+
<!-- Gives some information about where in the PTX project the set came from -->
|
|
329
|
+
<!-- Some info changes with WW variables, such as due date -->
|
|
330
|
+
<xsl:template match="*" mode="header-content">
|
|
331
|
+
<!-- Inneficient: indented text in variable, then strip indentation -->
|
|
332
|
+
<!-- Alternative: wrap each line in "text" with linefeeds -->
|
|
333
|
+
<xsl:variable name="header-text">
|
|
334
|
+
<xsl:text>
|
|
335
|
+
# Header file for problem set </xsl:text><xsl:apply-templates select="." mode="numbered-title-filesafe" />
|
|
336
|
+
<xsl:text>
|
|
337
|
+
# This header file can be used for both the screen and hardcopy output
|
|
338
|
+
|
|
339
|
+
DOCUMENT();
|
|
340
|
+
|
|
341
|
+
loadMacros(
|
|
342
|
+
"PG.pl",
|
|
343
|
+
"PGbasicmacros.pl",
|
|
344
|
+
"PGML.pl",
|
|
345
|
+
"PGcourse.pl",
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
TEXT($BEGIN_ONE_COLUMN);
|
|
349
|
+
|
|
350
|
+
$texTopLine = "\noindent {\large \bf $studentName}\hfill{\large \bf {".protect_underbar($courseName)."}}";
|
|
351
|
+
if (defined($sectionName) and ($sectionName ne '')) {$texTopLine .= " {\large \bf { Section: ".protect_underbar($sectionName)." } }"};
|
|
352
|
+
$texTopLine .= "\par";
|
|
353
|
+
|
|
354
|
+
####################################################
|
|
355
|
+
#
|
|
356
|
+
# MODES provides for distinct output for TeX and HTML
|
|
357
|
+
#
|
|
358
|
+
####################################################
|
|
359
|
+
|
|
360
|
+
TEXT(MODES(
|
|
361
|
+
TeX =>"$texTopLine",
|
|
362
|
+
HTML=>"",
|
|
363
|
+
));
|
|
364
|
+
|
|
365
|
+
TEXT(MODES(
|
|
366
|
+
TeX =>"\noindent{\large \sc {Assignment ".protect_underbar($setNumber)." due $formatedDueDate}}\par".
|
|
367
|
+
"\noindent \bigskip ",
|
|
368
|
+
HTML=>"<span style='font-variant: small-caps; font-size:large;'>WeBWorK Assignment ".protect_underbar($setNumber)." is due: $formattedDueDate. </span>$PAR",
|
|
369
|
+
));
|
|
370
|
+
</xsl:text><xsl:choose><xsl:when test="$document-root//frontmatter/colophon/website"><xsl:text>
|
|
371
|
+
TEXT(MODES(
|
|
372
|
+
TeX =>"\noindent This assignment contains exercises from </xsl:text><xsl:apply-templates select="." mode="type-name" /><xsl:text> </xsl:text><xsl:apply-templates select="." mode="number" /><xsl:text> of </xsl:text><xsl:apply-templates select="$document-root" mode="title-simple" /><xsl:text>.",
|
|
373
|
+
HTML=>"This assignment contains exercises from ".htmlLink(qq!</xsl:text><xsl:apply-templates select="$document-root//frontmatter/colophon/website/url/@href" /><xsl:text>/</xsl:text><xsl:apply-templates select="." mode="visible-id" /><xsl:text>.html!,"</xsl:text><xsl:apply-templates select="." mode="type-name" /><xsl:text> </xsl:text><xsl:apply-templates select="." mode="number" /><xsl:text>")." of </xsl:text><xsl:apply-templates select="$document-root" mode="title-simple" /><xsl:text>."
|
|
374
|
+
));
|
|
375
|
+
</xsl:text></xsl:when><xsl:otherwise><xsl:text>
|
|
376
|
+
TEXT("This assignment contains exercises from </xsl:text><xsl:apply-templates select="." mode="type-name" /><xsl:text> </xsl:text><xsl:apply-templates select="." mode="number" /><xsl:text> of </xsl:text><xsl:apply-templates select="$document-root" mode="title-simple" /><xsl:text>.");
|
|
377
|
+
</xsl:text></xsl:otherwise></xsl:choose>
|
|
378
|
+
|
|
379
|
+
<xsl:text>
|
|
380
|
+
TEXT($END_ONE_COLUMN);
|
|
381
|
+
|
|
382
|
+
ENDDOCUMENT();
|
|
383
|
+
</xsl:text>
|
|
384
|
+
</xsl:variable>
|
|
385
|
+
<!-- lazy, strips indentation, etc -->
|
|
386
|
+
<xsl:call-template name="sanitize-text">
|
|
387
|
+
<xsl:with-param name="text" select="$header-text" />
|
|
388
|
+
</xsl:call-template>
|
|
389
|
+
</xsl:template>
|
|
390
|
+
|
|
391
|
+
</xsl:stylesheet>
|