PhilipTrauner / pygments-github-css

GitHub syntax highlighter color scheme for Pygments.
MIT License
11 stars 3 forks source link

Update to new Github style? #1

Open fladd opened 4 years ago

fladd commented 4 years ago

Hi there,

great Pygments style! I was wondering whether you have plans to update it reflect the current Github style?

image

PhilipTrauner commented 4 years ago

I was pretty surprised to hear that they've reworked the token style, as I've never noticed any changes. After comparing Markdown and how its rendered by different GitHub features I now know why: They don't seem to apply the new style everywhere.

Here's a quick comparison:

Unmodified pygmentsUnmodified pygments
Modified pygmentsModified pygments
GitHub Markdown PreviewGitHub Markdown Preview
GitHub GistGitHub Gist

Unmodified pygments still closely (within the constraints pointed out in the README.md) matches GitHub Markdown Preview.

GitHub Gist is definitely different though, so I've tried to replicate it by making the following changes which are illustrated by Modified pygments.

diff --git a/dist/style/github.css b/dist/style/github.css
index 3af9410..359bd0f 100644
--- a/dist/style/github.css
+++ b/dist/style/github.css
@@ -1,5 +1,5 @@
 .highlight .hll { background-color: #ffffcc }
-.highlight  { background: #f8f8f8; }
+.highlight  { background: #f6f8fa; }
 .highlight .c { color: #6a737d } /* Comment */
 .highlight .err {  } /* Error */
 .highlight .k { color: #d73a49 } /* Keyword */
@@ -29,12 +29,12 @@
 .highlight .m { color: #666666 } /* Literal.Number */
 .highlight .s { color: #032f62 } /* Literal.String */
 .highlight .na { } /* Name.Attribute */
-.highlight .nb { color: #005cc5 } /* Name.Builtin */
-.highlight .nc { color: #6f42c1 } /* Name.Class */
+.highlight .nb { color: #6f42c1 } /* Name.Builtin */
+.highlight .nc { color: #e36209 } /* Name.Class */
 .highlight .no { color: #005cc5 } /* Name.Constant */
 .highlight .nd { color: #6f42c1 } /* Name.Decorator */
 .highlight .ni { color: #005cc5 } /* Name.Entity */
-.highlight .ne { color: #005cc5 } /* Name.Exception */
+.highlight .ne { color: #e36209 } /* Name.Exception */
 .highlight .nf { color: #6f42c1 } /* Name.Function */
 .highlight .nl { color: #005cc5 } /* Name.Label */
 .highlight .nn { color: #6f42c1 } /* Name.Namespace */

I'm not opposed to pushing these to master, so please me know if you are satisfied with the result 🙂

fladd commented 4 years ago

Looks good.

Some more observations:

  1. Shouldn't things like "is" and "not" in Python be blue, rather than orange.

  2. I also spotted some other differences in other languages (HTML, Ruby, C++). Not sure if they were related to changes at GitHub or due to limitations of Pygments.

    Have a look at those examples here: https://gist.github.com/fladd/3280e197f0b9d6958c25b121e7ac3390

  3. You could also consider switching on operators. Since they are blue now, the additional colouring of dots by Pygments is barely seen and not too distracting.

fladd commented 3 years ago

Any news on this?

PhilipTrauner commented 3 years ago

Don't have time to perform these changes right now, but would still be open to merging this in if you put together a PR. (please update the "Compromises" table as well) 🙂