summaryrefslogtreecommitdiff
path: root/pygments/formatters
diff options
context:
space:
mode:
authorMatthias Bussonnier <bussonniermatthias@gmail.com>2015-12-18 18:52:00 +0100
committerMatthias Bussonnier <bussonniermatthias@gmail.com>2015-12-18 18:52:00 +0100
commit87b90dc3dacf1a5f668fe404fd2d62a23ecf9358 (patch)
treef1b87c0fce1ccf21d8d7a917161eae025086a9c0 /pygments/formatters
parent2b910cf6b576321b1261379ca2be2d2f19d88ae1 (diff)
parent0121547da1fb4a8719bb2faec1b1501e5066eaf9 (diff)
downloadpygments-87b90dc3dacf1a5f668fe404fd2d62a23ecf9358.tar.gz
merge with origin
Diffstat (limited to 'pygments/formatters')
-rw-r--r--pygments/formatters/terminal256.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/pygments/formatters/terminal256.py b/pygments/formatters/terminal256.py
index af311955..9055b10b 100644
--- a/pygments/formatters/terminal256.py
+++ b/pygments/formatters/terminal256.py
@@ -27,6 +27,8 @@
import sys
from pygments.formatter import Formatter
+from pygments.console import codes
+from pygments.style import ansilist
__all__ = ['Terminal256Formatter', 'TerminalTrueColorFormatter']
@@ -47,7 +49,10 @@ class EscapeSequence:
def color_string(self):
attrs = []
if self.fg is not None:
- attrs.extend(("38", "5", "%i" % self.fg))
+ if self.fg in ansilist:
+ attrs.append(codes[self.fg[5:]][2:-1])
+ else :
+ attrs.extend(("38", "5", "%i" % self.fg))
if self.bg is not None:
attrs.extend(("48", "5", "%i" % self.bg))
if self.bold:
@@ -169,6 +174,10 @@ class Terminal256Formatter(Formatter):
def _color_index(self, color):
index = self.best_match.get(color, None)
+ if color in ansilist:
+ # strip the `#ansi` part an look up code
+ index = color
+ self.best_match[color] = index
if index is None:
try:
rgb = int(str(color), 16)