diff options
| author | scoder <none@none> | 2008-04-23 07:15:11 +0200 |
|---|---|---|
| committer | scoder <none@none> | 2008-04-23 07:15:11 +0200 |
| commit | 21dfe8d37910d5683d8502c729789187fe73d445 (patch) | |
| tree | 7378358e269b0bcc25217b1a4381b5da12d28aa2 /doc | |
| parent | 45ab7f4e44d8c08c7ea7dc7457f417ca43d951c1 (diff) | |
| download | python-lxml-21dfe8d37910d5683d8502c729789187fe73d445.tar.gz | |
[svn r3571] r4028@delle: sbehnel | 2008-04-22 23:30:05 +0200
PDF layout fixes
--HG--
branch : trunk
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/mklatex.py | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/doc/mklatex.py b/doc/mklatex.py index c2683028..37c20042 100644 --- a/doc/mklatex.py +++ b/doc/mklatex.py @@ -22,6 +22,30 @@ htmlnsmap = {"h" : "http://www.w3.org/1999/xhtml"} replace_invalid = re.compile(r'[-_/.\s\\]').sub +# LaTeX snippets + +DOCUMENT_CLASS = r""" +\documentclass[10pt,english]{report} +\usepackage[a4paper]{geometry} +\parindent0pt +\parskip1ex +""" + +PYGMENTS_IMPORT = r""" +\usepackage{fancyvrb} +\input{_part_pygments.tex} +""" + +def write_chapter(master, title, outname): + master.write(r""" +\chapter{%s} +\label{_part_%s} +\input{_part_%s} +""".replace(' ', '') % (title, outname, outname)) + + +# the program ---- + def rest2latex(script, source_path, dest_path): command = ('%s %s %s %s > %s' % (sys.executable, script, RST2LATEX_OPTIONS, @@ -182,24 +206,18 @@ def publish(dirname, lxml_path, release): print "Building %s\n" % TARGET_FILE master = file( os.path.join(dirname, TARGET_FILE), "w") for hln in header: - if hln.startswith("\\documentclass"): + if hln.startswith(r"\documentclass"): #hln = hln.replace('article', 'book') - hln = "\\documentclass[10pt,english]{book}\n\\usepackage[a4paper]{geometry}\n" - elif hln.startswith("\\begin{document}"): + hln = DOCUMENT_CLASS + elif hln.startswith(r"\begin{document}"): # pygments support - master.write("\\usepackage{fancyvrb}\n") - master.write("\\input{_part_pygments.tex}\n") - elif hln.startswith("\\title{"): + master.write(PYGMENTS_IMPORT) + elif hln.startswith(r"\title{"): hln = re.sub("\{[^\}]*\}", '{%s}' % book_title, hln) master.write(hln) master.write("\\tableofcontents\n\n") - def write_chapter(title, outname): - master.write( - "\\chapter{%s}\n\\label{_part_%s}\n\n\\input{_part_%s}\n\n" % ( - title, outname, outname)) - for section, text_files in SITE_STRUCTURE: master.write("\\part{%s}\n\n" % section) for filename in text_files: @@ -213,11 +231,11 @@ def publish(dirname, lxml_path, release): basename = os.path.splitext(os.path.basename(filename))[0] basename = BASENAME_MAP.get(basename, basename) outname = basename + '.tex' - write_chapter(titles[outname], outname) + write_chapter(master, titles[outname], outname) - write_chapter("Changes", chgname) + write_chapter(master, "Changes", chgname) - master.write("\end{document}\n") + master.write("\\end{document}\n") if __name__ == '__main__': publish(sys.argv[1], sys.argv[2], sys.argv[3]) |
