From ab4401272d1b8507effd51da00f40bafe81f2b44 Mon Sep 17 00:00:00 2001 From: Marcin Koziej Date: Mon, 5 Dec 2011 14:20:58 +0100 Subject: [PATCH] change passing customizations to TeX source --- librarian/__init__.py | 4 ++-- librarian/pdf.py | 15 ++++++++++++++- librarian/pdf/wl.cls | 9 +++++++-- librarian/pdf/wl2tex.xslt | 4 +--- setup.py | 0 5 files changed, 24 insertions(+), 8 deletions(-) mode change 100644 => 100755 setup.py diff --git a/librarian/__init__.py b/librarian/__init__.py index 5b6981d..a672486 100644 --- a/librarian/__init__.py +++ b/librarian/__init__.py @@ -8,11 +8,11 @@ import os class ParseError(Exception): def __str__(self): """ Dirty workaround for Python Unicode handling problems. """ - return self.message.message + return self.message def __unicode__(self): """ Dirty workaround for Python Unicode handling problems. """ - return self.message.message + return self.message class ValidationError(Exception): pass diff --git a/librarian/pdf.py b/librarian/pdf.py index b3725b4..1bfd949 100644 --- a/librarian/pdf.py +++ b/librarian/pdf.py @@ -35,6 +35,13 @@ STYLESHEETS = { 'wl2tex': 'pdf/wl2tex.xslt', } +CUSTOMIZATIONS = [ + 'nofootnotes', + 'nothemes', + 'onehalfleading', + 'doubleleading', + 'nowlfont', + ] def insert_tags(doc, split_re, tagname, exclude=None): """ inserts for every occurence of `split_re' in text nodes in the `doc' tree @@ -168,7 +175,7 @@ def package_available(package, args='', verbose=False): def transform(provider, slug=None, file_path=None, output_file=None, output_dir=None, make_dir=False, verbose=False, save_tex=None, morefloats=None, - cover=None, flags=None): + cover=None, flags=None, customizations=None): """ produces a PDF file with XeLaTeX provider: a DocProvider @@ -182,6 +189,7 @@ def transform(provider, slug=None, file_path=None, morefloats (old/new/none): force specific morefloats cover: a cover.Cover object flags: less-advertising, + customizations: user requested customizations regarding various formatting parameters (passed to wl LaTeX class) """ # Parse XSLT @@ -208,6 +216,10 @@ def transform(provider, slug=None, file_path=None, elif package_available('morefloats', 'maxfloats=19'): document.edoc.getroot().set('morefloats', 'new') + # add customizations + if customizations is not None: + document.edoc.getroot().set('customizations', u','.join(customizations)) + # hack the tree move_motifs_inside(document.edoc) hack_motifs(document.edoc) @@ -223,6 +235,7 @@ def transform(provider, slug=None, file_path=None, # wl -> TeXML style_filename = get_stylesheet("wl2tex") style = etree.parse(style_filename) + texml = document.transform(style) # TeXML -> LaTeX diff --git a/librarian/pdf/wl.cls b/librarian/pdf/wl.cls index 415e14a..37d1d24 100644 --- a/librarian/pdf/wl.cls +++ b/librarian/pdf/wl.cls @@ -11,8 +11,7 @@ % a4paper,... - paper size as required by LaTeX % nowlfont - don't use customized WL font -%\usepackage{setspace} - +\RequirePackage{setspace} \RequirePackage{type1cm} \DeclareOption{13pt}{% \AtEndOfClass{% @@ -43,6 +42,12 @@ \DeclareOption{doubleleading}{\AtBeginDocument{\doublespacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}} \DeclareOption{onehalfleading}{\AtBeginDocument{\onehalfspacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}} +%% This does not really work, since dvipdfm(x) will use it's configuration in /etc/texmf/dvipdfm(x) and force a global paper size setting. +\DeclareOption{a5paper}{% + \setlength{\paperheight}{210mm}% + \setlength{\paperwidth}{148mm}} + + \newif\ifshowfootnotes \showfootnotestrue \DeclareOption{nofootnotes}{\showfootnotesfalse} diff --git a/librarian/pdf/wl2tex.xslt b/librarian/pdf/wl2tex.xslt index ec5e4d3..25d76d9 100644 --- a/librarian/pdf/wl2tex.xslt +++ b/librarian/pdf/wl2tex.xslt @@ -15,7 +15,7 @@ - \documentclass[a4paper, oneside, 11pt]{book} + \documentclass[]{wl} @@ -31,8 +31,6 @@ \def\{} - - \usepackage{wl} diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 -- 2.20.1