Skip to content

Commit

Permalink
Migrate highlight style to CSS variables
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Oct 7, 2022
1 parent 5854680 commit 6a91fac
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 54 deletions.
46 changes: 41 additions & 5 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,49 @@ so that we can apply CSS-filters to change the arrow color in themes */
color: var(--right-side-color);
}

pre.rust {
tab-size: 4;
-moz-tab-size: 4;
}

/* Code highlighting */
pre.rust .kw {
color: var(--code-highlight-kw-color);
}
pre.rust .kw-2,
pre.rust .lifetime {
color: var(--code-highlight-kw-2-color);
}
pre.rust .prelude-ty,
pre.rust .prelude-val {
color: var(--code-highlight-prelude-color);
}
pre.rust .string {
color: var(--code-highlight-string-color);
}
pre.rust .number,
pre.rust .bool-val {
color: var(--code-highlight-literal-color);
}
pre.rust .self {
color: var(--code-highlight-self-color);
}
pre.rust .attribute {
color: var(--code-highlight-attribute-color);
}
pre.rust .macro,
pre.rust .macro-nonterminal {
color: var(--code-highlight-macro-color);
}
pre.rust .question-mark {
font-weight: bold;
color: var(--code-highlight-question-mark-color);
}
pre.rust .comment {
color: var(--code-highlight-comment-color);
}
pre.rust .doccomment {
color: var(--code-highlight-doc-comment-color);
}

.example-wrap.compile_fail,
Expand Down Expand Up @@ -1309,11 +1350,6 @@ h3.variant {
font-size: 1.25rem;
}

pre.rust {
tab-size: 4;
-moz-tab-size: 4;
}

.search-failed {
text-align: center;
margin-top: 20px;
Expand Down
31 changes: 11 additions & 20 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--stab-background-color: #314559;
--stab-code-color: #e6e1cf;
--search-color: #fff;
--code-highlight-kw-color: #ff7733;
--code-highlight-kw-2-color: #f33;
--code-highlight-prelude-color: #69f2df;
--code-highlight-string-color: #b8cc52;
--code-highlight-literal-color: #7fd4fd;
--code-highlight-attribute-color: #e6e1cf;
--code-highlight-self-color: #36a3d9;
--code-highlight-macro-color: #a37acc;
--code-highlight-question-mark-color: #ff9011;
--code-highlight-comment-color: #788797;
--code-highlight-doc-comment-color: #a1ac88;
}

.slider {
Expand Down Expand Up @@ -124,9 +135,6 @@ pre, .rustdoc.source .example-wrap {

.content .item-info::before { color: #ccc; }

pre.rust .comment { color: #788797; }
pre.rust .doccomment { color: #a1ac88; }

.sidebar h2 a,
.sidebar h3 a {
color: white;
Expand Down Expand Up @@ -161,23 +169,6 @@ details.rustdoc-toggle > summary::before {

.src-line-numbers :target { background-color: transparent; }

/* Code highlighting */
pre.rust .number, pre.rust .string { color: #b8cc52; }
pre.rust .kw, pre.rust .kw-2, pre.rust .prelude-ty,
pre.rust .bool-val, pre.rust .prelude-val,
pre.rust .lifetime { color: #ff7733; }
pre.rust .macro, pre.rust .macro-nonterminal { color: #a37acc; }
pre.rust .question-mark {
color: #ff9011;
}
pre.rust .self {
color: #36a3d9;
font-style: italic;
}
pre.rust .attribute {
color: #e6e1cf;
}

pre.example-line-numbers {
color: #5c67736e;
border: none;
Expand Down
26 changes: 11 additions & 15 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
--stab-background-color: #314559;
--stab-code-color: #e6e1cf;
--search-color: #111;
--code-highlight-kw-color: #ab8ac1;
--code-highlight-kw-2-color: #d97f26;
--code-highlight-prelude-color: #769acb;
--code-highlight-string-color: #83a300;
--code-highlight-literal-color: #1c959b;
--code-highlight-attribute-color: #ee6868;
--code-highlight-self-color: #ee6868;
--code-highlight-macro-color: #3e999f;
--code-highlight-question-mark-color: #ff9011;
--code-highlight-comment-color: #8d8d8b;
--code-highlight-doc-comment-color: #8ca375;
}

.slider {
Expand All @@ -62,9 +73,6 @@ input:focus + .slider {

.content .item-info::before { color: #ccc; }

pre.rust .comment { color: #8d8d8b; }
pre.rust .doccomment { color: #8ca375; }

body.source .example-wrap pre.rust a {
background: #333;
}
Expand All @@ -86,18 +94,6 @@ details.rustdoc-toggle > summary::before {

.src-line-numbers :target { background-color: transparent; }

/* Code highlighting */
pre.rust .kw { color: #ab8ac1; }
pre.rust .kw-2, pre.rust .prelude-ty { color: #769acb; }
pre.rust .number, pre.rust .string { color: #83a300; }
pre.rust .self, pre.rust .bool-val, pre.rust .prelude-val,
pre.rust .attribute { color: #ee6868; }
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
pre.rust .lifetime { color: #d97f26; }
pre.rust .question-mark {
color: #ff9011;
}

pre.example-line-numbers {
border-color: #4a4949;
}
Expand Down
25 changes: 11 additions & 14 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
--stab-background-color: #fff5d6;
--stab-code-color: #000;
--search-color: #000;
--code-highlight-kw-color: #8959a8;
--code-highlight-kw-2-color: #b76514;
--code-highlight-prelude-color: #4271ae;
--code-highlight-string-color: #718c00;
--code-highlight-literal-color: #261ff9;
--code-highlight-attribute-color: #c82829;
--code-highlight-self-color: #c82829;
--code-highlight-macro-color: #3e999f;
--code-highlight-question-mark-color: #ff9011;
--code-highlight-comment-color: #8e908c;
--code-highlight-doc-comment-color: #4d4d4c;
}

.slider {
Expand Down Expand Up @@ -78,20 +89,6 @@ body.source .example-wrap pre.rust a {

.src-line-numbers :target { background-color: transparent; }

/* Code highlighting */
pre.rust .kw { color: #8959A8; }
pre.rust .kw-2, pre.rust .prelude-ty { color: #4271AE; }
pre.rust .number, pre.rust .string { color: #718C00; }
pre.rust .self, pre.rust .bool-val, pre.rust .prelude-val,
pre.rust .attribute { color: #C82829; }
pre.rust .comment { color: #8E908C; }
pre.rust .doccomment { color: #4D4D4C; }
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
pre.rust .lifetime { color: #B76514; }
pre.rust .question-mark {
color: #ff9011;
}

pre.example-line-numbers {
border-color: #c7c7c7;
}
Expand Down

0 comments on commit 6a91fac

Please sign in to comment.