X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=python%2Fbook_latex.py;h=c94240cd54e2b3dc783a7b65b8e93d7ae5718e61;hb=1d509b27723ea1c359b51c0f2fe623a32867d6f9;hp=dfb6fc0ac741617c530ef69701a43a1eaa2790c9;hpb=8860a7700be8348848bba7972ad86ef46721c544;p=lilypond.git diff --git a/python/book_latex.py b/python/book_latex.py index dfb6fc0ac7..c94240cd54 100644 --- a/python/book_latex.py +++ b/python/book_latex.py @@ -3,9 +3,15 @@ import re import tempfile import os +import subprocess import book_base as BookBase from book_snippets import * import lilylib as ly +global _;_=ly._ + +progress = ly.progress +warning = ly.warning +error = ly.error # Recognize special sequences in the input. # @@ -63,6 +69,17 @@ Latex_snippet_res = { (?P\S+?) })''', + 'musicxml_file': + r'''(?smx) + ^[^%\n]*? + (?P + \\musicxmlfile\s*( + \[ + \s*(?P.*?)\s* + \])?\s*\{ + (?P\S+?) + })''', + 'singleline_comment': r'''(?mx) ^.*? @@ -101,6 +118,7 @@ Latex_output = { OUTPUT: r'''{%% \parindent 0pt +\noindent \ifx\preLilyPondExample \undefined \else \expandafter\preLilyPondExample @@ -116,9 +134,9 @@ Latex_output = { PRINTFILENAME: '''\\texttt{%(filename)s} ''', - QUOTE: r'''\begin{quotation} + QUOTE: r'''\begin{quote} %(str)s -\end{quotation}''', +\end{quote}''', VERBATIM: r'''\noindent \begin{verbatim}%(verb)s\end{verbatim} @@ -163,12 +181,20 @@ def get_latex_textwidth (source, global_options): tmp_handle.write (latex_document) tmp_handle.close () - ly.system ('%s %s' % (global_options.latex_program, tmpfile), - be_verbose=global_options.verbose) - parameter_string = file (logfile).read() - + progress (_ ("Running `%s' on file `%s' to detect default page settings.\n") + % (global_options.latex_program, tmpfile)); + cmd = '%s %s' % (global_options.latex_program, tmpfile); + proc = subprocess.Popen (cmd, + universal_newlines=True, shell=True, + stdout=subprocess.PIPE, stderr=subprocess.PIPE); + if proc.returncode != 0: + warning (_ ("Unable to auto-detect default page settings:\n%s") + % proc.communicate ()[1]); os.unlink (tmpfile) - os.unlink (logfile) + parameter_string = "" + if os.path.exists (logfile): + parameter_string = file (logfile).read() + os.unlink (logfile) columns = 0 m = re.search ('columns=([0-9.]+)', parameter_string)