Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2d09736

Browse files
author
armandocumate
committedDec 13, 2022
merge conflicts
2 parents 847b4ce + 36e1f01 commit 2d09736

File tree

14 files changed

+102
-36
lines changed

14 files changed

+102
-36
lines changed
 

‎CHANGELOG.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Changelog
22

3+
## mdBook 0.4.22
4+
[40c06f5...4844f72](https://github.com/rust-lang/mdBook/compare/40c06f5...4844f72)
5+
6+
### Added
7+
- Added a `--chapter` option to `mdbook test` to specify a specific chapter to test.
8+
[#1741](https://github.com/rust-lang/mdBook/pull/1741)
9+
- Added CSS styling for `<kbd>` tags.
10+
[#1906](https://github.com/rust-lang/mdBook/pull/1906)
11+
- Added pre-compiled binaries for `x86_64-unknown-linux-musl` and `aarch64-unknown-linux-musl` (see [Releases](https://github.com/rust-lang/mdBook/releases)).
12+
[#1862](https://github.com/rust-lang/mdBook/pull/1862)
13+
- Added `build.extra-watch-dirs` which is an array of additional directories to watch for changes when running `mdbook serve`.
14+
[#1884](https://github.com/rust-lang/mdBook/pull/1884)
15+
16+
### Changed
17+
- Removed the `type="text/javascript"` attribute from `<script>` tags.
18+
[#1881](https://github.com/rust-lang/mdBook/pull/1881)
19+
- Switched to building with Rust Edition 2021.
20+
This raises the minimum supported Rust version to 1.56.
21+
[#1887](https://github.com/rust-lang/mdBook/pull/1887)
22+
- When hidden code is hidden, the hidden parts are no longer copied to the clipboard via the copy button.
23+
[#1911](https://github.com/rust-lang/mdBook/pull/1911)
24+
- Various HTML changes and fixes to be more compliant with HTML5.
25+
[#1924](https://github.com/rust-lang/mdBook/pull/1924)
26+
- The theme picker now shows which theme is currently selected.
27+
[#1935](https://github.com/rust-lang/mdBook/pull/1935)
28+
29+
### Fixed
30+
- Avoid blank line at the end of an ACE code block
31+
[#1836](https://github.com/rust-lang/mdBook/pull/1836)
32+
33+
334
## mdBook 0.4.21
435
[92afe9b...8f01d02](https://github.com/rust-lang/mdBook/compare/92afe9b...8f01d02)
536

‎Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "mdbook"
3-
version = "0.4.21"
3+
version = "0.4.22"
44
authors = [
55
"Mathieu David <mathieudavid@mathieudavid.org>",
66
"Michael-F-Bryan <michaelfbryan@gmail.com>",
77
"Matt Ickstadt <mattico8@gmail.com>"
88
]
9-
documentation = "http://rust-lang.github.io/mdBook/index.html"
9+
documentation = "https://rust-lang.github.io/mdBook/index.html"
1010
edition = "2021"
1111
exclude = ["/guide/*"]
1212
keywords = ["book", "gitbook", "rustbook", "markdown"]

‎guide/src/continuous-integration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A simple approach would be to use the popular `curl` CLI tool to download the ex
2121

2222
```sh
2323
mkdir bin
24-
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.21/mdbook-v0.4.21-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
24+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.22/mdbook-v0.4.22-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
2525
bin/mdbook build
2626
```
2727

‎guide/src/format/configuration/general.md

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ This controls the build process of your book.
8787
build-dir = "book" # the directory where the output is placed
8888
create-missing = true # whether or not to create missing pages
8989
use-default-preprocessors = true # use the default preprocessors
90+
extra-watch-dirs = [] # directories to watch for triggering builds
9091
```
9192

9293
- **build-dir:** The directory to put the rendered book in. By default this is
@@ -108,3 +109,6 @@ use-default-preprocessors = true # use the default preprocessors
108109
default preprocessors from running.
109110
- Adding `[preprocessor.links]`, for example, will ensure, regardless of
110111
`use-default-preprocessors` that `links` it will run.
112+
- **extra-watch-dirs**: A list of paths to directories that will be watched in
113+
the `watch` and `serve` commands. Changes to files under these directories will
114+
trigger rebuilds. Useful if your book depends on files outside its `src` directory.

‎guide/src/guide/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ To make it easier to run, put the path to the binary into your `PATH`.
2020

2121
To build the `mdbook` executable from source, you will first need to install Rust and Cargo.
2222
Follow the instructions on the [Rust installation page].
23-
mdBook currently requires at least Rust version 1.54.
23+
mdBook currently requires at least Rust version 1.56.
2424

2525
Once you have installed Rust, the following command can be used to build and install mdBook:
2626

‎src/cmd/watch.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,17 @@ where
146146
// Add the book.toml file to the watcher if it exists
147147
let _ = watcher.watch(book.root.join("book.toml"), NonRecursive);
148148

149+
for dir in &book.config.build.extra_watch_dirs {
150+
let path = dir.canonicalize().unwrap();
151+
if let Err(e) = watcher.watch(&path, Recursive) {
152+
error!(
153+
"Error while watching extra directory {:?}:\n {:?}",
154+
path, e
155+
);
156+
std::process::exit(1);
157+
}
158+
}
159+
149160
info!("Listening for changes...");
150161

151162
loop {
@@ -166,7 +177,11 @@ where
166177
})
167178
.collect::<Vec<_>>();
168179

169-
let paths = remove_ignored_files(&book.root, &paths[..]);
180+
// If we are watching files outside the current repository (via extra-watch-dirs), then they are definitionally
181+
// ignored by gitignore. So we handle this case by including such files into the watched paths list.
182+
let any_external_paths = paths.iter().filter(|p| !p.starts_with(&book.root)).cloned();
183+
let mut paths = remove_ignored_files(&book.root, &paths[..]);
184+
paths.extend(any_external_paths);
170185

171186
if !paths.is_empty() {
172187
closure(paths, &book.root);

‎src/config.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ pub struct BuildConfig {
438438
/// Should the default preprocessors always be used when they are
439439
/// compatible with the renderer?
440440
pub use_default_preprocessors: bool,
441+
/// Extra directories to trigger rebuild when watching/serving
442+
pub extra_watch_dirs: Vec<PathBuf>,
441443
}
442444

443445
impl Default for BuildConfig {
@@ -446,6 +448,7 @@ impl Default for BuildConfig {
446448
build_dir: PathBuf::from("book"),
447449
create_missing: true,
448450
use_default_preprocessors: true,
451+
extra_watch_dirs: Vec::new(),
449452
}
450453
}
451454
}
@@ -527,10 +530,9 @@ pub struct HtmlConfig {
527530
/// directly jumping to editing the currently viewed page.
528531
/// Contains {path} that is replaced with chapter source file path
529532
pub edit_url_template: Option<String>,
530-
/// Endpoint of websocket, for livereload usage. Value loaded from .toml file
531-
/// is ignored, because our code overrides this field with the value [`LIVE_RELOAD_ENDPOINT`]
532-
///
533-
/// [`LIVE_RELOAD_ENDPOINT`]: cmd::serve::LIVE_RELOAD_ENDPOINT
533+
/// Endpoint of websocket, for livereload usage. Value loaded from .toml
534+
/// file is ignored, because our code overrides this field with an
535+
/// internal value (`LIVE_RELOAD_ENDPOINT)
534536
///
535537
/// This config item *should not be edited* by the end user.
536538
#[doc(hidden)]
@@ -772,6 +774,7 @@ mod tests {
772774
build_dir: PathBuf::from("outputs"),
773775
create_missing: false,
774776
use_default_preprocessors: true,
777+
extra_watch_dirs: Vec::new(),
775778
};
776779
let rust_should_be = RustConfig { edition: None };
777780
let playground_should_be = Playground {
@@ -982,6 +985,7 @@ mod tests {
982985
build_dir: PathBuf::from("my-book"),
983986
create_missing: true,
984987
use_default_preprocessors: true,
988+
extra_watch_dirs: Vec::new(),
985989
};
986990

987991
let html_should_be = HtmlConfig {

‎src/renderer/html_handlebars/hbs_renderer.rs

+2
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ impl HtmlHandlebars {
340340
);
341341
handlebars.register_helper("previous", Box::new(helpers::navigation::previous));
342342
handlebars.register_helper("next", Box::new(helpers::navigation::next));
343+
// TODO: remove theme_option in 0.5, it is not needed.
343344
handlebars.register_helper("theme_option", Box::new(helpers::theme::theme_option));
344345
}
345346

@@ -630,6 +631,7 @@ fn make_data(
630631
);
631632
}
632633

634+
// TODO: remove default_theme in 0.5, it is not needed.
633635
let default_theme = match html_config.default_theme {
634636
Some(ref theme) => theme.to_lowercase(),
635637
None => "light".to_string(),

‎src/theme/book.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ function playground_text(playground, hidden = true) {
168168
.filter(function (node) {return node.classList.contains("editable"); })
169169
.forEach(function (block) { block.classList.remove('language-rust'); });
170170

171-
Array
172171
code_nodes
173172
.filter(function (node) {return !node.classList.contains("editable"); })
174173
.forEach(function (block) { hljs.highlightBlock(block); });
@@ -302,6 +301,13 @@ function playground_text(playground, hidden = true) {
302301
themePopup.querySelector("button#" + get_theme()).focus();
303302
}
304303

304+
function updateThemeSelected() {
305+
themePopup.querySelectorAll('.theme-selected').forEach(function (el) {
306+
el.classList.remove('theme-selected');
307+
});
308+
themePopup.querySelector("button#" + get_theme()).classList.add('theme-selected');
309+
}
310+
305311
function hideThemes() {
306312
themePopup.style.display = 'none';
307313
themeToggleButton.setAttribute('aria-expanded', false);
@@ -357,6 +363,7 @@ function playground_text(playground, hidden = true) {
357363

358364
html.classList.remove(previousTheme);
359365
html.classList.add(theme);
366+
updateThemeSelected();
360367
}
361368

362369
// Set theme

‎src/theme/css/chrome.css

+9-5
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ ul#searchresults span.teaser em {
507507
padding: 0;
508508
list-style: none;
509509
display: none;
510+
/* Don't let the children's background extend past the rounded corners. */
511+
overflow: hidden;
510512
}
511513
.theme-popup .default {
512514
color: var(--icons);
@@ -515,7 +517,7 @@ ul#searchresults span.teaser em {
515517
width: 100%;
516518
border: 0;
517519
margin: 0;
518-
padding: 2px 10px;
520+
padding: 2px 20px;
519521
line-height: 25px;
520522
white-space: nowrap;
521523
text-align: left;
@@ -527,8 +529,10 @@ ul#searchresults span.teaser em {
527529
.theme-popup .theme:hover {
528530
background-color: var(--theme-hover);
529531
}
530-
.theme-popup .theme:hover:first-child,
531-
.theme-popup .theme:hover:last-child {
532-
border-top-left-radius: inherit;
533-
border-top-right-radius: inherit;
532+
533+
.theme-selected::before {
534+
display: inline-block;
535+
content: "✓";
536+
margin-left: -14px;
537+
width: 14px;
534538
}

‎src/theme/index.hbs

+16-17
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<!-- Custom HTML head -->
1616
{{> head}}
1717

18-
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
1918
<meta name="description" content="{{ description }}">
2019
<meta name="viewport" content="width=device-width, initial-scale=1">
2120
<meta name="theme-color" content="#ffffff" />
@@ -122,11 +121,11 @@
122121
<i class="fa fa-paint-brush"></i>
123122
</button>
124123
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
125-
<li role="none"><button role="menuitem" class="theme" id="light">{{ theme_option "Light" }}</button></li>
126-
<li role="none"><button role="menuitem" class="theme" id="rust">{{ theme_option "Rust" }}</button></li>
127-
<li role="none"><button role="menuitem" class="theme" id="coal">{{ theme_option "Coal" }}</button></li>
128-
<li role="none"><button role="menuitem" class="theme" id="navy">{{ theme_option "Navy" }}</button></li>
129-
<li role="none"><button role="menuitem" class="theme" id="ayu">{{ theme_option "Ayu" }}</button></li>
124+
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
125+
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
126+
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
127+
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
128+
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
130129
</ul>
131130
{{#if search_enabled}}
132131
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
@@ -270,22 +269,22 @@
270269
{{/if}}
271270

272271
{{#if playground_js}}
273-
<script src="{{ path_to_root }}ace.js" charset="utf-8"></script>
274-
<script src="{{ path_to_root }}editor.js" charset="utf-8"></script>
275-
<script src="{{ path_to_root }}mode-rust.js" charset="utf-8"></script>
276-
<script src="{{ path_to_root }}theme-dawn.js" charset="utf-8"></script>
277-
<script src="{{ path_to_root }}theme-tomorrow_night.js" charset="utf-8"></script>
272+
<script src="{{ path_to_root }}ace.js"></script>
273+
<script src="{{ path_to_root }}editor.js"></script>
274+
<script src="{{ path_to_root }}mode-rust.js"></script>
275+
<script src="{{ path_to_root }}theme-dawn.js"></script>
276+
<script src="{{ path_to_root }}theme-tomorrow_night.js"></script>
278277
{{/if}}
279278

280279
{{#if search_js}}
281-
<script src="{{ path_to_root }}elasticlunr.min.js" charset="utf-8"></script>
282-
<script src="{{ path_to_root }}mark.min.js" charset="utf-8"></script>
283-
<script src="{{ path_to_root }}searcher.js" charset="utf-8"></script>
280+
<script src="{{ path_to_root }}elasticlunr.min.js"></script>
281+
<script src="{{ path_to_root }}mark.min.js"></script>
282+
<script src="{{ path_to_root }}searcher.js"></script>
284283
{{/if}}
285284

286-
<script src="{{ path_to_root }}clipboard.min.js" charset="utf-8"></script>
287-
<script src="{{ path_to_root }}highlight.js" charset="utf-8"></script>
288-
<script src="{{ path_to_root }}book.js" charset="utf-8"></script>
285+
<script src="{{ path_to_root }}clipboard.min.js"></script>
286+
<script src="{{ path_to_root }}highlight.js"></script>
287+
<script src="{{ path_to_root }}book.js"></script>
289288

290289
<!-- Custom JS scripts -->
291290
{{#each additional_js}}

‎src/theme/redirect.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Redirecting...</title>
6-
<meta http-equiv="refresh" content="0;URL='{{url}}'">
7-
<meta rel="canonical" href="{{url}}">
6+
<meta http-equiv="refresh" content="0; URL={{url}}">
7+
<link rel="canonical" href="{{url}}">
88
</head>
99
<body>
1010
<p>Redirecting to... <a href="{{url}}">{{url}}</a>.</p>

‎tests/init.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn run_mdbook_init_with_custom_book_and_src_locations() {
9595
let contents = fs::read_to_string(temp.path().join("book.toml")).unwrap();
9696
assert_eq!(
9797
contents,
98-
"[book]\nauthors = []\nlanguage = \"en\"\nmultilingual = false\nsrc = \"in\"\n\n[build]\nbuild-dir = \"out\"\ncreate-missing = true\nuse-default-preprocessors = true\n"
98+
"[book]\nauthors = []\nlanguage = \"en\"\nmultilingual = false\nsrc = \"in\"\n\n[build]\nbuild-dir = \"out\"\ncreate-missing = true\nextra-watch-dirs = []\nuse-default-preprocessors = true\n"
9999
);
100100
}
101101

0 commit comments

Comments
 (0)
Please sign in to comment.