-
Notifications
You must be signed in to change notification settings - Fork 0
/
stylesheet.xsl
executable file
·262 lines (209 loc) · 7.98 KB
/
stylesheet.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?xml version="1.0" encoding="utf-8"?>
<!--
This is an XSL stylesheet which converts mscript XML files into XSLT.
Use the XSLT command to perform the conversion.
Ned Gulley and Matthew Simoneau, September 2003
Copyright 1984-2007 The MathWorks, Inc.
$Revision: 1.1.6.7 $ $Date: 2008/02/29 12:45:30 $
-->
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:escape="http://www.mathworks.com/namespace/latex/escape"
xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">
<xsl:output method="text" indent="no"/>
<xsl:template match="mscript">
% This LaTeX was auto-generated from an M-file by MATLAB.
% To make changes, update the M-file and republish this document.
\documentclass{article}
\usepackage{graphicx}
\usepackage{color}
\sloppy
\definecolor{lightgray}{gray}{0.5}
\setlength{\parindent}{10pt}
\usepackage[margin=.5in]{geometry}
\begin{document}
\title{Gastric and pyloric rhtyhms at different temperatures}
\author{Srinivas Gorur-Shandilya}
\maketitle
<!-- Determine if the there should be an introduction section. -->
<xsl:variable name="hasIntro" select="count(cell[@style = 'overview'])"/>
<xsl:if test = "$hasIntro">
\section*{<xsl:apply-templates select="cell[1]/steptitle"/>}
<xsl:apply-templates select="cell[1]/text"/>
</xsl:if>
<xsl:variable name="body-cells" select="cell[not(@style = 'overview')]"/>
<!-- Include contents if there are titles for any subsections. -->
<xsl:if test="count(cell/steptitle[not(@style = 'document')])">
<xsl:call-template name="contents">
<xsl:with-param name="body-cells" select="$body-cells"/>
</xsl:call-template>
</xsl:if>
<!-- Loop over each cell -->
<xsl:for-each select="$body-cells">
<!-- Title of cell -->
<xsl:if test="steptitle">
<xsl:variable name="headinglevel">
<xsl:choose>
<xsl:when test="steptitle[@style = 'document']">section</xsl:when>
<xsl:otherwise>subsection</xsl:otherwise>
</xsl:choose>
</xsl:variable>
\<xsl:value-of select="$headinglevel"/>*{<xsl:apply-templates select="steptitle"/>}
</xsl:if>
<!-- Contents of each cell -->
<xsl:apply-templates select="text"/>
<xsl:apply-templates select="mcode"/>
<xsl:apply-templates select="mcodeoutput"/>
<xsl:apply-templates select="img"/>
</xsl:for-each>
<xsl:if test="copyright">
\begin{par} \footnotesize \color{lightgray} \begin{flushright}
\emph{<xsl:apply-templates select="copyright"/>}
\end{flushright} \color{black} \normalsize \end{par}
</xsl:if>
\end{document}
</xsl:template>
<xsl:template name="contents">
<xsl:param name="body-cells"/>
\subsection*{Contents}
\begin{itemize}
\setlength{\itemsep}{-1ex}<xsl:for-each select="$body-cells">
<xsl:if test="./steptitle">
\item <xsl:apply-templates select="steptitle"/>
</xsl:if>
</xsl:for-each>
\end{itemize}
</xsl:template>
<!-- HTML Tags in text sections -->
<xsl:template match="p">\begin{par}
<xsl:apply-templates/><xsl:text>
\end{par} \vspace{1em}
</xsl:text>
</xsl:template>
<xsl:template match="ul">\begin{itemize}
\setlength{\itemsep}{-1ex}
<xsl:apply-templates/>\end{itemize}
</xsl:template>
<xsl:template match="ol">\begin{enumerate}
\setlength{\itemsep}{-1ex}
<xsl:apply-templates/>\end{enumerate}
</xsl:template>
<xsl:template match="li"> \item <xsl:apply-templates/><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="pre">
<xsl:choose>
<xsl:when test="@class='error'">
\begin{verbatim}<xsl:value-of select="."/>\end{verbatim}
</xsl:when>
<xsl:otherwise>
\begin{verbatim}<xsl:value-of select="."/>\end{verbatim}
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="b">\textbf{<xsl:apply-templates/>}</xsl:template>
<xsl:template match="tt">\texttt{<xsl:apply-templates/>}</xsl:template>
<xsl:template match="i">\textit{<xsl:apply-templates/>}</xsl:template>
<xsl:template match="a">\begin{verbatim}<xsl:value-of select="."/>\end{verbatim}</xsl:template>
<xsl:template match="text()">
<!-- Escape special characters in text -->
<xsl:call-template name="replace">
<xsl:with-param name="string" select="."/>
</xsl:call-template>
</xsl:template>
<xsl:template match="equation">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="latex">
<xsl:value-of select="@text" disable-output-escaping="yes"/>
</xsl:template>
<xsl:template match="html"/>
<!-- Code input and output -->
<xsl:template match="mcode">\begin{verbatim}
<xsl:value-of select="."/>
\end{verbatim}
</xsl:template>
<xsl:template match="mcodeoutput">
<xsl:choose>
<xsl:when test="substring(.,0,8)='<latex>'">
<xsl:value-of select="substring(.,8,string-length(.)-16)" disable-output-escaping="yes"/>
</xsl:when>
<xsl:otherwise>
\color{lightgray} \begin{verbatim}<xsl:value-of select="."/>\end{verbatim} \color{black}
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Figure and model snapshots -->
<xsl:template match="img">
\includegraphics [width=\textwidth]{<xsl:value-of select="@src"/>}
</xsl:template>
<!-- Colors for syntax-highlighted input code -->
<xsl:template match="mwsh:code">\begin{verbatim}<xsl:apply-templates/>\end{verbatim}
</xsl:template>
<xsl:template match="mwsh:keywords">
<span class="keyword"><xsl:value-of select="."/></span>
</xsl:template>
<xsl:template match="mwsh:strings">
<span class="string"><xsl:value-of select="."/></span>
</xsl:template>
<xsl:template match="mwsh:comments">
<span class="comment"><xsl:value-of select="."/></span>
</xsl:template>
<xsl:template match="mwsh:unterminated_strings">
<span class="untermstring"><xsl:value-of select="."/></span>
</xsl:template>
<xsl:template match="mwsh:system_commands">
<span class="syscmd"><xsl:value-of select="."/></span>
</xsl:template>
<!-- Used to escape special characters in the LaTeX output. -->
<escape:replacements>
<!-- special TeX characters -->
<replace><from>$</from><to>\$</to></replace>
<replace><from>&</from><to>\&</to></replace>
<replace><from>%</from><to>\%</to></replace>
<replace><from>#</from><to>\#</to></replace>
<replace><from>_</from><to>\_</to></replace>
<replace><from>{</from><to>\{</to></replace>
<replace><from>}</from><to>\}</to></replace>
<!-- mainly in code -->
<replace><from>~</from><to>\ensuremath{\tilde{\;}}</to></replace>
<replace><from>^</from><to>\^{}</to></replace>
<replace><from>\</from><to>\ensuremath{\backslash}</to></replace>
<!-- mainly in math -->
<replace><from>|</from><to>\ensuremath{|}</to></replace>
<replace><from><</from><to>\ensuremath{<}</to></replace>
<replace><from>></from><to>\ensuremath{>}</to></replace>
</escape:replacements>
<xsl:variable name="replacements" select="document('')/xsl:stylesheet/escape:replacements/replace"/>
<xsl:template name="replace">
<xsl:param name="string"/>
<xsl:param name="next" select="1"/>
<xsl:variable name="count" select="count($replacements)"/>
<xsl:variable name="first" select="$replacements[$next]"/>
<xsl:choose>
<xsl:when test="$next > $count">
<xsl:value-of select="$string"/>
</xsl:when>
<xsl:when test="contains($string, $first/from)">
<xsl:call-template name="replace">
<xsl:with-param name="string"
select="substring-before($string, $first/from)"/>
<xsl:with-param name="next" select="$next+1" />
</xsl:call-template>
<xsl:copy-of select="$first/to" />
<xsl:call-template name="replace">
<xsl:with-param name="string"
select="substring-after($string, $first/from)"/>
<xsl:with-param name="next" select="$next"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="replace">
<xsl:with-param name="string" select="$string"/>
<xsl:with-param name="next" select="$next+1"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>