summaryrefslogtreecommitdiff
path: root/sphinx/ext/pngmath.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-01-11 09:17:27 +0100
committerGeorg Brandl <georg@python.org>2014-01-11 09:17:27 +0100
commitfe0532a6e3207da5cf183b6356559997db6510d1 (patch)
tree484ceaa053dcce41a3460b5e72147fcde9c5fe54 /sphinx/ext/pngmath.py
parentcfecf17aedb81318c17240d8237b590455601df9 (diff)
downloadsphinx-git-fe0532a6e3207da5cf183b6356559997db6510d1.tar.gz
Closes #923: Take the entire LaTeX document into account when caching
pngmath-generated images. This rebuilds them correctly when ``pngmath_latex_preamble`` changes.
Diffstat (limited to 'sphinx/ext/pngmath.py')
-rw-r--r--sphinx/ext/pngmath.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py
index a9a2203ac..e23bbd06f 100644
--- a/sphinx/ext/pngmath.py
+++ b/sphinx/ext/pngmath.py
@@ -82,8 +82,10 @@ def render_math(self, math):
may not fail since that indicates a problem in the math source.
"""
use_preview = self.builder.config.pngmath_use_preview
+ latex = DOC_HEAD + self.builder.config.pngmath_latex_preamble
+ latex += (use_preview and DOC_BODY_PREVIEW or DOC_BODY) % math
- shasum = "%s.png" % sha(math.encode('utf-8')).hexdigest()
+ shasum = "%s.png" % sha(latex.encode('utf-8')).hexdigest()
relfn = posixpath.join(self.builder.imgpath, 'math', shasum)
outfn = path.join(self.builder.outdir, '_images', 'math', shasum)
if path.isfile(outfn):
@@ -95,9 +97,6 @@ def render_math(self, math):
hasattr(self.builder, '_mathpng_warned_dvipng'):
return None, None
- latex = DOC_HEAD + self.builder.config.pngmath_latex_preamble
- latex += (use_preview and DOC_BODY_PREVIEW or DOC_BODY) % math
-
# use only one tempdir per build -- the use of a directory is cleaner
# than using temporary files, since we can clean up everything at once
# just removing the whole directory (see cleanup_tempdir)