X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/b92b58ba86f08f04b4f0436479d3d73ce0c03f00..ab4401272d1b8507effd51da00f40bafe81f2b44:/librarian/pdf.py?ds=inline diff --git a/librarian/pdf.py b/librarian/pdf.py index 476fbee..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 @@ -152,7 +159,7 @@ def package_available(package, args='', verbose=False): fpath = os.path.join(tempdir, 'test.tex') f = open(fpath, 'w') f.write(r""" - \documentclass{book} + \documentclass{wl} \usepackage[%s]{%s} \begin{document} \end{document} @@ -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 @@ -245,7 +258,7 @@ def transform(provider, slug=None, file_path=None, shutil.copy(tex_path, save_tex) # LaTeX -> PDF - shutil.copy(get_resource('pdf/wl.sty'), temp) + shutil.copy(get_resource('pdf/wl.cls'), temp) shutil.copy(get_resource('res/wl-logo.png'), temp) cwd = os.getcwd()