]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/book_latex.py
Doc-fr: nitpicks in LM
[lilypond.git] / python / book_latex.py
index 8097443f7f320f01c858e2cac7af597eb6f1de66..fcd539aeaa8219eeeb5e8d07e4860e632ae31bb9 100644 (file)
@@ -3,6 +3,7 @@
 import re
 import tempfile
 import os
+import subprocess
 import book_base as BookBase
 from book_snippets import *
 import lilylib as ly
@@ -133,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}
@@ -173,19 +174,31 @@ def get_latex_textwidth (source, global_options):
     latex_document = LATEX_INSPECTION_DOCUMENT % {'preamble': preamble}
 
     (handle, tmpfile) = tempfile.mkstemp('.tex')
-    logfile = os.path.splitext (tmpfile)[0] + '.log'
-    logfile = os.path.split (logfile)[1]
+    tmpfileroot = os.path.splitext (tmpfile)[0]
+    tmpfileroot = os.path.split (tmpfileroot)[1]
+    auxfile = tmpfileroot + '.aux'
+    logfile = tmpfileroot + '.log'
 
     tmp_handle = os.fdopen (handle,'w')
     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);
+    (parameter_string, error_string) = proc.communicate ()
+    if proc.returncode != 0:
+        warning (_ ("Unable to auto-detect default page settings:\n%s")
+                 % error_string);
     os.unlink (tmpfile)
-    os.unlink (logfile)
+    if os.path.exists (auxfile):
+        os.unlink (auxfile)
+    if os.path.exists (logfile):
+        parameter_string = file (logfile).read()
+        os.unlink (logfile)
 
     columns = 0
     m = re.search ('columns=([0-9.]+)', parameter_string)