Repository: xonsh/xonsh

Issue:
Output syntax highlighting fails with pygments 2.4.0
This should not happen

## xonfig

<details>
```
$ xonfig
+------------------+---------------------+
| xonsh            | 0.9.0               |
| Git SHA          | 3edd2df7            |
| Commit Date      | May 9 07:50:20 2019 |
| Python           | 3.6.8               |
| PLY              | 3.11                |
| have readline    | True                |
| prompt toolkit   | 2.0.9               |
| shell type       | readline            |
| pygments         | 2.4.0               |
| on posix         | True                |
| on linux         | True                |
| distro           | ubuntu              |
| on darwin        | False               |
| on windows       | False               |
| on cygwin        | False               |
| on msys2         | False               |
| is superuser     | False               |
| default encoding | utf-8               |
| xonsh encoding   | utf-8               |
| encoding errors  | surrogateescape     |
+------------------+---------------------+
```
</details>

## Expected Behavior
<!--- Tell us what should happen -->

## Current Behavior
<!--- Tell us what happens instead of the expected behavior -->
<!--- If part of your bug report is a traceback, please first enter debug mode before triggering the error
To enter debug mode, set the environment variable `XONSH_DEBUG=1` _before_ starting `xonsh`.  
On Linux and OSX, an easy way to to do this is to run `env XONSH_DEBUG=1 xonsh` -->

### Traceback (if applicable)

<details>
```
scopatz@artemis ~ $ 355 * 0.8
Traceback (most recent call last):
  File "/home/scopatz/.local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 17551, in default
    run_compiled_code(code, self.ctx, None, "single")
  File "/home/scopatz/.local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 2943, in run_compiled_code
    func(code, glb, loc)
  File "<xonsh-code>", line 1, in <module>
  File "/home/scopatz/.local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 23824, in _pprint_displayhook
    print_color(tokens, end=end)
  File "/home/scopatz/.local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 6126, in print_color
    builtins.__xonsh__.shell.shell.print_color(string, **kwargs)
  File "/home/scopatz/.local/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 20250, in print_color
    style_proxy = pyghooks.xonsh_style_proxy(self.styler)
  File "/home/scopatz/.local/lib/python3.6/site-packages/xonsh/pyghooks.py", line 553, in xonsh_style_proxy
    class XonshStyleProxy(Style):
  File "/home/scopatz/miniconda/lib/python3.6/site-packages/pygments/style.py", line 112, in __new__
    ndef[4] = colorformat(styledef[3:])
  File "/home/scopatz/miniconda/lib/python3.6/site-packages/pygments/style.py", line 79, in colorformat
    assert False, "wrong color format %r" % text
AssertionError: wrong color format '#ansilightgray'
```
</details>

## Steps to Reproduce
<!--- Please try to write out a minimal reproducible snippet to trigger the bug, it will help us fix it! -->



Discussion:

Resolving patch:
diff --git a/xonsh/pyghooks.py b/xonsh/pyghooks.py
--- a/xonsh/pyghooks.py
+++ b/xonsh/pyghooks.py
@@ -516,7 +516,11 @@ def style_name(self, value):
         self._style_name = value
         # Convert new ansicolor names to old PTK1 names
         # Can be remvoed when PTK1 support is dropped.
-        if builtins.__xonsh__.shell.shell_type != "prompt_toolkit2":
+        if (
+            builtins.__xonsh__.shell.shell_type != "prompt_toolkit2"
+            and pygments_version_info()
+            and pygments_version_info() < (2, 4, 0)
+        ):
             for smap in [self.trap, cmap, PTK_STYLE, self._smap]:
                 smap.update(ansicolors_to_ptk1_names(smap))
         if ON_WINDOWS and "prompt_toolkit" in builtins.__xonsh__.shell.shell_type:
@@ -548,7 +552,8 @@ def xonsh_style_proxy(styler):
     # Monky patch pygments' list of known ansi colors
     # with the new ansi color names used by PTK2
     # Can be removed once pygment names get fixed.
-    pygments.style.ansicolors.update(ANSICOLOR_NAMES_MAP)
+    if pygments_version_info() and pygments_version_info() < (2, 4, 0):
+        pygments.style.ansicolors.update(ANSICOLOR_NAMES_MAP)
 
     class XonshStyleProxy(Style):
         """Simple proxy class to fool prompt toolkit."""
@@ -1314,6 +1319,9 @@ def _monkey_patch_pygments_codes():
     """ Monky patch pygments' dict of console codes,
         with new color names
     """
+    if pygments_version_info() and pygments_version_info() >= (2, 4, 0):
+        return
+
     import pygments.console
 
     if "brightblack" in pygments.console.codes:
diff --git a/xonsh/tools.py b/xonsh/tools.py
--- a/xonsh/tools.py
+++ b/xonsh/tools.py
@@ -51,6 +51,7 @@
     PYTHON_VERSION_INFO,
     expanduser,
     os_environ,
+    pygments_version_info,
 )
 
 
@@ -1894,6 +1895,8 @@ def hardcode_colors_for_win10(style_map):
 def ansicolors_to_ptk1_names(stylemap):
     """Converts ansicolor names in a stylemap to old PTK1 color names
     """
+    if pygments_version_info() and pygments_version_info() >= (2, 4, 0):
+        return stylemap
     modified_stylemap = {}
     for token, style_str in stylemap.items():
         for color, ptk1_color in ANSICOLOR_NAMES_MAP.items():


Test patch: