summaryrefslogtreecommitdiff
path: root/pygments/formatter.py
diff options
context:
space:
mode:
authorgbrandl <devnull@localhost>2009-03-31 10:26:55 -0500
committergbrandl <devnull@localhost>2009-03-31 10:26:55 -0500
commit7b95efab48d9ec79e995bf4d6db10fd049e3395a (patch)
tree48fc9b840dab83976a85af85d1c705dbaa051a0b /pygments/formatter.py
parentf12c878ed096137c91658a0f62f0070e08c2afea (diff)
downloadpygments-7b95efab48d9ec79e995bf4d6db10fd049e3395a.tar.gz
Port Pygments to Python 3.1.
Diffstat (limited to 'pygments/formatter.py')
-rw-r--r--pygments/formatter.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/pygments/formatter.py b/pygments/formatter.py
index a577a4e3..d6c75a01 100644
--- a/pygments/formatter.py
+++ b/pygments/formatter.py
@@ -9,6 +9,8 @@
:license: BSD, see LICENSE for details.
"""
+import codecs
+
from pygments.util import get_bool_opt
from pygments.styles import get_style_by_name
@@ -84,4 +86,7 @@ class Formatter(object):
Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``
tuples and write it into ``outfile``.
"""
- raise NotImplementedError()
+ if self.encoding:
+ # wrap the outfile in a StreamWriter
+ outfile = codecs.lookup(self.encoding)[3](outfile)
+ return self.format_unencoded(tokensource, outfile)