summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2020-03-24 12:43:20 -0700
committerGitHub <noreply@github.com>2020-03-24 20:43:20 +0100
commit4e8e1e14083b223383061391312eb595dc479eb5 (patch)
treed49b460aa9f72b481fa9e937942d36283e0d9156
parent2baed040c2c6c8c02808a88633f50a0585958351 (diff)
Don't highlight code spans in headers. (#1162)
-rw-r--r--src/theme/book.js13
-rw-r--r--src/theme/css/general.css5
2 files changed, 12 insertions, 6 deletions
diff --git a/src/theme/book.js b/src/theme/book.js
index 8fda7a6c..dd33881a 100644
--- a/src/theme/book.js
+++ b/src/theme/book.js
@@ -143,6 +143,11 @@ function playpen_text(playpen) {
languages: [], // Languages used for auto-detection
});
+ let code_nodes = Array
+ .from(document.querySelectorAll('code'))
+ // Don't highlight `inline code` blocks in headers.
+ .filter(function (node) {return !node.parentElement.classList.contains("header"); });
+
if (window.ace) {
// language-rust class needs to be removed for editable
// blocks or highlightjs will capture events
@@ -154,16 +159,12 @@ function playpen_text(playpen) {
.from(document.querySelectorAll('code:not(.editable)'))
.forEach(function (block) { hljs.highlightBlock(block); });
} else {
- Array
- .from(document.querySelectorAll('code'))
- .forEach(function (block) { hljs.highlightBlock(block); });
+ code_nodes.forEach(function (block) { hljs.highlightBlock(block); });
}
// Adding the hljs class gives code blocks the color css
// even if highlighting doesn't apply
- Array
- .from(document.querySelectorAll('code'))
- .forEach(function (block) { block.classList.add('hljs'); });
+ code_nodes.forEach(function (block) { block.classList.add('hljs'); });
Array.from(document.querySelectorAll("code.language-rust")).forEach(function (block) {
diff --git a/src/theme/css/general.css b/src/theme/css/general.css
index 65c27776..e2df5d65 100644
--- a/src/theme/css/general.css
+++ b/src/theme/css/general.css
@@ -25,6 +25,11 @@ code {
font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */
}
+/* Don't change font size in headers. */
+h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
+ font-size: unset;
+}
+
.left { float: left; }
.right { float: right; }
.boring { opacity: 0.6; }