Don't highlight code spans in headers. (#1162)
This commit is contained in:
parent
2baed040c2
commit
4e8e1e1408
|
@ -143,6 +143,11 @@ function playpen_text(playpen) {
|
||||||
languages: [], // Languages used for auto-detection
|
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) {
|
if (window.ace) {
|
||||||
// language-rust class needs to be removed for editable
|
// language-rust class needs to be removed for editable
|
||||||
// blocks or highlightjs will capture events
|
// blocks or highlightjs will capture events
|
||||||
|
@ -154,16 +159,12 @@ function playpen_text(playpen) {
|
||||||
.from(document.querySelectorAll('code:not(.editable)'))
|
.from(document.querySelectorAll('code:not(.editable)'))
|
||||||
.forEach(function (block) { hljs.highlightBlock(block); });
|
.forEach(function (block) { hljs.highlightBlock(block); });
|
||||||
} else {
|
} else {
|
||||||
Array
|
code_nodes.forEach(function (block) { hljs.highlightBlock(block); });
|
||||||
.from(document.querySelectorAll('code'))
|
|
||||||
.forEach(function (block) { hljs.highlightBlock(block); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding the hljs class gives code blocks the color css
|
// Adding the hljs class gives code blocks the color css
|
||||||
// even if highlighting doesn't apply
|
// even if highlighting doesn't apply
|
||||||
Array
|
code_nodes.forEach(function (block) { block.classList.add('hljs'); });
|
||||||
.from(document.querySelectorAll('code'))
|
|
||||||
.forEach(function (block) { block.classList.add('hljs'); });
|
|
||||||
|
|
||||||
Array.from(document.querySelectorAll("code.language-rust")).forEach(function (block) {
|
Array.from(document.querySelectorAll("code.language-rust")).forEach(function (block) {
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,11 @@ code {
|
||||||
font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */
|
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; }
|
.left { float: left; }
|
||||||
.right { float: right; }
|
.right { float: right; }
|
||||||
.boring { opacity: 0.6; }
|
.boring { opacity: 0.6; }
|
||||||
|
|
Loading…
Reference in New Issue