1 <?xml version="1.0" encoding="utf-8"?>
4 This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5 Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
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#" >
13 <xsl:output encoding="utf-8" indent="yes" version="2.0" />
15 <xsl:template match="utwor">
16 <TeXML xmlns="http://getfo.sourceforge.net/texml/ns1">
18 \documentclass[<xsl:value-of select="@customizations"/>]{wl}
20 <!-- flags and values set on root -->
22 \newif\ifflaglessadvertising
23 <xsl:for-each select="@*[starts-with(name(), 'flag-')]">
25 <xsl:attribute name="name"><xsl:value-of select="wl:texcommand(name())" />true</xsl:attribute>
29 <xsl:for-each select="@*[starts-with(name(), 'data-')]">
31 \def\<xsl:value-of select="wl:texcommand(name())" />{<TeXML escape="1"><xsl:value-of select="."/></TeXML>}
37 <xsl:when test="@morefloats = 'new'">
39 \usepackage[maxfloats=53]{morefloats}
42 <xsl:when test="@morefloats = 'old'">
44 \usepackage{morefloats}
47 <xsl:when test="@morefloats = 'none'" />
50 \IfFileExists{morefloats.sty}{
51 \usepackage{morefloats}
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' />
61 <xsl:if test="@data-cover-width">
62 <cmd name="makecover">
64 <parm><xsl:value-of select="210 * @data-cover-height div @data-cover-width" />mm</parm>
67 <xsl:if test="@thanks">
69 \def\thanknote{<TeXML escape="1"><xsl:value-of select="@thanks" /></TeXML>}
72 <cmd name="maketitle" />
74 <cmd name="tytul"><parm>
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" />
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' />
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" >
98 <cmd name="tableofcontents" />
99 <cmd name="clearpage" />
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" />
106 <xsl:if test="@data-cover-by">
107 \def\coverby{Okładka na podstawie:
109 <xsl:when test="@data-cover-source">
110 \href{\datacoversource}{\datacoverby}
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>.}
124 <xsl:if test="@sponsor-note|data-sponsor">
128 <xsl:when test="@sponsor-note">
129 <TeXML escape="1"><xsl:value-of select="@sponsor-note" /></TeXML>
132 Sfinansowano ze~środków:
138 <xsl:apply-templates select="data-sponsor" mode="sponsor" />
149 \def\enotesize{\normalsize}
155 <cmd name="editorialsection" />
161 <xsl:template match="utwor" mode="part">
162 <cmd name="tytul"><parm>
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" />
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' />
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" />
181 <!-- =================== -->
182 <!-- = MAIN TITLE PAGE = -->
183 <!-- = (from DC) = -->
184 <!-- =================== -->
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" />
190 <xsl:template match="rdf:RDF" mode="titlepage">
192 \def\authors{<TeXML escape="1"><xsl:call-template name="authors" /></TeXML>}
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>}
197 \def\bookurl{<TeXML escape="1"><xsl:value-of select=".//dc:identifier.url" /></TeXML>}
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>}.}
206 <xsl:if test=".//dc:source">
207 Tekst opracowany na podstawie: <TeXML escape="1"><xsl:apply-templates select=".//dc:source" mode="inline" /></TeXML>
211 <xsl:if test=".//dc:publisher">
214 <xsl:for-each select=".//dc:publisher/text()">
215 <xsl:value-of select="."/>
216 <xsl:if test="not(position() = last())">, </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-')"/>}
230 <!-- ============== -->
231 <!-- = BOOK TITLE = -->
232 <!-- = (from DC) = -->
233 <!-- ============== -->
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" />
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>
245 <cmd name="nazwanadpodutworu"><parm>
246 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
249 <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
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" />
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" />
262 <cmd name="translatorsline" />
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 <!-- ==================================================================================== -->
276 match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto|ramka">
278 <xsl:attribute name="name">
279 <xsl:value-of select="wl:texcommand(name())" />
281 <parm><xsl:apply-templates/></parm>
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>
292 <xsl:template match="kwestia">
294 <parm><xsl:apply-templates select="strofa|akap|didaskalia" /></parm>
298 <xsl:template match="ilustr">
300 <xsl:when test="@oblew = 'true'">
302 <env name="wrapfigure">
305 <cmd name="includegraphics">
306 <opt>width=<cmd name="linewidth"/></opt>
307 <parm><xsl:value-of select="@src"/></parm>
313 <parm><xsl:value-of select="@src" /></parm>
314 <parm><xsl:value-of select="@alt" /></parm>
320 <!-- ========================================== -->
321 <!-- = PARAGRAPH TAGS = -->
322 <!-- = (can contain inline and special tags) = -->
323 <!-- ========================================== -->
325 <!-- only in root -->
327 match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
330 <xsl:attribute name="name">
331 <xsl:value-of select="wl:texcommand(name())" />
333 <parm><xsl:apply-templates mode="inline"/></parm>
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>
341 <cmd name="nazwapodutworu">
342 <parm><xsl:apply-templates mode="inline"/></parm>
344 <xsl:call-template name="strip-for-toc" />
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">
353 <xsl:when test="@inline">
354 <xsl:apply-templates mode="inline"/>
358 <xsl:attribute name="name">
359 <xsl:value-of select="wl:texcommand(name())" />
361 <parm><xsl:apply-templates mode="inline"/></parm>
367 <xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_akt|naglowek_scena">
369 <xsl:attribute name="name">
370 <xsl:value-of select="wl:texcommand(name())" />
372 <parm><xsl:apply-templates mode="inline"/></parm>
374 <xsl:call-template name="strip-for-toc" />
379 <xsl:template match="strofa" mode="inline">
380 <env name="minipage">
382 <parm><cmd name="linewidth" /></parm>
383 <parm><xsl:apply-templates select="." /></parm>
387 <xsl:template match="strofa">
388 <cmd name="strofa"><parm>
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]" />
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]" />
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]" />
417 <xsl:template name="verse">
418 <xsl:param name="verse-content" />
419 <xsl:param name="verse-type" />
422 <xsl:attribute name="name">
424 <xsl:when test="$verse-type != ''">
425 <xsl:value-of select='wl:texcommand(name($verse-type))' />
427 <xsl:otherwise>wers</xsl:otherwise>
430 <xsl:if test="string($verse-content/@typ)">
431 <opt><xsl:value-of select="$verse-content/@typ" />em</opt>
433 <parm><xsl:apply-templates select="$verse-content" mode="inline"/></parm>
437 <!-- ================================================ -->
438 <!-- = INLINE TAGS = -->
439 <!-- = (contain other inline tags and special tags) = -->
440 <!-- ================================================ -->
443 <xsl:template mode="inline"
444 match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|indeks_dolny|wieksze_odstepy">
446 <xsl:attribute name="name">
447 <xsl:value-of select="wl:texcommand(name())" />
451 <xsl:when test="@blocks">
452 <xsl:apply-templates/>
455 <xsl:apply-templates mode="inline"/>
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>
472 <!-- ============================================== -->
473 <!-- = STANDALONE TAGS = -->
474 <!-- = (cannot contain any other tags) = -->
475 <!-- ============================================== -->
477 match="sekcja_swiatlo|sekcja_asterysk|separator_linia">
479 <xsl:attribute name="name">
480 <xsl:value-of select="wl:texcommand(name())" />
486 <!-- ================ -->
487 <!-- = SPECIAL TAGS = -->
488 <!-- ================ -->
492 <xsl:template match="begin|end|motyw">
493 <xsl:apply-templates select='.' mode="inline" />
496 <xsl:template match="begin" mode="inline" />
497 <xsl:template match="end" mode="inline" />
499 <xsl:template match="motyw" mode="inline">
501 <xsl:if test="@moved">
502 <opt name="moved"><xsl:value-of select="@moved" /></opt>
504 <parm><xsl:apply-templates mode="inline" /></parm>
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" />
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" />
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>
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" />
541 <xsl:template name="strip-for-toc">
542 <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
544 <xsl:when test="name() = 'nbsp'">
545 <xsl:text> </xsl:text>
547 <xsl:when test="name() = 'dywiz'">
548 <xsl:text>-</xsl:text>
550 <xsl:when test="name() = 'alien'">
551 <xsl:apply-templates mode="inline" />
553 <xsl:when test="name() = 'slowo_obce'">
554 <xsl:call-template name="strip-for-toc" />
557 <xsl:value-of select="."/>
563 <xsl:template match="data-sponsor" mode="sponsor">
564 <cmd name="par"><parm>
566 <xsl:when test="@src">
567 \includegraphics[height=0.25\textwidth,width=0.25\textwidth,keepaspectratio]{<xsl:value-of select="@src" />}
570 <xsl:value-of select="@name" />
576 <xsl:template match="mat" mode="inline">
578 <xsl:text>$</xsl:text>
579 <xsl:value-of select="wl:mathml_latex(.)" />
580 <xsl:text>$</xsl:text>
584 <xsl:template match="mat">
586 <xsl:text>$$</xsl:text>
587 <xsl:value-of select="wl:mathml_latex(.)" />
588 <xsl:text>$$</xsl:text>
592 <xsl:template match="tabela|tabelka">
594 <cmd name="vspace"><parm>1em</parm></cmd>
595 <group><cmd name="raggedright" />
596 <xsl:element name="env">
597 <xsl:attribute name="name">
599 <xsl:when test="name(.)='tabela'">longtabu</xsl:when>
600 <xsl:otherwise>tabu</xsl:otherwise>
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>
606 <xsl:when test="@ramka='1' or @ramki='1'">
608 <xsl:apply-templates mode="wiersze-ramki"/>
611 <xsl:apply-templates/>
616 <cmd name="vspace"><parm>1em</parm></cmd>
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" />
623 <xsl:template match="wiersz">
624 <xsl:apply-templates />
625 <spec cat="esc"/><spec cat="esc"/>
627 <xsl:template match="kol">
628 <xsl:apply-templates mode="inline"/>
629 <xsl:if test="position() < last()">
635 <!-- ============== -->
636 <!-- = ADDED TAGS = -->
637 <!-- ============== -->
640 <xsl:template match="dywiz" mode="inline">
644 <xsl:template match="nbsp" mode="inline">
648 <xsl:template match="alien" mode="inline">
651 <xsl:apply-templates mode="inline" />
655 <!-- ================ -->
656 <!-- = IGNORED TAGS = -->
657 <!-- ================ -->
658 <xsl:template match="extra|uwaga" />
659 <xsl:template match="extra|uwaga" mode="inline" />
661 <xsl:template match="nota_red" />
662 <xsl:template match="abstrakt" />
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>
673 <xsl:value-of select="wl:substitute_entities(wl:strip(.))" />
675 <xsl:if test="following-sibling::node() and wl:ends_white(.)">
676 <xsl:text> </xsl:text>