From 41c7e7265c387e3cad26c0d97685e8279d6b476d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 1 May 2020 06:11:26 +0000 Subject: [PATCH] deploy: 75014632413b319cb87db5b3e54bba2d6a21ac05 --- book.js | 37 ++++++++++++++++++++++--------------- chapter_1.html | 4 ++-- css/chrome.css | 2 +- css/general.css | 5 +++++ index.html | 4 ++-- print.html | 4 ++-- 6 files changed, 34 insertions(+), 22 deletions(-) diff --git a/book.js b/book.js index 8fda7a6..a335324 100644 --- a/book.js +++ b/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) { @@ -284,7 +285,7 @@ function playpen_text(playpen) { function showThemes() { themePopup.style.display = 'block'; themeToggleButton.setAttribute('aria-expanded', true); - themePopup.querySelector("button#" + document.body.className).focus(); + themePopup.querySelector("button#" + get_theme()).focus(); } function hideThemes() { @@ -293,6 +294,16 @@ function playpen_text(playpen) { themeToggleButton.focus(); } + function get_theme() { + var theme; + try { theme = localStorage.getItem('mdbook-theme'); } catch (e) { } + if (theme === null || theme === undefined) { + return default_theme; + } else { + return theme; + } + } + function set_theme(theme, store = true) { let ace_theme; @@ -324,9 +335,7 @@ function playpen_text(playpen) { }); } - var previousTheme; - try { previousTheme = localStorage.getItem('mdbook-theme'); } catch (e) { } - if (previousTheme === null || previousTheme === undefined) { previousTheme = default_theme; } + var previousTheme = get_theme(); if (store) { try { localStorage.setItem('mdbook-theme', theme); } catch (e) { } @@ -337,9 +346,7 @@ function playpen_text(playpen) { } // Set theme - var theme; - try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } - if (theme === null || theme === undefined) { theme = default_theme; } + var theme = get_theme(); set_theme(theme, false); @@ -408,7 +415,6 @@ function playpen_text(playpen) { (function sidebar() { var html = document.querySelector("html"); var sidebar = document.getElementById("sidebar"); - var sidebarScrollBox = document.querySelector(".sidebar-scrollbox"); var sidebarLinks = document.querySelectorAll('#sidebar a'); var sidebarToggleButton = document.getElementById("sidebar-toggle"); var sidebarResizeHandle = document.getElementById("sidebar-resize-handle"); @@ -507,7 +513,8 @@ function playpen_text(playpen) { // Scroll sidebar to current active section var activeSection = document.getElementById("sidebar").querySelector(".active"); if (activeSection) { - sidebarScrollBox.scrollTop = activeSection.offsetTop; + // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView + activeSection.scrollIntoView({ block: 'center' }); } })(); diff --git a/chapter_1.html b/chapter_1.html index a3f53b2..66778b2 100644 --- a/chapter_1.html +++ b/chapter_1.html @@ -80,8 +80,8 @@ diff --git a/css/chrome.css b/css/chrome.css index 33ca3ab..9ca8633 100644 --- a/css/chrome.css +++ b/css/chrome.css @@ -423,7 +423,7 @@ ul#searchresults span.teaser em { display: none; } -.chapter li.expanded { +.chapter li.chapter-item { line-height: 1.5em; margin-top: 0.6em; } diff --git a/css/general.css b/css/general.css index 65c2777..e2df5d6 100644 --- a/css/general.css +++ b/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; } diff --git a/index.html b/index.html index 560aa00..c6091e9 100644 --- a/index.html +++ b/index.html @@ -80,8 +80,8 @@ diff --git a/print.html b/print.html index bf084cb..6c6252b 100644 --- a/print.html +++ b/print.html @@ -82,8 +82,8 @@