mirror of https://github.com/searxng/searxng.git
[feature] dark theme for code highlighter in the result list
Closes: https://github.com/searxng/searxng/issues/1354 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
432febd810
commit
935aed7ca4
|
@ -3,98 +3,171 @@
|
||||||
using pygments version 2.16.1
|
using pygments version 2.16.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.code-highlight .linenos {
|
|
||||||
-webkit-touch-callout: none;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-khtml-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
-ms-user-select: none;
|
|
||||||
user-select: none;
|
|
||||||
cursor: default;
|
|
||||||
|
|
||||||
&::selection {
|
.code-highlight {
|
||||||
background: transparent; /* WebKit/Blink Browsers */
|
|
||||||
}
|
|
||||||
&::-moz-selection {
|
|
||||||
background: transparent; /* Gecko Browsers */
|
|
||||||
}
|
|
||||||
|
|
||||||
margin-right: 8px;
|
pre { line-height: 100%; }
|
||||||
text-align: right;
|
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; }
|
||||||
|
.hll { background-color: #ffffcc }
|
||||||
|
.c { color: #3D7B7B; font-style: italic } /* Comment */
|
||||||
|
.err { border: 1px solid #FF0000 } /* Error */
|
||||||
|
.k { color: #008000; font-weight: bold } /* Keyword */
|
||||||
|
.o { color: #666666 } /* Operator */
|
||||||
|
.ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
|
||||||
|
.cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
|
||||||
|
.cp { color: #9C6500 } /* Comment.Preproc */
|
||||||
|
.cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */
|
||||||
|
.c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */
|
||||||
|
.cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
|
||||||
|
.gd { color: #A00000 } /* Generic.Deleted */
|
||||||
|
.ge { font-style: italic } /* Generic.Emph */
|
||||||
|
.ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
|
||||||
|
.gr { color: #E40000 } /* Generic.Error */
|
||||||
|
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||||
|
.gi { color: #008400 } /* Generic.Inserted */
|
||||||
|
.go { color: #717171 } /* Generic.Output */
|
||||||
|
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
||||||
|
.gs { font-weight: bold } /* Generic.Strong */
|
||||||
|
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||||||
|
.gt { color: #0044DD } /* Generic.Traceback */
|
||||||
|
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
|
||||||
|
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
|
||||||
|
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
|
||||||
|
.kp { color: #008000 } /* Keyword.Pseudo */
|
||||||
|
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
|
||||||
|
.kt { color: #B00040 } /* Keyword.Type */
|
||||||
|
.m { color: #666666 } /* Literal.Number */
|
||||||
|
.s { color: #BA2121 } /* Literal.String */
|
||||||
|
.na { color: #687822 } /* Name.Attribute */
|
||||||
|
.nb { color: #008000 } /* Name.Builtin */
|
||||||
|
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
||||||
|
.no { color: #880000 } /* Name.Constant */
|
||||||
|
.nd { color: #AA22FF } /* Name.Decorator */
|
||||||
|
.ni { color: #717171; font-weight: bold } /* Name.Entity */
|
||||||
|
.ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
|
||||||
|
.nf { color: #0000FF } /* Name.Function */
|
||||||
|
.nl { color: #767600 } /* Name.Label */
|
||||||
|
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
||||||
|
.nt { color: #008000; font-weight: bold } /* Name.Tag */
|
||||||
|
.nv { color: #19177C } /* Name.Variable */
|
||||||
|
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
||||||
|
.w { color: #bbbbbb } /* Text.Whitespace */
|
||||||
|
.mb { color: #666666 } /* Literal.Number.Bin */
|
||||||
|
.mf { color: #666666 } /* Literal.Number.Float */
|
||||||
|
.mh { color: #666666 } /* Literal.Number.Hex */
|
||||||
|
.mi { color: #666666 } /* Literal.Number.Integer */
|
||||||
|
.mo { color: #666666 } /* Literal.Number.Oct */
|
||||||
|
.sa { color: #BA2121 } /* Literal.String.Affix */
|
||||||
|
.sb { color: #BA2121 } /* Literal.String.Backtick */
|
||||||
|
.sc { color: #BA2121 } /* Literal.String.Char */
|
||||||
|
.dl { color: #BA2121 } /* Literal.String.Delimiter */
|
||||||
|
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
|
||||||
|
.s2 { color: #BA2121 } /* Literal.String.Double */
|
||||||
|
.se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */
|
||||||
|
.sh { color: #BA2121 } /* Literal.String.Heredoc */
|
||||||
|
.si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */
|
||||||
|
.sx { color: #008000 } /* Literal.String.Other */
|
||||||
|
.sr { color: #A45A77 } /* Literal.String.Regex */
|
||||||
|
.s1 { color: #BA2121 } /* Literal.String.Single */
|
||||||
|
.ss { color: #19177C } /* Literal.String.Symbol */
|
||||||
|
.bp { color: #008000 } /* Name.Builtin.Pseudo */
|
||||||
|
.fm { color: #0000FF } /* Name.Function.Magic */
|
||||||
|
.vc { color: #19177C } /* Name.Variable.Class */
|
||||||
|
.vg { color: #19177C } /* Name.Variable.Global */
|
||||||
|
.vi { color: #19177C } /* Name.Variable.Instance */
|
||||||
|
.vm { color: #19177C } /* Name.Variable.Magic */
|
||||||
|
.il { color: #666666 } /* Literal.Number.Integer.Long */
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-highlight pre { line-height: 125%; }
|
.code-highlight-dark(){
|
||||||
.code-highlight td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
|
.code-highlight {
|
||||||
.code-highlight span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
|
|
||||||
.code-highlight td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
|
pre { line-height: 100%; }
|
||||||
.code-highlight span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
|
td.linenos .normal { color: #3c4354; background-color: transparent; padding-left: 5px; padding-right: 5px; }
|
||||||
.code-highlight .hll { background-color: #ffffcc }
|
span.linenos { color: #3c4354; background-color: transparent; padding-left: 5px; padding-right: 5px; }
|
||||||
.code-highlight { background: #f8f8f8; }
|
td.linenos .special { color: #3c4354; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
|
||||||
.code-highlight .c { color: #3D7B7B; font-style: italic } /* Comment */
|
span.linenos.special { color: #3c4354; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
|
||||||
.code-highlight .err { border: 1px solid #FF0000 } /* Error */
|
.hll { background-color: #6e7681 }
|
||||||
.code-highlight .k { color: #008000; font-weight: bold } /* Keyword */
|
.c { color: #7e8aa1 } /* Comment */
|
||||||
.code-highlight .o { color: #666666 } /* Operator */
|
.err { color: #f88f7f } /* Error */
|
||||||
.code-highlight .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
|
.esc { color: #d4d2c8 } /* Escape */
|
||||||
.code-highlight .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
|
.g { color: #d4d2c8 } /* Generic */
|
||||||
.code-highlight .cp { color: #9C6500 } /* Comment.Preproc */
|
.k { color: #FFAD66 } /* Keyword */
|
||||||
.code-highlight .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */
|
.l { color: #D5FF80 } /* Literal */
|
||||||
.code-highlight .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */
|
.n { color: #d4d2c8 } /* Name */
|
||||||
.code-highlight .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
|
.o { color: #FFAD66 } /* Operator */
|
||||||
.code-highlight .gd { color: #A00000 } /* Generic.Deleted */
|
.x { color: #d4d2c8 } /* Other */
|
||||||
.code-highlight .ge { font-style: italic } /* Generic.Emph */
|
.p { color: #d4d2c8 } /* Punctuation */
|
||||||
.code-highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
|
.ch { color: #f88f7f; font-style: italic } /* Comment.Hashbang */
|
||||||
.code-highlight .gr { color: #E40000 } /* Generic.Error */
|
.cm { color: #7e8aa1 } /* Comment.Multiline */
|
||||||
.code-highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
.cp { color: #FFAD66; font-weight: bold } /* Comment.Preproc */
|
||||||
.code-highlight .gi { color: #008400 } /* Generic.Inserted */
|
.cpf { color: #7e8aa1 } /* Comment.PreprocFile */
|
||||||
.code-highlight .go { color: #717171 } /* Generic.Output */
|
.c1 { color: #7e8aa1 } /* Comment.Single */
|
||||||
.code-highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
.cs { color: #7e8aa1; font-style: italic } /* Comment.Special */
|
||||||
.code-highlight .gs { font-weight: bold } /* Generic.Strong */
|
.gd { color: #f88f7f; background-color: #3d1e20 } /* Generic.Deleted */
|
||||||
.code-highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
.ge { color: #d4d2c8; font-style: italic } /* Generic.Emph */
|
||||||
.code-highlight .gt { color: #0044DD } /* Generic.Traceback */
|
.ges { color: #d4d2c8 } /* Generic.EmphStrong */
|
||||||
.code-highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
|
.gr { color: #f88f7f } /* Generic.Error */
|
||||||
.code-highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
|
.gh { color: #d4d2c8 } /* Generic.Heading */
|
||||||
.code-highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
|
.gi { color: #6ad4af; background-color: #19362c } /* Generic.Inserted */
|
||||||
.code-highlight .kp { color: #008000 } /* Keyword.Pseudo */
|
.go { color: #7e8aa1 } /* Generic.Output */
|
||||||
.code-highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
|
.gp { color: #d4d2c8 } /* Generic.Prompt */
|
||||||
.code-highlight .kt { color: #B00040 } /* Keyword.Type */
|
.gs { color: #d4d2c8; font-weight: bold } /* Generic.Strong */
|
||||||
.code-highlight .m { color: #666666 } /* Literal.Number */
|
.gu { color: #d4d2c8 } /* Generic.Subheading */
|
||||||
.code-highlight .s { color: #BA2121 } /* Literal.String */
|
.gt { color: #f88f7f } /* Generic.Traceback */
|
||||||
.code-highlight .na { color: #687822 } /* Name.Attribute */
|
.kc { color: #FFAD66 } /* Keyword.Constant */
|
||||||
.code-highlight .nb { color: #008000 } /* Name.Builtin */
|
.kd { color: #FFAD66 } /* Keyword.Declaration */
|
||||||
.code-highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
.kn { color: #FFAD66 } /* Keyword.Namespace */
|
||||||
.code-highlight .no { color: #880000 } /* Name.Constant */
|
.kp { color: #FFAD66 } /* Keyword.Pseudo */
|
||||||
.code-highlight .nd { color: #AA22FF } /* Name.Decorator */
|
.kr { color: #FFAD66 } /* Keyword.Reserved */
|
||||||
.code-highlight .ni { color: #717171; font-weight: bold } /* Name.Entity */
|
.kt { color: #73D0FF } /* Keyword.Type */
|
||||||
.code-highlight .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
|
.ld { color: #D5FF80 } /* Literal.Date */
|
||||||
.code-highlight .nf { color: #0000FF } /* Name.Function */
|
.m { color: #DFBFFF } /* Literal.Number */
|
||||||
.code-highlight .nl { color: #767600 } /* Name.Label */
|
.s { color: #D5FF80 } /* Literal.String */
|
||||||
.code-highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
.na { color: #FFD173 } /* Name.Attribute */
|
||||||
.code-highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
|
.nb { color: #FFD173 } /* Name.Builtin */
|
||||||
.code-highlight .nv { color: #19177C } /* Name.Variable */
|
.nc { color: #73D0FF } /* Name.Class */
|
||||||
.code-highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
.no { color: #FFD173 } /* Name.Constant */
|
||||||
.code-highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
.nd { color: #7e8aa1; font-weight: bold; font-style: italic } /* Name.Decorator */
|
||||||
.code-highlight .mb { color: #666666 } /* Literal.Number.Bin */
|
.ni { color: #95E6CB } /* Name.Entity */
|
||||||
.code-highlight .mf { color: #666666 } /* Literal.Number.Float */
|
.ne { color: #73D0FF } /* Name.Exception */
|
||||||
.code-highlight .mh { color: #666666 } /* Literal.Number.Hex */
|
.nf { color: #FFD173 } /* Name.Function */
|
||||||
.code-highlight .mi { color: #666666 } /* Literal.Number.Integer */
|
.nl { color: #d4d2c8 } /* Name.Label */
|
||||||
.code-highlight .mo { color: #666666 } /* Literal.Number.Oct */
|
.nn { color: #d4d2c8 } /* Name.Namespace */
|
||||||
.code-highlight .sa { color: #BA2121 } /* Literal.String.Affix */
|
.nx { color: #d4d2c8 } /* Name.Other */
|
||||||
.code-highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
|
.py { color: #FFD173 } /* Name.Property */
|
||||||
.code-highlight .sc { color: #BA2121 } /* Literal.String.Char */
|
.nt { color: #5CCFE6 } /* Name.Tag */
|
||||||
.code-highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */
|
.nv { color: #d4d2c8 } /* Name.Variable */
|
||||||
.code-highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
|
.ow { color: #FFAD66 } /* Operator.Word */
|
||||||
.code-highlight .s2 { color: #BA2121 } /* Literal.String.Double */
|
.pm { color: #d4d2c8 } /* Punctuation.Marker */
|
||||||
.code-highlight .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */
|
.w { color: #d4d2c8 } /* Text.Whitespace */
|
||||||
.code-highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
|
.mb { color: #DFBFFF } /* Literal.Number.Bin */
|
||||||
.code-highlight .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */
|
.mf { color: #DFBFFF } /* Literal.Number.Float */
|
||||||
.code-highlight .sx { color: #008000 } /* Literal.String.Other */
|
.mh { color: #DFBFFF } /* Literal.Number.Hex */
|
||||||
.code-highlight .sr { color: #A45A77 } /* Literal.String.Regex */
|
.mi { color: #DFBFFF } /* Literal.Number.Integer */
|
||||||
.code-highlight .s1 { color: #BA2121 } /* Literal.String.Single */
|
.mo { color: #DFBFFF } /* Literal.Number.Oct */
|
||||||
.code-highlight .ss { color: #19177C } /* Literal.String.Symbol */
|
.sa { color: #F29E74 } /* Literal.String.Affix */
|
||||||
.code-highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
|
.sb { color: #D5FF80 } /* Literal.String.Backtick */
|
||||||
.code-highlight .fm { color: #0000FF } /* Name.Function.Magic */
|
.sc { color: #D5FF80 } /* Literal.String.Char */
|
||||||
.code-highlight .vc { color: #19177C } /* Name.Variable.Class */
|
.dl { color: #D5FF80 } /* Literal.String.Delimiter */
|
||||||
.code-highlight .vg { color: #19177C } /* Name.Variable.Global */
|
.sd { color: #7e8aa1 } /* Literal.String.Doc */
|
||||||
.code-highlight .vi { color: #19177C } /* Name.Variable.Instance */
|
.s2 { color: #D5FF80 } /* Literal.String.Double */
|
||||||
.code-highlight .vm { color: #19177C } /* Name.Variable.Magic */
|
.se { color: #95E6CB } /* Literal.String.Escape */
|
||||||
.code-highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
|
.sh { color: #D5FF80 } /* Literal.String.Heredoc */
|
||||||
|
.si { color: #95E6CB } /* Literal.String.Interpol */
|
||||||
|
.sx { color: #95E6CB } /* Literal.String.Other */
|
||||||
|
.sr { color: #95E6CB } /* Literal.String.Regex */
|
||||||
|
.s1 { color: #D5FF80 } /* Literal.String.Single */
|
||||||
|
.ss { color: #DFBFFF } /* Literal.String.Symbol */
|
||||||
|
.bp { color: #5CCFE6 } /* Name.Builtin.Pseudo */
|
||||||
|
.fm { color: #FFD173 } /* Name.Function.Magic */
|
||||||
|
.vc { color: #d4d2c8 } /* Name.Variable.Class */
|
||||||
|
.vg { color: #d4d2c8 } /* Name.Variable.Global */
|
||||||
|
.vi { color: #d4d2c8 } /* Name.Variable.Instance */
|
||||||
|
.vm { color: #d4d2c8 } /* Name.Variable.Magic */
|
||||||
|
.il { color: #DFBFFF } /* Literal.Number.Integer.Long */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,9 +1,51 @@
|
||||||
.code-highlight pre {
|
@import "../generated/pygments.less";
|
||||||
overflow: auto;
|
|
||||||
background-color: inherit;
|
.codelines {
|
||||||
color: inherit;
|
margin: @results-margin 0 0 0;
|
||||||
border: inherit;
|
padding: @result-padding 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stylelint-disable no-invalid-position-at-import-rule
|
.code-highlight-sxng() {
|
||||||
@import "../generated/pygments.less";
|
.code-highlight {
|
||||||
|
pre {
|
||||||
|
overflow: auto;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0 0 0.75rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.linenos {
|
||||||
|
user-select: none;
|
||||||
|
cursor: default;
|
||||||
|
|
||||||
|
&::selection {
|
||||||
|
background: transparent; /* WebKit/Blink Browsers */
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-moz-selection {
|
||||||
|
background: transparent; /* Gecko Browsers */
|
||||||
|
}
|
||||||
|
margin-right: 8px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.linenos {
|
||||||
|
color: #64708d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-highlight-sxng();
|
||||||
|
|
||||||
|
/// Dark Theme (autoswitch based on device pref)
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root.theme-auto {
|
||||||
|
.code-highlight-dark();
|
||||||
|
.code-highlight-sxng();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dark Theme by preferences
|
||||||
|
:root.theme-dark {
|
||||||
|
.code-highlight-dark();
|
||||||
|
.code-highlight-sxng();
|
||||||
|
}
|
||||||
|
|
|
@ -2,12 +2,31 @@
|
||||||
|
|
||||||
{{ result_header(result, favicons, image_proxify) -}}
|
{{ result_header(result, favicons, image_proxify) -}}
|
||||||
{{- result_sub_header(result) -}}
|
{{- result_sub_header(result) -}}
|
||||||
{%- if result.content %}{{ result.content|safe }}{% endif %}</p>
|
|
||||||
{%- if result.repository -%}
|
{%- if result.content -%}
|
||||||
<p class="content"><a href="{{ result.repository|safe }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.repository }}</a></p>
|
<p class="content">
|
||||||
|
{{- result.content|safe -}}
|
||||||
|
</p>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
{%- if result.repository -%}
|
||||||
|
<p class="content">{{- '' -}}
|
||||||
|
{{ _('repo') }}: {{- ' ' -}}
|
||||||
|
<a href="{{ result.repository|safe }}"{{- ' ' -}}
|
||||||
|
{% if results_on_new_tab %}
|
||||||
|
target="_blank" {{- ' ' -}}
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
{%- else -%}
|
||||||
|
rel="noreferrer"
|
||||||
|
{%- endif -%}
|
||||||
|
>
|
||||||
|
{{- result.repository -}}
|
||||||
|
</a>{{- '' -}}
|
||||||
|
</p>
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
<div dir="ltr" class="codelines">
|
<div dir="ltr" class="codelines">
|
||||||
{{- result.codelines|code_highlighter(result.code_language)|safe -}}
|
{{- result.codelines|code_highlighter(result.code_language)|safe -}}
|
||||||
</div>{{- '' -}}
|
</div>
|
||||||
|
|
||||||
{{- result_sub_footer(result, proxify) -}}
|
{{- result_sub_footer(result, proxify) -}}
|
||||||
{{ result_footer(result) }}
|
{{- result_footer(result) -}}
|
||||||
|
|
|
@ -216,7 +216,7 @@ def code_highlighter(codelines, language=None):
|
||||||
lexer = get_lexer_by_name(language, stripall=True)
|
lexer = get_lexer_by_name(language, stripall=True)
|
||||||
|
|
||||||
except Exception as e: # pylint: disable=broad-except
|
except Exception as e: # pylint: disable=broad-except
|
||||||
logger.exception(e, exc_info=True)
|
logger.warning("pygments lexer: %s " % e)
|
||||||
# if lexer is not found, using default one
|
# if lexer is not found, using default one
|
||||||
lexer = get_lexer_by_name('text', stripall=True)
|
lexer = get_lexer_by_name('text', stripall=True)
|
||||||
|
|
||||||
|
|
|
@ -1,69 +1,71 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
"""
|
"""Update pygments style
|
||||||
Update pygments style
|
|
||||||
|
|
||||||
Call this script after each upgrade of pygments
|
Call this script after each upgrade of pygments
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# pylint: disable=C0116
|
from pathlib import Path
|
||||||
|
|
||||||
# set path
|
|
||||||
from os.path import join
|
|
||||||
import pygments
|
import pygments
|
||||||
from pygments.formatters import HtmlFormatter # pylint: disable=E0611
|
from pygments.formatters import HtmlFormatter
|
||||||
from pygments.style import Style
|
|
||||||
from pygments.token import Comment, Error, Generic, Keyword, Literal, Name, Operator, Text
|
|
||||||
|
|
||||||
from searx import searx_dir
|
from searx import searx_dir
|
||||||
|
|
||||||
CSSCLASS = '.code-highlight'
|
LESS_FILE = Path(searx_dir) / 'static/themes/simple/src/generated/pygments.less'
|
||||||
RULE_CODE_LINENOS = """ .linenos {
|
|
||||||
-webkit-touch-callout: none;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-khtml-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
-ms-user-select: none;
|
|
||||||
user-select: none;
|
|
||||||
cursor: default;
|
|
||||||
|
|
||||||
&::selection {
|
HEADER = f"""\
|
||||||
background: transparent; /* WebKit/Blink Browsers */
|
/*
|
||||||
}
|
|
||||||
&::-moz-selection {
|
|
||||||
background: transparent; /* Gecko Browsers */
|
|
||||||
}
|
|
||||||
|
|
||||||
margin-right: 8px;
|
|
||||||
text-align: right;
|
|
||||||
}"""
|
|
||||||
|
|
||||||
|
|
||||||
def get_output_filename(relative_name):
|
|
||||||
return join(searx_dir, relative_name)
|
|
||||||
|
|
||||||
|
|
||||||
def get_css(cssclass, style):
|
|
||||||
result = f"""/*
|
|
||||||
this file is generated automatically by searxng_extra/update/update_pygments.py
|
this file is generated automatically by searxng_extra/update/update_pygments.py
|
||||||
using pygments version {pygments.__version__}
|
using pygments version {pygments.__version__}
|
||||||
*/\n\n"""
|
*/
|
||||||
css_text = HtmlFormatter(style=style).get_style_defs(cssclass)
|
|
||||||
result += cssclass + RULE_CODE_LINENOS + '\n\n'
|
"""
|
||||||
for line in css_text.splitlines():
|
|
||||||
if ' ' in line and not line.startswith(cssclass):
|
START_LIGHT_THEME = """
|
||||||
line = cssclass + ' ' + line
|
.code-highlight {
|
||||||
result += line + '\n'
|
"""
|
||||||
return result
|
|
||||||
|
END_LIGHT_THEME = """
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
START_DARK_THEME = """
|
||||||
|
.code-highlight-dark(){
|
||||||
|
.code-highlight {
|
||||||
|
"""
|
||||||
|
|
||||||
|
END_DARK_THEME = """
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
def main():
|
class Formatter(HtmlFormatter):
|
||||||
|
@property
|
||||||
|
def _pre_style(self):
|
||||||
|
return 'line-height: 100%;'
|
||||||
|
|
||||||
fname = 'static/themes/simple/src/generated/pygments.less'
|
def get_style_lines(self, arg=None):
|
||||||
print("update: %s" % fname)
|
style_lines = []
|
||||||
with open(get_output_filename(fname), 'w') as f:
|
style_lines.extend(self.get_linenos_style_defs())
|
||||||
f.write(get_css(CSSCLASS, 'default'))
|
style_lines.extend(self.get_background_style_defs(arg))
|
||||||
|
style_lines.extend(self.get_token_style_defs(arg))
|
||||||
|
return style_lines
|
||||||
|
|
||||||
|
|
||||||
|
def generat_css(light_style, dark_style) -> str:
|
||||||
|
css = HEADER + START_LIGHT_THEME
|
||||||
|
for line in Formatter(style=light_style).get_style_lines():
|
||||||
|
css += '\n ' + line
|
||||||
|
css += END_LIGHT_THEME + START_DARK_THEME
|
||||||
|
for line in Formatter(style=dark_style).get_style_lines():
|
||||||
|
css += '\n ' + line
|
||||||
|
css += END_DARK_THEME
|
||||||
|
return css
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
print("update: %s" % LESS_FILE)
|
||||||
|
with open(LESS_FILE, 'w') as f:
|
||||||
|
f.write(generat_css('default', 'lightbulb'))
|
||||||
|
|
Loading…
Reference in New Issue