Bidi text in titles.
[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 Wolne Lektury. 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|werset|adresat|miejsce_data|naglowek_listu|pozdrowienie|podpis">
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="list">
368   <cmd name="wllist">
369     <parm><xsl:apply-templates mode="inline"/></parm>
370   </cmd>
371 </xsl:template>
372
373
374 <xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_akt|naglowek_scena">
375     <cmd>
376         <xsl:attribute name="name">
377             <xsl:value-of select="wl:texcommand(name())" />
378         </xsl:attribute>
379         <parm><xsl:apply-templates mode="inline"/></parm>
380         <parm>
381             <xsl:call-template name="strip-for-toc" />
382         </parm>
383     </cmd>
384 </xsl:template>
385
386 <xsl:template match="strofa" mode="inline">
387     <env name="minipage">
388         <opt>t</opt>
389         <parm><cmd name="linewidth" /></parm>
390         <parm><xsl:apply-templates select="." /></parm>
391     </env>
392 </xsl:template>
393
394 <xsl:template match="strofa">
395   <cmd name="strofa"><parm>
396     <xsl:choose>
397         <xsl:when test="count(br) > 0">
398             <xsl:call-template name="verse">
399                 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
400                 <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]" />
401             </xsl:call-template>
402             <xsl:for-each select="br">
403                 <TeXML escape="0">\\{}</TeXML>
404                 <!-- Each BR tag "consumes" text after it -->
405                 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
406                 <xsl:call-template name="verse">
407                     <xsl:with-param name="verse-content"
408                         select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
409                     <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]" />
410                 </xsl:call-template>
411             </xsl:for-each>
412         </xsl:when>
413         <xsl:otherwise>
414             <xsl:call-template name="verse">
415                 <xsl:with-param name="verse-content" select="text() | node()" />
416                 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
417             </xsl:call-template>
418         </xsl:otherwise>
419     </xsl:choose>
420   </parm></cmd>
421 </xsl:template>
422
423
424 <xsl:template name="verse">
425     <xsl:param name="verse-content" />
426     <xsl:param name="verse-type" />
427
428     <cmd>
429         <xsl:attribute name="name">
430             <xsl:choose>
431                 <xsl:when test="$verse-type != ''">
432                     <xsl:value-of select='wl:texcommand(name($verse-type))' />
433                 </xsl:when>
434                 <xsl:otherwise>wers</xsl:otherwise>
435             </xsl:choose>
436         </xsl:attribute>
437         <xsl:if test="string($verse-content/@typ)">
438             <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
439         </xsl:if>
440         <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
441     </cmd>
442 </xsl:template>
443
444 <!-- ================================================ -->
445 <!-- = INLINE TAGS                                  = -->
446 <!-- = (contain other inline tags and special tags) = -->
447 <!-- ================================================ -->
448
449
450 <xsl:template mode="inline"
451     match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|indeks_dolny|wieksze_odstepy">
452     <cmd>
453         <xsl:attribute name="name">
454                 <xsl:value-of select="wl:texcommand(name())" />
455         </xsl:attribute>
456         <parm>
457           <xsl:choose>
458             <xsl:when test="@blocks">
459               <xsl:apply-templates/>
460             </xsl:when>
461             <xsl:otherwise>
462               <xsl:apply-templates mode="inline"/>
463             </xsl:otherwise>
464           </xsl:choose>
465         </parm>
466     </cmd>
467 </xsl:template>
468
469
470
471 <xsl:template match="tytul_dziela" mode="inline">
472     <cmd name="tytuldziela"><parm>
473         <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
474     </parm></cmd>
475 </xsl:template>
476
477
478
479 <!-- ============================================== -->
480 <!-- = STANDALONE TAGS                            = -->
481 <!-- = (cannot contain any other tags)            = -->
482 <!-- ============================================== -->
483 <xsl:template
484     match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
485     <cmd>
486         <xsl:attribute name="name">
487             <xsl:value-of select="wl:texcommand(name())" />
488         </xsl:attribute>
489     </cmd>
490 </xsl:template>
491
492
493 <!-- ================ -->
494 <!-- = SPECIAL TAGS = -->
495 <!-- ================ -->
496 <!-- Themes -->
497
498
499 <xsl:template match="begin|end|motyw">
500     <xsl:apply-templates select='.' mode="inline" />
501 </xsl:template>
502
503 <xsl:template match="begin" mode="inline" />
504 <xsl:template match="end" mode="inline" />
505
506 <xsl:template match="motyw" mode="inline">
507     <cmd name="motyw">
508         <xsl:if test="@moved">
509             <opt name="moved"><xsl:value-of select="@moved" /></opt>
510         </xsl:if>
511         <parm><xsl:apply-templates mode="inline" /></parm>
512     </cmd>
513 </xsl:template>
514
515 <xsl:template name="authors">
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="authors2">
523     <xsl:for-each select="../..//dc:creator_parsed">
524         <xsl:if test="position() != 1">, </xsl:if>
525         <xsl:apply-templates mode="inline" />
526     </xsl:for-each>
527 </xsl:template>
528
529 <xsl:template name="editors">
530     <xsl:if test="@editors">
531         <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
532         <xsl:value-of select="@editors" />
533         <xsl:text>.</xsl:text>
534     </xsl:if>
535 </xsl:template>
536
537 <xsl:template name="translators">
538     <xsl:if test=".//dc:contributor.translator_parsed">
539         <cmd name='translator'><parm>
540             <xsl:for-each select=".//dc:contributor.translator_parsed">
541                 <xsl:if test="position() != 1">, </xsl:if>
542                 <xsl:apply-templates mode="inline" />
543             </xsl:for-each>
544         </parm></cmd>
545     </xsl:if>
546 </xsl:template>
547
548 <xsl:template name="strip-for-toc">
549     <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
550         <xsl:choose>
551             <xsl:when test="name() = 'nbsp'">
552                 <xsl:text> </xsl:text>
553             </xsl:when>
554             <xsl:when test="name() = 'dywiz'">
555                 <xsl:text>-</xsl:text>
556             </xsl:when>
557             <xsl:when test="name() = 'alien'">
558                 <xsl:apply-templates mode="inline" />
559             </xsl:when>
560             <xsl:when test="name() = 'slowo_obce'">
561                 <xsl:call-template name="strip-for-toc" />
562             </xsl:when>
563             <xsl:otherwise>
564                 <xsl:value-of select="."/>
565             </xsl:otherwise>
566         </xsl:choose>
567     </xsl:for-each>
568 </xsl:template>
569
570 <xsl:template match="data-sponsor" mode="sponsor">
571     <cmd name="par"><parm>
572     <xsl:choose>
573         <xsl:when test="@src">
574             \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
575         </xsl:when>
576         <xsl:otherwise>
577             <xsl:value-of select="@name" />
578         </xsl:otherwise>
579     </xsl:choose>
580     </parm></cmd>
581 </xsl:template>
582
583 <xsl:template match="mat" mode="inline">
584     <TeXML escape="0">
585         <xsl:text>$</xsl:text>
586         <xsl:value-of select="wl:mathml_latex(.)" />
587         <xsl:text>$</xsl:text>
588     </TeXML>
589 </xsl:template>
590
591 <xsl:template match="mat">
592     <TeXML escape="0">
593         <xsl:text>$$</xsl:text>
594         <xsl:value-of select="wl:mathml_latex(.)" />
595         <xsl:text>$$</xsl:text>
596     </TeXML>
597 </xsl:template>
598
599 <xsl:template match="tabela|tabelka">
600     <cmd name="par" />
601     <cmd name="vspace"><parm>1em</parm></cmd>
602     <group><cmd name="raggedright" />
603     <xsl:element name="env">
604         <xsl:attribute name="name">
605             <xsl:choose>
606                 <xsl:when test="name(.)='tabela'">longtabu</xsl:when>
607                 <xsl:otherwise>tabu</xsl:otherwise>
608             </xsl:choose>
609         </xsl:attribute> to <TeXML escape="0">\textwidth </TeXML>
610       <!--parm><cmd name="textwidth"/></parm-->
611       <parm><TeXML escape="0"><xsl:value-of select="@_format" /></TeXML></parm>
612         <xsl:choose>
613         <xsl:when test="@ramka='1' or @ramki='1'">
614           <cmd name="hline" />
615           <xsl:apply-templates mode="wiersze-ramki"/>
616         </xsl:when>
617         <xsl:otherwise>
618           <xsl:apply-templates/>
619         </xsl:otherwise>
620         </xsl:choose>
621     </xsl:element>
622     </group>
623     <cmd name="vspace"><parm>1em</parm></cmd>
624 </xsl:template>
625 <xsl:template match="wiersz" mode="wiersze-ramki">
626     <xsl:apply-templates />
627     <spec cat="esc"/><spec cat="esc"/>
628     <cmd name="hline" gr="0" />
629 </xsl:template>
630 <xsl:template match="wiersz">
631     <xsl:apply-templates />
632     <spec cat="esc"/><spec cat="esc"/>
633 </xsl:template>
634 <xsl:template match="kol">
635     <xsl:apply-templates mode="inline"/>
636     <xsl:if test="position() &lt; last()">
637     <spec cat="align"/>
638     </xsl:if>
639 </xsl:template>
640
641
642 <!-- ============== -->
643 <!-- = ADDED TAGS = -->
644 <!-- ============== -->
645
646
647 <xsl:template match="dywiz" mode="inline">
648     <cmd name="dywiz" />
649 </xsl:template>
650
651 <xsl:template match="nbsp" mode="inline">
652     <spec cat="tilde" />
653 </xsl:template>
654
655 <xsl:template match="alien" mode="inline">
656     <group>
657         <cmd name="alien" />
658         <xsl:apply-templates mode="inline" />
659     </group>
660 </xsl:template>
661
662 <!-- ================ -->
663 <!-- = IGNORED TAGS = -->
664 <!-- ================ -->
665 <xsl:template match="extra|uwaga" />
666 <xsl:template match="extra|uwaga" mode="inline" />
667
668 <xsl:template match="nota_red" />
669 <xsl:template match="abstrakt" />
670
671 <!-- ======== -->
672 <!-- = TEXT = -->
673 <!-- ======== -->
674 <xsl:template match="text()" />
675 <xsl:template match="text()" mode="inline">
676     <xsl:if test="preceding-sibling::node() and wl:starts_white(.)">
677       <xsl:text> </xsl:text>
678     </xsl:if>
679
680     <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
681
682     <xsl:if test="following-sibling::node() and wl:ends_white(.)">
683       <xsl:text> </xsl:text>
684     </xsl:if>
685 </xsl:template>
686
687
688
689 <xsl:template match="f_spot">
690   <xsl:if test="@active">
691     <cmd name="clearpage"/>
692     <cmd name="thispagestyle"><parm>empty</parm></cmd>
693     <cmd name="vspace*"><parm><cmd name="fill"/></parm></cmd>
694     <env name="center">
695       <env name="framed">
696         <cmd name="vspace*"><parm>2em</parm></cmd>
697         <cmd name="Large"><parm>
698           <xsl:apply-templates mode="fspot"/>
699         </parm></cmd>
700         <cmd name="vspace*"><parm>2em</parm></cmd>
701       </env>
702     </env>
703     <cmd name="vspace*"><parm><cmd name="fill"/></parm></cmd>
704   </xsl:if>
705 </xsl:template>
706 <xsl:template match="br" mode="fspot">
707   <TeXML escape="0">
708     \\
709   </TeXML>
710 </xsl:template>
711 <xsl:template match="text()" mode="fspot">
712   <xsl:value-of select="." />
713 </xsl:template>
714 <xsl:template match="a" mode="fspot">
715   <TeXML escape="0">\href{<xsl:value-of select="@href" />}{<TeXML escape="1"><xsl:apply-templates mode="fspot" /></TeXML>}</TeXML>
716 </xsl:template>
717 <xsl:template match="nbsp" mode="fspot">
718   <spec cat="tilde" />
719 </xsl:template>
720
721
722
723 </xsl:stylesheet>