summaryrefslogtreecommitdiff
path: root/sphinx/ext/pngmath.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2015-03-08 17:03:00 +0100
committerGeorg Brandl <georg@python.org>2015-03-08 17:03:00 +0100
commitb5c2279e05b3f18b660b29c8bd0989fbb8a1582a (patch)
treebf4f1390758c6e807e7d816fe1f869a6ce7b7ea2 /sphinx/ext/pngmath.py
parentba9dcaac5120f58c3cc0bc455b4beceab3a4abd9 (diff)
downloadsphinx-git-b5c2279e05b3f18b660b29c8bd0989fbb8a1582a.tar.gz
ext: pep8 fixes
Diffstat (limited to 'sphinx/ext/pngmath.py')
-rw-r--r--sphinx/ext/pngmath.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py
index 374b7ab32..b0d3fafbb 100644
--- a/sphinx/ext/pngmath.py
+++ b/sphinx/ext/pngmath.py
@@ -28,6 +28,7 @@ from sphinx.util.osutil import ensuredir, ENOENT, cd
from sphinx.util.pycompat import sys_encoding
from sphinx.ext.mathbase import setup_math as mathbase_setup, wrap_displaymath
+
class MathExtError(SphinxError):
category = 'Math extension error'
@@ -67,6 +68,7 @@ DOC_BODY_PREVIEW = r'''
depth_re = re.compile(br'\[\d+ depth=(-?\d+)\]')
+
def render_math(self, math):
"""Render the LaTeX math expression *math* using latex and dvipng.
@@ -166,6 +168,7 @@ def render_math(self, math):
return relfn, depth
+
def cleanup_tempdir(app, exc):
if exc:
return
@@ -176,11 +179,13 @@ def cleanup_tempdir(app, exc):
except Exception:
pass
+
def get_tooltip(self, node):
if self.builder.config.pngmath_add_tooltips:
return ' alt="%s"' % self.encode(node['latex']).strip()
return ''
+
def html_visit_math(self, node):
try:
fname, depth = render_math(self, '$'+node['latex']+'$')
@@ -202,6 +207,7 @@ def html_visit_math(self, node):
self.body.append(c + '/>')
raise nodes.SkipNode
+
def html_visit_displaymath(self, node):
if node['nowrap']:
latex = node['latex']
@@ -224,8 +230,8 @@ def html_visit_displaymath(self, node):
self.body.append('<span class="math">%s</span></p>\n</div>' %
self.encode(node['latex']).strip())
else:
- self.body.append(('<img src="%s"' % fname) + get_tooltip(self, node)
- + '/></p>\n</div>')
+ self.body.append(('<img src="%s"' % fname) + get_tooltip(self, node) +
+ '/></p>\n</div>')
raise nodes.SkipNode