From 1dc46e65830ad0a36bc1501efe80d997b76d2c55 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 15 Dec 2008 19:24:34 +0100 Subject: [PATCH] * #72: In pngmath, make it possible to give a full path to LaTeX and dvipng on Windows. For that to work, the ``pngmath_latex`` and ``pngmath_dvipng`` options are no longer split into command and additional arguments; use ``pngmath_latex_args`` and ``pngmath_dvipng_args`` to give additional arguments. --- CHANGES | 6 ++++++ doc/ext/math.rst | 14 +++++++++++--- sphinx/ext/pngmath.py | 10 ++++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 8c47893f2..0a22fbacc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,12 @@ Release 0.5.1 (in development) ============================== +* #72: In pngmath, make it possible to give a full path to LaTeX and + dvipng on Windows. For that to work, the ``pngmath_latex`` and + ``pngmath_dvipng`` options are no longer split into command and + additional arguments; use ``pngmath_latex_args`` and + ``pngmath_dvipng_args`` to give additional arguments. + * Don't crash on failing doctests with non-ASCII characters. * Don't crash on writing status messages and warnings containing diff --git a/doc/ext/math.rst b/doc/ext/math.rst index 73cc5cab9..f2664dfe4 100644 --- a/doc/ext/math.rst +++ b/doc/ext/math.rst @@ -110,9 +110,6 @@ There are various config values you can set to influence how the images are buil may need to set this to a full path if ``latex`` not in the executable search path. - This string is split into words with :func:`shlex.split`, so that you can - include arguments as well if needed. - Since this setting is not portable from system to system, it is normally not useful to set it in ``conf.py``; rather, giving it on the :program:`sphinx-build` command line via the :option:`-D` option should be @@ -120,12 +117,23 @@ There are various config values you can set to influence how the images are buil sphinx-build -b html -D pngmath_latex=C:\tex\latex.exe . _build/html + .. versionchanged:: 0.5.1 + This value should only contain the path to the latex executable, not + further arguments; use :confval:`pngmath_latex_args` for that purpose. + .. confval:: pngmath_dvipng The command name with which to invoke ``dvipng``. The default is ``'dvipng'``; you may need to set this to a full path if ``dvipng`` is not in the executable search path. +.. confval:: pngmath_latex_args + + Additional arguments to give to latex, as a list. The default is an empty + list. + + .. versionadded:: 0.5.1 + .. confval:: pngmath_latex_preamble Additional LaTeX code to put into the preamble of the short LaTeX files that diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py index 02b6b8204..e3c812a1a 100644 --- a/sphinx/ext/pngmath.py +++ b/sphinx/ext/pngmath.py @@ -10,7 +10,6 @@ """ import re -import shlex import shutil import tempfile import posixpath @@ -103,8 +102,10 @@ def render_math(self, math): # build latex command; old versions of latex don't have the # --output-directory option, so we have to manually chdir to the # temp dir to run it. - ltx_args = shlex.split(self.builder.config.pngmath_latex) - ltx_args += ['--interaction=nonstopmode', 'math.tex'] + ltx_args = [self.builder.config.pngmath_latex, '--interaction=nonstopmode'] + # add custom args from the config file + ltx_args.extend(self.builder.config.pngmath_latex_args) + ltx_args.append('math.tex') curdir = getcwd() chdir(tempdir) @@ -131,7 +132,7 @@ def render_math(self, math): ensuredir(path.dirname(outfn)) # use some standard dvipng arguments - dvipng_args = shlex.split(self.builder.config.pngmath_dvipng) + dvipng_args = [self.builder.config.pngmath_dvipng] dvipng_args += ['-o', outfn, '-T', 'tight', '-z9'] # add custom ones from config value dvipng_args.extend(self.builder.config.pngmath_dvipng_args) @@ -218,5 +219,6 @@ def setup(app): app.add_config_value('pngmath_latex', 'latex', False) app.add_config_value('pngmath_use_preview', False, False) app.add_config_value('pngmath_dvipng_args', ['-gamma 1.5', '-D 110'], False) + app.add_config_value('pngmath_latex_args', [], False) app.add_config_value('pngmath_latex_preamble', '', False) app.connect('build-finished', cleanup_tempdir)