mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Avoid overriding rustdoc highlighting
Only run highlight.js on .60 code blocks, to not interfere with rustdoc Relates to #282
This commit is contained in:
parent
8ecddc120a
commit
0236bbcf07
1 changed files with 8 additions and 3 deletions
|
@ -63,15 +63,18 @@
|
||||||
<script src="https://sixtyfps.io/highlight.pack.js"></script>
|
<script src="https://sixtyfps.io/highlight.pack.js"></script>
|
||||||
<script src="https://sixtyfps.io/highlight_60.js"></script>
|
<script src="https://sixtyfps.io/highlight_60.js"></script>
|
||||||
<script>
|
<script>
|
||||||
hljs.initHighlightingOnLoad();
|
|
||||||
// If we're running in rustdoc, change the hljs generated classes to the rustdoc
|
// If we're running in rustdoc, change the hljs generated classes to the rustdoc
|
||||||
// ones, so that the highlighting adjusts to the theme correctly.
|
// ones, so that the highlighting adjusts to the theme correctly.
|
||||||
if (window.localStorage.getItem("rustdoc-theme") !== null) {
|
if (window.localStorage.getItem("rustdoc-theme") !== null) {
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
|
// Only highlight .60 blocks, leave the others to rustdoc
|
||||||
|
for (dot60Block of document.querySelectorAll("pre code.language-60")) {
|
||||||
|
hljs.highlightBlock(dot60Block)
|
||||||
|
}
|
||||||
|
|
||||||
// Some of the rustdoc selectors require the pre element to have the rust class
|
// Some of the rustdoc selectors require the pre element to have the rust class
|
||||||
for (codeBlocks of document.querySelectorAll(".language-60.hljs")) {
|
for (codeBlock of document.querySelectorAll(".language-60.hljs")) {
|
||||||
codeBlocks.parentElement.classList.add("rust")
|
codeBlock.parentElement.classList.add("rust")
|
||||||
}
|
}
|
||||||
|
|
||||||
const highlightJSToRustDoc = [
|
const highlightJSToRustDoc = [
|
||||||
|
@ -92,5 +95,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
hljs.initHighlightingOnLoad();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue