From af14cbd2465885adaf9ad3aec05f76fdb7acc075 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 25 Dec 2020 10:53:33 -0500 Subject: [PATCH 1/2] Highlight code blocks according to the current theme --- templates/base.html | 3 +-- templates/macros.html | 25 +++++++++++++++++++++++-- templates/style/base.scss | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/templates/base.html b/templates/base.html index 50752830f..1a07dcf86 100644 --- a/templates/base.html +++ b/templates/base.html @@ -13,13 +13,12 @@ - {%- block css -%}{%- endblock css -%} - {%- block title -%} Docs.rs {%- endblock title -%} + {%- block css -%}{%- endblock css -%} diff --git a/templates/macros.html b/templates/macros.html index 59b57d74f..3ecc7e2c2 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -22,8 +22,29 @@ {# Makes the appropriate CSS imports for highlighting #} {% macro highlight_css() %} {# Load the highlighting theme css #} - + {% endmacro highlight_css %} {# diff --git a/templates/style/base.scss b/templates/style/base.scss index 22d8ec0f6..d0b683d9b 100644 --- a/templates/style/base.scss +++ b/templates/style/base.scss @@ -97,7 +97,7 @@ body { border-bottom: 1px solid; } pre { - background-color: #F5F5F5; + background-color: var(--color-background-code); padding: 14px; } code, kbd, pre, samp { From 74c531106a7796e29f63a021e00f5ed16de17ff3 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 25 Dec 2020 11:51:15 -0500 Subject: [PATCH 2/2] Fix highlighting for users visiting in private mode --- templates/macros.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/macros.html b/templates/macros.html index 3ecc7e2c2..cac4f54d4 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -30,6 +30,7 @@ case "ayu": stylesheet = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/dark.min.css"; break; + case "null": // The user is visiting docs.rs for the first time and hasn't set a theme yet. case "light": stylesheet = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/github.min.css"; break;