from StringIO import StringIO
from tempfile import mkdtemp
import re
+from copy import deepcopy
import sys
sys.path.append('..') # for running from working copy
document = load_including_children(provider, slug)
+ # dirty hack for the marginpar-creates-orphans LaTeX problem
+ # see http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=latex/2304
+ for motif in document.edoc.findall('//strofa//motyw'):
+ # find relevant verse-level tag
+ verse, stanza = motif, motif.getparent()
+ while stanza is not None and stanza.tag != 'strofa':
+ verse, stanza = stanza, stanza.getparent()
+ breaks_before = sum(1 for i in verse.itersiblings('br', preceding=True))
+ breaks_after = sum(1 for i in verse.itersiblings('br'))
+ if (breaks_before == 0 and breaks_after > 0) or breaks_after == 1:
+ move_by = 1
+ if breaks_after == 2:
+ move_by += 1
+ moved_motif = deepcopy(motif)
+ motif.tag = 'span'
+ motif.text = None
+ moved_motif.tail = None
+ moved_motif.set('moved', str(move_by))
+
+ for br in verse.itersiblings(tag='br'):
+ if move_by > 1:
+ move_by -= 1
+ continue
+ br.addnext(moved_motif)
+ break
+
substitute_hyphens(document.edoc)
fix_hanging(document.edoc)
\makeFNabove
\usepackage{color}
-\definecolor{theme-gray}{gray}{.3}
+\definecolor{theme}{gray}{.3}
\setlength{\marginparsep}{2em}
\setlength{\marginparwidth}{8.5em}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}
-\lfoot{\footnotesize \@author, \emph{\@title}}
+\lfoot{{\footnotesize \@author, \emph{\@title}}}
\cfoot{}
-\rfoot{\footnotesize \thepage}
+\rfoot{{\footnotesize \thepage}}
\clubpenalty=100000
\widowpenalty=100000
\renewcommand{\maketitle}{
+ {
\thispagestyle{empty}
\footnotesize
- \color{theme-gray}
+ \color{theme}
\noindent \begin{minipage}[t]{.35\textwidth}\vspace{0pt}
\includegraphics[width=\textwidth]{pdf/wl-logo.png}
\begin{figure}[b!]
\footnotesize
- \color{theme-gray}
+ \color{theme}
\noindent \rule{\linewidth}{0.4pt}
Szkolna biblioteka internetowa Wolne Lektury tworzona jest dzięki pracy Wolontariuszy, ale to osoby
tę sekcję, ale autor konwertera chciał się popisać, że umie coś takiego zrobić.
\color{black}
\end{figure}
+ }
}
-
<!-- Themes -->
-<xsl:template match="begin" mode="inline">
- <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
- <!--cmd name="mbox" />
- <cmd name="marginpar">
- <parm><cmd name="raggedright"><parm>
- <cmd name="hspace"><parm>0pt</parm></cmd>
- <cmd name="footnotesize"><parm>
- <cmd name="color"><parm>theme-gray</parm><parm>
- <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
- </parm></cmd>
- </parm></cmd>
- </parm></cmd></parm>
- </cmd-->
-</xsl:template>
-
-<xsl:template match="begin|end">
+<xsl:template match="begin|end|motyw">
<xsl:apply-templates select='.' mode="inline" />
</xsl:template>
+<xsl:template match="begin" mode="inline" />
<xsl:template match="end" mode="inline" />
-<xsl:template match="motyw" mode="inline" />
+
+<xsl:template match="motyw" mode="inline">
+ <cmd name="mbox" />
+ <cmd name="marginpar">
+ <parm>
+ <cmd name="vspace"><parm>-8pt</parm></cmd>
+ <xsl:if test="@moved">
+ <cmd name="vspace"><parm>-<xsl:value-of select="@moved" /><cmd name="baselineskip" /></parm></cmd>
+ </xsl:if>
+ <cmd name="raggedright"><parm>
+ <cmd name="hspace"><parm>0pt</parm></cmd>
+ <cmd name="footnotesize"><parm>
+ <cmd name="color"><parm>theme</parm><parm>
+ <xsl:value-of select="." />
+ </parm></cmd>
+ </parm></cmd>
+ </parm></cmd>
+ </parm>
+ </cmd>
+</xsl:template>
<!-- ============== -->