From: Radek Czajka Date: Mon, 25 Oct 2010 14:24:18 +0000 (+0200) Subject: pdf with motifs (dirty hack for marginpar-orphan problem) X-Git-Tag: 1.7~261 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/a67b6e3ad2751083a433228454665c212c9a5a1e?ds=inline pdf with motifs (dirty hack for marginpar-orphan problem) --- diff --git a/librarian/pdf.py b/librarian/pdf.py index 659390d..b9ead15 100644 --- a/librarian/pdf.py +++ b/librarian/pdf.py @@ -10,6 +10,7 @@ import shutil from StringIO import StringIO from tempfile import mkdtemp import re +from copy import deepcopy import sys sys.path.append('..') # for running from working copy @@ -96,6 +97,32 @@ def transform(provider, slug, output_file=None, output_dir=None): 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) diff --git a/librarian/pdf/wl.sty b/librarian/pdf/wl.sty index f904646..0f60d20 100644 --- a/librarian/pdf/wl.sty +++ b/librarian/pdf/wl.sty @@ -12,7 +12,7 @@ \makeFNabove \usepackage{color} -\definecolor{theme-gray}{gray}{.3} +\definecolor{theme}{gray}{.3} \setlength{\marginparsep}{2em} \setlength{\marginparwidth}{8.5em} @@ -26,9 +26,9 @@ \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 @@ -36,9 +36,10 @@ \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} @@ -60,7 +61,7 @@ \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 @@ -68,5 +69,5 @@ tę sekcję, ale autor konwertera chciał się popisać, że umie coś takiego zrobić. \color{black} \end{figure} + } } - diff --git a/librarian/xslt/wl2tex.xslt b/librarian/xslt/wl2tex.xslt index 5de6d85..dd0a878 100644 --- a/librarian/xslt/wl2tex.xslt +++ b/librarian/xslt/wl2tex.xslt @@ -364,27 +364,32 @@ - - - - - - + + - + + + + + + -8pt + + - + + + 0pt + + theme + + + + + + +