diff options
-rw-r--r-- | HISTORY.txt | 1 | ||||
-rw-r--r-- | docutils/writers/latex2e/__init__.py | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/HISTORY.txt b/HISTORY.txt index c1c0178d6..111ff38cf 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -109,6 +109,7 @@ Changes Since 0.4 * docutils/writers/latex2e/__init__.py: + - Put ensuremath around some latin1 chars. - Set ``usepackage[utf8x]{inputenc}`` for utf-8. - New option ``--use-bibtex=style,db1,db2``. - New option ``--reference-label`` to allow usage of LaTeX ref for diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py index e643d77c6..7f7ef3570 100644 --- a/docutils/writers/latex2e/__init__.py +++ b/docutils/writers/latex2e/__init__.py @@ -823,6 +823,17 @@ class LaTeXTranslator(nodes.NodeVisitor): text = text.replace(uchar,self.latex_equivalents[uchar]) return text + def ensure_math(self, text): + if not self.__dict__.has_key('ensure_math_re'): + chars = { + # lnot,pm,twosuperior,threesuperior,mu,onesuperior,times,div + 'latin1' : '\xac\xb1\xb2\xb3\xb5\xb9\xd7\xf7' , + # also latin5 and latin9 + } + self.ensure_math_re = re.compile('([%s])' % chars['latin1']) + text = self.ensure_math_re.sub(r'\\ensuremath{\1}', text) + return text + def encode(self, text): """ Encode special characters (``# $ % & ~ _ ^ \ { }``) in `text` & return @@ -910,6 +921,7 @@ class LaTeXTranslator(nodes.NodeVisitor): text = text.replace(' ', '~') if self.latex_encoding != 'utf8': text = self.unicode_to_latex(text) + text = self.ensure_math(text) return text def attval(self, text, |