[PATCH 16 of 17 v3] cli: front-end-create: generate pygments.css dynamically

Thomas De Schampheleire patrickdepinguin at gmail.com
Thu Oct 18 20:49:39 UTC 2018


# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
# Date 1537041136 -7200
#      Sat Sep 15 21:52:16 2018 +0200
# Node ID 74b778755efd7cc575dbb68c7fa9428c11c66748
# Parent  1cfd34ff0aa47e1ff21b91d683a1e6937c8d8417
cli: front-end-create: generate pygments.css dynamically

Rather than having pygments.css part of the Kallithea sources, generate it
on the fly via front-end-create

Idea comes from Dominik Ruf.

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -23,6 +23,7 @@ syntax: regexp
 ^\.pydevproject$
 ^\.coverage$
 ^kallithea/public/css/style\.css(\.map)?$
+^kallithea/public/css/pygments.css$
 ^theme\.less$
 ^kallithea\.db$
 ^test\.db$
diff --git a/kallithea/bin/kallithea_cli_front_end.py b/kallithea/bin/kallithea_cli_front_end.py
--- a/kallithea/bin/kallithea_cli_front_end.py
+++ b/kallithea/bin/kallithea_cli_front_end.py
@@ -48,3 +48,10 @@ def front_end_create(install_deps, gener
         csspath = os.path.join(rootdir, 'kallithea', 'public', 'css', 'style.css')
         subprocess.check_call([lesscpath, '--relative-urls', '--source-map',
                 '--source-map-less-inline', lesspath, csspath])
+        with open(os.path.join(rootdir, 'kallithea', 'public', 'css', 'pygments.css'), 'w') as f:
+            subprocess.check_call(['pygmentize',
+                    '-S', 'default',
+                    '-f', 'html',
+                    '-a', '.code-highlight'],
+                    stdout=f)
+
diff --git a/kallithea/public/css/pygments.css b/kallithea/public/css/pygments.css
deleted file mode 100644
--- a/kallithea/public/css/pygments.css
+++ /dev/null
@@ -1,69 +0,0 @@
-.code-highlight .hll { background-color: #ffffcc }
-.code-highlight  { background: #f8f8f8; }
-.code-highlight .c { color: #408080; font-style: italic } /* Comment */
-.code-highlight .err { border: 1px solid #FF0000 } /* Error */
-.code-highlight .k { color: #008000; font-weight: bold } /* Keyword */
-.code-highlight .o { color: #666666 } /* Operator */
-.code-highlight .ch { color: #408080; font-style: italic } /* Comment.Hashbang */
-.code-highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
-.code-highlight .cp { color: #BC7A00 } /* Comment.Preproc */
-.code-highlight .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
-.code-highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
-.code-highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
-.code-highlight .gd { color: #A00000 } /* Generic.Deleted */
-.code-highlight .ge { font-style: italic } /* Generic.Emph */
-.code-highlight .gr { color: #FF0000 } /* Generic.Error */
-.code-highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
-.code-highlight .gi { color: #00A000 } /* Generic.Inserted */
-.code-highlight .go { color: #888888 } /* Generic.Output */
-.code-highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
-.code-highlight .gs { font-weight: bold } /* Generic.Strong */
-.code-highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
-.code-highlight .gt { color: #0044DD } /* Generic.Traceback */
-.code-highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
-.code-highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
-.code-highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
-.code-highlight .kp { color: #008000 } /* Keyword.Pseudo */
-.code-highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
-.code-highlight .kt { color: #B00040 } /* Keyword.Type */
-.code-highlight .m { color: #666666 } /* Literal.Number */
-.code-highlight .s { color: #BA2121 } /* Literal.String */
-.code-highlight .na { color: #7D9029 } /* Name.Attribute */
-.code-highlight .nb { color: #008000 } /* Name.Builtin */
-.code-highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
-.code-highlight .no { color: #880000 } /* Name.Constant */
-.code-highlight .nd { color: #AA22FF } /* Name.Decorator */
-.code-highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
-.code-highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
-.code-highlight .nf { color: #0000FF } /* Name.Function */
-.code-highlight .nl { color: #A0A000 } /* Name.Label */
-.code-highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
-.code-highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
-.code-highlight .nv { color: #19177C } /* Name.Variable */
-.code-highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
-.code-highlight .w { color: #bbbbbb } /* Text.Whitespace */
-.code-highlight .mb { color: #666666 } /* Literal.Number.Bin */
-.code-highlight .mf { color: #666666 } /* Literal.Number.Float */
-.code-highlight .mh { color: #666666 } /* Literal.Number.Hex */
-.code-highlight .mi { color: #666666 } /* Literal.Number.Integer */
-.code-highlight .mo { color: #666666 } /* Literal.Number.Oct */
-.code-highlight .sa { color: #BA2121 } /* Literal.String.Affix */
-.code-highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
-.code-highlight .sc { color: #BA2121 } /* Literal.String.Char */
-.code-highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */
-.code-highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
-.code-highlight .s2 { color: #BA2121 } /* Literal.String.Double */
-.code-highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
-.code-highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
-.code-highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
-.code-highlight .sx { color: #008000 } /* Literal.String.Other */
-.code-highlight .sr { color: #BB6688 } /* Literal.String.Regex */
-.code-highlight .s1 { color: #BA2121 } /* Literal.String.Single */
-.code-highlight .ss { color: #19177C } /* Literal.String.Symbol */
-.code-highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
-.code-highlight .fm { color: #0000FF } /* Name.Function.Magic */
-.code-highlight .vc { color: #19177C } /* Name.Variable.Class */
-.code-highlight .vg { color: #19177C } /* Name.Variable.Global */
-.code-highlight .vi { color: #19177C } /* Name.Variable.Instance */
-.code-highlight .vm { color: #19177C } /* Name.Variable.Magic */
-.code-highlight .il { color: #666666 } /* Literal.Number.Integer.Long */


More information about the kallithea-general mailing list