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/" >
12 <xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" version="2.0" />
13 <xsl:strip-space elements="opowiadanie powiesc dramat_wierszowany_l dramat_wierszowany_lp dramat_wspolczesny liryka_l liryka_lp wywiad"/>
14 <xsl:template match="utwor">
16 <xsl:when test="@full-page">
19 <title>Książka z serwisu WolneLektury.pl</title>
20 <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
25 font: Georgia, "Times New Roman", serif;
32 text-decoration: none;
40 /* ================================== */
41 /* = Header with logo and menu = */
42 /* ================================== */
44 margin: 3.4em 0 0 1.4em;
80 #menu li a:hover, #menu li a:active {
82 background: #FFF url(/static/img/arrow-down.png) no-repeat center right;
87 background: #FFF url(/static/img/arrow-up.png) no-repeat center right;
105 #toc, #themes, #nota_red, #info {
112 border-bottom: 0.25em solid #DDD;
113 border-right: 0.25em solid #DDD;
122 #toc ol, #themes ol {
133 padding: 0 0 1.5em 1.5em;
158 /* =================================================== */
159 /* = Common elements: headings, paragraphs and lines = */
160 /* =================================================== */
193 /* ======================== */
194 /* = Footnotes and themes = */
195 /* ======================== */
197 border-left: 0.1em solid #DDDDDD;
204 font-variant: normal;
206 text-transform: none;
207 text-decoration: none;
211 margin-right: -9.5em;
212 margin-bottom: 0.5em;
228 #footnotes .annotation {
256 margin: -0.25em -0.5em;
262 padding: 0.25em 0.5em;
266 .anchor:hover, #book-text .anchor:active {
268 background-color: #CCC;
271 /* =================== */
272 /* = Custom elements = */
273 /* =================== */
278 margin-bottom: 0.25em;
285 margin-bottom: -0.25em;
304 margin: 0.5em 0 0 1.5em;
315 div.kwestia div.stanza {
336 border-bottom: 0.1em solid #999;
337 padding-bottom: 1.5em;
340 div.note p, div.dedication p, div.note p.paragraph, div.dedication p.paragraph {
353 border-bottom: 0.1em solid #000;
364 padding: 0 0 0 1.5em;
371 em.math, em.foreign-word, em.book-title, em.didaskalia {
376 letter-spacing: 0.1em;
381 font-variant: small-caps;
389 /* =================================== */
390 /* = Hide some elements for printing = */
391 /* =================================== */
394 #menu {display: none;}
398 <xsl:call-template name="book-text" />
403 <xsl:call-template name="book-text" />
408 <xsl:template name="book-text">
410 <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
411 <xsl:if test="count(descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)])">
414 <xsl:for-each select="descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)]">
416 <a name="{concat('footnote-', generate-id(.))}" />
417 <a href="{concat('#anchor-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
419 <xsl:when test="count(akap|akap_cd|strofa) = 0">
420 <p><xsl:apply-templates select="text()|*" mode="inline" />
421 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
425 <xsl:apply-templates select="text()|*" mode="inline" />
436 <!-- ============================================================================== -->
437 <!-- = MASTER TAG = -->
438 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
439 <!-- ============================================================================== -->
440 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
441 <xsl:apply-templates select="nota_red" mode="special" />
442 <xsl:if test="nazwa_utworu">
444 <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
445 <xsl:call-template name="translators" />
448 <xsl:apply-templates />
452 <!-- ==================================================================================== -->
453 <!-- = BLOCK TAGS = -->
454 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
455 <!-- ==================================================================================== -->
456 <xsl:template match="nota">
457 <div class="note"><xsl:apply-templates /></div>
460 <xsl:template match="lista_osob">
461 <div class="person-list">
462 <h3><xsl:value-of select="naglowek_listy" /></h3>
464 <xsl:apply-templates select="lista_osoba" />
469 <xsl:template match="dedykacja">
470 <div class="dedication"><xsl:apply-templates /></div>
473 <xsl:template match="kwestia">
474 <div class="kwestia">
475 <xsl:apply-templates select="strofa|akap|didaskalia" />
479 <xsl:template match="dlugi_cytat|poezja_cyt">
480 <blockquote><xsl:apply-templates /></blockquote>
483 <xsl:template match="motto">
484 <div class="motto"><xsl:apply-templates mode="inline" /></div>
488 <!-- ========================================== -->
489 <!-- = PARAGRAPH TAGS = -->
490 <!-- = (can contain inline and special tags) = -->
491 <!-- ========================================== -->
493 <xsl:template match="autor_utworu" mode="header">
494 <span class="author"><xsl:apply-templates mode="inline" /></span>
497 <xsl:template match="nazwa_utworu" mode="header">
498 <span class="title"><xsl:apply-templates mode="inline" /></span>
501 <xsl:template match="dzielo_nadrzedne" mode="header">
502 <span class="collection"><xsl:apply-templates mode="inline" /></span>
505 <xsl:template match="podtytul" mode="header">
506 <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
509 <!-- Section headers (included in index)-->
510 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
511 <xsl:call-template name="section-anchor"/>
512 <h2><xsl:apply-templates mode="inline" /></h2>
515 <xsl:template match="naglowek_scena|naglowek_rozdzial">
516 <xsl:call-template name="section-anchor"/>
517 <h3><xsl:apply-templates mode="inline" /></h3>
520 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
521 <xsl:call-template name="section-anchor"/>
522 <h4><xsl:apply-templates mode="inline" /></h4>
525 <!-- Other paragraph tags -->
526 <xsl:template match="miejsce_czas">
527 <xsl:call-template name="section-anchor"/>
528 <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
531 <xsl:template match="didaskalia">
532 <xsl:call-template name="section-anchor"/>
533 <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
536 <xsl:template match="lista_osoba">
537 <li><xsl:apply-templates mode="inline" /></li>
540 <xsl:template match="akap|akap_dialog|akap_cd">
541 <p class="paragraph">
542 <xsl:call-template name="section-anchor"/>
543 <xsl:apply-templates mode="inline" />
547 <xsl:template match="strofa">
549 <xsl:call-template name="section-anchor"/>
551 <xsl:when test="count(br) > 0">
552 <xsl:call-template name="verse">
553 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
554 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
556 <xsl:for-each select="br">
557 <!-- Each BR tag "consumes" text after it -->
558 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
559 <xsl:call-template name="verse">
560 <xsl:with-param name="verse-content"
561 select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
562 <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')][1]" />
567 <xsl:call-template name="verse">
568 <xsl:with-param name="verse-content" select="text() | node()" />
569 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
576 <xsl:template name="verse">
577 <xsl:param name="verse-content" />
578 <xsl:param name="verse-type" />
581 <xsl:when test="name($verse-type) = 'wers_akap'">
582 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
584 <xsl:when test="name($verse-type) = 'wers_wciety'">
586 <xsl:when test="$verse-content/@typ">
587 <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
590 <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
594 <xsl:when test="name($verse-type) = 'wers_cd'">
595 <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
598 <xsl:apply-templates select="$verse-content" mode="inline" />
602 <xsl:template match="motto_podpis">
603 <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
607 <!-- ================================================ -->
608 <!-- = INLINE TAGS = -->
609 <!-- = (contain other inline tags and special tags) = -->
610 <!-- ================================================ -->
612 <xsl:template match="pa|pe|pr|pt" mode="inline">
613 <a name="{concat('anchor-', generate-id(.))}" />
614 <a href="{concat('#footnote-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
617 <!-- Other inline tags -->
618 <xsl:template match="mat" mode="inline">
619 <em class="math"><xsl:apply-templates mode="inline" /></em>
622 <xsl:template match="didask_tekst" mode="inline">
623 <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
626 <xsl:template match="slowo_obce" mode="inline">
627 <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
630 <xsl:template match="tytul_dziela" mode="inline">
631 <em class="book-title">
632 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
636 <xsl:template match="wyroznienie" mode="inline">
637 <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
640 <xsl:template match="osoba" mode="inline">
641 <em class="person"><xsl:apply-templates mode="inline" /></em>
645 <!-- ============================================== -->
646 <!-- = STANDALONE TAGS = -->
647 <!-- = (cannot contain any other tags) = -->
648 <!-- ============================================== -->
649 <xsl:template match="sekcja_swiatlo">
650 <hr class="spacer" />
653 <xsl:template match="sekcja_asterysk">
654 <p class="spacer-asterisk">*</p>
657 <xsl:template match="separator_linia">
658 <hr class="spacer-line" />
662 <!-- ================ -->
663 <!-- = SPECIAL TAGS = -->
664 <!-- ================ -->
666 <xsl:template match="begin" mode="inline">
667 <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
668 <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
669 <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
673 <xsl:template match="end" mode="inline">
674 <span class="theme-end" fid="{substring(@id, 2)}"> </span>
677 <xsl:template match="begin|end">
678 <xsl:apply-templates select='.' mode="inline" />
681 <xsl:template match="motyw" mode="inline" />
684 <xsl:template match="nota_red" mode="special">
686 <xsl:apply-templates />
691 <xsl:template name="translators">
692 <xsl:if test="//dc:contributor.translator">
693 <span class="translator">
694 <xsl:text>tłum. </xsl:text>
695 <xsl:for-each select="//dc:contributor.translator">
696 <xsl:if test="position() != 1">, </xsl:if>
697 <xsl:apply-templates mode="person" />
703 <xsl:template match="text()" mode="person">
704 <xsl:value-of select="wl:person_name(.)" />
708 <!-- ================ -->
709 <!-- = IGNORED TAGS = -->
710 <!-- ================ -->
711 <xsl:template match="extra|uwaga" />
712 <xsl:template match="extra|uwaga" mode="inline" />
714 <xsl:template match="nota_red" />
719 <xsl:template match="text()" />
720 <xsl:template match="text()" mode="inline">
721 <xsl:value-of select="wl:substitute_entities(.)" />
727 <xsl:template name="section-anchor">
729 this formula works as follows:
730 - get all ancestors including self
731 - choose the header (third one from root): utwor/book-type/header
732 - get all preceding siblings
734 - create an <a name="sec123"/> tag.
736 <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />