diff options
author | Georg Brandl <georg@python.org> | 2010-05-22 14:42:53 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-05-22 14:42:53 +0200 |
commit | 34d9cc8b7f7ebdc884fe16b9bf67adb22d44ef27 (patch) | |
tree | cbd033f3045a85ebacae285b8573b45511136b45 /sphinx/ext/pngmath.py | |
parent | 6bc1ce0527566b26b2fee166669dae8c6817d003 (diff) | |
parent | 8de55d5d979ba9a1493a3fa5b81fc5cc47c476cc (diff) | |
download | sphinx-git-34d9cc8b7f7ebdc884fe16b9bf67adb22d44ef27.tar.gz |
merge with 0.6
Diffstat (limited to 'sphinx/ext/pngmath.py')
-rw-r--r-- | sphinx/ext/pngmath.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py index 93fa301d8..7f3997543 100644 --- a/sphinx/ext/pngmath.py +++ b/sphinx/ext/pngmath.py @@ -10,6 +10,7 @@ """ import re +import codecs import shutil import tempfile import posixpath @@ -33,7 +34,7 @@ class MathExtError(SphinxError): DOC_HEAD = r''' \documentclass[12pt]{article} -\usepackage[utf8]{inputenc} +\usepackage[utf8x]{inputenc} \usepackage{amsmath} \usepackage{amsthm} \usepackage{amssymb} @@ -89,8 +90,6 @@ def render_math(self, math): latex = DOC_HEAD + self.builder.config.pngmath_latex_preamble latex += (use_preview and DOC_BODY_PREVIEW or DOC_BODY) % math - if isinstance(latex, unicode): - latex = latex.encode('utf-8') # 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 @@ -100,7 +99,7 @@ def render_math(self, math): else: tempdir = self.builder._mathpng_tempdir - tf = open(path.join(tempdir, 'math.tex'), 'w') + tf = codecs.open(path.join(tempdir, 'math.tex'), 'w', 'utf-8') tf.write(latex) tf.close() @@ -183,7 +182,8 @@ def html_visit_math(self, node): try: fname, depth = render_math(self, '$'+node['latex']+'$') except MathExtError, exc: - sm = nodes.system_message(str(exc), type='WARNING', level=2, + msg = unicode(str(exc), 'utf-8', 'replace') + sm = nodes.system_message(msg, type='WARNING', level=2, backrefs=[], source=node['latex']) sm.walkabout(self) self.builder.warn('display latex %r: ' % node['latex'] + str(exc)) |