-
Notifications
You must be signed in to change notification settings - Fork 16
/
fromivoadoc.xslt
209 lines (143 loc) · 4.3 KB
/
fromivoadoc.xslt
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
<?xml version="1.0"?>
<stylesheet version="1.0"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<!-- XSLT for a partial automation of the migration from ivoadoc
XHTML to ivoatex -->
<output method="text"/>
<strip-space elements="*"/>
<template match="h:html">
\documentclass{ivoa}
\input tthdefs
\ivoagroup{FIXTHIS}
\author[FIXTHIS]{FIXTHIS}
\editor[FIXTHIS]{FIXTHIS}
\previousversion{FIXTHIS}
<apply-templates/>
</template>
<template match="h:p">
<apply-templates/>
<text>

</text>
</template>
<template match="h:body">
\begin{document}
<apply-templates/>
\end{document}
</template>
<!-- Common inline markup -->
<template match="h:cite">\citep{<apply-templates/>}</template>
<template match="h:em">\emph{<apply-templates/>}</template>
<template match="h:strong">\textbf{<apply-templates/>}</template>
<template match="h:span[@class='xref']">\ref{<apply-templates/>}</template>
<template match="h:code">\texttt{<apply-templates/>}</template>
<template match="h:a[@href]"
>\href{<value-of select="@href"/>}{<apply-templates/>}</template>
<template match="h:br">\\</template>
<!-- Tables (these will definitely require polishing) -->
<template match="h:table">
\begin{table}
\begin{tabular}[FIXTHIS]
<apply-templates/>
\end{tabular}
\end{table}
</template>
<template match="h:tr">
<apply-templates/>\\
</template>
<template match="h:td[position()!=last()]">
<apply-templates/>&</template>
<template match="h:td[position()=last()]">
<apply-templates/></template>
<template match="h:th[position()!=last()]">
\textbf{<apply-templates/>}&</template>
<template match="h:th[position()=last()]">
\textbf{<apply-templates/>}</template>
<template match="h:tbody"><apply-templates/></template>
<template match="h:thead"><apply-templates/></template>
<template match="h:div[@class='tablewrap']"><apply-templates/></template>
<!-- Images and other block-level stuff -->
<template match="h:img">
\includegraphics[width=0.9\textwidth]{<value-of select="src"/>}
</template>
<template match="h:div[@class='figure']">
\begin{figure}
<apply-templates/>
FIXTHIS: Mark up caption
\end{figure}
</template>
<template match="h:dl">
\begin{description}
<apply-templates/>
\end{description}
</template>
<template match="h:dt">\item[<apply-templates/>]</template>
<template match="h:dd"><apply-templates/><text>
</text></template>
<template match="h:pre">
\begin{verbatim}<apply-templates/>\end{verbatim}
</template>
<template match="h:ul">
\begin{itemize}
<apply-templates/>
\end{itemize}
</template>
<template match="h:ol">
\begin{enumerate}
<apply-templates/>
\end{enumerate}
</template>
<template match="h:li">
\item <apply-templates/>{}
</template>
<!-- Sectioning -->
<template match="h:h2">
\section{<apply-templates/>}
<apply-templates mode="extract-labels"/>
</template>
<template match="h:h3">
\subsection{<apply-templates/>}
<apply-templates mode="extract-labels"/>
</template>
<template match="h:h4">
\subsubsection{<apply-templates/>}
<apply-templates mode="extract-labels"/>
</template>
<template match="h:a" mode="extract-labels">
\label{<value-of select="@id"/>}
</template>
<template match="h:a[@name]"><!--
we have no idea what to do with a random anchor --><apply-templates
/></template>
<template match="h:a[@id]"><!--
we have no idea what to do with a random anchor --><apply-templates
/></template>
<template match="h:div[@class='section']">
% HTML section start
<apply-templates/>
% HTML section ends
</template>
<!-- Pull some stuff from the document header, throw away the rest -->
<template match="h:div[@class='head']">
<apply-templates mode="head"/>
</template>
<template match="h:h2[text()='Abstract']" mode="head">
\begin{abstract}
<variable name="myPos" select="position()"/>
<apply-templates select="../*[$myPos+1]"/>
\end{abstract}
</template>
<template match="h:head">
\title{<value-of select="h:title"/>}
</template>
<template match="*" mode="head">
</template>
<!-- Fallback so unmapped stuff doesn't just vanish -->
<template match="*" priority="-10">
<<value-of select="local-name()"/>><apply-templates
/></<value-of select="local-name()"/>>
</template>
<!-- other stuff -->
<template match="comment()">
% <value-of select="normalize-space(.)"/><text>
</text>
</template>
</stylesheet>