mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#393: Fix the usage of Unicode characters in mathematic formulas when using the `pngmath
` extension.
This commit is contained in:
parent
0d4bc53e9e
commit
c41f516dda
3
CHANGES
3
CHANGES
@ -1,6 +1,9 @@
|
||||
Release 0.6.6 (in development)
|
||||
==============================
|
||||
|
||||
* #393: Fix the usage of Unicode characters in mathematic formulas
|
||||
when using the ``pngmath`` extension.
|
||||
|
||||
* #404: Make ``\and`` work properly in the author field of the
|
||||
``latex_documents`` setting.
|
||||
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user