diff options
-rw-r--r-- | docs/src/formatters.txt | 5 | ||||
-rw-r--r-- | pygments/formatters/rtf.py | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/docs/src/formatters.txt b/docs/src/formatters.txt index b4d8dc65..4eb64e7d 100644 --- a/docs/src/formatters.txt +++ b/docs/src/formatters.txt @@ -24,6 +24,11 @@ All formatters support this option: If this is ``""`` or ``None``, Unicode strings will be written to the output file, which most file-like objects do not support. + For example, `pygments.highlight()` will return a Unicode string if + called with no `outfile` argument and a formatter that has `encoding` + set to ``None`` because it uses a `StringIO.StringIO` object that + supports Unicode arguments to `write()`. Using a regular file object + wouldn't work. The `HtmlFormatter` and `LatexFormatter` classes support these options: diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py index 1aa0b9b8..16a69ae2 100644 --- a/pygments/formatters/rtf.py +++ b/pygments/formatters/rtf.py @@ -69,9 +69,6 @@ class RtfFormatter(Formatter): return text.replace('\n', '\\par\n') def format(self, tokensource, outfile): - if not self.encoding: - outfile.write(u'') - outfile.write(r'{\rtf1\ansi\deff0' r'{\fonttbl{\f0\fmodern\fprq1\fcharset0%s;}}{\colortbl;' % (self.fontface and ' ' + self._escape(self.fontface) or '')) |