Remove direct verse styling from html.
[librarian.git] / src / librarian / xslt / book2html.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
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">
15     <xsl:choose>
16         <xsl:when test="@full-page">
17             <html>
18             <head>
19                 <title>Książka z serwisu WolneLektury.pl</title>
20                 <meta charset="utf-8" />
21                 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
22                 <link rel="stylesheet" type="text/css">
23                         <xsl:attribute name="href">
24                                 <xsl:value-of select="$css" />
25                         </xsl:attribute>
26                 </link>
27                 <style>
28                   .ilustr.prawo img {
29                   float: right;
30                   }
31                   .ilustr.lewo img {
32                   float: left;
33                   }
34                   .ilustr.srodek {
35                   text-align: center;
36                   }
37                   .ilustr .stop {
38                   clear: both;
39                   }
40                   .ilustr.oblew .stop {
41                   clear: none;
42                   }
43
44                   .ilustr.oblew img {
45                     margin-bottom: 1em;
46                   }
47                   .ilustr.oblew.lewo img {
48                     margin-right: 2em;
49                     }
50                     .ilustr.oblew.prawo img {
51                     margin-left: 2em;
52                     }
53
54
55                     .ilustr img {
56                     min-width: 200px !important;
57                     }
58                     @media screen and (max-width: 320px) {
59                     .ilustr img {
60                     width: 100% !important;
61                     min-width: auto !important;
62                     }
63                     .ilustr.lewo img {
64                     float: none;
65                     }
66                     .ilustr.prawo img {
67                     float:none;
68                     }
69                     .ilustr.oblew.prawo img {
70                     margin-left: 0;
71                     }
72                     .ilustr.oblew.lewo img{
73                     margin-right: 0;
74                     }
75                     .ilustr .stop {
76                     clear: none;
77                     }
78
79                     }
80                 </style>
81             </head>
82             <body>
83               <xsl:call-template name="book-text" />
84
85               <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
86               <script src="http://malsup.github.io/min/jquery.cycle2.min.js"></script>
87             </body>
88             </html>
89         </xsl:when>
90         <xsl:otherwise>
91             <xsl:call-template name="book-text" />
92         </xsl:otherwise>
93     </xsl:choose>
94 </xsl:template>
95
96 <xsl:template name="book-text">
97     <div id="book-text">
98         <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
99         <xsl:if test="count(descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)])">
100             <div id="footnotes">
101                 <h3>Przypisy</h3>
102                 <xsl:for-each select="descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)]">
103                     <div>
104                         <xsl:attribute name="class">fn-<xsl:value-of select="name()" /></xsl:attribute>
105                         <a name="{concat('footnote-', generate-id(.))}" />
106                         <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>
107                         <xsl:choose>
108                             <xsl:when test="count(akap|akap_cd|strofa) = 0">
109                                 <p><xsl:apply-templates select="text()|*" mode="inline" />
110                                 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
111                                 <xsl:if test="name()='pt'"> [przypis tłumacza]</xsl:if>
112                                 <xsl:if test="name()='pr'"> [przypis redakcyjny]</xsl:if>
113                                 <xsl:if test="name()='pe'"> [przypis edytorski]</xsl:if>
114                                 </p>
115                             </xsl:when>
116                             <xsl:otherwise>
117                               <xsl:apply-templates />
118                               <p>
119                                 <xsl:if test="name()='pa'"> [przypis autorski]</xsl:if>
120                                 <xsl:if test="name()='pt'"> [przypis tłumacza]</xsl:if>
121                                 <xsl:if test="name()='pr'"> [przypis redakcyjny]</xsl:if>
122                                 <xsl:if test="name()='pe'"> [przypis edytorski]</xsl:if>
123                               </p>
124                             </xsl:otherwise>
125                         </xsl:choose>
126                     </div>
127                 </xsl:for-each>
128             </div>
129         </xsl:if>
130     </div>
131 </xsl:template>
132
133
134 <!-- ============================================================================== -->
135 <!-- = MASTER TAG                                                                 = -->
136 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
137 <!-- ============================================================================== -->
138 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
139     <xsl:apply-templates select="nota_red" mode="special" />
140     <xsl:if test="nazwa_utworu">
141         <h1>
142             <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
143             <xsl:call-template name="translators" />
144         </h1>
145     </xsl:if>
146     <xsl:apply-templates />
147 </xsl:template>
148
149
150 <!-- ==================================================================================== -->
151 <!-- = BLOCK TAGS                                                                       = -->
152 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
153 <!-- ==================================================================================== -->
154 <xsl:template match="nota">
155     <div class="note"><xsl:apply-templates /></div>
156 </xsl:template>
157
158 <xsl:template match="lista_osob">
159     <xsl:call-template name="section-anchor"/>
160     <div class="person-list">
161         <h3><xsl:value-of select="naglowek_listy" /></h3>
162         <ol>
163             <xsl:apply-templates select="lista_osoba" />
164         </ol>
165     </div>
166 </xsl:template>
167
168 <xsl:template match="dedykacja">
169     <div class="dedication"><xsl:apply-templates /></div>
170 </xsl:template>
171
172 <xsl:template match="ramka">
173     <div class="frame"><xsl:apply-templates /></div>
174 </xsl:template>
175
176 <xsl:template match="kwestia">
177     <div class="kwestia">
178         <xsl:apply-templates select="strofa|akap|didaskalia" />
179     </div>
180 </xsl:template>
181
182 <xsl:template match="dlugi_cytat|poezja_cyt">
183     <blockquote><xsl:apply-templates /></blockquote>
184 </xsl:template>
185
186 <xsl:template match="motto">
187     <xsl:call-template name="section-anchor"/>
188     <div class="motto">
189       <xsl:call-template name="block-args" />
190       <xsl:apply-templates />
191     </div>
192 </xsl:template>
193
194 <xsl:template match="ilustr" mode="inline">
195     <xsl:apply-templates select="."/>
196 </xsl:template>
197
198 <xsl:template match="ilustr">
199   <div>
200     <xsl:call-template name="block-args" />
201
202     <xsl:attribute name="class">
203       <xsl:text>ilustr </xsl:text>
204       <xsl:value-of select="@wyrownanie"/>
205       <xsl:if test="@oblew">
206         <xsl:text> oblew</xsl:text>
207       </xsl:if>
208     </xsl:attribute>
209     
210     <img>
211       <xsl:attribute name="src">
212         <xsl:value-of select="@src" />
213       </xsl:attribute>
214       <xsl:attribute name="srcset">
215         <xsl:value-of select="@srcset" />
216       </xsl:attribute>
217       <xsl:attribute name="sizes">
218         (min-width: 718px) 600px,
219         (min-width: 600px) calc(100vw - 118px),
220         (min-width: 320px) calc(100vw - 75px),
221         (min-width: 15em) calc(100wv - 60px),
222         calc(100wv - 40px)
223       </xsl:attribute>
224       <xsl:attribute name="alt">
225         <xsl:value-of select="@alt" />
226       </xsl:attribute>
227       <xsl:attribute name="title">
228         <xsl:value-of select="@alt" />
229       </xsl:attribute>
230
231       <xsl:if test="@szer">
232         <xsl:attribute name="style">
233           <xsl:text>width: </xsl:text>
234           <xsl:value-of select="@szer"/>
235         </xsl:attribute>
236       </xsl:if>
237     </img>
238
239     <div class="stop"></div>
240   </div>
241 </xsl:template>
242
243 <xsl:template match="animacja">
244   <div class="animacja cycle-slideshow" data-cycle-pause-on-hover="true" data-cycle-next="> img" data-cycle-fx="fadeout" data-cycle-paused="true">
245     <xsl:call-template name="block-args" />
246     <xsl:apply-templates/>
247   </div>
248 </xsl:template>
249
250
251 <!-- ========================================== -->
252 <!-- = PARAGRAPH TAGS                         = -->
253 <!-- = (can contain inline and special tags)  = -->
254 <!-- ========================================== -->
255 <!-- Title page -->
256 <xsl:template match="autor_utworu" mode="header">
257   <span class="author">
258     <xsl:call-template name="block-args" />
259     <xsl:apply-templates mode="inline" />
260   </span>
261 </xsl:template>
262
263 <xsl:template match="nazwa_utworu" mode="header">
264   <span class="title">
265     <xsl:call-template name="block-args" />
266     <xsl:apply-templates mode="inline" />
267   </span>
268 </xsl:template>
269
270 <xsl:template match="dzielo_nadrzedne" mode="header">
271   <span class="collection">
272     <xsl:call-template name="block-args" />
273     <xsl:apply-templates mode="inline" />
274   </span>
275 </xsl:template>
276
277 <xsl:template match="podtytul" mode="header">
278   <span class="subtitle">
279     <xsl:call-template name="block-args" />
280     <xsl:apply-templates mode="inline" />
281   </span>
282 </xsl:template>
283
284 <!-- Section headers (included in index)-->
285 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
286   <xsl:call-template name="section-anchor"/>
287   <h2>
288     <xsl:call-template name="block-args" />
289     <xsl:apply-templates mode="inline" />
290   </h2>
291 </xsl:template>
292
293 <xsl:template match="podtytul_akt|podtytul_czesc">
294   <div class="subtitle2">
295     <xsl:call-template name="block-args" />
296     <xsl:apply-templates mode="inline" />
297   </div>
298 </xsl:template>
299
300 <xsl:template match="naglowek_scena|naglowek_rozdzial">
301     <xsl:call-template name="section-anchor"/>
302     <h3>
303       <xsl:call-template name="block-args" />
304       <xsl:apply-templates mode="inline" />
305     </h3>
306 </xsl:template>
307
308 <xsl:template match="podtytul_scena|podtytul_rozdzial">
309   <div class="subtitle3">
310     <xsl:call-template name="block-args" />
311     <xsl:apply-templates mode="inline" />
312   </div>
313 </xsl:template>
314
315 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
316   <xsl:call-template name="section-anchor"/>
317   <h4>
318     <xsl:call-template name="block-args" />
319     <xsl:apply-templates mode="inline" />
320   </h4>
321 </xsl:template>
322
323 <xsl:template match="podtytul_podrozdzial">
324   <div class="subtitle4">
325     <xsl:call-template name="block-args" />
326     <xsl:apply-templates mode="inline" />
327   </div>
328 </xsl:template>
329
330 <!-- Other paragraph tags -->
331 <xsl:template match="miejsce_czas">
332   <xsl:call-template name="section-anchor"/>
333   <p class="place-and-time">
334     <xsl:call-template name="block-args" />
335     <xsl:apply-templates mode="inline" />
336   </p>
337 </xsl:template>
338
339 <xsl:template match="didaskalia">
340   <xsl:call-template name="section-anchor"/>
341   <div class="didaskalia">
342     <xsl:call-template name="block-args" />
343     <xsl:apply-templates mode="inline" />
344   </div>
345 </xsl:template>
346
347 <xsl:template match="lista_osoba">
348     <li><xsl:apply-templates mode="inline" /></li>
349 </xsl:template>
350
351 <xsl:template match="akap|akap_dialog|akap_cd">
352     <p class="paragraph">
353       <xsl:call-template name="block-args" />
354       <xsl:call-template name="section-anchor"/>
355         <xsl:apply-templates mode="inline" />
356     </p>
357 </xsl:template>
358
359 <xsl:template match="strofa" mode="inline">
360     <xsl:apply-templates select="." />
361 </xsl:template>
362
363 <xsl:template match="strofa">
364   <div class="stanza">
365     <xsl:call-template name="block-args" />
366       <xsl:call-template name="section-anchor"/>
367         <xsl:choose>
368             <xsl:when test="count(br) > 0">
369                 <xsl:call-template name="verse">
370                     <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
371                     <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' or name() = 'wers_srodek'][1]" />
372                 </xsl:call-template>
373                 <xsl:for-each select="br">              
374                                 <!-- Each BR tag "consumes" text after it -->
375                     <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
376                     <xsl:call-template name="verse">
377                         <xsl:with-param name="verse-content"
378                             select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
379                         <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' or name() = 'wers_srodek')][1]" />
380                     </xsl:call-template>
381                 </xsl:for-each>
382             </xsl:when>
383             <xsl:otherwise>
384                 <xsl:call-template name="verse">
385                     <xsl:with-param name="verse-content" select="text() | node()" />
386                     <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej|wers_srodek[1]" />
387                  </xsl:call-template>
388             </xsl:otherwise>
389         </xsl:choose>
390     </div>
391 </xsl:template>
392
393 <xsl:template name="verse">
394     <xsl:param name="verse-content" />
395     <xsl:param name="verse-type" />
396     <div class="verse">
397       <xsl:attribute name="class">
398         <xsl:text>verse</xsl:text>
399         <xsl:choose>
400             <xsl:when test="name($verse-type) = 'wers_akap'">
401               <xsl:text> verse-p</xsl:text>
402             </xsl:when>
403             <xsl:when test="name($verse-type) = 'wers_wciety'">
404               <xsl:text> verse-indent</xsl:text>
405               <xsl:if test="$verse-content/@typ">
406                 <xsl:text> verse-indent-</xsl:text>
407                 <xsl:value-of select="$verse-content/@typ" />
408               </xsl:if>
409             </xsl:when>
410             <xsl:when test="name($verse-type) = 'wers_cd'">
411               <xsl:text> verse-cont</xsl:text>
412             </xsl:when>
413             <xsl:when test="name($verse-type) = 'wers_do_prawej'">
414               <xsl:text> verse-right</xsl:text>
415             </xsl:when>
416             <xsl:when test="name($verse-type) = 'wers_srodek'">
417               <xsl:text> verse-center</xsl:text>
418             </xsl:when>
419         </xsl:choose>
420       </xsl:attribute>
421       <xsl:apply-templates select="$verse-content" mode="inline" />
422     </div>
423 </xsl:template>
424
425 <xsl:template match="motto_podpis">
426     <xsl:call-template name="section-anchor"/>
427     <p class="motto_podpis">
428       <xsl:call-template name="block-args" />
429       <xsl:apply-templates mode="inline" />
430     </p>
431 </xsl:template>
432
433 <xsl:template match="tabela|tabelka">
434     <xsl:call-template name="section-anchor"/>
435     <xsl:choose>
436         <xsl:when test="@ramka = '1'">
437           <table class="border">
438             <xsl:call-template name="block-args" />
439             <xsl:apply-templates />
440           </table>
441         </xsl:when>
442         <xsl:otherwise>
443           <table>
444             <xsl:call-template name="block-args" />
445             <xsl:apply-templates />
446           </table>
447         </xsl:otherwise>
448     </xsl:choose>
449 </xsl:template>
450 <xsl:template match="wiersz">
451     <tr><xsl:apply-templates /></tr>
452 </xsl:template>
453 <xsl:template match="kol">
454     <td><xsl:apply-templates mode="inline" /></td>
455 </xsl:template>
456
457 <xsl:template match="mat">
458     <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*" /></math>
459 </xsl:template>
460
461
462 <!-- ================================================ -->
463 <!-- = INLINE TAGS                                  = -->
464 <!-- = (contain other inline tags and special tags) = -->
465 <!-- ================================================ -->
466 <!-- Annotations -->
467 <xsl:template match="pa|pe|pr|pt" mode="inline">
468     <a name="{concat('anchor-', generate-id(.))}" />
469     <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>
470 </xsl:template>
471
472 <xsl:template match="ref" mode="inline">
473   <a class="reference" data-uri="">
474     <xsl:attribute name="data-uri">
475       <xsl:value-of select="@href"/>
476     </xsl:attribute>
477   </a>
478 </xsl:template>
479
480 <!-- Other inline tags -->
481 <xsl:template match="mat" mode="inline">
482     <math xmlns="http://www.w3.org/1998/Math/MathML"><xsl:copy-of select="*|text()" /></math>
483 </xsl:template>
484
485 <xsl:template match="didask_tekst" mode="inline">
486     <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
487 </xsl:template>
488
489 <xsl:template match="slowo_obce" mode="inline">
490     <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
491 </xsl:template>
492
493 <xsl:template match="tytul_dziela" mode="inline">
494     <em class="book-title">
495         <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
496     </em>
497 </xsl:template>
498
499 <xsl:template match="wyroznienie" mode="inline">
500     <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
501 </xsl:template>
502
503 <xsl:template match="wieksze_odstepy" mode="inline">
504     <em class="wieksze-odstepy"><xsl:apply-templates mode="inline" /></em>
505 </xsl:template>
506
507 <xsl:template match="indeks_dolny" mode="inline">
508     <sub><xsl:apply-templates mode="inline" /></sub>
509 </xsl:template>
510
511 <xsl:template match="osoba" mode="inline">
512     <em class="person"><xsl:apply-templates mode="inline" /></em>
513 </xsl:template>
514
515 <xsl:template match="www" mode="inline">
516     <a target="_blank">
517         <xsl:attribute name="href">
518             <xsl:value-of select="text()"/>
519         </xsl:attribute>
520         <xsl:apply-templates mode="inline" />
521     </a>
522 </xsl:template>
523
524 <!-- ============================================== -->
525 <!-- = STANDALONE TAGS                            = -->
526 <!-- = (cannot contain any other tags)            = -->
527 <!-- ============================================== -->
528 <xsl:template match="sekcja_swiatlo">
529     <hr class="spacer" />
530 </xsl:template>
531
532 <xsl:template match="sekcja_asterysk">
533     <p class="spacer-asterisk">*</p>
534 </xsl:template>
535
536 <xsl:template match="separator_linia">
537     <hr class="spacer-line" />
538 </xsl:template>
539
540
541 <!-- ================ -->
542 <!-- = SPECIAL TAGS = -->
543 <!-- ================ -->
544 <!-- Themes -->
545 <xsl:template match="begin" mode="inline">
546     <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
547     <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
548         <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
549     </a>
550 </xsl:template>
551
552 <xsl:template match="end" mode="inline">
553     <span class="theme-end" fid="{substring(@id, 2)}"> </span>
554 </xsl:template>
555
556 <xsl:template match="begin|end">
557     <xsl:apply-templates select='.' mode="inline" />
558 </xsl:template>
559
560 <xsl:template match="motyw" mode="inline" />
561
562
563 <xsl:template match="nota_red" mode="special">
564     <div id="nota_red">
565         <xsl:apply-templates />
566     </div>
567 </xsl:template>
568
569
570 <xsl:template name="translators">
571     <xsl:if test="//dc:contributor.translator">
572         <span class="translator">
573             <xsl:text>tłum. </xsl:text>
574             <xsl:for-each select="//dc:contributor.translator">
575                 <xsl:if test="position() != 1">, </xsl:if>
576                 <xsl:apply-templates mode="person" />
577             </xsl:for-each>
578         </span>
579     </xsl:if>
580 </xsl:template>
581
582 <xsl:template match="text()" mode="person">
583     <xsl:value-of select="wl:person_name(.)" />
584 </xsl:template>
585
586 <xsl:template match="rownolegle">
587     <xsl:apply-templates mode="rownolegle" />
588 </xsl:template>
589 <xsl:template match="*" mode="rownolegle">
590   <!-- is it last? -->
591   <div>
592     <xsl:attribute name="class">
593       <xsl:text>rownolegly-blok</xsl:text>
594       <xsl:if test="not(following-sibling::*)">
595         <xsl:text> last</xsl:text>
596       </xsl:if>
597       <xsl:if test="not(preceding-sibling::*)">
598         <xsl:text> first</xsl:text>
599       </xsl:if>
600     </xsl:attribute>
601     <xsl:attribute name="style">
602       <xsl:text>border-left: 2px solid red; padding-left: .5em;</xsl:text>
603       <xsl:if test="not(following-sibling::*)">
604         <xsl:text> border-radius: 0 0 0 .75em;</xsl:text>
605       </xsl:if>
606       <xsl:if test="not(preceding-sibling::*)">
607         <xsl:text> border-radius: .75em 0 0 0;</xsl:text>
608       </xsl:if>
609     </xsl:attribute>
610     <xsl:apply-templates match="." />
611   </div>
612 </xsl:template>
613
614 <xsl:template match="tab" mode="inline">
615   <span>
616     <xsl:choose>
617       <xsl:when test="@szer">
618         <xsl:attribute name="style">display: inline-block; width: <xsl:value-of select="@szer" />em</xsl:attribute>
619       </xsl:when>
620       <xsl:otherwise>
621         <xsl:attribute name="style">display: inline-block; width: 1em</xsl:attribute>
622       </xsl:otherwise>
623     </xsl:choose>
624   </span>
625 </xsl:template>
626
627
628 <!-- ================ -->
629 <!-- = IGNORED TAGS = -->
630 <!-- ================ -->
631 <xsl:template match="extra|uwaga" />
632 <xsl:template match="extra|uwaga" mode="inline" />
633
634 <xsl:template match="nota_red" />
635 <xsl:template match="abstrakt" />
636
637 <!-- ======== -->
638 <!-- = TEXT = -->
639 <!-- ======== -->
640 <xsl:template match="text()" />
641 <xsl:template match="text()" mode="inline">
642     <xsl:value-of select="wl:substitute_entities(.)" />
643 </xsl:template>
644
645 <!-- ========= -->
646 <!-- = utils = -->
647 <!-- ========= -->
648 <xsl:template name="section-anchor">
649   <!-- 
650        this formula works as follows:
651        - get all ancestors including self
652        - choose the header (third one from root): utwor/book-type/header
653        - get all preceding siblings
654        - count them
655        - create an <a name="sec123"/> tag.
656   -->
657         <a name="{concat('sec', count(ancestor-or-self::*[last()-2]/preceding-sibling::*) + 1)}" />
658 </xsl:template>
659
660 <xsl:template name="block-args">
661   <xsl:if test="@id">
662     <xsl:attribute name="id">
663       <xsl:text>wl-</xsl:text>
664       <xsl:value-of select="@id"/>
665     </xsl:attribute>
666   </xsl:if>
667 </xsl:template>
668
669 <xsl:template match="numeracja">
670         <span class="numeracja">
671                 <xsl:attribute name="data-start">
672                         <xsl:value-of select="@start" />
673                 </xsl:attribute>
674         </span>
675 </xsl:template>
676
677 </xsl:stylesheet>