~ubuntu-branches/ubuntu/raring/wxwidgets2.8/raring

« back to all changes in this revision

Viewing changes to wxPython/wx/tools/Editra/src/extern/pygments/formatters/rtf.py

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2012-01-07 13:59:25 UTC
  • mfrom: (1.1.9) (5.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20120107135925-2601miy9ullcon9j
Tags: 2.8.12.1-6ubuntu1
* Resync from Debian, changes that were kept:
  - debian/rules: re-enable mediactrl. This allows libwx_gtk2u_media-2.8 to be
    built, as this is required by some applications (LP: #632984)
  - debian/control: Build-dep on libxt-dev for mediactrl.
  - Patches
    + fix-bashism-in-example
* Add conflict on python-wxgtk2.8 (<< 2.8.12.1-6ubuntu1~) to python-wxversion
  to guarantee upgrade ordering when moving from pycentral to dh_python2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
    A formatter that generates RTF files.
7
7
 
8
 
    :copyright: 2006-2007 by Armin Ronacher.
9
 
    :license: BSD, see LICENSE for more details.
 
8
    :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS.
 
9
    :license: BSD, see LICENSE for details.
10
10
"""
11
11
 
12
12
from pygments.formatter import Formatter
52
52
        """
53
53
        Formatter.__init__(self, **options)
54
54
        self.fontface = options.get('fontface') or ''
55
 
        if self.encoding in ('utf-8', 'utf-16', 'utf-32'):
56
 
            self.encoding = None
57
55
 
58
56
    def _escape(self, text):
59
57
        return text.replace('\\', '\\\\') \
67
65
 
68
66
        # escape text
69
67
        text = self._escape(text)
70
 
        encoding = self.encoding or 'iso-8859-15'
 
68
        if self.encoding in ('utf-8', 'utf-16', 'utf-32'):
 
69
            encoding = 'iso-8859-15'
 
70
        else:
 
71
            encoding = self.encoding or 'iso-8859-15'
71
72
 
72
73
        buf = []
73
74
        for c in text:
75
76
                ansic = c.encode(encoding, 'ignore') or '?'
76
77
                if ord(ansic) > 128:
77
78
                    ansic = '\\\'%x' % ord(ansic)
 
79
                else:
 
80
                    ansic = c
78
81
                buf.append(r'\ud{\u%d%s}' % (ord(c), ansic))
79
82
            else:
80
83
                buf.append(str(c))
81
84
 
82
85
        return ''.join(buf).replace('\n', '\\par\n')
83
86
 
84
 
    def format(self, tokensource, outfile):
 
87
    def format_unencoded(self, tokensource, outfile):
85
88
        # rtf 1.8 header
86
89
        outfile.write(r'{\rtf1\ansi\deff0'
87
90
                      r'{\fonttbl{\f0\fmodern\fprq1\fcharset0%s;}}'