Fix XML entities left from MathML.
[librarian.git] / librarian / pdf / wl2tex.xslt
index d39b61a..43a3274 100644 (file)
@@ -36,7 +36,7 @@
         <xsl:choose>
             <xsl:when test="@morefloats = 'new'">
                 <TeXML escape="0">
-                    \usepackage[maxfloats=64]{morefloats}
+                    \usepackage[maxfloats=53]{morefloats}
                 </TeXML>
             </xsl:when>
             <xsl:when test="@morefloats = 'old'">
                 </xsl:otherwise>
               </xsl:choose>
             </parm></cmd>
+            <xsl:if test="//utwor//utwor or //naglowek_czesc or //naglowek_akt or //srodtytul or //naglowek_scena or //naglowek_rozdzial">
+                <cmd name="ifshowtoc" />
+                <cmd name="setcounter" >
+                    <parm>tocdepth</parm>
+                    <parm>3</parm>
+                </cmd>
+                <cmd name="tableofcontents" />
+                <cmd name="clearpage" />
+                <cmd name="fi" />
+            </xsl:if>
             <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
             <xsl:apply-templates select="utwor" mode="part" />
 
                 </xsl:if>
                 \def\editors{<TeXML escape="1"><xsl:call-template name="editors" /></TeXML>}
                 <xsl:if test="@funders">
-                    \def\funders{Publikację ufundowali i ufundowały:
+                    \def\funders{Publikację wsparli i wsparły:
                         <TeXML escape="1"><xsl:value-of select="@funders" /></TeXML>.}
                 </xsl:if>
 
       <xsl:choose>
         <xsl:when test="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu">
             <!-- title in master -->
-            <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="title" />
+            <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/nazwa_utworu" mode="part_title" />
             <xsl:apply-templates select="(powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny)/podtytul" mode="title" />
         </xsl:when>
         <xsl:otherwise>
             \href{http://creativecommons.org/licenses/by-sa/3.0/}{Creative Commons
             Uznanie Autorstwa – Na Tych Samych Warunkach 3.0 PL}.}
         <xsl:if test=".//dc:rights.license">
-            \def\rightsinfo{Ten utwór jest udostepniony na licencji
+            \def\rightsinfo{Ten utwór jest udostępniony na licencji
             \href{<xsl:value-of select=".//dc:rights.license" />}{<TeXML escape="1"><xsl:apply-templates select=".//dc:rights" mode="inline" /></TeXML>}.}
         </xsl:if>
 
                 Tekst opracowany na podstawie: <TeXML escape="1"><xsl:apply-templates select=".//dc:source" mode="inline" /></TeXML>
                 \vspace{.6em}
             </xsl:if>}
+        \def\publisherinfo{
+            <xsl:if test=".//dc:publisher">
+                Wydawca:
+                <TeXML escape="1">
+                    <xsl:for-each select=".//dc:publisher/text()">
+                        <xsl:value-of select="."/>
+                        <xsl:if test="not(position() = last())">, </xsl:if>
+                    </xsl:for-each>
+                </TeXML>
+                \vspace{.6em}
+            </xsl:if>}
         \def\description{<TeXML escape="1"><xsl:apply-templates select=".//dc:description" mode="inline" /></TeXML>}
+        <xsl:if test=".//meta[@id='pdf-id']">
+            <xsl:variable name="isbn" select=".//meta[@id='pdf-id']"/>
+            \def\isbn{ISBN <xsl:value-of select="substring-after($isbn, 'ISBN-')"/>}
+        </xsl:if>
     </TeXML>
 </xsl:template>
 
 </xsl:template>
 
 <xsl:template match="rdf:RDF" mode="dctitle">
-    <cmd name="nazwapodutworu"><parm>
+    <xsl:if test="../../rdf:RDF//use_subauthor">
+        <cmd name="autorpodutworu">
+            <parm><xsl:call-template name="authors" /></parm>
+        </cmd>
+    </xsl:if>
+    <cmd name="nazwanadpodutworu"><parm>
+        <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
+    </parm>
+    <parm>
         <xsl:apply-templates select=".//dc:title/node()" mode="inline" />
     </parm></cmd>
 </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">
+    match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny|nota|dedykacja|dlugi_cytat|poezja_cyt|motto|ramka">
     <cmd>
         <xsl:attribute name="name">
             <xsl:value-of select="wl:texcommand(name())" />
     </cmd>
 </xsl:template>
 
+<xsl:template match="ilustr">
+    <cmd name="ilustr">
+        <parm><xsl:value-of select="@src" /></parm>
+        <parm><xsl:value-of select="@alt" /></parm>
+    </cmd>
+</xsl:template>
 
 <!-- ========================================== -->
 <!-- = PARAGRAPH TAGS                         = -->
     </cmd>
 </xsl:template>
 
+<xsl:template match="nazwa_utworu" mode="part_title">
+    <xsl:if test="../../rdf:RDF//use_subauthor">
+        <cmd name="autorpodutworu"><parm><xsl:call-template name="authors2"/></parm></cmd>
+    </xsl:if>
+    <cmd name="nazwapodutworu">
+        <parm><xsl:apply-templates mode="inline"/></parm>
+        <parm>
+            <xsl:call-template name="strip-for-toc" />
+        </parm>
+    </cmd>
+</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">
+       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">
     <cmd>
         <xsl:attribute name="name">
             <xsl:value-of select="wl:texcommand(name())" />
     </cmd>
 </xsl:template>
 
+<xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_akt|naglowek_scena">
+    <cmd>
+        <xsl:attribute name="name">
+            <xsl:value-of select="wl:texcommand(name())" />
+        </xsl:attribute>
+        <parm><xsl:apply-templates mode="inline"/></parm>
+        <parm>
+            <xsl:call-template name="strip-for-toc" />
+        </parm>
+    </cmd>
+</xsl:template>
+
+<xsl:template match="strofa" mode="inline">
+    <env name="minipage">
+        <opt>t</opt>
+        <parm><cmd name="linewidth" /></parm>
+        <parm><xsl:apply-templates select="." /></parm>
+    </env>
+</xsl:template>
+
 <xsl:template match="strofa">
   <cmd name="strofa"><parm>
     <xsl:choose>
         <xsl:when test="count(br) > 0">
             <xsl:call-template name="verse">
                 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
-                <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
+                <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]" />
             </xsl:call-template>
             <xsl:for-each select="br">
                 <TeXML escape="0">\\{}</TeXML>
                 <xsl:call-template name="verse">
                     <xsl:with-param name="verse-content"
                         select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
-                    <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]" />
+                    <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]" />
                 </xsl:call-template>
             </xsl:for-each>
         </xsl:when>
         <xsl:otherwise>
             <xsl:call-template name="verse">
                 <xsl:with-param name="verse-content" select="text() | node()" />
-                <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
+                <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd|wers_do_prawej[1]" />
             </xsl:call-template>
         </xsl:otherwise>
     </xsl:choose>
 <!-- ================================================ -->
 
 <xsl:template mode="inline"
-    match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba">
+    match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|indeks_dolny|wieksze_odstepy">
     <cmd>
         <xsl:attribute name="name">
             <xsl:value-of select="wl:texcommand(name())" />
     </xsl:for-each>
 </xsl:template>
 
+<xsl:template name="authors2">
+    <xsl:for-each select="../..//dc:creator_parsed">
+        <xsl:if test="position() != 1">, </xsl:if>
+        <xsl:apply-templates mode="inline" />
+    </xsl:for-each>
+</xsl:template>
+
 <xsl:template name="editors">
     <xsl:if test="@editors">
         <xsl:text>Opracowanie redakcyjne i przypisy: </xsl:text>
     </xsl:if>
 </xsl:template>
 
+<xsl:template name="strip-for-toc">
+    <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
+        <xsl:choose>
+            <xsl:when test="name() = 'nbsp'">
+                <xsl:text> </xsl:text>
+            </xsl:when>
+            <xsl:when test="name() = 'dywiz'">
+                <xsl:text>-</xsl:text>
+            </xsl:when>
+            <xsl:when test="name() = 'alien'">
+                <xsl:apply-templates mode="inline" />
+            </xsl:when>
+            <xsl:when test="name() = 'slowo_obce'">
+                <xsl:call-template name="strip-for-toc" />
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="."/>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:for-each>
+</xsl:template>
+
 <xsl:template match="data-sponsor" mode="sponsor">
     <cmd name="par"><parm>
     <xsl:choose>
     </parm></cmd>
 </xsl:template>
 
+<xsl:template match="mat" mode="inline">
+    <TeXML escape="0">
+        <xsl:text>$</xsl:text>
+        <xsl:value-of select="wl:mathml_latex(.)" />
+        <xsl:text>$</xsl:text>
+    </TeXML>
+</xsl:template>
+
+<xsl:template match="mat">
+    <TeXML escape="0">
+        <xsl:text>$$</xsl:text>
+        <xsl:value-of select="wl:mathml_latex(.)" />
+        <xsl:text>$$</xsl:text>
+    </TeXML>
+</xsl:template>
+
+<xsl:template match="tabela|tabelka">
+    <cmd name="par" />
+    <cmd name="vspace"><parm>1em</parm></cmd>
+    <group><cmd name="raggedright" />
+    <xsl:element name="env">
+        <xsl:attribute name="name">
+            <xsl:choose>
+                <xsl:when test="name(.)='tabela'">longtabu</xsl:when>
+                <xsl:otherwise>tabu</xsl:otherwise>
+            </xsl:choose>
+        </xsl:attribute> to <TeXML escape="0">\textwidth </TeXML>
+      <!--parm><cmd name="textwidth"/></parm-->
+      <parm><TeXML escape="0"><xsl:value-of select="@_format" /></TeXML></parm>
+        <xsl:choose>
+        <xsl:when test="@ramka='1' or @ramki='1'">
+          <cmd name="hline" />
+          <xsl:apply-templates mode="wiersze-ramki"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates/>
+        </xsl:otherwise>
+        </xsl:choose>
+    </xsl:element>
+    </group>
+    <cmd name="vspace"><parm>1em</parm></cmd>
+</xsl:template>
+<xsl:template match="wiersz" mode="wiersze-ramki">
+    <xsl:apply-templates />
+    <spec cat="esc"/><spec cat="esc"/>
+    <cmd name="hline" gr="0" />
+</xsl:template>
+<xsl:template match="wiersz">
+    <xsl:apply-templates />
+    <spec cat="esc"/><spec cat="esc"/>
+</xsl:template>
+<xsl:template match="kol">
+    <xsl:apply-templates mode="inline"/>
+    <xsl:if test="position() &lt; last()">
+    <spec cat="align"/>
+    </xsl:if>
+</xsl:template>
+
+
 <!-- ============== -->
 <!-- = ADDED TAGS = -->
 <!-- ============== -->
 <xsl:template match="extra|uwaga" mode="inline" />
 
 <xsl:template match="nota_red" />
+<xsl:template match="abstrakt" />
 
 <!-- ======== -->
 <!-- = TEXT = -->