wl style for XeLaTeX is now a class. Accepts several parameters affecting output...
[librarian.git] / librarian / pdf / wl2tex.xslt
index 4ca109e..ec5e4d3 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
+
    This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
    Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
-  
+
 -->
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:wl="http://wolnelektury.pl/functions"
     <TeXML xmlns="http://getfo.sourceforge.net/texml/ns1">
         <TeXML escape="0">
         \documentclass[a4paper, oneside, 11pt]{book}
+
+        <!-- flags and values set on root -->
+
+        \newif\ifflaglessadvertising
+        <xsl:for-each select="@*[starts-with(name(), 'flag-')]">
+            <cmd>
+                <xsl:attribute name="name"><xsl:value-of select="wl:texcommand(name())" />true</xsl:attribute>
+            </cmd>
+        </xsl:for-each>
+
+        <xsl:for-each select="@*[starts-with(name(), 'data-')]">
+            <TeXML escape="0">
+                \def\<xsl:value-of select="wl:texcommand(name())" />{<TeXML escape="1"><xsl:value-of select="."/></TeXML>}
+            </TeXML>
+        </xsl:for-each>
+
         \usepackage{wl}
         </TeXML>
 
         <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" mode='titlepage' />
 
         <env name="document">
+            <xsl:if test="@data-cover-width">
+                <cmd name="makecover">
+                    <parm><xsl:value-of select="210 * @data-cover-width div @data-cover-height" />mm</parm>
+                    <parm>210mm</parm>
+                </cmd>
+            </xsl:if>
             <cmd name="maketitle" />
 
             <cmd name="tytul"><parm>
     <TeXML escape="0">
         \def\authors{<xsl:call-template name="authors" />}
         \author{\authors}
-        \title{<xsl:apply-templates select=".//dc:title" />}
+        \title{<xsl:apply-templates select=".//dc:title" mode="inline" />}
         \def\translatorsline{<xsl:call-template name="translators" />}
 
         \def\bookurl{<xsl:value-of select=".//dc:identifier.url" />}
 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
 <!-- ==================================================================================== -->
 
-<xsl:template 
+<xsl:template
     match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto">
     <cmd>
         <xsl:attribute name="name">
 <!-- ========================================== -->
 
 <!-- only in root -->
-<xsl:template 
+<xsl:template
     match="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul"
     mode="title">
     <cmd>
 </xsl:template>
 
 
-<xsl:template 
+<xsl:template
     match="naglowek_akt|naglowek_czesc|srodtytul|naglowek_osoba|naglowek_podrozdzial|naglowek_scena|naglowek_rozdzial|miejsce_czas|didaskalia|lista_osoba|akap|akap_dialog|akap_cd|motto_podpis|naglowek_listy">
     <cmd>
         <xsl:attribute name="name">
 </xsl:template>
 
 <xsl:template name="editors">
-    <xsl:for-each select=".//dc:contributor.editor_parsed|.//dc:contributor.technical_editor_parsed">
-        <xsl:if test="position() != 1">, </xsl:if>
-        <xsl:apply-templates mode="inline" />
-    </xsl:for-each>
+    <xsl:if test="//dc:contributor.editor_parsed|//dc:contributor.technical_editor_parsed">
+        <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
+        <xsl:for-each select="//dc:contributor.editor_parsed|//dc:contributor.technical_editor_parsed[not(//dc:contributor.editor_parsed/text()=text())]">
+            <xsl:sort select="@sortkey" />
+            <xsl:if test="position() != 1">, </xsl:if>
+            <xsl:apply-templates mode="inline" />
+        </xsl:for-each>.
+    </xsl:if>
 </xsl:template>
 
 <xsl:template name="translators">
 </xsl:template>
 
 
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>