Repository: ipython/ipython

Issue:
Prompt hard to read because it uses hardcoded colors
I find some colors are hard to read, especially the red used for the output when using a dark background. The [contrast ratio is only 2.35](https://contrast-ratio.com/#%23990000-on-black) which is too low according to [WCAG21](https://www.w3.org/TR/WCAG21/#contrast-minimum).

![barely readable red output ptompt on black background](https://user-images.githubusercontent.com/202576/87507527-d4137000-c66d-11ea-8293-8e3b2b6f406c.png)

A similar issue was discussed a while ago in #9670. However, I feel like a crucial aspect was missed: It is impossible to guarantee sufficient contrast if you hardcode colors and don't know the background. So IMHO the better fix would be to not hardcode any colors and use ANSI colors instead.


Discussion:

Resolving patch:
diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py
--- a/IPython/terminal/interactiveshell.py
+++ b/IPython/terminal/interactiveshell.py
@@ -48,17 +48,17 @@ class _NoStyle(Style): pass
 
 
 _style_overrides_light_bg = {
-            Token.Prompt: '#0000ff',
-            Token.PromptNum: '#0000ee bold',
-            Token.OutPrompt: '#cc0000',
-            Token.OutPromptNum: '#bb0000 bold',
+            Token.Prompt: '#ansibrightblue',
+            Token.PromptNum: '#ansiblue bold',
+            Token.OutPrompt: '#ansibrightred',
+            Token.OutPromptNum: '#ansired bold',
 }
 
 _style_overrides_linux = {
-            Token.Prompt: '#00cc00',
-            Token.PromptNum: '#00bb00 bold',
-            Token.OutPrompt: '#cc0000',
-            Token.OutPromptNum: '#bb0000 bold',
+            Token.Prompt: '#ansibrightgreen',
+            Token.PromptNum: '#ansigreen bold',
+            Token.OutPrompt: '#ansibrightred',
+            Token.OutPromptNum: '#ansired bold',
 }
 
 def get_default_editor():
@@ -350,16 +350,16 @@ def _make_style_from_name_or_cls(self, name_or_cls):
                 # looks like. These tweaks to the default theme help with that.
                 style_cls = get_style_by_name('default')
                 style_overrides.update({
-                    Token.Number: '#007700',
+                    Token.Number: '#ansigreen',
                     Token.Operator: 'noinherit',
-                    Token.String: '#BB6622',
-                    Token.Name.Function: '#2080D0',
-                    Token.Name.Class: 'bold #2080D0',
-                    Token.Name.Namespace: 'bold #2080D0',
+                    Token.String: '#ansiyellow',
+                    Token.Name.Function: '#ansiblue',
+                    Token.Name.Class: 'bold #ansiblue',
+                    Token.Name.Namespace: 'bold #ansiblue',
                     Token.Name.Variable.Magic: '#ansiblue',
-                    Token.Prompt: '#009900',
+                    Token.Prompt: '#ansigreen',
                     Token.PromptNum: '#ansibrightgreen bold',
-                    Token.OutPrompt: '#990000',
+                    Token.OutPrompt: '#ansired',
                     Token.OutPromptNum: '#ansibrightred bold',
                 })
 
@@ -383,9 +383,9 @@ def _make_style_from_name_or_cls(self, name_or_cls):
             else:
                 style_cls = name_or_cls
             style_overrides = {
-                Token.Prompt: '#009900',
+                Token.Prompt: '#ansigreen',
                 Token.PromptNum: '#ansibrightgreen bold',
-                Token.OutPrompt: '#990000',
+                Token.OutPrompt: '#ansired',
                 Token.OutPromptNum: '#ansibrightred bold',
             }
         style_overrides.update(self.highlighting_style_overrides)


Test patch: