Avoid hanging conjunction on covers.
[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             <cmd name="editorialsection" />
144
145         </env>
146     </TeXML>
147 </xsl:template>
148
149 <xsl:template match="utwor" mode="part">
150     <cmd name="tytul"><parm>
151       <xsl:choose>
152         <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
153             <!-- title in master -->
154             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="part_title" />
155             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
156         </xsl:when>
157         <xsl:otherwise>
158             <!-- look for title in dc -->
159             <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
160             <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='dctitle' />
161         </xsl:otherwise>
162       </xsl:choose>
163     </parm></cmd>
164
165     <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
166     <xsl:apply-templates select="utwor" mode="part" />
167 </xsl:template>
168
169 <!-- =================== -->
170 <!-- = MAIN TITLE PAGE = -->
171 <!-- = (from DC)       = -->
172 <!-- =================== -->
173
174 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="titlepage">
175     <xsl:apply-templates select="rdf:RDF" mode="titlepage" />
176 </xsl:template>
177
178 <xsl:template match="rdf:RDF" mode="titlepage">
179     <TeXML escape="0">
180         \def\authors{<TeXML escape="1"><xsl:call-template name="authors" /></TeXML>}
181         \author{\authors}
182         \title{<TeXML escape="1"><xsl:apply-templates select=".//dc:title" mode="inline" /></TeXML>}
183         \def\translatorsline{<TeXML escape="1"><xsl:call-template name="translators" /></TeXML>}
184
185         \def\bookurl{<TeXML escape="1"><xsl:value-of select=".//dc:identifier.url" /></TeXML>}
186
187         \def\rightsinfo{Ten utwór nie jest objęty majątkowym prawem autorskim i~znajduje się w~domenie
188             publicznej, co oznacza że możesz go swobodnie wykorzystywać, publikować
189             i~rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi materiałami
190             (przypisy, motywy literackie etc.), które podlegają prawu autorskiemu, to
191             te dodatkowe materiały udostępnione są na licencji
192             \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
193             Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
194         <xsl:if test=".//dc:rights.license">
195             \def\rightsinfo{Ten utwór jest udostępniony na licencji
196             \href{<xsl:value-of select=".//dc:rights.license" />}{<TeXML escape="1"><xsl:apply-templates select=".//dc:rights" mode="inline" /></TeXML>}.}
197         </xsl:if>
198
199         \def\sourceinfo{
200             <xsl:if test=".//dc:source">
201                 Tekst opracowany na podstawie: <TeXML escape="1"><xsl:apply-templates select=".//dc:source" mode="inline" /></TeXML>
202                 \vspace{.6em}
203             </xsl:if>}
204         \def\publisherinfo{
205             <xsl:if test=".//dc:publisher">
206                 Wydawca:
207                 <TeXML escape="1">
208                     <xsl:for-each select=".//dc:publisher/text()">
209                         <xsl:value-of select="."/>
210                         <xsl:if test="not(position() = last())">, </xsl:if>
211                     </xsl:for-each>
212                 </TeXML>
213                 \vspace{.6em}
214             </xsl:if>}
215         \def\description{<TeXML escape="1"><xsl:apply-templates select=".//dc:description" mode="inline" /></TeXML>}
216         <xsl:if test=".//meta[@id='pdf-id']">
217             <xsl:variable name="isbn" select=".//meta[@id='pdf-id']"/>
218             \def\isbn{ISBN <xsl:value-of select="substring-after($isbn, 'ISBN-')"/>}
219         </xsl:if>
220     </TeXML>
221 </xsl:template>
222
223
224 <!-- ============== -->
225 <!-- = BOOK TITLE = -->
226 <!-- = (from DC)  = -->
227 <!-- ============== -->
228
229 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="dctitle">
230     <xsl:apply-templates select="rdf:RDF" mode="dctitle" />
231 </xsl:template>
232
233 <xsl:template match="rdf:RDF" mode="dctitle">
234     <xsl:if test="../../rdf:RDF//use_subauthor">
235         <cmd name="autorpodutworu">
236             <parm><xsl:call-template name="authors" /></parm>
237         </cmd>
238     </xsl:if>
239     <cmd name="nazwanadpodutworu"><parm>
240         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
241     </parm>
242     <parm>
243         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
244     </parm></cmd>
245 </xsl:template>
246
247 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode="firstdctitle">
248     <xsl:apply-templates select="rdf:RDF" mode="firstdctitle" />
249 </xsl:template>
250
251 <xsl:template match="rdf:RDF" mode="firstdctitle">
252     <cmd name="autorutworu"><parm><cmd name="authors"/></parm></cmd>
253     <cmd name="nazwautworu"><parm>
254         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
255     </parm></cmd>
256     <cmd name="translatorsline" />
257 </xsl:template>
258
259
260 <!-- ============================================================================== -->
261 <!-- = MASTER TAG                                                                 = -->
262 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
263 <!-- ============================================================================== -->
264 <!-- ==================================================================================== -->
265 <!-- = BLOCK TAGS                                                                       = -->
266 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
267 <!-- ==================================================================================== -->
268
269 <xsl:template
270     match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto|ramka">
271     <cmd>
272         <xsl:attribute name="name">
273             <xsl:value-of select="wl:texcommand(name())" />
274         </xsl:attribute>
275         <parm><xsl:apply-templates/></parm>
276     </cmd>
277 </xsl:template>
278
279 <xsl:template match="lista_osob">
280     <cmd name="listaosob">
281         <parm><xsl:apply-templates select="naglowek_listy" /></parm>
282         <parm><xsl:apply-templates select="lista_osoba" /></parm>
283     </cmd>
284 </xsl:template>
285
286 <xsl:template match="kwestia">
287     <cmd name="kwestia">
288         <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
289     </cmd>
290 </xsl:template>
291
292 <xsl:template match="ilustr">
293   <xsl:choose>
294     <xsl:when test="@oblew = 'true'">
295       <cmd name="par"/>
296       <env name="wrapfigure">
297         <parm>R</parm>
298         <parm>5cm</parm>
299         <cmd name="includegraphics">
300           <opt>width=<cmd name="linewidth"/></opt>
301           <parm><xsl:value-of select="@src"/></parm>
302         </cmd>
303       </env>
304     </xsl:when>
305     <xsl:otherwise>
306       <cmd name="ilustr">
307         <parm><xsl:value-of select="@src" /></parm>
308         <parm><xsl:value-of select="@alt" /></parm>
309       </cmd>
310     </xsl:otherwise>
311   </xsl:choose>
312 </xsl:template>
313
314 <!-- ========================================== -->
315 <!-- = PARAGRAPH TAGS                         = -->
316 <!-- = (can contain inline and special tags)  = -->
317 <!-- ========================================== -->
318
319 <!-- only in root -->
320 <xsl:template
321     match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
322     mode="title">
323     <cmd>
324         <xsl:attribute name="name">
325             <xsl:value-of select="wl:texcommand(name())" />
326         </xsl:attribute>
327         <parm><xsl:apply-templates mode="inline"/></parm>
328     </cmd>
329 </xsl:template>
330
331 <xsl:template match="nazwa_utworu" mode="part_title">
332     <xsl:if test="../../rdf:RDF//use_subauthor">
333         <cmd name="autorpodutworu"><parm><xsl:call-template name="authors2"/></parm></cmd>
334     </xsl:if>
335     <cmd name="nazwapodutworu">
336         <parm><xsl:apply-templates mode="inline"/></parm>
337         <parm>
338             <xsl:call-template name="strip-for-toc" />
339         </parm>
340     </cmd>
341 </xsl:template>
342
343
344 <xsl:template
345         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">
346     <cmd>
347         <xsl:attribute name="name">
348             <xsl:value-of select="wl:texcommand(name())" />
349         </xsl:attribute>
350         <parm><xsl:apply-templates mode="inline"/></parm>
351     </cmd>
352 </xsl:template>
353
354 <xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_akt|naglowek_scena">
355     <cmd>
356         <xsl:attribute name="name">
357             <xsl:value-of select="wl:texcommand(name())" />
358         </xsl:attribute>
359         <parm><xsl:apply-templates mode="inline"/></parm>
360         <parm>
361             <xsl:call-template name="strip-for-toc" />
362         </parm>
363     </cmd>
364 </xsl:template>
365
366 <xsl:template match="strofa" mode="inline">
367     <env name="minipage">
368         <opt>t</opt>
369         <parm><cmd name="linewidth" /></parm>
370         <parm><xsl:apply-templates select="." /></parm>
371     </env>
372 </xsl:template>
373
374 <xsl:template match="strofa">
375   <cmd name="strofa"><parm>
376     <xsl:choose>
377         <xsl:when test="count(br) > 0">
378             <xsl:call-template name="verse">
379                 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
380                 <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]" />
381             </xsl:call-template>
382             <xsl:for-each select="br">
383                 <TeXML escape="0">\\{}</TeXML>
384                 <!-- Each BR tag "consumes" text after it -->
385                 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
386                 <xsl:call-template name="verse">
387                     <xsl:with-param name="verse-content"
388                         select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
389                     <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]" />
390                 </xsl:call-template>
391             </xsl:for-each>
392         </xsl:when>
393         <xsl:otherwise>
394             <xsl:call-template name="verse">
395                 <xsl:with-param name="verse-content" select="text() | node()" />
396                 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
397             </xsl:call-template>
398         </xsl:otherwise>
399     </xsl:choose>
400   </parm></cmd>
401 </xsl:template>
402
403
404 <xsl:template name="verse">
405     <xsl:param name="verse-content" />
406     <xsl:param name="verse-type" />
407
408     <cmd>
409         <xsl:attribute name="name">
410             <xsl:choose>
411                 <xsl:when test="$verse-type != ''">
412                     <xsl:value-of select='wl:texcommand(name($verse-type))' />
413                 </xsl:when>
414                 <xsl:otherwise>wers</xsl:otherwise>
415             </xsl:choose>
416         </xsl:attribute>
417         <xsl:if test="string($verse-content/@typ)">
418             <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
419         </xsl:if>
420         <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
421     </cmd>
422 </xsl:template>
423
424 <!-- ================================================ -->
425 <!-- = INLINE TAGS                                  = -->
426 <!-- = (contain other inline tags and special tags) = -->
427 <!-- ================================================ -->
428
429 <xsl:template mode="inline"
430     match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|indeks_dolny|wieksze_odstepy">
431     <cmd>
432         <xsl:attribute name="name">
433             <xsl:value-of select="wl:texcommand(name())" />
434         </xsl:attribute>
435         <parm><xsl:apply-templates mode="inline"/></parm>
436     </cmd>
437 </xsl:template>
438
439
440
441 <xsl:template match="tytul_dziela" mode="inline">
442     <cmd name="tytuldziela"><parm>
443         <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
444     </parm></cmd>
445 </xsl:template>
446
447
448
449 <!-- ============================================== -->
450 <!-- = STANDALONE TAGS                            = -->
451 <!-- = (cannot contain any other tags)            = -->
452 <!-- ============================================== -->
453 <xsl:template
454     match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
455     <cmd>
456         <xsl:attribute name="name">
457             <xsl:value-of select="wl:texcommand(name())" />
458         </xsl:attribute>
459     </cmd>
460 </xsl:template>
461
462
463 <!-- ================ -->
464 <!-- = SPECIAL TAGS = -->
465 <!-- ================ -->
466 <!-- Themes -->
467
468
469 <xsl:template match="begin|end|motyw">
470     <xsl:apply-templates select='.' mode="inline" />
471 </xsl:template>
472
473 <xsl:template match="begin" mode="inline" />
474 <xsl:template match="end" mode="inline" />
475
476 <xsl:template match="motyw" mode="inline">
477     <cmd name="motyw">
478         <xsl:if test="@moved">
479             <opt name="moved"><xsl:value-of select="@moved" /></opt>
480         </xsl:if>
481         <parm><xsl:apply-templates mode="inline" /></parm>
482     </cmd>
483 </xsl:template>
484
485 <xsl:template name="authors">
486     <xsl:for-each select=".//dc:creator_parsed">
487         <xsl:if test="position() != 1">, </xsl:if>
488         <xsl:apply-templates mode="inline" />
489     </xsl:for-each>
490 </xsl:template>
491
492 <xsl:template name="authors2">
493     <xsl:for-each select="../..//dc:creator_parsed">
494         <xsl:if test="position() != 1">, </xsl:if>
495         <xsl:apply-templates mode="inline" />
496     </xsl:for-each>
497 </xsl:template>
498
499 <xsl:template name="editors">
500     <xsl:if test="@editors">
501         <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
502         <xsl:value-of select="@editors" />
503         <xsl:text>.</xsl:text>
504     </xsl:if>
505 </xsl:template>
506
507 <xsl:template name="translators">
508     <xsl:if test=".//dc:contributor.translator_parsed">
509         <cmd name='translator'><parm>
510             <xsl:for-each select=".//dc:contributor.translator_parsed">
511                 <xsl:if test="position() != 1">, </xsl:if>
512                 <xsl:apply-templates mode="inline" />
513             </xsl:for-each>
514         </parm></cmd>
515     </xsl:if>
516 </xsl:template>
517
518 <xsl:template name="strip-for-toc">
519     <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
520         <xsl:choose>
521             <xsl:when test="name() = 'nbsp'">
522                 <xsl:text> </xsl:text>
523             </xsl:when>
524             <xsl:when test="name() = 'dywiz'">
525                 <xsl:text>-</xsl:text>
526             </xsl:when>
527             <xsl:when test="name() = 'alien'">
528                 <xsl:apply-templates mode="inline" />
529             </xsl:when>
530             <xsl:when test="name() = 'slowo_obce'">
531                 <xsl:call-template name="strip-for-toc" />
532             </xsl:when>
533             <xsl:otherwise>
534                 <xsl:value-of select="."/>
535             </xsl:otherwise>
536         </xsl:choose>
537     </xsl:for-each>
538 </xsl:template>
539
540 <xsl:template match="data-sponsor" mode="sponsor">
541     <cmd name="par"><parm>
542     <xsl:choose>
543         <xsl:when test="@src">
544             \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
545         </xsl:when>
546         <xsl:otherwise>
547             <xsl:value-of select="@name" />
548         </xsl:otherwise>
549     </xsl:choose>
550     </parm></cmd>
551 </xsl:template>
552
553 <xsl:template match="mat" mode="inline">
554     <TeXML escape="0">
555         <xsl:text>$</xsl:text>
556         <xsl:value-of select="wl:mathml_latex(.)" />
557         <xsl:text>$</xsl:text>
558     </TeXML>
559 </xsl:template>
560
561 <xsl:template match="mat">
562     <TeXML escape="0">
563         <xsl:text>$$</xsl:text>
564         <xsl:value-of select="wl:mathml_latex(.)" />
565         <xsl:text>$$</xsl:text>
566     </TeXML>
567 </xsl:template>
568
569 <xsl:template match="tabela|tabelka">
570     <cmd name="par" />
571     <cmd name="vspace"><parm>1em</parm></cmd>
572     <group><cmd name="raggedright" />
573     <xsl:element name="env">
574         <xsl:attribute name="name">
575             <xsl:choose>
576                 <xsl:when test="name(.)='tabela'">longtabu</xsl:when>
577                 <xsl:otherwise>tabu</xsl:otherwise>
578             </xsl:choose>
579         </xsl:attribute> to <TeXML escape="0">\textwidth </TeXML>
580       <!--parm><cmd name="textwidth"/></parm-->
581       <parm><TeXML escape="0"><xsl:value-of select="@_format" /></TeXML></parm>
582         <xsl:choose>
583         <xsl:when test="@ramka='1' or @ramki='1'">
584           <cmd name="hline" />
585           <xsl:apply-templates mode="wiersze-ramki"/>
586         </xsl:when>
587         <xsl:otherwise>
588           <xsl:apply-templates/>
589         </xsl:otherwise>
590         </xsl:choose>
591     </xsl:element>
592     </group>
593     <cmd name="vspace"><parm>1em</parm></cmd>
594 </xsl:template>
595 <xsl:template match="wiersz" mode="wiersze-ramki">
596     <xsl:apply-templates />
597     <spec cat="esc"/><spec cat="esc"/>
598     <cmd name="hline" gr="0" />
599 </xsl:template>
600 <xsl:template match="wiersz">
601     <xsl:apply-templates />
602     <spec cat="esc"/><spec cat="esc"/>
603 </xsl:template>
604 <xsl:template match="kol">
605     <xsl:apply-templates mode="inline"/>
606     <xsl:if test="position() &lt; last()">
607     <spec cat="align"/>
608     </xsl:if>
609 </xsl:template>
610
611
612 <!-- ============== -->
613 <!-- = ADDED TAGS = -->
614 <!-- ============== -->
615
616
617 <xsl:template match="dywiz" mode="inline">
618     <cmd name="dywiz" />
619 </xsl:template>
620
621 <xsl:template match="nbsp" mode="inline">
622     <spec cat="tilde" />
623 </xsl:template>
624
625 <xsl:template match="alien" mode="inline">
626     <group>
627         <cmd name="alien" />
628         <xsl:apply-templates mode="inline" />
629     </group>
630 </xsl:template>
631
632 <!-- ================ -->
633 <!-- = IGNORED TAGS = -->
634 <!-- ================ -->
635 <xsl:template match="extra|uwaga" />
636 <xsl:template match="extra|uwaga" mode="inline" />
637
638 <xsl:template match="nota_red" />
639 <xsl:template match="abstrakt" />
640
641 <!-- ======== -->
642 <!-- = TEXT = -->
643 <!-- ======== -->
644 <xsl:template match="text()" />
645 <xsl:template match="text()" mode="inline">
646     <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
647       <xsl:text> </xsl:text>
648     </xsl:if>
649
650     <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
651
652     <xsl:if test="following-sibling::node() and wl:ends_white(.)">
653       <xsl:text> </xsl:text>
654     </xsl:if>
655 </xsl:template>
656
657
658 </xsl:stylesheet>