Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/janraasch/hugo-bearblog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Jorgensen <andrew@jorgensenfamily.us>2021-04-13 18:24:30 +0300
committerGitHub <noreply@github.com>2021-04-13 18:24:30 +0300
commitb8c8871191bcc2ece9007a0941e5145c62e4e3ab (patch)
treeca4a1963e6baf19d067093bcfdf53e35af9576a5
parentbe0ba327e3a0615d81e58e77c88a67682df01b77 (diff)
fix: code highlighting using Chroma (#20)
Chroma sets `color` (usually) and `background-color` directly on a `<pre>` element under a `<div class="highlight">` but the theme was interfering with those color settings from both the `code` and `pre code` selectors. Since Chroma highlighting is under a `highlight` class we can `unset` the colors that are set by the `code` selector elsewhere, so that under a `<code>` element that's under a `<div class="highlight">` it will just inherit from the `<pre>` above it where Chroma sets all it's colors. The `color: initial;` instead of `color: unset;` is needed because some Chroma styles don't set a default text color, and if you use `unset` instead that lets the browser use a lighter default text color when using a dark color scheme. That's a sort of long winded way of saying that I think I've fixed the color interference problem in a way that won't mess with anything else in the theme. I've tested this on a wide selection of Chroma styles, with both light and dark color schemes and it seems to work correctly in all cases. Which is to say that Chroma appears to have full control of both `color` and `background-color` for code blocks that it's highlighting. Fixes #19
-rw-r--r--layouts/partials/style.html5
1 files changed, 5 insertions, 0 deletions
diff --git a/layouts/partials/style.html b/layouts/partials/style.html
index 6d1a66b..173aec9 100644
--- a/layouts/partials/style.html
+++ b/layouts/partials/style.html
@@ -75,6 +75,11 @@
font-size: 14px;
}
+ div.highlight code {
+ background-color: unset;
+ color: initial;
+ }
+
blockquote {
border-left: 1px solid #999;
color: #222;