xml-›tex-›pdf works, tables, 3cols, footnotes, TOC
authorMarcin Koziej <marcin@koziej.info>
Mon, 3 Mar 2014 11:34:23 +0000 (12:34 +0100)
committerMarcin Koziej <marcin@koziej.info>
Mon, 3 Mar 2014 11:43:28 +0000 (12:43 +0100)
librarian/fonts/SIL Open Font License.txt [deleted file]
librarian/pdf.py
librarian/pdf/fnprep.cls
librarian/pdf/wl2tex.xslt

diff --git a/librarian/fonts/SIL Open Font License.txt b/librarian/fonts/SIL Open Font License.txt
deleted file mode 100755 (executable)
index e08390d..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-Copyright (c) 2010, Sebastian Kosch (sebastian@aldusleaf.org), with Reserved Font Name "Crimson Text".
-
-This Font Software is licensed under the SIL Open Font License, Version 1.1.
-This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
-
------------------------------------------------------------
-SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
------------------------------------------------------------
-
-PREAMBLE
-The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
-
-The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
-
-DEFINITIONS
-"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
-
-"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
-
-"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
-
-"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
-
-"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
-
-PERMISSION & CONDITIONS
-Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
-
-1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
-
-2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
-
-3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
-
-4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
-
-5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
-
-TERMINATION
-This license becomes null and void if any of the above conditions are not met.
-
-DISCLAIMER
-THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
\ No newline at end of file
index a5c4253..b619f1d 100644 (file)
@@ -30,6 +30,7 @@ from librarian import ParseError, DCNS, get_resource, OutputFile
 from librarian import functions
 from librarian.cover import WLCover
 
+import itertools, operator
 
 functions.reg_substitute_entities()
 functions.reg_strip()
@@ -95,6 +96,29 @@ def fix_hanging(doc):
                 exclude=[DCNS("identifier.url"), DCNS("rights.license")]
                 )
 
+def fake_tables(doc):
+    for tabela in doc.findall("//tabela"):
+        # are we dealing with a table of proper structure?
+        # two levels of same tags, and all tags on second level 
+        # must be of same count.
+        def tag_count(m, k):
+            m[k.tag] = m.get(k.tag, 0) + 1
+            return m
+
+        child_tags = reduce(tag_count, list(tabela), {})
+        if len(child_tags) != 1: 
+            return
+        grandchild_tags = reduce(tag_count, itertools.chain(*[list(c) for c in tabela]), {})
+        if len(grandchild_tags) != 1:
+            return
+        if len(set(grandchild_tags.values())) != 1:
+            return
+
+        for row in tabela:
+            row.tag = 'r'
+            for col in row:
+                col.tag = 'c'
+    return
 
 def move_motifs_inside(doc):
     """ moves motifs to be into block elements """
@@ -241,6 +265,7 @@ def transform(wldoc, verbose=False, save_tex=None, save_texml=None, morefloats=N
         # hack the tree
         move_motifs_inside(document.edoc)
         hack_motifs(document.edoc)
+        fake_tables(document.edoc)
         parse_creator(document.edoc)
         substitute_hyphens(document.edoc)
         fix_hanging(document.edoc)
@@ -275,6 +300,7 @@ def transform(wldoc, verbose=False, save_tex=None, save_texml=None, morefloats=N
         # LaTeX -> PDF
         shutil.copy(get_resource('pdf/wl.cls'), temp)
         shutil.copy(get_resource('pdf/wlpub.cls'), temp)
+        shutil.copy(get_resource('pdf/fnprep.cls'), temp)
         shutil.copy(get_resource('res/wl-logo.png'), temp)
         shutil.copy(get_resource('res/cover.jpg'), temp)
         if resources:
index 3cc56f5..dbd11c4 100644 (file)
@@ -13,8 +13,9 @@
 \RequirePackage{xifthen}
 \RequirePackage{environ} % environments with \BODY, for wyimek
 
-
+\PassOptionsToClass{landscape,twoside}{report}
 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
+
 \ProcessOptions\relax
 \LoadClass{report}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \usepackage{fancyhdr}
 \usepackage[MeX]{polski}
 
+\usepackage{longtable}
+\usepackage{booktabs}
+\usepackage{colortbl}
+
 \usepackage{trace}
 \usepackage{caption}
 \usepackage{tabularx}
@@ -42,6 +47,7 @@
 \usepackage{endnotes}
 \let\footnote=\endnote
 \newcommand{\printfootnotes}{%
+  \outmulticols
   \markboth{\MakeTextUppercase{Przypisy}}{}
   \renewcommand{\enoteheading}{}
   \begingroup
@@ -171,6 +177,11 @@ Mapping=tex-text
 %% \renewcommand{\footnotesize}{\addfontfeature{LetterSpace=1.0}\fontsize{9}{10.74}\selectfont}
 
 
+% • • • • • • • • Multicols  •
+\newif\ifinmulticols \inmulticolsfalse
+
+\newcommand{\inmulticols}[0]{\ifinmulticols{}\else\begin{multicols*}{3}\inmulticolstrue\fi}
+\newcommand{\outmulticols}[0]{\ifinmulticols{}\end{multicols*}\clearpage\inmulticolsfalse\else\fi}
 
 % • • • • • • • • • COLORS • •
 \definecolor{stoK}{cmyk}{0,0,0,1}
@@ -179,6 +190,8 @@ Mapping=tex-text
 \definecolor{graybg}{cmyk}{0,0,0,0.55}
 %\color{stoK}
 
+\arrayrulecolor{headcolor}
+
 % • • • • • • • • METADATA • •
 
 \makeatletter
@@ -427,33 +440,33 @@ Mapping=tex-text
 
   %% \paperheight=210mm
 
-  \newgeometry{paperwidth=297mm,paperheight=210mm}
-  \pdfpageheight=210mm
-  \pdfpagewidth=297mm
+  %% \newgeometry{paperwidth=297mm,paperheight=210mm}
+  %% \pdfpageheight=210mm
+  %% \pdfpagewidth=297mm
 
-  \thispagestyle{empty}
-  \newlength{\PictHOffset}
-  \newlength{\PictVOffset}
-  \setlength{\PictHOffset}{1in}
-  \addtolength{\PictHOffset}{\hoffset}
-  \addtolength{\PictHOffset}{\oddsidemargin}
+  %% \thispagestyle{empty}
+  %% \newlength{\PictHOffset}
+  %% \newlength{\PictVOffset}
+  %% \setlength{\PictHOffset}{1in}
+  %% \addtolength{\PictHOffset}{\hoffset}
+  %% \addtolength{\PictHOffset}{\oddsidemargin}
 
-  \setlength{\PictVOffset}{1in}
-  \addtolength{\PictVOffset}{\voffset}
-  \addtolength{\PictVOffset}{\topmargin}
-  \addtolength{\PictVOffset}{\headheight}
-  \addtolength{\PictVOffset}{\headsep}
-  \addtolength{\PictVOffset}{\topskip}
+  %% \setlength{\PictVOffset}{1in}
+  %% \addtolength{\PictVOffset}{\voffset}
+  %% \addtolength{\PictVOffset}{\topmargin}
+  %% \addtolength{\PictVOffset}{\headheight}
+  %% \addtolength{\PictVOffset}{\headsep}
+  %% \addtolength{\PictVOffset}{\topskip}
 
-  \addtolength{\PictVOffset}{-\paperheight}
+  %% \addtolength{\PictVOffset}{-\paperheight}
 
-  \noindent\hspace*{-\PictHOffset}%
-  \raisebox{\PictVOffset}[0pt][0pt]{\makebox[0pt][l]{%
-      \includegraphics[height=\pdfpageheight,width=\pdfpagewidth]{cover.pdf}}}
+  %% \noindent\hspace*{-\PictHOffset}%
+  %% \raisebox{\PictVOffset}[0pt][0pt]{\makebox[0pt][l]{%
+  %%     \includegraphics[height=\pdfpageheight,width=\pdfpagewidth]{cover.pdf}}}
 
-  \restoregeometry
-  \pdfpageheight=210mm
-  \pdfpagewidth=148mm
+  %% \restoregeometry
+  %% \pdfpageheight=210mm
+  %% \pdfpagewidth=148mm
 
   }
 
@@ -461,52 +474,50 @@ Mapping=tex-text
   %\vspace{\paperheight}
   \thispagestyle{empty}
   \cleardoublepage
-  \setcounter{page}{1}
-  \thispagestyle{empty}
-  \begin{center}
-  \intro
-  {
-    \begin{spacing}{1.4}
-    \Huge \noindent \thetitle
-    \end{spacing}
-  }
-  \end{center}
+  %% \setcounter{page}{1}
+  %% \thispagestyle{empty}
+  %% \begin{center}
+  %% {
+  %%   \begin{spacing}{1.4}
+  %%   \Huge \noindent \thetitle
+  %%   \end{spacing}
+  %% }
+  %% \end{center}
 
-  \vspace{\baselineskip}
+  %% \vspace{\baselineskip}
 
-  \begin{center}
-    \intro
-    {
-      \huge \noindent
-      \theauthor
+  %% \begin{center}
+  %%   \intro
+  %%   {
+  %%     \huge \noindent
+  %%     \theauthor
 
-    }
-  \end{center}
-                  %\emph{\thankyou}\\
-                  %\indent\emph{You made this book possible.}
-  \vspace{7\baselineskip}
+  %%   }
+  %% \end{center}
+  %%                 %\emph{\thankyou}\\
+  %%                 %\indent\emph{You made this book possible.}
+  %% \vspace{7\baselineskip}
 
-  \begin{center}
-    \includegraphics[scale=.2]{logo.eps}
-  \end{center}
+  %% \begin{center}
+  %%   \includegraphics[scale=.2]{logo.eps}
+  %% \end{center}
 
 }
 
 
 \newcommand{\editorialsection}{
   \clearpage
-  \thispagestyle{empty}
-  {
-    \setlength{\parindent}{0mm}
-    \small
-  \input{editorial}
-  }
+  %% \thispagestyle{empty}
+  %% {
+  %%   \setlength{\parindent}{0mm}
+  %%   \small
+  %% \input{editorial}
+  %% }
 }
 
 \renewcommand*\contentsname{Spis treści}
 \newcommand{\spistresci}{
 {
-  \intro
   \setcounter{tocdepth}{0}
   \tableofcontents
   \newpage
@@ -630,6 +641,7 @@ Mapping=tex-text
 
 
 \newcommand{\naglowekrozdzial}[1]{%
+\inmulticols%
 \startcontents[chapter]
 \markboth{#1}{}
 %
@@ -640,6 +652,7 @@ Mapping=tex-text
 \par{\textsc{#1}}\nopagebreak%
 }
 \newcommand{\naglowekpodrozdzial}[1]{%
+\inmulticols%
 \section{#1}\nopagebreak%
 }
 \newcommand{\miejsceczas}[1]{%
@@ -650,6 +663,7 @@ Mapping=tex-text
 }
 
 \newcommand{\akap}[1]{%
+\inmulticols%
 #1
 
 % newline here needed, we don't use \par cause it ignores \noindent before
@@ -685,6 +699,11 @@ Mapping=tex-text
 \hspace*{#1}#2%
 }
 
+\newcommand{\pa}[1]{\NoCaseChange{\endnote{#1}}}
+\newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}}
+\newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}}
+\newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}}
+
 
 \newcommand{\mat}[1]{$#1$}
 
@@ -757,8 +776,8 @@ Mapping=tex-text
 
 
 \newcommand{\lista}[1]{%
+\inmulticols%
 \begin{compactenum}
-%\setlength{\parskip}{\parindent}
 #1
 \end{compactenum}
 }
@@ -770,10 +789,13 @@ Mapping=tex-text
 
 \newcommand{\www}[1]{{\normalfont\href{#1}{#1}}}
 
+
+
 % TABELA %
 
 \newenvironment{tabela}[0]%
-{\begin{longtable}{p{40mm}@{\hspace{5mm}}p{65mm}@{\hspace{5mm}}p{65mm}@{\hspace{5mm}}p{65mm}}}%
+{\renewcommand{\inmulticols}{\relax}%
+\begin{longtable}{p{40mm}@{\hspace{5mm}}p{65mm}@{\hspace{5mm}}p{65mm}@{\hspace{5mm}}p{65mm}}}%
 {\end{longtable}}
 
 \newcommand{\formatkomnaglowek}[1]% reset format
@@ -789,11 +811,11 @@ Mapping=tex-text
 }
 
 \newcommand{\tabelawiersz}[1]{
-    \cmidrule[0.7pt](r{5mm}){1-1}
-    \cmidrule[0.7pt](r{5mm}){2-2}
-    \cmidrule[0.7pt](r{5mm}){3-3}
-    \cmidrule[0.7pt](r{5mm}){4-4} \\[3mm]
-    #1
+    \cmidrule[0.7pt](r{5mm}){1-1}%
+    \cmidrule[0.7pt](r{5mm}){2-2}%
+    \cmidrule[0.7pt](r{5mm}){3-3}%
+    \cmidrule[0.7pt](r{5mm}){4-4} \\[1mm]
+#1
     \\[4mm]
 }
 
index 149fbde..c929c73 100644 (file)
 <xsl:strip-space elements="nota|akap|wyroznienie"/>
 
 <xsl:template mode="inline"
-    match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|punkt|www|nota_red">
+    match="pa|pe|pr|pt|mat|didask_tekst|slowo_obce|wyroznienie|osoba|lista|punkt|www|nota_red">
     <cmd>
         <xsl:attribute name="name">
             <xsl:value-of select="wl:texcommand(name())" />
      - first: is first column special?
 
  -->
-<xls:template match="tabela">
+<xsl:template match="tabela">
+  <cmd name="outmulticols"></cmd>
   <cmd name="begin"><parm>tabela</parm> </cmd>
   <xsl:apply-templates mode="tabela"/>
   <cmd name="end"><parm>tabela</parm> </cmd>
-</xls:template>
+</xsl:template>
 
 <xsl:template match="r" mode="tabela">
+<!--  R<xsl:value-of select="count(preceding-sibling::*)" />-->
   <xsl:choose>
-    <xsl:when test="position() = 1">
+    <xsl:when test="count(preceding-sibling::*) = 0">
       <cmd name="tabelanaglowek"><parm>
        <xsl:apply-templates mode="tabelanaglowek"/>
       </parm></cmd>
 </xsl:template>
 
 <xsl:template match="c" mode="tabelanaglowek">
-  <xsl:if test="position() > 1">&amp;</xsl:if>
+  <xsl:if test="count(preceding-sibling::*) > 0"><spec cat="align"/></xsl:if>
   <cmd name="tabelakomnaglowek"><parm>
     <xsl:apply-templates mode="inline"/>
   </parm></cmd>
 </xsl:template>
 
 <xsl:template match="c" mode="tabelawiersz">
+
   <xsl:choose>
-    <xsl:when test="position() = 1">
+    <xsl:when test="count(preceding-sibling::*) = 0">
       <cmd name="tabelakompierwsza"><parm>
        <xsl:apply-templates mode="inline"/>
       </parm></cmd>
     </xsl:when>
     <xsl:otherwise>
-      &amp;<cmd name="tabelakom"><parm>
+      <spec cat="align"/><cmd name="tabelakom"><parm>
        <xsl:apply-templates mode="inline"/>
       </parm></cmd>
     </xsl:otherwise>