Skip to content

Commit

Permalink
Add dark Pygments code theme
Browse files Browse the repository at this point in the history
  • Loading branch information
int-y1 authored and quantum5 committed Jan 8, 2023
1 parent 5886c24 commit 617a321
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 70 deletions.
1 change: 0 additions & 1 deletion dmoj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
SELENIUM_CUSTOM_CHROME_PATH = None
SELENIUM_CHROMEDRIVER_PATH = 'chromedriver'

PYGMENT_THEME = 'pygment-github.css'
INLINE_JQUERY = True
INLINE_FONTAWESOME = True
JQUERY_JS = '//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js'
Expand Down
2 changes: 1 addition & 1 deletion judge/management/commands/render_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def handle(self, *args, **options):
'math_engine': maker.math_engine,
}).replace('"//', '"https://').replace("'//", "'https://")
maker.title = problem_name
for file in ('style.css', 'pygment-github.css', 'mathjax_config.js'):
for file in ('style.css', 'mathjax_config.js'):
maker.load(file, os.path.join(settings.DMOJ_RESOURCES, file))
maker.make(debug=True)
if not maker.success:
Expand Down
1 change: 0 additions & 1 deletion judge/template_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def get_resource(request):
scheme = 'http'
return {
'STYLE_CSS': 'dark/style.css' if 'dark' in request.GET else 'style.css',
'PYGMENT_THEME': settings.PYGMENT_THEME,
'INLINE_JQUERY': settings.INLINE_JQUERY,
'INLINE_FONTAWESOME': settings.INLINE_FONTAWESOME,
'JQUERY_JS': settings.JQUERY_JS,
Expand Down
2 changes: 1 addition & 1 deletion judge/views/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def get(self, request, *args, **kwargs):
}).replace('"//', '"https://').replace("'//", "'https://")
maker.title = problem_name

assets = ['style.css', 'pygment-github.css']
assets = ['style.css']
if maker.math_engine == 'jax':
assets.append('mathjax_config.js')
for file in assets:
Expand Down
61 changes: 0 additions & 61 deletions resources/pygment-github.css

This file was deleted.

147 changes: 147 additions & 0 deletions resources/pygment-github.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
@import "vars";

code {
@if $is_light_theme {
.hll { background-color: #ffffcc }
.c { color: #999988; font-style: italic } /* Comment */
.err { color: #a61717; background-color: #e3d2d2 } /* Error */
.k { color: #000000; font-weight: bold } /* Keyword */
.o { color: #000000; font-weight: bold } /* Operator */
.cm { color: #999988; font-style: italic } /* Comment.Multiline */
.cp { color: #999999; font-weight: bold; font-style: italic } /* Comment.Preproc */
.c1 { color: #999988; font-style: italic } /* Comment.Single */
.cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.ge { color: #000000; font-style: italic } /* Generic.Emph */
.gr { color: #aa0000 } /* Generic.Error */
.gh { color: #999999 } /* Generic.Heading */
.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #555555 } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #aaaaaa } /* Generic.Subheading */
.gt { color: #aa0000 } /* Generic.Traceback */
.kc { color: #000000; font-weight: bold } /* Keyword.Constant */
.kd { color: #000000; font-weight: bold } /* Keyword.Declaration */
.kn { color: #000000; font-weight: bold } /* Keyword.Namespace */
.kp { color: #000000; font-weight: bold } /* Keyword.Pseudo */
.kr { color: #000000; font-weight: bold } /* Keyword.Reserved */
.kt { color: #445588; font-weight: bold } /* Keyword.Type */
.m { color: #009999 } /* Literal.Number */
.s { color: #d01040 } /* Literal.String */
.na { color: #008080 } /* Name.Attribute */
.nb { color: #0086B3 } /* Name.Builtin */
.nc { color: #445588; font-weight: bold } /* Name.Class */
.no { color: #008080 } /* Name.Constant */
.nd { color: #3c5d5d; font-weight: bold } /* Name.Decorator */
.ni { color: #800080 } /* Name.Entity */
.ne { color: #990000; font-weight: bold } /* Name.Exception */
.nf { color: #990000; font-weight: bold } /* Name.Function */
.nl { color: #990000; font-weight: bold } /* Name.Label */
.nn { color: #555555 } /* Name.Namespace */
.nt { color: #000080 } /* Name.Tag */
.nv { color: #008080 } /* Name.Variable */
.ow { color: #000000; font-weight: bold } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mf { color: #009999 } /* Literal.Number.Float */
.mh { color: #009999 } /* Literal.Number.Hex */
.mi { color: #009999 } /* Literal.Number.Integer */
.mo { color: #009999 } /* Literal.Number.Oct */
.sb { color: #d01040 } /* Literal.String.Backtick */
.sc { color: #d01040 } /* Literal.String.Char */
.sd { color: #d01040 } /* Literal.String.Doc */
.s2 { color: #d01040 } /* Literal.String.Double */
.se { color: #d01040 } /* Literal.String.Escape */
.sh { color: #d01040 } /* Literal.String.Heredoc */
.si { color: #d01040 } /* Literal.String.Interpol */
.sx { color: #d01040 } /* Literal.String.Other */
.sr { color: #009926 } /* Literal.String.Regex */
.s1 { color: #d01040 } /* Literal.String.Single */
.ss { color: #990073 } /* Literal.String.Symbol */
.bp { color: #999999 } /* Name.Builtin.Pseudo */
.vc { color: #008080 } /* Name.Variable.Class */
.vg { color: #008080 } /* Name.Variable.Global */
.vi { color: #008080 } /* Name.Variable.Instance */
.il { color: #009999 } /* Literal.Number.Integer.Long */
} @else {
.hll { background-color: #6e7681 }
.c { color: #8b949e; font-style: italic } /* Comment */
.err { color: #f85149 } /* Error */
.esc { color: #c9d1d9 } /* Escape */
.g { color: #c9d1d9 } /* Generic */
.k { color: #ff7b72 } /* Keyword */
.l { color: #a5d6ff } /* Literal */
.n { color: #c9d1d9 } /* Name */
.o { color: #ff7b72; font-weight: bold } /* Operator */
.x { color: #c9d1d9 } /* Other */
.p { color: #c9d1d9 } /* Punctuation */
.ch { color: #8b949e; font-style: italic } /* Comment.Hashbang */
.cm { color: #8b949e; font-style: italic } /* Comment.Multiline */
.cp { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Preproc */
.cpf { color: #8b949e; font-style: italic } /* Comment.PreprocFile */
.c1 { color: #8b949e; font-style: italic } /* Comment.Single */
.cs { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Special */
.gd { color: #ffa198; background-color: #490202 } /* Generic.Deleted */
.ge { color: #c9d1d9; font-style: italic } /* Generic.Emph */
.gr { color: #ffa198 } /* Generic.Error */
.gh { color: #79c0ff; font-weight: bold } /* Generic.Heading */
.gi { color: #56d364; background-color: #0f5323 } /* Generic.Inserted */
.go { color: #8b949e } /* Generic.Output */
.gp { color: #8b949e } /* Generic.Prompt */
.gs { color: #c9d1d9; font-weight: bold } /* Generic.Strong */
.gu { color: #79c0ff } /* Generic.Subheading */
.gt { color: #ff7b72 } /* Generic.Traceback */
.g-Underline { color: #c9d1d9; text-decoration: underline } /* Generic.Underline */
.kc { color: #79c0ff } /* Keyword.Constant */
.kd { color: #ff7b72 } /* Keyword.Declaration */
.kn { color: #ff7b72 } /* Keyword.Namespace */
.kp { color: #79c0ff } /* Keyword.Pseudo */
.kr { color: #ff7b72 } /* Keyword.Reserved */
.kt { color: #ff7b72 } /* Keyword.Type */
.ld { color: #79c0ff } /* Literal.Date */
.m { color: #a5d6ff } /* Literal.Number */
.s { color: #a5d6ff } /* Literal.String */
.na { color: #c9d1d9 } /* Name.Attribute */
.nb { color: #c9d1d9 } /* Name.Builtin */
.nc { color: #f0883e; font-weight: bold } /* Name.Class */
.no { color: #79c0ff; font-weight: bold } /* Name.Constant */
.nd { color: #d2a8ff; font-weight: bold } /* Name.Decorator */
.ni { color: #ffa657 } /* Name.Entity */
.ne { color: #f0883e; font-weight: bold } /* Name.Exception */
.nf { color: #d2a8ff; font-weight: bold } /* Name.Function */
.nl { color: #79c0ff; font-weight: bold } /* Name.Label */
.nn { color: #ff7b72 } /* Name.Namespace */
.nx { color: #c9d1d9 } /* Name.Other */
.py { color: #79c0ff } /* Name.Property */
.nt { color: #7ee787 } /* Name.Tag */
.nv { color: #79c0ff } /* Name.Variable */
.ow { color: #ff7b72; font-weight: bold } /* Operator.Word */
.pm { color: #c9d1d9 } /* Punctuation.Marker */
.w { color: #6e7681 } /* Text.Whitespace */
.mb { color: #a5d6ff } /* Literal.Number.Bin */
.mf { color: #a5d6ff } /* Literal.Number.Float */
.mh { color: #a5d6ff } /* Literal.Number.Hex */
.mi { color: #a5d6ff } /* Literal.Number.Integer */
.mo { color: #a5d6ff } /* Literal.Number.Oct */
.sa { color: #79c0ff } /* Literal.String.Affix */
.sb { color: #a5d6ff } /* Literal.String.Backtick */
.sc { color: #a5d6ff } /* Literal.String.Char */
.dl { color: #79c0ff } /* Literal.String.Delimiter */
.sd { color: #a5d6ff } /* Literal.String.Doc */
.s2 { color: #a5d6ff } /* Literal.String.Double */
.se { color: #79c0ff } /* Literal.String.Escape */
.sh { color: #79c0ff } /* Literal.String.Heredoc */
.si { color: #a5d6ff } /* Literal.String.Interpol */
.sx { color: #a5d6ff } /* Literal.String.Other */
.sr { color: #79c0ff } /* Literal.String.Regex */
.s1 { color: #a5d6ff } /* Literal.String.Single */
.ss { color: #a5d6ff } /* Literal.String.Symbol */
.bp { color: #c9d1d9 } /* Name.Builtin.Pseudo */
.fm { color: #d2a8ff; font-weight: bold } /* Name.Function.Magic */
.vc { color: #79c0ff } /* Name.Variable.Class */
.vg { color: #79c0ff } /* Name.Variable.Global */
.vi { color: #79c0ff } /* Name.Variable.Instance */
.vm { color: #79c0ff } /* Name.Variable.Magic */
.il { color: #a5d6ff } /* Literal.Number.Integer.Long */
}
}
1 change: 1 addition & 0 deletions resources/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "base";
@import "pygment-github";
@import "table";
@import "math";
@import "status";
Expand Down
2 changes: 2 additions & 0 deletions resources/vars-dark.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import "vars-common";

$is_light_theme: false;

$color_primary0: #000;
$color_primary5: #080808; // light background
$color_primary10: #111; // background
Expand Down
2 changes: 2 additions & 0 deletions resources/vars-default.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import "vars-common";

$is_light_theme: true;

$color_primary0: #fff;
$color_primary5: #f8f8f8; // light background
$color_primary10: #eee; // background
Expand Down
5 changes: 1 addition & 4 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@
{% endif %}
{% compress css %}
<link rel="stylesheet" href="{{ static(STYLE_CSS) }}">
{% if PYGMENT_THEME %}
<link rel="stylesheet" href="{{ static(PYGMENT_THEME) }}">
{% endif %}{% if INLINE_FONTAWESOME %}
<link rel="stylesheet" href="{{ static('libs/fontawesome/font-awesome.css') }}">{% endif %}
{% if INLINE_FONTAWESOME %}<link rel="stylesheet" href="{{ static('libs/fontawesome/font-awesome.css') }}">{% endif %}
<link rel="stylesheet" type="text/css" href="{{ static('libs/clipboard/tooltip.css') }}">
<link rel="stylesheet" type="text/css" href="{{ static('libs/select2/select2.css') }}">
{% endcompress %}
Expand Down
1 change: 0 additions & 1 deletion templates/problem/raw.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<html>
<head>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="pygment-github.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
html {
Expand Down

0 comments on commit 617a321

Please sign in to comment.