From 33165a21eb5b83f96d73e616414a1ee9e7227013 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 22 Dec 2010 12:51:53 +0100 Subject: [PATCH 1/1] pdf: use custom TeX commands and a style --- librarian/functions.py | 9 ++ librarian/pdf.py | 1 + librarian/pdf/wl.sty | 184 ++++++++++++++++++++++++++++ librarian/xslt/wl2tex.xslt | 238 ++++++++++--------------------------- 4 files changed, 255 insertions(+), 177 deletions(-) diff --git a/librarian/functions.py b/librarian/functions.py index 5ad723d..e5023b3 100644 --- a/librarian/functions.py +++ b/librarian/functions.py @@ -96,3 +96,12 @@ def reg_person_name(): _register_function(person_name) +def reg_texcommand(): + def texcommand(context, text): + """Remove non-letters""" + if isinstance(text, list): + text = ''.join(text) + return re.sub(r'[^a-zA-Z]', '', text).strip() + _register_function(texcommand) + + diff --git a/librarian/pdf.py b/librarian/pdf.py index bb1ba64..32fa571 100644 --- a/librarian/pdf.py +++ b/librarian/pdf.py @@ -29,6 +29,7 @@ functions.reg_substitute_entities() functions.reg_strip() functions.reg_starts_white() functions.reg_ends_white() +functions.reg_texcommand() STYLESHEETS = { 'wl2tex': 'xslt/wl2tex.xslt', diff --git a/librarian/pdf/wl.sty b/librarian/pdf/wl.sty index bfe2881..1299aec 100644 --- a/librarian/pdf/wl.sty +++ b/librarian/pdf/wl.sty @@ -78,3 +78,187 @@ % \end{figure} } } + + + + +\newcommand{\nazwapodutworu}[1]{% +\section*{#1}% +} + +\newcommand{\autorutworu}[1]{% +\subsection*{#1}% +} + +\newcommand{\nazwautworu}[1]{% +\section*{#1}% +} + +\newcommand{\powiesc}[1]{#1} +\newcommand{\opowiadanie}[1]{#1} +\newcommand{\lirykal}[1]{#1} +\newcommand{\lirykalp}[1]{#1} +\newcommand{\dramatwierszowanyl}[1]{#1} +\newcommand{\dramatwierszowanylp}[1]{#1} +\newcommand{\dramatwspolczesny}[1]{#1} + +\newcommand{\nota}[1]{% +\par{#1}% +} + +\newcommand{\dedykacja}[1]{% +\begin{em}% +\begin{flushright}% +#1% +\end{flushright}% +\end{em}% +} + +\newcommand{\dlugicytat}[1]{% +\begin{quotation}% +#1% +\end{quotation}% +} + +\newcommand{\poezjacyt}[1]{% +\begin{verse}% +#1% +\end{verse}% +} +\newcommand{\motto}[1]{% +\begin{em}% +#1% +\end{em}% +} +\newcommand{\listaosob}[2]{% +\par{#1}% +\begin{itemize}% +#2% +\end{itemize}% +} + +\newcommand{\nagloweklisty}[1]{% +\textbf{#1}% +} + +\newcommand{\listaosoba}[1]{% +\item{#1}% +} + +\newcommand{\kwestia}[1]{% +\par{#1}% +} + +\newcommand{\naglowekakt}[1]{% +\subsection*{#1}% +} +\newcommand{\naglowekczesc}[1]{% +\subsection*{#1}% +} +\newcommand{\srodtytul}[1]{% +\subsection*{#1}% +} + +\newcommand{\naglowekscena}[1]{% +\subsubsection*{#1}% +} +\newcommand{\naglowekrozdzia}[1]{% +\subsubsection*{#1}% +} + +\newcommand{\naglowekosoba}[1]{% +\par{#1}\nopagebreak% +} +\newcommand{\naglowekpodrozdzial}[1]{% +\par{#1}\nopagebreak% +} + +\newcommand{\miejsceczas}[1]{% +\par{\emph{#1}}% +} +\newcommand{\didaskalia}[1]{% +\par{\emph{#1}}% +} + +\newcommand{\akap}[1]{% +\par{#1}% +} +\newcommand{\akapdialog}[1]{% +\par{#1}% +} +\newcommand{\akapcd}[1]{% +\par{#1}% +} + +\newcommand{\mottopodpis}[1]{% +\begin{em}% +\begin{flushright}% +#1% +\end{flushright}% +\end{em}% +} + +\newcommand{\strofa}[1]{% +\par{\noindent{\ignorespaces#1\vspace{1em}}}% +} + +\newcommand{\wers}[1]{#1} + +\newcommand{\wersakap}[1]{% +\hspace*{1em}#1% +} +\newcommand{\werscd}[1]{% +\hspace*{8em}#1% +} +\newcommand{\werswciety}[2][1em]{% +\hspace*{#1}#2% +} + + +\newcommand{\pa}[1]{\footnote{#1}} +\newcommand{\pe}[1]{\footnote{#1}} +\newcommand{\pr}[1]{\footnote{#1}} +\newcommand{\pt}[1]{\footnote{#1}} + +\newcommand{\mat}[1]{$#1$} + +\newcommand{\didasktekst}[1]{% +\emph{#1}% +} +\newcommand{\slowoobce}[1]{% +\emph{#1}% +} +\newcommand{\tytuldziela}[1]{% +\emph{#1}% +} +\newcommand{\wyroznienie}[1]{% +\emph{#1}% +} + +\newcommand{\osoba}[1]{% +\textsc{#1}% +} + +\newcommand{\sekcjaswiatlo}{% +\hspace{30pt}% +} + +\newcommand{\sekcjaasterysk}{% +\par{*}% +} + +\newcommand{\separatorlinia}{% +\hrule{}% +} + +\newcommand{\motyw}[2][0]{% +\mbox{}% +\marginpar{% +\vspace{-8pt}% +\vspace{-#1\baselineskip}% +\raggedright{\hspace{0pt}% +\footnotesize{\color{theme}{#2}}}% +\vspace{\baselineskip}% +}% +} + diff --git a/librarian/xslt/wl2tex.xslt b/librarian/xslt/wl2tex.xslt index a6a9b56..0e2dbfe 100644 --- a/librarian/xslt/wl2tex.xslt +++ b/librarian/xslt/wl2tex.xslt @@ -106,21 +106,20 @@ - + - - + - + @@ -130,66 +129,34 @@ - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - + + + + - + - - - - - - - - - - - - - - - - - - @@ -198,67 +165,24 @@ - + - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -283,38 +207,28 @@ - 1em - + - 1em - - - - em - - - 1em - - - - - 8em - - - - - - - - - - + + + + + + + wers + + + + em + + + @@ -322,58 +236,40 @@ - - - + + + + + + + - - - - - - - - - - - - + „” - - - - - - - - - 30pt - - - - - * - - - - + + + + + + - @@ -388,23 +284,11 @@ - - - - -8pt - - - - - - 0pt - - theme - - - - - - + + + + + -- 2.20.1