Legimi cover colors.
[librarian.git] / src / librarian / pdf / wl2tex.xslt
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3
4    This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5    Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6
7 -->
8 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9     xmlns:wl="http://wolnelektury.pl/functions"
10     xmlns:dc="http://purl.org/dc/elements/1.1/"
11     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
12
13 <xsl:output encoding="utf-8" indent="yes" version="2.0" />
14
15 <xsl:template match="utwor">
16     <TeXML xmlns="http://getfo.sourceforge.net/texml/ns1">
17         <TeXML escape="0">
18         \documentclass[<xsl:value-of select="@customizations"/>]{wl}
19
20         <!-- flags and values set on root -->
21
22         \newif\ifflaglessadvertising
23         <xsl:for-each select="@*[starts-with(name(), 'flag-')]">
24             <cmd>
25                 <xsl:attribute name="name"><xsl:value-of select="wl:texcommand(name())" />true</xsl:attribute>
26             </cmd>
27         </xsl:for-each>
28
29         <xsl:for-each select="@*[starts-with(name(), 'data-')]">
30             <TeXML escape="0">
31                 \def\<xsl:value-of select="wl:texcommand(name())" />{<TeXML escape="1"><xsl:value-of select="."/></TeXML>}
32             </TeXML>
33         </xsl:for-each>
34         </TeXML>
35
36         <xsl:choose>
37             <xsl:when test="@morefloats = 'new'">
38                 <TeXML escape="0">
39                     \usepackage[maxfloats=53]{morefloats}
40                 </TeXML>
41             </xsl:when>
42             <xsl:when test="@morefloats = 'old'">
43                 <TeXML escape="0">
44                     \usepackage{morefloats}
45                 </TeXML>
46             </xsl:when>
47             <xsl:when test="@morefloats = 'none'" />
48             <xsl:otherwise>
49                 <TeXML escape="0">
50                     \IfFileExists{morefloats.sty}{
51                         \usepackage{morefloats}
52                     }{}
53                 </TeXML>
54             </xsl:otherwise>
55         </xsl:choose>
56
57         <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
58         <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='titlepage' />
59
60         <env name="document">
61             <xsl:if test="@data-cover-width">
62                 <cmd name="makecover">
63                     <parm>210mm</parm>
64                     <parm><xsl:value-of select="210 * @data-cover-height div @data-cover-width" />mm</parm>
65                 </cmd>
66             </xsl:if>
67                 <xsl:if test="@thanks">
68                     <TeXML escape="0">
69                         \def\thanknote{<TeXML escape="1"><xsl:value-of select="@thanks" /></TeXML>}
70                     </TeXML>
71                 </xsl:if>
72             <cmd name="maketitle" />
73
74             <cmd name="tytul"><parm>
75               <xsl:choose>
76                 <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
77                     <!-- title in master -->
78                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/autor_utworu" mode="title" />
79                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/dzielo_nadrzedne" mode="title" />
80                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
81                     <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
82                     <!-- dc in master or not -->
83                     <cmd name="translatorsline" />
84                 </xsl:when>
85                 <xsl:otherwise>
86                     <!-- look for author title in dc -->
87                     <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
88                     <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='firstdctitle' />
89                 </xsl:otherwise>
90               </xsl:choose>
91             </parm></cmd>
92             <xsl:if test="//utwor//utwor or //naglowek_czesc or //naglowek_akt or //srodtytul or //naglowek_scena or //naglowek_rozdzial">
93                 <cmd name="ifshowtoc" />
94                 <cmd name="setcounter" >
95                     <parm>tocdepth</parm>
96                     <parm>3</parm>
97                 </cmd>
98                 <cmd name="tableofcontents" />
99                 <cmd name="clearpage" />
100                 <cmd name="fi" />
101             </xsl:if>
102             <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
103             <xsl:apply-templates select="utwor" mode="part" />
104
105             <TeXML escape="0">
106                 <xsl:if test="@data-cover-by">
107                 \def\coverby{Okładka na podstawie:
108                     <xsl:choose>
109                     <xsl:when test="@data-cover-source">
110                         \href{\datacoversource}{\datacoverby}
111                     </xsl:when>
112                     <xsl:otherwise>
113                         \datacoverby{}
114                     </xsl:otherwise>
115                     </xsl:choose>
116                 }
117                 </xsl:if>
118                 \def\editors{<TeXML escape="1"><xsl:call-template name="editors" /></TeXML>}
119                 <xsl:if test="@funders">
120                     \def\funders{Publikację wsparli i wsparły:
121                         <TeXML escape="1"><xsl:value-of select="@funders" /></TeXML>.}
122                 </xsl:if>
123
124                 <xsl:if test="@sponsor-note|data-sponsor">
125                     \def\sponsors{
126                         \scriptsize
127                         <xsl:choose>
128                             <xsl:when test="@sponsor-note">
129                                 <TeXML escape="1"><xsl:value-of select="@sponsor-note" /></TeXML>
130                             </xsl:when>
131                             <xsl:otherwise>
132                                 Sfinansowano ze~środków:
133                             </xsl:otherwise>
134                         </xsl:choose>
135
136                         \vspace{1em}
137
138                         <xsl:apply-templates select="data-sponsor" mode="sponsor" />
139                     }
140                 </xsl:if>
141             </TeXML>
142
143             <TeXML escape="0">
144                     \ifendnotes
145 \newpage
146 \begingroup
147 \parindent 0pt
148 \parskip 2ex
149 \def\enotesize{\normalsize}
150 \printendnotes
151                     \endgroup
152                     \fi
153             </TeXML>
154
155             <cmd name="editorialsection" />
156
157         </env>
158     </TeXML>
159 </xsl:template>
160
161 <xsl:template match="utwor" mode="part">
162     <cmd name="tytul"><parm>
163       <xsl:choose>
164         <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
165             <!-- title in master -->
166             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="part_title" />
167             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
168         </xsl:when>
169         <xsl:otherwise>
170             <!-- look for title in dc -->
171             <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
172             <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
173         </xsl:otherwise>
174       </xsl:choose>
175     </parm></cmd>
176
177     <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
178     <xsl:apply-templates select="utwor" mode="part" />
179 </xsl:template>
180
181 <!-- =================== -->
182 <!-- = MAIN TITLE PAGE = -->
183 <!-- = (from DC)       = -->
184 <!-- =================== -->
185
186 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
187     <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
188 </xsl:template>
189
190 <xsl:template match="rdf:RDF" mode="titlepage">
191     <TeXML escape="0">
192         \def\authors{<TeXML escape="1"><xsl:call-template name="authors" /></TeXML>}
193         \author{\authors}
194         \title{<TeXML escape="1"><xsl:apply-templates select=".//dc:title" mode="inline" /></TeXML>}
195         \def\translatorsline{<TeXML escape="1"><xsl:call-template name="translators" /></TeXML>}
196
197         \def\bookurl{<TeXML escape="1"><xsl:value-of select=".//dc:identifier.url" /></TeXML>}
198
199         \def\rightsinfo{Ten utwór jest w~domenie publicznej.}
200         <xsl:if test=".//dc:rights.license">
201             \def\rightsinfo{Ten utwór jest udostępniony na licencji
202             \href{<xsl:value-of select=".//dc:rights.license" />}{<TeXML escape="1"><xsl:apply-templates select=".//dc:rights" mode="inline" /></TeXML>}.}
203         </xsl:if>
204
205         \def\sourceinfo{
206             <xsl:if test=".//dc:source">
207                 Tekst opracowany na podstawie: <TeXML escape="1"><xsl:apply-templates select=".//dc:source" mode="inline" /></TeXML>
208                 \vspace{.6em}
209             </xsl:if>}
210         \def\publisherinfo{
211             <xsl:if test=".//dc:publisher">
212                 Wydawca:
213                 <TeXML escape="1">
214                     <xsl:for-each select=".//dc:publisher/text()">
215                         <xsl:value-of select="."/>
216                         <xsl:if test="not(position() = last())">, </xsl:if>
217                     </xsl:for-each>
218                 </TeXML>
219                 \vspace{.6em}
220             </xsl:if>}
221         \def\description{<TeXML escape="1"><xsl:apply-templates select=".//dc:description" mode="inline" /></TeXML>}
222         <xsl:if test=".//meta[@id='pdf-id']">
223             <xsl:variable name="isbn" select=".//meta[@id='pdf-id']"/>
224             \def\isbn{ISBN <xsl:value-of select="substring-after($isbn, 'ISBN-')"/>}
225         </xsl:if>
226     </TeXML>
227 </xsl:template>
228
229
230 <!-- ============== -->
231 <!-- = BOOK TITLE = -->
232 <!-- = (from DC)  = -->
233 <!-- ============== -->
234
235 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
236     <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
237 </xsl:template>
238
239 <xsl:template match="rdf:RDF" mode="dctitle">
240     <xsl:if test="../../rdf:RDF//use_subauthor">
241         <cmd name="autorpodutworu">
242             <parm><xsl:call-template name="authors" /></parm>
243         </cmd>
244     </xsl:if>
245     <cmd name="nazwanadpodutworu"><parm>
246         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
247     </parm>
248     <parm>
249         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
250     </parm></cmd>
251 </xsl:template>
252
253 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
254     <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
255 </xsl:template>
256
257 <xsl:template match="rdf:RDF" mode="firstdctitle">
258     <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
259     <cmd name="nazwautworu"><parm>
260         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
261     </parm></cmd>
262     <cmd name="translatorsline" />
263 </xsl:template>
264
265
266 <!-- ============================================================================== -->
267 <!-- = MASTER TAG                                                                 = -->
268 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
269 <!-- ============================================================================== -->
270 <!-- ==================================================================================== -->
271 <!-- = BLOCK TAGS                                                                       = -->
272 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
273 <!-- ==================================================================================== -->
274
275 <xsl:template
276     match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto|ramka">
277     <cmd>
278         <xsl:attribute name="name">
279             <xsl:value-of select="wl:texcommand(name())" />
280         </xsl:attribute>
281         <parm><xsl:apply-templates/></parm>
282     </cmd>
283 </xsl:template>
284
285 <xsl:template match="lista_osob">
286     <cmd name="listaosob">
287         <parm><xsl:apply-templates select="naglowek_listy" /></parm>
288         <parm><xsl:apply-templates select="lista_osoba" /></parm>
289     </cmd>
290 </xsl:template>
291
292 <xsl:template match="kwestia">
293     <cmd name="kwestia">
294         <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
295     </cmd>
296 </xsl:template>
297
298 <xsl:template match="ilustr">
299   <xsl:choose>
300     <xsl:when test="@oblew = 'true'">
301       <cmd name="par"/>
302       <env name="wrapfigure">
303         <parm>R</parm>
304         <parm>5cm</parm>
305         <cmd name="includegraphics">
306           <opt>width=<cmd name="linewidth"/></opt>
307           <parm><xsl:value-of select="@src"/></parm>
308         </cmd>
309       </env>
310     </xsl:when>
311     <xsl:otherwise>
312       <cmd name="ilustr">
313         <parm><xsl:value-of select="@src" /></parm>
314         <parm><xsl:value-of select="@alt" /></parm>
315       </cmd>
316     </xsl:otherwise>
317   </xsl:choose>
318 </xsl:template>
319
320 <!-- ========================================== -->
321 <!-- = PARAGRAPH TAGS                         = -->
322 <!-- = (can contain inline and special tags)  = -->
323 <!-- ========================================== -->
324
325 <!-- only in root -->
326 <xsl:template
327     match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
328     mode="title">
329     <cmd>
330         <xsl:attribute name="name">
331             <xsl:value-of select="wl:texcommand(name())" />
332         </xsl:attribute>
333         <parm><xsl:apply-templates mode="inline"/></parm>
334     </cmd>
335 </xsl:template>
336
337 <xsl:template match="nazwa_utworu" mode="part_title">
338     <xsl:if test="../../rdf:RDF//use_subauthor">
339         <cmd name="autorpodutworu"><parm><xsl:call-template name="authors2"/></parm></cmd>
340     </xsl:if>
341     <cmd name="nazwapodutworu">
342         <parm><xsl:apply-templates mode="inline"/></parm>
343         <parm>
344             <xsl:call-template name="strip-for-toc" />
345         </parm>
346     </cmd>
347 </xsl:template>
348
349
350 <xsl:template
351     match="naglowek_osoba|naglowek_podrozdzial|podtytul_podrozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_dialog|akap_cd|motto_podpis|naglowek_listy|srodtytul|podtytul_czesc|podtytul_rozdzial|podtytul_akt|podtytul_scena">
352   <xsl:choose>
353     <xsl:when test="@inline">
354       <xsl:apply-templates mode="inline"/>
355     </xsl:when>
356     <xsl:otherwise>
357       <cmd>
358         <xsl:attribute name="name">
359             <xsl:value-of select="wl:texcommand(name())" />
360         </xsl:attribute>
361         <parm><xsl:apply-templates mode="inline"/></parm>
362       </cmd>
363     </xsl:otherwise>
364   </xsl:choose>
365 </xsl:template>
366
367 <xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_akt|naglowek_scena">
368     <cmd>
369         <xsl:attribute name="name">
370             <xsl:value-of select="wl:texcommand(name())" />
371         </xsl:attribute>
372         <parm><xsl:apply-templates mode="inline"/></parm>
373         <parm>
374             <xsl:call-template name="strip-for-toc" />
375         </parm>
376     </cmd>
377 </xsl:template>
378
379 <xsl:template match="strofa" mode="inline">
380     <env name="minipage">
381         <opt>t</opt>
382         <parm><cmd name="linewidth" /></parm>
383         <parm><xsl:apply-templates select="." /></parm>
384     </env>
385 </xsl:template>
386
387 <xsl:template match="strofa">
388   <cmd name="strofa"><parm>
389     <xsl:choose>
390         <xsl:when test="count(br) > 0">
391             <xsl:call-template name="verse">
392                 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
393                 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd' or name() = 'wers_do_prawej'][1]" />
394             </xsl:call-template>
395             <xsl:for-each select="br">
396                 <TeXML escape="0">\\{}</TeXML>
397                 <!-- Each BR tag "consumes" text after it -->
398                 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
399                 <xsl:call-template name="verse">
400                     <xsl:with-param name="verse-content"
401                         select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
402                     <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd' or name() = 'wers_do_prawej')][1]" />
403                 </xsl:call-template>
404             </xsl:for-each>
405         </xsl:when>
406         <xsl:otherwise>
407             <xsl:call-template name="verse">
408                 <xsl:with-param name="verse-content" select="text() | node()" />
409                 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
410             </xsl:call-template>
411         </xsl:otherwise>
412     </xsl:choose>
413   </parm></cmd>
414 </xsl:template>
415
416
417 <xsl:template name="verse">
418     <xsl:param name="verse-content" />
419     <xsl:param name="verse-type" />
420
421     <cmd>
422         <xsl:attribute name="name">
423             <xsl:choose>
424                 <xsl:when test="$verse-type != ''">
425                     <xsl:value-of select='wl:texcommand(name($verse-type))' />
426                 </xsl:when>
427                 <xsl:otherwise>wers</xsl:otherwise>
428             </xsl:choose>
429         </xsl:attribute>
430         <xsl:if test="string($verse-content/@typ)">
431             <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
432         </xsl:if>
433         <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
434     </cmd>
435 </xsl:template>
436
437 <!-- ================================================ -->
438 <!-- = INLINE TAGS                                  = -->
439 <!-- = (contain other inline tags and special tags) = -->
440 <!-- ================================================ -->
441
442
443 <xsl:template mode="inline"
444     match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|indeks_dolny|wieksze_odstepy">
445     <cmd>
446         <xsl:attribute name="name">
447                 <xsl:value-of select="wl:texcommand(name())" />
448         </xsl:attribute>
449         <parm>
450           <xsl:choose>
451             <xsl:when test="@blocks">
452               <xsl:apply-templates/>
453             </xsl:when>
454             <xsl:otherwise>
455               <xsl:apply-templates mode="inline"/>
456             </xsl:otherwise>
457           </xsl:choose>
458         </parm>
459     </cmd>
460 </xsl:template>
461
462
463
464 <xsl:template match="tytul_dziela" mode="inline">
465     <cmd name="tytuldziela"><parm>
466         <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
467     </parm></cmd>
468 </xsl:template>
469
470
471
472 <!-- ============================================== -->
473 <!-- = STANDALONE TAGS                            = -->
474 <!-- = (cannot contain any other tags)            = -->
475 <!-- ============================================== -->
476 <xsl:template
477     match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
478     <cmd>
479         <xsl:attribute name="name">
480             <xsl:value-of select="wl:texcommand(name())" />
481         </xsl:attribute>
482     </cmd>
483 </xsl:template>
484
485
486 <!-- ================ -->
487 <!-- = SPECIAL TAGS = -->
488 <!-- ================ -->
489 <!-- Themes -->
490
491
492 <xsl:template match="begin|end|motyw">
493     <xsl:apply-templates select='.' mode="inline" />
494 </xsl:template>
495
496 <xsl:template match="begin" mode="inline" />
497 <xsl:template match="end" mode="inline" />
498
499 <xsl:template match="motyw" mode="inline">
500     <cmd name="motyw">
501         <xsl:if test="@moved">
502             <opt name="moved"><xsl:value-of select="@moved" /></opt>
503         </xsl:if>
504         <parm><xsl:apply-templates mode="inline" /></parm>
505     </cmd>
506 </xsl:template>
507
508 <xsl:template name="authors">
509     <xsl:for-each select=".//dc:creator_parsed">
510         <xsl:if test="position() != 1">, </xsl:if>
511         <xsl:apply-templates mode="inline" />
512     </xsl:for-each>
513 </xsl:template>
514
515 <xsl:template name="authors2">
516     <xsl:for-each select="../..//dc:creator_parsed">
517         <xsl:if test="position() != 1">, </xsl:if>
518         <xsl:apply-templates mode="inline" />
519     </xsl:for-each>
520 </xsl:template>
521
522 <xsl:template name="editors">
523     <xsl:if test="@editors">
524         <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
525         <xsl:value-of select="@editors" />
526         <xsl:text>.</xsl:text>
527     </xsl:if>
528 </xsl:template>
529
530 <xsl:template name="translators">
531     <xsl:if test=".//dc:contributor.translator_parsed">
532         <cmd name='translator'><parm>
533             <xsl:for-each select=".//dc:contributor.translator_parsed">
534                 <xsl:if test="position() != 1">, </xsl:if>
535                 <xsl:apply-templates mode="inline" />
536             </xsl:for-each>
537         </parm></cmd>
538     </xsl:if>
539 </xsl:template>
540
541 <xsl:template name="strip-for-toc">
542     <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
543         <xsl:choose>
544             <xsl:when test="name() = 'nbsp'">
545                 <xsl:text> </xsl:text>
546             </xsl:when>
547             <xsl:when test="name() = 'dywiz'">
548                 <xsl:text>-</xsl:text>
549             </xsl:when>
550             <xsl:when test="name() = 'alien'">
551                 <xsl:apply-templates mode="inline" />
552             </xsl:when>
553             <xsl:when test="name() = 'slowo_obce'">
554                 <xsl:call-template name="strip-for-toc" />
555             </xsl:when>
556             <xsl:otherwise>
557                 <xsl:value-of select="."/>
558             </xsl:otherwise>
559         </xsl:choose>
560     </xsl:for-each>
561 </xsl:template>
562
563 <xsl:template match="data-sponsor" mode="sponsor">
564     <cmd name="par"><parm>
565     <xsl:choose>
566         <xsl:when test="@src">
567             \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
568         </xsl:when>
569         <xsl:otherwise>
570             <xsl:value-of select="@name" />
571         </xsl:otherwise>
572     </xsl:choose>
573     </parm></cmd>
574 </xsl:template>
575
576 <xsl:template match="mat" mode="inline">
577     <TeXML escape="0">
578         <xsl:text>$</xsl:text>
579         <xsl:value-of select="wl:mathml_latex(.)" />
580         <xsl:text>$</xsl:text>
581     </TeXML>
582 </xsl:template>
583
584 <xsl:template match="mat">
585     <TeXML escape="0">
586         <xsl:text>$$</xsl:text>
587         <xsl:value-of select="wl:mathml_latex(.)" />
588         <xsl:text>$$</xsl:text>
589     </TeXML>
590 </xsl:template>
591
592 <xsl:template match="tabela|tabelka">
593     <cmd name="par" />
594     <cmd name="vspace"><parm>1em</parm></cmd>
595     <group><cmd name="raggedright" />
596     <xsl:element name="env">
597         <xsl:attribute name="name">
598             <xsl:choose>
599                 <xsl:when test="name(.)='tabela'">longtabu</xsl:when>
600                 <xsl:otherwise>tabu</xsl:otherwise>
601             </xsl:choose>
602         </xsl:attribute> to <TeXML escape="0">\textwidth </TeXML>
603       <!--parm><cmd name="textwidth"/></parm-->
604       <parm><TeXML escape="0"><xsl:value-of select="@_format" /></TeXML></parm>
605         <xsl:choose>
606         <xsl:when test="@ramka='1' or @ramki='1'">
607           <cmd name="hline" />
608           <xsl:apply-templates mode="wiersze-ramki"/>
609         </xsl:when>
610         <xsl:otherwise>
611           <xsl:apply-templates/>
612         </xsl:otherwise>
613         </xsl:choose>
614     </xsl:element>
615     </group>
616     <cmd name="vspace"><parm>1em</parm></cmd>
617 </xsl:template>
618 <xsl:template match="wiersz" mode="wiersze-ramki">
619     <xsl:apply-templates />
620     <spec cat="esc"/><spec cat="esc"/>
621     <cmd name="hline" gr="0" />
622 </xsl:template>
623 <xsl:template match="wiersz">
624     <xsl:apply-templates />
625     <spec cat="esc"/><spec cat="esc"/>
626 </xsl:template>
627 <xsl:template match="kol">
628     <xsl:apply-templates mode="inline"/>
629     <xsl:if test="position() &lt; last()">
630     <spec cat="align"/>
631     </xsl:if>
632 </xsl:template>
633
634
635 <!-- ============== -->
636 <!-- = ADDED TAGS = -->
637 <!-- ============== -->
638
639
640 <xsl:template match="dywiz" mode="inline">
641     <cmd name="dywiz" />
642 </xsl:template>
643
644 <xsl:template match="nbsp" mode="inline">
645     <spec cat="tilde" />
646 </xsl:template>
647
648 <xsl:template match="alien" mode="inline">
649     <group>
650         <cmd name="alien" />
651         <xsl:apply-templates mode="inline" />
652     </group>
653 </xsl:template>
654
655 <!-- ================ -->
656 <!-- = IGNORED TAGS = -->
657 <!-- ================ -->
658 <xsl:template match="extra|uwaga" />
659 <xsl:template match="extra|uwaga" mode="inline" />
660
661 <xsl:template match="nota_red" />
662 <xsl:template match="abstrakt" />
663
664 <!-- ======== -->
665 <!-- = TEXT = -->
666 <!-- ======== -->
667 <xsl:template match="text()" />
668 <xsl:template match="text()" mode="inline">
669     <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
670       <xsl:text> </xsl:text>
671     </xsl:if>
672
673     <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
674
675     <xsl:if test="following-sibling::node() and wl:ends_white(.)">
676       <xsl:text> </xsl:text>
677     </xsl:if>
678 </xsl:template>
679
680
681 </xsl:stylesheet>