From 6ea59bad517948bd8b5fd82f4c621811ee5c6b88 Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Sun, 25 Sep 2022 21:18:13 +0100
Subject: [PATCH 07/10] css: Dark mode for Pygments' syntax highlight

This patch updates Pygments' syntax highlight CSS to support dark mode.
It uses two themes from Pygments: `default` for light (same as before),
and `native` for dark.
---
 static/syntax.css | 146 ++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 127 insertions(+), 19 deletions(-)

diff --git a/static/syntax.css b/static/syntax.css
index 097e4d2..f8f1919 100644
--- a/static/syntax.css
+++ b/static/syntax.css
@@ -1,30 +1,37 @@
 
 /* CSS for syntax highlighting.
- * Generated by pygments (what we use for syntax highlighting):
+ * Generated by pygments (what we use for syntax highlighting).
  *
- * $ pygmentize -S default -f html -a .source_code
+ * Light mode:  pygmentize -S default -f html -a .source_code
  */
 
+pre { line-height: 125%; }
+td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
 .source_code .hll { background-color: #ffffcc }
-.source_code  { background: #f8f8f8; }
-.source_code .c { color: #408080; font-style: italic } /* Comment */
+.source_code { background: #f8f8f8; }
+.source_code .c { color: #3D7B7B; font-style: italic } /* Comment */
 .source_code .err { border: 1px solid #FF0000 } /* Error */
 .source_code .k { color: #008000; font-weight: bold } /* Keyword */
 .source_code .o { color: #666666 } /* Operator */
-.source_code .cm { color: #408080; font-style: italic } /* Comment.Multiline */
-.source_code .cp { color: #BC7A00 } /* Comment.Preproc */
-.source_code .c1 { color: #408080; font-style: italic } /* Comment.Single */
-.source_code .cs { color: #408080; font-style: italic } /* Comment.Special */
+.source_code .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
+.source_code .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
+.source_code .cp { color: #9C6500 } /* Comment.Preproc */
+.source_code .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */
+.source_code .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */
+.source_code .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
 .source_code .gd { color: #A00000 } /* Generic.Deleted */
 .source_code .ge { font-style: italic } /* Generic.Emph */
-.source_code .gr { color: #FF0000 } /* Generic.Error */
+.source_code .gr { color: #E40000 } /* Generic.Error */
 .source_code .gh { color: #000080; font-weight: bold } /* Generic.Heading */
-.source_code .gi { color: #00A000 } /* Generic.Inserted */
-.source_code .go { color: #808080 } /* Generic.Output */
+.source_code .gi { color: #008400 } /* Generic.Inserted */
+.source_code .go { color: #717171 } /* Generic.Output */
 .source_code .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
 .source_code .gs { font-weight: bold } /* Generic.Strong */
 .source_code .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
-.source_code .gt { color: #0040D0 } /* Generic.Traceback */
+.source_code .gt { color: #0044DD } /* Generic.Traceback */
 .source_code .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
 .source_code .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
 .source_code .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
@@ -33,38 +40,139 @@
 .source_code .kt { color: #B00040 } /* Keyword.Type */
 .source_code .m { color: #666666 } /* Literal.Number */
 .source_code .s { color: #BA2121 } /* Literal.String */
-.source_code .na { color: #7D9029 } /* Name.Attribute */
+.source_code .na { color: #687822 } /* Name.Attribute */
 .source_code .nb { color: #008000 } /* Name.Builtin */
 .source_code .nc { color: #0000FF; font-weight: bold } /* Name.Class */
 .source_code .no { color: #880000 } /* Name.Constant */
 .source_code .nd { color: #AA22FF } /* Name.Decorator */
-.source_code .ni { color: #999999; font-weight: bold } /* Name.Entity */
-.source_code .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
+.source_code .ni { color: #717171; font-weight: bold } /* Name.Entity */
+.source_code .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
 .source_code .nf { color: #0000FF } /* Name.Function */
-.source_code .nl { color: #A0A000 } /* Name.Label */
+.source_code .nl { color: #767600 } /* Name.Label */
 .source_code .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
 .source_code .nt { color: #008000; font-weight: bold } /* Name.Tag */
 .source_code .nv { color: #19177C } /* Name.Variable */
 .source_code .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
 .source_code .w { color: #bbbbbb } /* Text.Whitespace */
+.source_code .mb { color: #666666 } /* Literal.Number.Bin */
 .source_code .mf { color: #666666 } /* Literal.Number.Float */
 .source_code .mh { color: #666666 } /* Literal.Number.Hex */
 .source_code .mi { color: #666666 } /* Literal.Number.Integer */
 .source_code .mo { color: #666666 } /* Literal.Number.Oct */
+.source_code .sa { color: #BA2121 } /* Literal.String.Affix */
 .source_code .sb { color: #BA2121 } /* Literal.String.Backtick */
 .source_code .sc { color: #BA2121 } /* Literal.String.Char */
+.source_code .dl { color: #BA2121 } /* Literal.String.Delimiter */
 .source_code .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
 .source_code .s2 { color: #BA2121 } /* Literal.String.Double */
-.source_code .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
+.source_code .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */
 .source_code .sh { color: #BA2121 } /* Literal.String.Heredoc */
-.source_code .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
+.source_code .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */
 .source_code .sx { color: #008000 } /* Literal.String.Other */
-.source_code .sr { color: #BB6688 } /* Literal.String.Regex */
+.source_code .sr { color: #A45A77 } /* Literal.String.Regex */
 .source_code .s1 { color: #BA2121 } /* Literal.String.Single */
 .source_code .ss { color: #19177C } /* Literal.String.Symbol */
 .source_code .bp { color: #008000 } /* Name.Builtin.Pseudo */
+.source_code .fm { color: #0000FF } /* Name.Function.Magic */
 .source_code .vc { color: #19177C } /* Name.Variable.Class */
 .source_code .vg { color: #19177C } /* Name.Variable.Global */
 .source_code .vi { color: #19177C } /* Name.Variable.Instance */
+.source_code .vm { color: #19177C } /* Name.Variable.Magic */
 .source_code .il { color: #666666 } /* Literal.Number.Integer.Long */
 
+/*
+ * Dark mode:  pygmentize -S native -f html -a .source_code
+ */
+
+@media (prefers-color-scheme: dark) {
+
+pre { line-height: 125%; }
+td.linenos .normal { color: #aaaaaa; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+span.linenos { color: #aaaaaa; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+.source_code .hll { background-color: #404040 }
+.source_code { background: #202020; color: #d0d0d0 }
+.source_code .c { color: #ababab; font-style: italic } /* Comment */
+.source_code .err { color: #a61717; background-color: #e3d2d2 } /* Error */
+.source_code .esc { color: #d0d0d0 } /* Escape */
+.source_code .g { color: #d0d0d0 } /* Generic */
+.source_code .k { color: #6ebf26; font-weight: bold } /* Keyword */
+.source_code .l { color: #d0d0d0 } /* Literal */
+.source_code .n { color: #d0d0d0 } /* Name */
+.source_code .o { color: #d0d0d0 } /* Operator */
+.source_code .x { color: #d0d0d0 } /* Other */
+.source_code .p { color: #d0d0d0 } /* Punctuation */
+.source_code .ch { color: #ababab; font-style: italic } /* Comment.Hashbang */
+.source_code .cm { color: #ababab; font-style: italic } /* Comment.Multiline */
+.source_code .cp { color: #cd2828; font-weight: bold } /* Comment.Preproc */
+.source_code .cpf { color: #ababab; font-style: italic } /* Comment.PreprocFile */
+.source_code .c1 { color: #ababab; font-style: italic } /* Comment.Single */
+.source_code .cs { color: #e50808; font-weight: bold; background-color: #520000 } /* Comment.Special */
+.source_code .gd { color: #d22323 } /* Generic.Deleted */
+.source_code .ge { color: #d0d0d0; font-style: italic } /* Generic.Emph */
+.source_code .gr { color: #d22323 } /* Generic.Error */
+.source_code .gh { color: #ffffff; font-weight: bold } /* Generic.Heading */
+.source_code .gi { color: #589819 } /* Generic.Inserted */
+.source_code .go { color: #cccccc } /* Generic.Output */
+.source_code .gp { color: #aaaaaa } /* Generic.Prompt */
+.source_code .gs { color: #d0d0d0; font-weight: bold } /* Generic.Strong */
+.source_code .gu { color: #ffffff; text-decoration: underline } /* Generic.Subheading */
+.source_code .gt { color: #d22323 } /* Generic.Traceback */
+.source_code .kc { color: #6ebf26; font-weight: bold } /* Keyword.Constant */
+.source_code .kd { color: #6ebf26; font-weight: bold } /* Keyword.Declaration */
+.source_code .kn { color: #6ebf26; font-weight: bold } /* Keyword.Namespace */
+.source_code .kp { color: #6ebf26 } /* Keyword.Pseudo */
+.source_code .kr { color: #6ebf26; font-weight: bold } /* Keyword.Reserved */
+.source_code .kt { color: #6ebf26; font-weight: bold } /* Keyword.Type */
+.source_code .ld { color: #d0d0d0 } /* Literal.Date */
+.source_code .m { color: #51b2fd } /* Literal.Number */
+.source_code .s { color: #ed9d13 } /* Literal.String */
+.source_code .na { color: #bbbbbb } /* Name.Attribute */
+.source_code .nb { color: #2fbccd } /* Name.Builtin */
+.source_code .nc { color: #71adff; text-decoration: underline } /* Name.Class */
+.source_code .no { color: #40ffff } /* Name.Constant */
+.source_code .nd { color: #ffa500 } /* Name.Decorator */
+.source_code .ni { color: #d0d0d0 } /* Name.Entity */
+.source_code .ne { color: #bbbbbb } /* Name.Exception */
+.source_code .nf { color: #71adff } /* Name.Function */
+.source_code .nl { color: #d0d0d0 } /* Name.Label */
+.source_code .nn { color: #71adff; text-decoration: underline } /* Name.Namespace */
+.source_code .nx { color: #d0d0d0 } /* Name.Other */
+.source_code .py { color: #d0d0d0 } /* Name.Property */
+.source_code .nt { color: #6ebf26; font-weight: bold } /* Name.Tag */
+.source_code .nv { color: #40ffff } /* Name.Variable */
+.source_code .ow { color: #6ebf26; font-weight: bold } /* Operator.Word */
+.source_code .w { color: #666666 } /* Text.Whitespace */
+.source_code .mb { color: #51b2fd } /* Literal.Number.Bin */
+.source_code .mf { color: #51b2fd } /* Literal.Number.Float */
+.source_code .mh { color: #51b2fd } /* Literal.Number.Hex */
+.source_code .mi { color: #51b2fd } /* Literal.Number.Integer */
+.source_code .mo { color: #51b2fd } /* Literal.Number.Oct */
+.source_code .sa { color: #ed9d13 } /* Literal.String.Affix */
+.source_code .sb { color: #ed9d13 } /* Literal.String.Backtick */
+.source_code .sc { color: #ed9d13 } /* Literal.String.Char */
+.source_code .dl { color: #ed9d13 } /* Literal.String.Delimiter */
+.source_code .sd { color: #ed9d13 } /* Literal.String.Doc */
+.source_code .s2 { color: #ed9d13 } /* Literal.String.Double */
+.source_code .se { color: #ed9d13 } /* Literal.String.Escape */
+.source_code .sh { color: #ed9d13 } /* Literal.String.Heredoc */
+.source_code .si { color: #ed9d13 } /* Literal.String.Interpol */
+.source_code .sx { color: #ffa500 } /* Literal.String.Other */
+.source_code .sr { color: #ed9d13 } /* Literal.String.Regex */
+.source_code .s1 { color: #ed9d13 } /* Literal.String.Single */
+.source_code .ss { color: #ed9d13 } /* Literal.String.Symbol */
+.source_code .bp { color: #2fbccd } /* Name.Builtin.Pseudo */
+.source_code .fm { color: #71adff } /* Name.Function.Magic */
+.source_code .vc { color: #40ffff } /* Name.Variable.Class */
+.source_code .vg { color: #40ffff } /* Name.Variable.Global */
+.source_code .vi { color: #40ffff } /* Name.Variable.Instance */
+.source_code .vm { color: #40ffff } /* Name.Variable.Magic */
+.source_code .il { color: #51b2fd } /* Literal.Number.Integer.Long */
+
+/* Dark mode - my overrides, because the defaults are too bright. */
+
+.source_code .gh { color: rgb(189, 193, 198); }
+.source_code .gu { color: rgb(189, 193, 198); }
+}
+
-- 
2.43.0

