diff options
Diffstat (limited to 'pygments/formatters')
-rw-r--r-- | pygments/formatters/img.py | 4 | ||||
-rw-r--r-- | pygments/formatters/rtf.py | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/pygments/formatters/img.py b/pygments/formatters/img.py index 4f9fb1b0..db5bee3b 100644 --- a/pygments/formatters/img.py +++ b/pygments/formatters/img.py @@ -295,6 +295,7 @@ class ImageFormatter(Formatter): raise PilNotAvailable( 'Python Imaging Library is required for this formatter') Formatter.__init__(self, **options) + self.encoding = 'latin1' # let pygments.format() do the right thing # Read the style self.styles = dict(self.style) if self.style.background_color is None: @@ -478,8 +479,7 @@ class ImageFormatter(Formatter): draw = ImageDraw.Draw(im) recth = im.size[-1] rectw = self.image_pad + self.line_number_width - self.line_number_pad - draw.rectangle([(0, 0), - (rectw, recth)], + draw.rectangle([(0, 0), (rectw, recth)], fill=self.line_number_bg) draw.line([(rectw, 0), (rectw, recth)], fill=self.line_number_fg) del draw diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py index cf65a927..de768ac1 100644 --- a/pygments/formatters/rtf.py +++ b/pygments/formatters/rtf.py @@ -9,6 +9,8 @@ :license: BSD, see LICENSE for details. """ +from __future__ import unicode_literals + from pygments.formatter import Formatter from pygments.util import get_int_opt, _surrogatepair @@ -48,8 +50,6 @@ class RtfFormatter(Formatter): aliases = ['rtf'] filenames = ['*.rtf'] - unicodeoutput = False - def __init__(self, **options): """ Additional options accepted: @@ -87,18 +87,18 @@ class RtfFormatter(Formatter): buf.append(str(c)) elif (2**7) <= cn < (2**16): # single unicode escape sequence - buf.append(r'{\u%d}' % cn) + buf.append('{\\u%d}' % cn) elif (2**16) <= cn: # RTF limits unicode to 16 bits. # Force surrogate pairs h,l = _surrogatepair(cn) - buf.append(r'{\u%d}{\u%d}' % (h,l)) + buf.append('{\\u%d}{\\u%d}' % (h,l)) return ''.join(buf).replace('\n', '\\par\n') def format_unencoded(self, tokensource, outfile): # rtf 1.8 header - outfile.write(r'{\rtf1\ansi\uc0\deff0' + outfile.write('{\\rtf1\\ansi\\uc0\\deff0' r'{\fonttbl{\f0\fmodern\fprq1\fcharset0%s;}}' r'{\colortbl;' % (self.fontface and ' ' + self._escape(self.fontface) or @@ -136,7 +136,7 @@ class RtfFormatter(Formatter): if style['italic']: buf.append(r'\i') if style['underline']: - buf.append(r'\ul') + buf.append('\\ul') if style['border']: buf.append(r'\chbrdr\chcfpat%d' % color_mapping[style['border']]) |