summaryrefslogtreecommitdiff
path: root/pygments/formatters
diff options
context:
space:
mode:
authorMatthäus G. Chajdas <dev@anteru.net>2020-09-08 20:33:25 +0200
committerMatthäus G. Chajdas <dev@anteru.net>2020-09-08 20:33:25 +0200
commit203ef1eff6daebab6f95b0b49e6e6a58168073fb (patch)
tree7defa199f48a34787f980b6400d8bbaa9380039a /pygments/formatters
parente09d4e0cf23d7c6069ddc690942ceb4cd23fd556 (diff)
parentb2c91c70ee536b0472100d1273818f8bb45529fe (diff)
downloadpygments-git-bug/angular-html.tar.gz
Merge branch 'master' into bug/angular-htmlbug/angular-html
# Conflicts: # tests/test_shell.py
Diffstat (limited to 'pygments/formatters')
-rw-r--r--pygments/formatters/html.py12
-rw-r--r--pygments/formatters/latex.py18
-rw-r--r--pygments/formatters/other.py8
-rw-r--r--pygments/formatters/rtf.py52
4 files changed, 45 insertions, 45 deletions
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py
index 421710f7..29cc9fb8 100644
--- a/pygments/formatters/html.py
+++ b/pygments/formatters/html.py
@@ -27,11 +27,11 @@ __all__ = ['HtmlFormatter']
_escape_html_table = {
- ord('&'): u'&amp;',
- ord('<'): u'&lt;',
- ord('>'): u'&gt;',
- ord('"'): u'&quot;',
- ord("'"): u'&#39;',
+ ord('&'): '&amp;',
+ ord('<'): '&lt;',
+ ord('>'): '&gt;',
+ ord('"'): '&quot;',
+ ord("'"): '&#39;',
}
@@ -433,7 +433,7 @@ class HtmlFormatter(Formatter):
self.linenostep = abs(get_int_opt(options, 'linenostep', 1))
self.linenospecial = abs(get_int_opt(options, 'linenospecial', 0))
self.nobackground = get_bool_opt(options, 'nobackground', False)
- self.lineseparator = options.get('lineseparator', u'\n')
+ self.lineseparator = options.get('lineseparator', '\n')
self.lineanchors = options.get('lineanchors', '')
self.linespans = options.get('linespans', '')
self.anchorlinenos = get_bool_opt(options, 'anchorlinenos', False)
diff --git a/pygments/formatters/latex.py b/pygments/formatters/latex.py
index 9e23740d..a0e9421b 100644
--- a/pygments/formatters/latex.py
+++ b/pygments/formatters/latex.py
@@ -265,7 +265,7 @@ class LatexFormatter(Formatter):
self.right = self.escapeinside[1]
else:
self.escapeinside = ''
- self.envname = options.get('envname', u'Verbatim')
+ self.envname = options.get('envname', 'Verbatim')
self._create_stylesheet()
@@ -336,17 +336,17 @@ class LatexFormatter(Formatter):
realoutfile = outfile
outfile = StringIO()
- outfile.write(u'\\begin{' + self.envname + u'}[commandchars=\\\\\\{\\}')
+ outfile.write('\\begin{' + self.envname + '}[commandchars=\\\\\\{\\}')
if self.linenos:
start, step = self.linenostart, self.linenostep
- outfile.write(u',numbers=left' +
- (start and u',firstnumber=%d' % start or u'') +
- (step and u',stepnumber=%d' % step or u''))
+ outfile.write(',numbers=left' +
+ (start and ',firstnumber=%d' % start or '') +
+ (step and ',stepnumber=%d' % step or ''))
if self.mathescape or self.texcomments or self.escapeinside:
- outfile.write(u',codes={\\catcode`\\$=3\\catcode`\\^=7\\catcode`\\_=8}')
+ outfile.write(',codes={\\catcode`\\$=3\\catcode`\\^=7\\catcode`\\_=8}')
if self.verboptions:
- outfile.write(u',' + self.verboptions)
- outfile.write(u']\n')
+ outfile.write(',' + self.verboptions)
+ outfile.write(']\n')
for ttype, value in tokensource:
if ttype in Token.Comment:
@@ -409,7 +409,7 @@ class LatexFormatter(Formatter):
else:
outfile.write(value)
- outfile.write(u'\\end{' + self.envname + u'}\n')
+ outfile.write('\\end{' + self.envname + '}\n')
if self.full:
encoding = self.encoding or 'utf8'
diff --git a/pygments/formatters/other.py b/pygments/formatters/other.py
index 9f8bab4b..a86e81e0 100644
--- a/pygments/formatters/other.py
+++ b/pygments/formatters/other.py
@@ -119,12 +119,12 @@ class RawTokenFormatter(Formatter):
flush()
-TESTCASE_BEFORE = u'''\
+TESTCASE_BEFORE = '''\
def testNeedsName(lexer):
fragment = %r
tokens = [
'''
-TESTCASE_AFTER = u'''\
+TESTCASE_AFTER = '''\
]
assert list(lexer.get_tokens(fragment)) == tokens
'''
@@ -152,8 +152,8 @@ class TestcaseFormatter(Formatter):
rawbuf.append(value)
outbuf.append('%s(%s, %r),\n' % (indentation, ttype, value))
- before = TESTCASE_BEFORE % (u''.join(rawbuf),)
- during = u''.join(outbuf)
+ before = TESTCASE_BEFORE % (''.join(rawbuf),)
+ during = ''.join(outbuf)
after = TESTCASE_AFTER
if self.encoding is None:
outfile.write(before + during + after)
diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py
index 7f51bacd..34393d47 100644
--- a/pygments/formatters/rtf.py
+++ b/pygments/formatters/rtf.py
@@ -10,7 +10,7 @@
"""
from pygments.formatter import Formatter
-from pygments.util import get_int_opt, _surrogatepair
+from pygments.util import get_int_opt, surrogatepair
__all__ = ['RtfFormatter']
@@ -65,14 +65,14 @@ class RtfFormatter(Formatter):
self.fontsize = get_int_opt(options, 'fontsize', 0)
def _escape(self, text):
- return text.replace(u'\\', u'\\\\') \
- .replace(u'{', u'\\{') \
- .replace(u'}', u'\\}')
+ return text.replace('\\', '\\\\') \
+ .replace('{', '\\{') \
+ .replace('}', '\\}')
def _escape_text(self, text):
# empty strings, should give a small performance improvement
if not text:
- return u''
+ return ''
# escape text
text = self._escape(text)
@@ -85,21 +85,21 @@ class RtfFormatter(Formatter):
buf.append(str(c))
elif (2**7) <= cn < (2**16):
# single unicode escape sequence
- buf.append(u'{\\u%d}' % cn)
+ buf.append('{\\u%d}' % cn)
elif (2**16) <= cn:
# RTF limits unicode to 16 bits.
# Force surrogate pairs
- buf.append(u'{\\u%d}{\\u%d}' % _surrogatepair(cn))
+ buf.append('{\\u%d}{\\u%d}' % surrogatepair(cn))
- return u''.join(buf).replace(u'\n', u'\\par\n')
+ return ''.join(buf).replace('\n', '\\par\n')
def format_unencoded(self, tokensource, outfile):
# rtf 1.8 header
- outfile.write(u'{\\rtf1\\ansi\\uc0\\deff0'
- u'{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0%s;}}'
- u'{\\colortbl;' % (self.fontface and
- u' ' + self._escape(self.fontface) or
- u''))
+ outfile.write('{\\rtf1\\ansi\\uc0\\deff0'
+ '{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0%s;}}'
+ '{\\colortbl;' % (self.fontface and
+ ' ' + self._escape(self.fontface) or
+ ''))
# convert colors and save them in a mapping to access them later.
color_mapping = {}
@@ -108,15 +108,15 @@ class RtfFormatter(Formatter):
for color in style['color'], style['bgcolor'], style['border']:
if color and color not in color_mapping:
color_mapping[color] = offset
- outfile.write(u'\\red%d\\green%d\\blue%d;' % (
+ outfile.write('\\red%d\\green%d\\blue%d;' % (
int(color[0:2], 16),
int(color[2:4], 16),
int(color[4:6], 16)
))
offset += 1
- outfile.write(u'}\\f0 ')
+ outfile.write('}\\f0 ')
if self.fontsize:
- outfile.write(u'\\fs%d' % (self.fontsize))
+ outfile.write('\\fs%d' % self.fontsize)
# highlight stream
for ttype, value in tokensource:
@@ -125,23 +125,23 @@ class RtfFormatter(Formatter):
style = self.style.style_for_token(ttype)
buf = []
if style['bgcolor']:
- buf.append(u'\\cb%d' % color_mapping[style['bgcolor']])
+ buf.append('\\cb%d' % color_mapping[style['bgcolor']])
if style['color']:
- buf.append(u'\\cf%d' % color_mapping[style['color']])
+ buf.append('\\cf%d' % color_mapping[style['color']])
if style['bold']:
- buf.append(u'\\b')
+ buf.append('\\b')
if style['italic']:
- buf.append(u'\\i')
+ buf.append('\\i')
if style['underline']:
- buf.append(u'\\ul')
+ buf.append('\\ul')
if style['border']:
- buf.append(u'\\chbrdr\\chcfpat%d' %
+ buf.append('\\chbrdr\\chcfpat%d' %
color_mapping[style['border']])
- start = u''.join(buf)
+ start = ''.join(buf)
if start:
- outfile.write(u'{%s ' % start)
+ outfile.write('{%s ' % start)
outfile.write(self._escape_text(value))
if start:
- outfile.write(u'}')
+ outfile.write('}')
- outfile.write(u'}')
+ outfile.write('}')