summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2016-02-02 13:52:04 +0100
committerGeorg Brandl <georg@python.org>2016-02-02 13:52:04 +0100
commit9b8a2ef3d351ddd22e0564598d7e5eee2f78296d (patch)
tree73e816b83eef45a890a2347e21a38d03d4afd32c
parent3c6eb0e8258c7d90aa08800da9f60441d7dcb485 (diff)
downloadpygments-git-9b8a2ef3d351ddd22e0564598d7e5eee2f78296d.tar.gz
Added a mapping table for LaTeX encodings and added utf8 (closes #1152)
-rw-r--r--CHANGES1
-rw-r--r--pygments/formatters/latex.py9
2 files changed, 9 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 65baaa37..698868ca 100644
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,7 @@ Version 2.1.1
- Fixed Jython compatibility (#1205)
- Fixed HTML formatter output with leading empty lines (#1111)
+- Added a mapping table for LaTeX encodings and added utf8 (#1152)
- Fixed image formatter font searching on Macs (#1188)
- Fixed deepcopy-ing of Token instances (#1168)
- Fixed Julia string interpolation (#1170)
diff --git a/pygments/formatters/latex.py b/pygments/formatters/latex.py
index 15e68e37..66d521f5 100644
--- a/pygments/formatters/latex.py
+++ b/pygments/formatters/latex.py
@@ -413,11 +413,18 @@ class LatexFormatter(Formatter):
outfile.write(u'\\end{' + self.envname + u'}\n')
if self.full:
+ encoding = self.encoding or 'utf8'
+ # map known existings encodings from LaTeX distribution
+ encoding = {
+ 'utf_8': 'utf8',
+ 'latin_1': 'latin1',
+ 'iso_8859_1': 'latin1',
+ }.get(encoding.replace('-', '_'), encoding)
realoutfile.write(DOC_TEMPLATE %
dict(docclass = self.docclass,
preamble = self.preamble,
title = self.title,
- encoding = self.encoding or 'utf8',
+ encoding = encoding,
styledefs = self.get_style_defs(),
code = outfile.getvalue()))