From a2c88ae0f17b7ffacd551a6b410ef8a0a384a3ac Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Sun, 2 Apr 2023 21:35:08 +0200 Subject: [PATCH 01/48] Convert links from http to https protocol --- .github/workflows/main.yml | 4 ++-- guide/src/format/theme/README.md | 2 +- src/config.rs | 2 +- src/theme/book.js | 2 +- src/theme/tomorrow-night.css | 4 ++-- test_book/src/individual/image.md | 8 ++++---- test_book/src/individual/mixed.md | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 37ccfde9..51254983 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,7 @@ jobs: # sync MSRV with docs: guide/src/guide/installation.md and Cargo.toml rust: 1.60.0 steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Install Rust run: bash ci/install-rust.sh ${{ matrix.rust }} - name: Build and run tests @@ -46,7 +46,7 @@ jobs: name: Rustfmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Install Rust run: rustup update stable && rustup default stable && rustup component add rustfmt - run: cargo fmt --check diff --git a/guide/src/format/theme/README.md b/guide/src/format/theme/README.md index 1aeb6dc7..23da5a04 100644 --- a/guide/src/format/theme/README.md +++ b/guide/src/format/theme/README.md @@ -1,6 +1,6 @@ # Theme -The default renderer uses a [handlebars](http://handlebarsjs.com/) template to +The default renderer uses a [handlebars](https://handlebarsjs.com) template to render your markdown files and comes with a default theme included in the mdBook binary. diff --git a/src/config.rs b/src/config.rs index 0c367d84..1a30c507 100644 --- a/src/config.rs +++ b/src/config.rs @@ -308,7 +308,7 @@ impl<'de> serde::Deserialize<'de> for Config { warn!("`description` under a table called `[book]`, move the `destination` entry"); warn!("from `[output.html]`, renamed to `build-dir`, under a table called"); warn!("`[build]`, and it should all work."); - warn!("Documentation: http://rust-lang.github.io/mdBook/format/config.html"); + warn!("Documentation: https://rust-lang.github.io/mdBook/format/config.html"); return Ok(Config::from_legacy(raw)); } diff --git a/src/theme/book.js b/src/theme/book.js index e303ebb4..f2516be7 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -68,7 +68,7 @@ function playground_text(playground, hidden = true) { } // updates the visibility of play button based on `no_run` class and - // used crates vs ones available on http://play.rust-lang.org + // used crates vs ones available on https://play.rust-lang.org function update_play_button(pre_block, playground_crates) { var play_button = pre_block.querySelector(".play-button"); diff --git a/src/theme/tomorrow-night.css b/src/theme/tomorrow-night.css index 5b4aca77..81fe276e 100644 --- a/src/theme/tomorrow-night.css +++ b/src/theme/tomorrow-night.css @@ -1,7 +1,7 @@ /* Tomorrow Night Theme */ -/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ +/* https://github.com/jmblog/color-themes-for-highlightjs */ /* Original theme - https://github.com/chriskempson/tomorrow-theme */ -/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ +/* https://github.com/jmblog/color-themes-for-highlightjs */ /* Tomorrow Comment */ .hljs-comment { diff --git a/test_book/src/individual/image.md b/test_book/src/individual/image.md index c73db95a..8bb66d33 100644 --- a/test_book/src/individual/image.md +++ b/test_book/src/individual/image.md @@ -4,19 +4,19 @@ For copyright and trademark information on these images, please check [rust-artw ## A 16x16 image -![16x16 rust-lang logo](http://rust-lang.org/logos/rust-logo-16x16.png) +![16x16 rust-lang logo](https://rust-lang.org/logos/rust-logo-16x16.png) ## A 32x32 image -![32x32 rust-lang logo](http://rust-lang.org/logos/rust-logo-32x32-blk.png) +![32x32 rust-lang logo](https://rust-lang.org/logos/rust-logo-32x32-blk.png) ## A 256x256 image -![256x256 rust-lang logo](http://rust-lang.org/logos/rust-logo-256x256.png) +![256x256 rust-lang logo](https://rust-lang.org/logos/rust-logo-256x256.png) ## A 512x512 image -![512x512 rust-lang logo](http://rust-lang.org/logos/rust-logo-512x512-blk.png) +![512x512 rust-lang logo](https://rust-lang.org/logos/rust-logo-512x512-blk.png) ## A large image diff --git a/test_book/src/individual/mixed.md b/test_book/src/individual/mixed.md index e9d101b2..10b487a0 100644 --- a/test_book/src/individual/mixed.md +++ b/test_book/src/individual/mixed.md @@ -31,7 +31,7 @@ fn main(){ A random image sprinkled in between -![16x16 rust-lang logo](http://rust-lang.org/logos/rust-logo-16x16.png) +![16x16 rust-lang logo](https://rust-lang.org/logos/rust-logo-16x16.png) --- From bffdb0b03d7b94af26083053191a4d77feb4fb1a Mon Sep 17 00:00:00 2001 From: Sean Poulter Date: Mon, 3 Apr 2023 23:00:40 -0400 Subject: [PATCH 02/48] fix(cli): init --force skips confirmation prompts --- src/cmd/init.rs | 4 +++- tests/cli/init.rs | 24 ++++++++++++++++++++++++ tests/cli/mod.rs | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/cli/init.rs diff --git a/src/cmd/init.rs b/src/cmd/init.rs index d8ce93d1..3a60d975 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -56,7 +56,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> { "git" => builder.create_gitignore(true), _ => builder.create_gitignore(false), }; - } else { + } else if !args.get_flag("force") { println!("\nDo you want a .gitignore to be created? (y/n)"); if confirm() { builder.create_gitignore(true); @@ -65,6 +65,8 @@ pub fn execute(args: &ArgMatches) -> Result<()> { config.book.title = if args.contains_id("title") { args.get_one::("title").map(String::from) + } else if args.get_flag("force") { + None } else { request_book_title() }; diff --git a/tests/cli/init.rs b/tests/cli/init.rs new file mode 100644 index 00000000..7f992237 --- /dev/null +++ b/tests/cli/init.rs @@ -0,0 +1,24 @@ +use crate::cli::cmd::mdbook_cmd; +use crate::dummy_book::DummyBook; + +use mdbook::config::Config; + +/// Run `mdbook init` with `--force` to skip the confirmation prompts +#[test] +fn base_mdbook_init_can_skip_confirmation_prompts() { + let temp = DummyBook::new().build().unwrap(); + + // doesn't exist before + assert!(!temp.path().join("book").exists()); + + let mut cmd = mdbook_cmd(); + cmd.args(&["init", "--force"]).current_dir(temp.path()); + cmd.assert() + .success() + .stdout(predicates::str::contains("\nAll done, no errors...\n")); + + let config = Config::from_disk(temp.path().join("book.toml")).unwrap(); + assert_eq!(config.book.title, None); + + assert!(!temp.path().join(".gitignore").exists()); +} diff --git a/tests/cli/mod.rs b/tests/cli/mod.rs index 989f443f..152b4ee9 100644 --- a/tests/cli/mod.rs +++ b/tests/cli/mod.rs @@ -1,3 +1,4 @@ mod build; mod cmd; +mod init; mod test; From 0003072623b6de669c6f563fd9f49c09afec3154 Mon Sep 17 00:00:00 2001 From: Sean Poulter Date: Mon, 3 Apr 2023 08:36:47 -0400 Subject: [PATCH 03/48] docs(cli): Add docs for --force --- guide/src/cli/init.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guide/src/cli/init.md b/guide/src/cli/init.md index 99c0be09..5d0f9032 100644 --- a/guide/src/cli/init.md +++ b/guide/src/cli/init.md @@ -68,3 +68,7 @@ Create a `.gitignore` file configured to ignore the `book` directory created whe If not supplied, an interactive prompt will ask whether it should be created. [building]: build.md + +#### --force + +Skip the prompts to create a `.gitignore` and for the title for the book. From b9c6b326b7a65996884d881efd39ec08b22c4fe5 Mon Sep 17 00:00:00 2001 From: Sean Poulter Date: Mon, 3 Apr 2023 08:36:57 -0400 Subject: [PATCH 04/48] style(tests): Fixed issues reported by clippy --- tests/cli/init.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cli/init.rs b/tests/cli/init.rs index 7f992237..6bd12274 100644 --- a/tests/cli/init.rs +++ b/tests/cli/init.rs @@ -12,7 +12,7 @@ fn base_mdbook_init_can_skip_confirmation_prompts() { assert!(!temp.path().join("book").exists()); let mut cmd = mdbook_cmd(); - cmd.args(&["init", "--force"]).current_dir(temp.path()); + cmd.args(["init", "--force"]).current_dir(temp.path()); cmd.assert() .success() .stdout(predicates::str::contains("\nAll done, no errors...\n")); From c624fc078ba5cf62779692b2d05a20130c4b132e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Apr 2023 17:04:53 +0000 Subject: [PATCH 05/48] Bump h2 from 0.3.15 to 0.3.17 Bumps [h2](https://github.com/hyperium/h2) from 0.3.15 to 0.3.17. - [Release notes](https://github.com/hyperium/h2/releases) - [Changelog](https://github.com/hyperium/h2/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/h2/compare/v0.3.15...v0.3.17) --- updated-dependencies: - dependency-name: h2 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b05b697..d3ac85e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -526,9 +526,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "h2" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "66b91535aa35fea1523ad1b86cb6b53c28e0ae566ba4a460f4457e936cad7c6f" dependencies = [ "bytes", "fnv", From 7a435be018a96e12dd290ac209136cfb22dfa166 Mon Sep 17 00:00:00 2001 From: expikr <77922942+expikr@users.noreply.github.com> Date: Tue, 18 Apr 2023 01:53:38 +0800 Subject: [PATCH 06/48] Update init.md --- guide/src/cli/init.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/guide/src/cli/init.md b/guide/src/cli/init.md index 99c0be09..9256d860 100644 --- a/guide/src/cli/init.md +++ b/guide/src/cli/init.md @@ -67,4 +67,12 @@ mdbook init --title="my amazing book" Create a `.gitignore` file configured to ignore the `book` directory created when [building] a book. If not supplied, an interactive prompt will ask whether it should be created. +```bash +mdbook init --ignore=none +``` + +```bash +mdbook init --ignore=git +``` + [building]: build.md From 35fdd0020318048c3f6040ded9862da5bc783acc Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 22 Apr 2023 12:49:39 -0700 Subject: [PATCH 07/48] Switch from gitignore to ignore --- .github/workflows/main.yml | 2 +- Cargo.lock | 57 +++++++++++++++++++++++++-------- Cargo.toml | 10 +++--- guide/src/guide/installation.md | 2 +- src/cmd/watch.rs | 30 ++++++++--------- 5 files changed, 64 insertions(+), 37 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 51254983..fd6841d4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: - build: msrv os: ubuntu-20.04 # sync MSRV with docs: guide/src/guide/installation.md and Cargo.toml - rust: 1.60.0 + rust: 1.63.0 steps: - uses: actions/checkout@v3 - name: Install Rust diff --git a/Cargo.lock b/Cargo.lock index d3ac85e2..f9dfe4ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.0.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca0852af221f458706eb0725c03e4ed6c46af9ac98e6a689d5e634215d594dd" +checksum = "c3d4260bcc2e8fc9df1eac4919a720effeb63a3f0952f5bf4944adfa18897f09" dependencies = [ "memchr", "once_cell", @@ -510,20 +510,18 @@ dependencies = [ ] [[package]] -name = "gitignore" -version = "1.0.7" +name = "globset" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78aa90e4620c1498ac434c06ba6e521b525794bbdacf085d490cc794b4a2f9a4" +checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "glob", + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", ] -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - [[package]] name = "h2" version = "0.3.17" @@ -718,6 +716,23 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "ignore" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +dependencies = [ + "globset", + "lazy_static", + "log", + "memchr", + "regex", + "same-file", + "thread_local", + "walkdir", + "winapi-util", +] + [[package]] name = "indexmap" version = "1.9.2" @@ -823,6 +838,12 @@ dependencies = [ "libc", ] +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "libc" version = "0.2.138" @@ -914,8 +935,8 @@ dependencies = [ "elasticlunr-rs", "env_logger", "futures-util", - "gitignore", "handlebars", + "ignore", "log", "memchr", "notify", @@ -1658,6 +1679,16 @@ dependencies = [ "syn", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "tinyvec" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index ab3eae1f..f12e22ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ license = "MPL-2.0" readme = "README.md" repository = "https://github.com/rust-lang/mdBook" description = "Creates a book from markdown files" -rust-version = "1.60" +rust-version = "1.63" [dependencies] anyhow = "1.0.28" @@ -39,7 +39,7 @@ topological-sort = "0.2.2" # Watch feature notify = { version = "5.0.0", optional = true } notify-debouncer-mini = { version = "0.2.1", optional = true } -gitignore = { version = "1.0", optional = true } +ignore = { version = "0.4.20", optional = true } # Serve feature futures-util = { version = "0.3.4", optional = true } @@ -60,9 +60,9 @@ walkdir = "2.0" [features] default = ["watch", "serve", "search"] -watch = ["notify", "notify-debouncer-mini", "gitignore"] -serve = ["futures-util", "tokio", "warp"] -search = ["elasticlunr-rs", "ammonia"] +watch = ["dep:notify", "dep:notify-debouncer-mini", "dep:ignore"] +serve = ["dep:futures-util", "dep:tokio", "dep:warp"] +search = ["dep:elasticlunr-rs", "dep:ammonia"] [[bin]] doc = false diff --git a/guide/src/guide/installation.md b/guide/src/guide/installation.md index e6ddc1ac..34b9c9e4 100644 --- a/guide/src/guide/installation.md +++ b/guide/src/guide/installation.md @@ -20,7 +20,7 @@ To make it easier to run, put the path to the binary into your `PATH`. To build the `mdbook` executable from source, you will first need to install Rust and Cargo. Follow the instructions on the [Rust installation page]. -mdBook currently requires at least Rust version 1.60. +mdBook currently requires at least Rust version 1.63. Once you have installed Rust, the following command can be used to build and install mdBook: diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index bbc6bde7..4cc1b131 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -1,5 +1,6 @@ use super::command_prelude::*; use crate::{get_book_dir, open}; +use ignore::gitignore::Gitignore; use mdbook::errors::Result; use mdbook::utils; use mdbook::MDBook; @@ -62,14 +63,14 @@ fn remove_ignored_files(book_root: &Path, paths: &[PathBuf]) -> Vec { match find_gitignore(book_root) { Some(gitignore_path) => { - match gitignore::File::new(gitignore_path.as_path()) { - Ok(exclusion_checker) => filter_ignored_files(exclusion_checker, paths), - Err(_) => { - // We're unable to read the .gitignore file, so we'll silently allow everything. - // Please see discussion: https://github.com/rust-lang/mdBook/pull/1051 - paths.iter().map(|path| path.to_path_buf()).collect() - } + let (ignore, err) = Gitignore::new(&gitignore_path); + if let Some(err) = err { + warn!( + "error reading gitignore `{}`: {err}", + gitignore_path.display() + ); } + filter_ignored_files(ignore, paths) } None => { // There is no .gitignore file. @@ -85,18 +86,13 @@ fn find_gitignore(book_root: &Path) -> Option { .find(|p| p.exists()) } -fn filter_ignored_files(exclusion_checker: gitignore::File, paths: &[PathBuf]) -> Vec { +fn filter_ignored_files(ignore: Gitignore, paths: &[PathBuf]) -> Vec { paths .iter() - .filter(|path| match exclusion_checker.is_excluded(path) { - Ok(exclude) => !exclude, - Err(error) => { - warn!( - "Unable to determine if {:?} is excluded: {:?}. Including it.", - &path, error - ); - true - } + .filter(|path| { + !ignore + .matched_path_or_any_parents(path, path.is_dir()) + .is_ignore() }) .map(|path| path.to_path_buf()) .collect() From 04016f3be67aa61a463ce7ad39b5260626fbae76 Mon Sep 17 00:00:00 2001 From: Tetsuya Morimoto Date: Fri, 28 Apr 2023 12:46:49 +0900 Subject: [PATCH 08/48] Refactor the warning message related to copy_fonts so that a user simply configures it --- src/renderer/html_handlebars/hbs_renderer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index e170e2fc..479f5a78 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -294,7 +294,7 @@ impl HtmlHandlebars { if html_config.copy_fonts { warn!( "output.html.copy_fonts is deprecated.\n\ - Set copy_fonts=false and ensure the fonts you want are in \ + Set copy-fonts=false in book.toml and ensure the fonts you want are in \ the `theme/fonts/` directory." ); } @@ -304,7 +304,7 @@ impl HtmlHandlebars { if !html_config.copy_fonts && theme.fonts_css.is_none() { warn!( "output.html.copy_fonts is deprecated.\n\ - This book appears to have copy_fonts=false without a fonts.css file.\n\ + This book appears to have copy-fonts=false in book.toml without a fonts.css file.\n\ Add an empty `theme/fonts/fonts.css` file to squelch this warning." ); } From aac6de01ded9a4f578161cc772d3b1569ab0956b Mon Sep 17 00:00:00 2001 From: liutailin <67492103+cn-liutailin@users.noreply.github.com> Date: Sat, 13 May 2023 00:04:12 +0800 Subject: [PATCH 09/48] Update renderers.md Missing symbol ":" --- guide/src/format/configuration/renderers.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/guide/src/format/configuration/renderers.md b/guide/src/format/configuration/renderers.md index 16a42516..e71a9d7b 100644 --- a/guide/src/format/configuration/renderers.md +++ b/guide/src/format/configuration/renderers.md @@ -182,7 +182,7 @@ page-break = true # insert page-break after each chapter - **enable:** Enable print support. When `false`, all print support will not be rendered. Defaults to `true`. -- **page-break** Insert page breaks between chapters. Defaults to `true`. +- **page-break:** Insert page breaks between chapters. Defaults to `true`. ### `[output.html.fold]` @@ -218,8 +218,8 @@ runnable = true # displays a run button for rust code - **copyable:** Display the copy button on code snippets. Defaults to `true`. - **copy-js:** Copy JavaScript files for the editor to the output directory. Defaults to `true`. -- **line-numbers** Display line numbers on editable sections of code. Requires both `editable` and `copy-js` to be `true`. Defaults to `false`. -- **runnable** Displays a run button for rust code snippets. Changing this to `false` will disable the run in playground feature globally. Defaults to `true`. +- **line-numbers:** Display line numbers on editable sections of code. Requires both `editable` and `copy-js` to be `true`. Defaults to `false`. +- **runnable:** Displays a run button for rust code snippets. Changing this to `false` will disable the run in playground feature globally. Defaults to `true`. [Ace]: https://ace.c9.io/ From 75a6d65e5a25c4394f5fd2404d559d2309057df9 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 08:49:17 -0700 Subject: [PATCH 10/48] Don't warn on copy-fonts=true (the default) when fonts.css is overridden. --- src/renderer/html_handlebars/hbs_renderer.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 479f5a78..986b81c2 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -291,19 +291,12 @@ impl HtmlHandlebars { } if let Some(fonts_css) = &theme.fonts_css { if !fonts_css.is_empty() { - if html_config.copy_fonts { - warn!( - "output.html.copy_fonts is deprecated.\n\ - Set copy-fonts=false in book.toml and ensure the fonts you want are in \ - the `theme/fonts/` directory." - ); - } write_file(destination, "fonts/fonts.css", &fonts_css)?; } } if !html_config.copy_fonts && theme.fonts_css.is_none() { warn!( - "output.html.copy_fonts is deprecated.\n\ + "output.html.copy-fonts is deprecated.\n\ This book appears to have copy-fonts=false in book.toml without a fonts.css file.\n\ Add an empty `theme/fonts/fonts.css` file to squelch this warning." ); From 01047846a9df2c517c4c76276b2425bca11312c5 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 08:59:28 -0700 Subject: [PATCH 11/48] Don't copy the stock fonts if the user has overridden fonts.css. This wasn't behaving as I was really intending. --- src/renderer/html_handlebars/hbs_renderer.rs | 3 ++- tests/rendered_output.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 986b81c2..a7c99225 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -275,7 +275,8 @@ impl HtmlHandlebars { "FontAwesome/fonts/FontAwesome.ttf", theme::FONT_AWESOME_TTF, )?; - if html_config.copy_fonts { + // Don't copy the stock fonts if the user has specified their own fonts to use. + if html_config.copy_fonts && theme.fonts_css.is_none() { write_file(destination, "fonts/fonts.css", theme::fonts::CSS)?; for (file_name, contents) in theme::fonts::LICENSES.iter() { write_file(destination, file_name, contents)?; diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index a279c4f8..12999b44 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -891,8 +891,8 @@ fn custom_fonts() { assert_eq!(actual_files(&p.join("book/fonts")), &builtin_fonts); assert!(has_fonts_css(p)); - // Mixed with copy_fonts=true - // This should generate a deprecation warning. + // Mixed with copy-fonts=true + // Should ignore the copy-fonts setting since the user has provided their own fonts.css. let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap(); let p = temp.path(); MDBook::init(p).build().unwrap(); @@ -900,10 +900,10 @@ fn custom_fonts() { write_file(&p.join("theme/fonts"), "myfont.woff", b"").unwrap(); MDBook::load(p).unwrap().build().unwrap(); assert!(has_fonts_css(p)); - let mut expected = Vec::from(builtin_fonts); - expected.push("myfont.woff"); - expected.sort(); - assert_eq!(actual_files(&p.join("book/fonts")), expected.as_slice()); + assert_eq!( + actual_files(&p.join("book/fonts")), + ["fonts.css", "myfont.woff"] + ); // copy-fonts=false, no theme // This should generate a deprecation warning. From 0985691fbd308729006153d90da0ebac21edad2e Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 09:12:23 -0700 Subject: [PATCH 12/48] Update some direct dependencies --- Cargo.lock | 160 ++++++++++++++++++++++++++++------------------------- 1 file changed, 86 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9dfe4ac..2414f379 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +dependencies = [ + "memchr", +] + [[package]] name = "ammonia" version = "3.3.0" @@ -34,20 +43,27 @@ dependencies = [ ] [[package]] -name = "anyhow" -version = "1.0.69" +name = "anstyle" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anyhow" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "assert_cmd" -version = "2.0.8" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9834fcc22e0874394a010230586367d4a3e9f11b560f469262678547e1d2575e" +checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" dependencies = [ + "anstyle", "bstr", "doc-comment", - "predicates", + "predicates 3.0.3", "predicates-core", "predicates-tree", "wait-timeout", @@ -65,6 +81,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + [[package]] name = "bit-set" version = "0.5.3" @@ -139,9 +161,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "num-integer", @@ -326,9 +348,9 @@ checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "elasticlunr-rs" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94d9c8df0fe6879ca12e7633fdfe467c503722cc981fc463703472d2b876448" +checksum = "41e83863a500656dfa214fee6682de9c5b9f03de6860fec531235ed2ae9f6571" dependencies = [ "regex", "serde", @@ -515,7 +537,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", + "aho-corasick 0.7.20", "bstr", "fnv", "log", @@ -543,9 +565,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.3.6" +version = "4.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "035ef95d03713f2c347a72547b7cd38cbc9af7cd51e6099fb62d586d4a6dee3a" +checksum = "83c3372087601b532857d332f5957cbae686da52bb7810bf038c3e3c3cc2fa0d" dependencies = [ "log", "pest", @@ -567,7 +589,7 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" dependencies = [ - "base64", + "base64 0.13.1", "bitflags", "bytes", "headers-core", @@ -943,7 +965,7 @@ dependencies = [ "notify-debouncer-mini", "once_cell", "opener", - "predicates", + "predicates 2.1.5", "pretty_assertions", "pulldown-cmark", "regex", @@ -1065,9 +1087,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opener" @@ -1264,10 +1286,22 @@ dependencies = [ ] [[package]] -name = "predicates-core" -version = "1.0.5" +name = "predicates" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f883590242d3c6fc5bf50299011695fa6590c2c70eac95ee1bdb9a733ad1a2" +checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9" +dependencies = [ + "anstyle", + "difflib", + "itertools", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" [[package]] name = "predicates-tree" @@ -1361,11 +1395,11 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ - "aho-corasick", + "aho-corasick 1.0.1", "memchr", "regex-syntax", ] @@ -1378,18 +1412,9 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "rustix" @@ -1407,11 +1432,11 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "0.2.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64", + "base64 0.21.0", ] [[package]] @@ -1460,24 +1485,24 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.156" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.156" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" dependencies = [ "proc-macro2", "quote", @@ -1486,9 +1511,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.93" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -1507,17 +1532,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha-1" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sha1" version = "0.10.5" @@ -1611,16 +1625,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ "cfg-if", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix", + "windows-sys", ] [[package]] @@ -1746,9 +1759,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.17.2" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" +checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" dependencies = [ "futures-util", "log", @@ -1772,9 +1785,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] @@ -1820,18 +1833,18 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "tungstenite" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" +checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" dependencies = [ - "base64", + "base64 0.13.1", "byteorder", "bytes", "http", "httparse", "log", "rand", - "sha-1", + "sha1", "thiserror", "url", "utf-8", @@ -1919,12 +1932,11 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -1940,9 +1952,9 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed7b8be92646fc3d18b06147664ebc5f48d222686cb11a8755e561a735aacc6d" +checksum = "ba431ef570df1287f7f8b07e376491ad54f84d26ac473489427231e1718e1f69" dependencies = [ "bytes", "futures-channel", From be966cfe1f5f7da7091dde61a96295a179b6f4b8 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 09:27:32 -0700 Subject: [PATCH 13/48] Raise MSRV to 1.65 --- .github/workflows/main.yml | 2 +- Cargo.toml | 2 +- guide/src/guide/installation.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd6841d4..63566f7f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: - build: msrv os: ubuntu-20.04 # sync MSRV with docs: guide/src/guide/installation.md and Cargo.toml - rust: 1.63.0 + rust: 1.65.0 steps: - uses: actions/checkout@v3 - name: Install Rust diff --git a/Cargo.toml b/Cargo.toml index f12e22ab..c7db01c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ license = "MPL-2.0" readme = "README.md" repository = "https://github.com/rust-lang/mdBook" description = "Creates a book from markdown files" -rust-version = "1.63" +rust-version = "1.65" [dependencies] anyhow = "1.0.28" diff --git a/guide/src/guide/installation.md b/guide/src/guide/installation.md index 34b9c9e4..71213036 100644 --- a/guide/src/guide/installation.md +++ b/guide/src/guide/installation.md @@ -20,7 +20,7 @@ To make it easier to run, put the path to the binary into your `PATH`. To build the `mdbook` executable from source, you will first need to install Rust and Cargo. Follow the instructions on the [Rust installation page]. -mdBook currently requires at least Rust version 1.63. +mdBook currently requires at least Rust version 1.65. Once you have installed Rust, the following command can be used to build and install mdBook: From 45a8575b95107a4fc385936db3508b4043423c98 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 09:44:11 -0700 Subject: [PATCH 14/48] Apply clippy::needless_borrow --- src/book/book.rs | 2 +- src/book/init.rs | 7 ++-- src/book/mod.rs | 12 +++---- src/cmd/build.rs | 2 +- src/cmd/clean.rs | 2 +- src/cmd/init.rs | 2 +- src/cmd/serve.rs | 4 +-- src/cmd/test.rs | 2 +- src/cmd/watch.rs | 4 +-- src/preprocess/links.rs | 4 +-- src/renderer/html_handlebars/hbs_renderer.rs | 6 ++-- .../html_handlebars/helpers/navigation.rs | 2 +- src/renderer/markdown_renderer.rs | 4 +-- src/utils/fs.rs | 35 +++++++++---------- tests/alternative_backends.rs | 2 +- tests/dummy_book/mod.rs | 6 ++-- tests/rendered_output.rs | 8 ++--- 17 files changed, 50 insertions(+), 54 deletions(-) diff --git a/src/book/book.rs b/src/book/book.rs index b46843df..647a8042 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -277,7 +277,7 @@ fn load_chapter>( } let stripped = location - .strip_prefix(&src_dir) + .strip_prefix(src_dir) .expect("Chapters are always inside a book"); Chapter::new(&link.name, content, stripped, parent_names.clone()) diff --git a/src/book/init.rs b/src/book/init.rs index ebcdd934..faca1d09 100644 --- a/src/book/init.rs +++ b/src/book/init.rs @@ -198,8 +198,7 @@ impl BookBuilder { writeln!(f, "- [Chapter 1](./chapter_1.md)")?; let chapter_1 = src_dir.join("chapter_1.md"); - let mut f = - File::create(&chapter_1).with_context(|| "Unable to create chapter_1.md")?; + let mut f = File::create(chapter_1).with_context(|| "Unable to create chapter_1.md")?; writeln!(f, "# Chapter 1")?; } else { trace!("Existing summary found, no need to create stub files."); @@ -212,10 +211,10 @@ impl BookBuilder { fs::create_dir_all(&self.root)?; let src = self.root.join(&self.config.book.src); - fs::create_dir_all(&src)?; + fs::create_dir_all(src)?; let build = self.root.join(&self.config.build.build_dir); - fs::create_dir_all(&build)?; + fs::create_dir_all(build)?; Ok(()) } diff --git a/src/book/mod.rs b/src/book/mod.rs index 33fe93f7..a5e3e78c 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -99,7 +99,7 @@ impl MDBook { let root = book_root.into(); let src_dir = root.join(&config.book.src); - let book = book::load_book(&src_dir, &config.build)?; + let book = book::load_book(src_dir, &config.build)?; let renderers = determine_renderers(&config); let preprocessors = determine_preprocessors(&config)?; @@ -122,7 +122,7 @@ impl MDBook { let root = book_root.into(); let src_dir = root.join(&config.book.src); - let book = book::load_book_from_disk(&summary, &src_dir)?; + let book = book::load_book_from_disk(&summary, src_dir)?; let renderers = determine_renderers(&config); let preprocessors = determine_preprocessors(&config)?; @@ -309,7 +309,7 @@ impl MDBook { info!("Testing chapter '{}': {:?}", ch.name, chapter_path); // write preprocessed file to tempdir - let path = temp_dir.path().join(&chapter_path); + let path = temp_dir.path().join(chapter_path); let mut tmpf = utils::fs::create_file(&path)?; tmpf.write_all(ch.content.as_bytes())?; @@ -319,13 +319,13 @@ impl MDBook { if let Some(edition) = self.config.rust.edition { match edition { RustEdition::E2015 => { - cmd.args(&["--edition", "2015"]); + cmd.args(["--edition", "2015"]); } RustEdition::E2018 => { - cmd.args(&["--edition", "2018"]); + cmd.args(["--edition", "2018"]); } RustEdition::E2021 => { - cmd.args(&["--edition", "2021"]); + cmd.args(["--edition", "2021"]); } } } diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 14a9fec6..e40e5c0c 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -16,7 +16,7 @@ pub fn make_subcommand() -> Command { // Build command implementation pub fn execute(args: &ArgMatches) -> Result<()> { let book_dir = get_book_dir(args); - let mut book = MDBook::load(&book_dir)?; + let mut book = MDBook::load(book_dir)?; if let Some(dest_dir) = args.get_one::("dest-dir") { book.config.build.build_dir = dest_dir.into(); diff --git a/src/cmd/clean.rs b/src/cmd/clean.rs index 3ec605fe..48b4147c 100644 --- a/src/cmd/clean.rs +++ b/src/cmd/clean.rs @@ -16,7 +16,7 @@ pub fn make_subcommand() -> Command { // Clean command implementation pub fn execute(args: &ArgMatches) -> mdbook::errors::Result<()> { let book_dir = get_book_dir(args); - let book = MDBook::load(&book_dir)?; + let book = MDBook::load(book_dir)?; let dir_to_remove = match args.get_one::("dest-dir") { Some(dest_dir) => dest_dir.into(), diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 3a60d975..55d90081 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -86,7 +86,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> { /// Obtains author name from git config file by running the `git config` command. fn get_author_name() -> Option { let output = Command::new("git") - .args(&["config", "--get", "user.name"]) + .args(["config", "--get", "user.name"]) .output() .ok()?; diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index 88898567..eeb19cb3 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -48,7 +48,7 @@ pub fn make_subcommand() -> Command { // Serve command implementation pub fn execute(args: &ArgMatches) -> Result<()> { let book_dir = get_book_dir(args); - let mut book = MDBook::load(&book_dir)?; + let mut book = MDBook::load(book_dir)?; let port = args.get_one::("port").unwrap(); let hostname = args.get_one::("hostname").unwrap(); @@ -102,7 +102,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> { info!("Building book..."); // FIXME: This area is really ugly because we need to re-set livereload :( - let result = MDBook::load(&book_dir).and_then(|mut b| { + let result = MDBook::load(book_dir).and_then(|mut b| { update_config(&mut b); b.build() }); diff --git a/src/cmd/test.rs b/src/cmd/test.rs index 3efe130b..69f99f40 100644 --- a/src/cmd/test.rs +++ b/src/cmd/test.rs @@ -44,7 +44,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> { let chapter: Option<&str> = args.get_one::("chapter").map(|s| s.as_str()); let book_dir = get_book_dir(args); - let mut book = MDBook::load(&book_dir)?; + let mut book = MDBook::load(book_dir)?; if let Some(dest_dir) = args.get_one::("dest-dir") { book.config.build.build_dir = dest_dir.to_path_buf(); diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index 4cc1b131..e9806e1c 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -21,7 +21,7 @@ pub fn make_subcommand() -> Command { // Watch command implementation pub fn execute(args: &ArgMatches) -> Result<()> { let book_dir = get_book_dir(args); - let mut book = MDBook::load(&book_dir)?; + let mut book = MDBook::load(book_dir)?; let update_config = |book: &mut MDBook| { if let Some(dest_dir) = args.get_one::("dest-dir") { @@ -42,7 +42,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> { trigger_on_change(&book, |paths, book_dir| { info!("Files changed: {:?}\nBuilding book...\n", paths); - let result = MDBook::load(&book_dir).and_then(|mut b| { + let result = MDBook::load(book_dir).and_then(|mut b| { update_config(&mut b); b.build() }); diff --git a/src/preprocess/links.rs b/src/preprocess/links.rs index c2c81f52..0af21196 100644 --- a/src/preprocess/links.rs +++ b/src/preprocess/links.rs @@ -93,7 +93,7 @@ where for link in find_links(s) { replaced.push_str(&s[previous_end_index..link.start_index]); - match link.render_with_path(&path, chapter_title) { + match link.render_with_path(path, chapter_title) { Ok(new_content) => { if depth < MAX_LINK_NESTED_DEPTH { if let Some(rel_path) = link.link_type.relative_path(path) { @@ -327,7 +327,7 @@ impl<'a> Link<'a> { let base = base.as_ref(); match self.link_type { // omit the escape char - LinkType::Escaped => Ok((&self.link_text[1..]).to_owned()), + LinkType::Escaped => Ok(self.link_text[1..].to_owned()), LinkType::Include(ref pat, ref range_or_anchor) => { let target = base.join(pat); diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index a7c99225..ee27fd13 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -99,7 +99,7 @@ impl HtmlHandlebars { ctx.data.insert("title".to_owned(), json!(title)); ctx.data.insert( "path_to_root".to_owned(), - json!(utils::fs::path_to_root(&path)), + json!(utils::fs::path_to_root(path)), ); if let Some(ref section) = ch.number { ctx.data @@ -292,7 +292,7 @@ impl HtmlHandlebars { } if let Some(fonts_css) = &theme.fonts_css { if !fonts_css.is_empty() { - write_file(destination, "fonts/fonts.css", &fonts_css)?; + write_file(destination, "fonts/fonts.css", fonts_css)?; } } if !html_config.copy_fonts && theme.fonts_css.is_none() { @@ -547,7 +547,7 @@ impl Renderer for HtmlHandlebars { // Print version let mut print_content = String::new(); - fs::create_dir_all(&destination) + fs::create_dir_all(destination) .with_context(|| "Unexpected error when constructing destination path")?; let mut is_index = true; diff --git a/src/renderer/html_handlebars/helpers/navigation.rs b/src/renderer/html_handlebars/helpers/navigation.rs index b184c441..968a6701 100644 --- a/src/renderer/html_handlebars/helpers/navigation.rs +++ b/src/renderer/html_handlebars/helpers/navigation.rs @@ -127,7 +127,7 @@ fn render( context.insert( "path_to_root".to_owned(), - json!(utils::fs::path_to_root(&base_path)), + json!(utils::fs::path_to_root(base_path)), ); chapter diff --git a/src/renderer/markdown_renderer.rs b/src/renderer/markdown_renderer.rs index 13bd05cc..4a5a5c2a 100644 --- a/src/renderer/markdown_renderer.rs +++ b/src/renderer/markdown_renderer.rs @@ -37,14 +37,14 @@ impl Renderer for MarkdownRenderer { if !ch.is_draft_chapter() { utils::fs::write_file( &ctx.destination, - &ch.path.as_ref().expect("Checked path exists before"), + ch.path.as_ref().expect("Checked path exists before"), ch.content.as_bytes(), )?; } } } - fs::create_dir_all(&destination) + fs::create_dir_all(destination) .with_context(|| "Unexpected error when constructing destination path")?; Ok(()) diff --git a/src/utils/fs.rs b/src/utils/fs.rs index 67f7062d..8ad5aad8 100644 --- a/src/utils/fs.rs +++ b/src/utils/fs.rs @@ -210,39 +210,36 @@ mod tests { }; // Create a couple of files - if let Err(err) = fs::File::create(&tmp.path().join("file.txt")) { + if let Err(err) = fs::File::create(tmp.path().join("file.txt")) { panic!("Could not create file.txt: {}", err); } - if let Err(err) = fs::File::create(&tmp.path().join("file.md")) { + if let Err(err) = fs::File::create(tmp.path().join("file.md")) { panic!("Could not create file.md: {}", err); } - if let Err(err) = fs::File::create(&tmp.path().join("file.png")) { + if let Err(err) = fs::File::create(tmp.path().join("file.png")) { panic!("Could not create file.png: {}", err); } - if let Err(err) = fs::create_dir(&tmp.path().join("sub_dir")) { + if let Err(err) = fs::create_dir(tmp.path().join("sub_dir")) { panic!("Could not create sub_dir: {}", err); } - if let Err(err) = fs::File::create(&tmp.path().join("sub_dir/file.png")) { + if let Err(err) = fs::File::create(tmp.path().join("sub_dir/file.png")) { panic!("Could not create sub_dir/file.png: {}", err); } - if let Err(err) = fs::create_dir(&tmp.path().join("sub_dir_exists")) { + if let Err(err) = fs::create_dir(tmp.path().join("sub_dir_exists")) { panic!("Could not create sub_dir_exists: {}", err); } - if let Err(err) = fs::File::create(&tmp.path().join("sub_dir_exists/file.txt")) { + if let Err(err) = fs::File::create(tmp.path().join("sub_dir_exists/file.txt")) { panic!("Could not create sub_dir_exists/file.txt: {}", err); } - if let Err(err) = symlink( - &tmp.path().join("file.png"), - &tmp.path().join("symlink.png"), - ) { + if let Err(err) = symlink(tmp.path().join("file.png"), tmp.path().join("symlink.png")) { panic!("Could not symlink file.png: {}", err); } // Create output dir - if let Err(err) = fs::create_dir(&tmp.path().join("output")) { + if let Err(err) = fs::create_dir(tmp.path().join("output")) { panic!("Could not create output: {}", err); } - if let Err(err) = fs::create_dir(&tmp.path().join("output/sub_dir_exists")) { + if let Err(err) = fs::create_dir(tmp.path().join("output/sub_dir_exists")) { panic!("Could not create output/sub_dir_exists: {}", err); } @@ -253,22 +250,22 @@ mod tests { } // Check if the correct files where created - if !(&tmp.path().join("output/file.txt")).exists() { + if !tmp.path().join("output/file.txt").exists() { panic!("output/file.txt should exist") } - if (&tmp.path().join("output/file.md")).exists() { + if tmp.path().join("output/file.md").exists() { panic!("output/file.md should not exist") } - if !(&tmp.path().join("output/file.png")).exists() { + if !tmp.path().join("output/file.png").exists() { panic!("output/file.png should exist") } - if !(&tmp.path().join("output/sub_dir/file.png")).exists() { + if !tmp.path().join("output/sub_dir/file.png").exists() { panic!("output/sub_dir/file.png should exist") } - if !(&tmp.path().join("output/sub_dir_exists/file.txt")).exists() { + if !tmp.path().join("output/sub_dir_exists/file.txt").exists() { panic!("output/sub_dir/file.png should exist") } - if !(&tmp.path().join("output/symlink.png")).exists() { + if !tmp.path().join("output/symlink.png").exists() { panic!("output/symlink.png should exist") } } diff --git a/tests/alternative_backends.rs b/tests/alternative_backends.rs index cc7bfc7d..72594e57 100644 --- a/tests/alternative_backends.rs +++ b/tests/alternative_backends.rs @@ -90,7 +90,7 @@ fn relative_command_path() { .set("output.html", toml::value::Table::new()) .unwrap(); config.set("output.myrenderer.command", cmd_path).unwrap(); - let md = MDBook::init(&temp.path()) + let md = MDBook::init(temp.path()) .with_config(config) .build() .unwrap(); diff --git a/tests/dummy_book/mod.rs b/tests/dummy_book/mod.rs index d9d9a068..f91ed9f0 100644 --- a/tests/dummy_book/mod.rs +++ b/tests/dummy_book/mod.rs @@ -112,12 +112,12 @@ fn recursive_copy, B: AsRef>(from: A, to: B) -> Result<()> let from = from.as_ref(); let to = to.as_ref(); - for entry in WalkDir::new(&from) { + for entry in WalkDir::new(from) { let entry = entry.with_context(|| "Unable to inspect directory entry")?; let original_location = entry.path(); let relative = original_location - .strip_prefix(&from) + .strip_prefix(from) .expect("`original_location` is inside the `from` directory"); let new_location = to.join(relative); @@ -126,7 +126,7 @@ fn recursive_copy, B: AsRef>(from: A, to: B) -> Result<()> fs::create_dir_all(parent).with_context(|| "Couldn't create directory")?; } - fs::copy(&original_location, &new_location) + fs::copy(original_location, &new_location) .with_context(|| "Unable to copy file contents")?; } } diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 12999b44..886b01a4 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -275,7 +275,7 @@ fn root_index_html() -> Result { .with_context(|| "Book building failed")?; let index_page = temp.path().join("book").join("index.html"); - let html = fs::read_to_string(&index_page).with_context(|| "Unable to read index.html")?; + let html = fs::read_to_string(index_page).with_context(|| "Unable to read index.html")?; Ok(Document::from(html.as_str())) } @@ -412,7 +412,7 @@ fn recursive_includes_are_capped() { let content = &["Around the world, around the world Around the world, around the world Around the world, around the world"]; - assert_contains_strings(&recursive, content); + assert_contains_strings(recursive, content); } #[test] @@ -462,7 +462,7 @@ fn by_default_mdbook_use_index_preprocessor_to_convert_readme_to_index() { let second_index = temp.path().join("book").join("second").join("index.html"); let unexpected_strings = vec!["Second README"]; - assert_doesnt_contain_strings(&second_index, &unexpected_strings); + assert_doesnt_contain_strings(second_index, &unexpected_strings); } #[test] @@ -803,7 +803,7 @@ mod search { let src = read_book_index(temp.path()); let dest = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/searchindex_fixture.json"); - let dest = File::create(&dest).unwrap(); + let dest = File::create(dest).unwrap(); serde_json::to_writer_pretty(dest, &src).unwrap(); src From dc08e373209146d4bf4dd2957b74128b76dfd355 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 09:44:50 -0700 Subject: [PATCH 15/48] Apply clippy::borrow_deref_ref --- src/cmd/init.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 55d90081..2c6415b6 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -116,5 +116,5 @@ fn confirm() -> bool { io::stdout().flush().unwrap(); let mut s = String::new(); io::stdin().read_line(&mut s).ok(); - matches!(&*s.trim(), "Y" | "y" | "yes" | "Yes") + matches!(s.trim(), "Y" | "y" | "yes" | "Yes") } From 54df8234ed6466571cd18148b8e577e35d02980b Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 09:45:46 -0700 Subject: [PATCH 16/48] Apply clippy::let_unit_value --- src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 1a30c507..a58a48bc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -703,7 +703,7 @@ trait Updateable<'de>: Serialize + Deserialize<'de> { let mut raw = Value::try_from(&self).expect("unreachable"); if let Ok(value) = Value::try_from(value) { - let _ = raw.insert(key, value); + raw.insert(key, value); } else { return; } From 0ef3bb1cc635c60a7acc8bc6222f732e60acd70f Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 09:46:30 -0700 Subject: [PATCH 17/48] Apply clippy::needless_borrowed_reference --- src/book/book.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/book/book.rs b/src/book/book.rs index 647a8042..3531de38 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -317,7 +317,7 @@ impl<'a> Iterator for BookItems<'a> { fn next(&mut self) -> Option { let item = self.items.pop_front(); - if let Some(&BookItem::Chapter(ref ch)) = item { + if let Some(BookItem::Chapter(ch)) = item { // if we wanted a breadth-first iterator we'd `extend()` here for sub_item in ch.sub_items.iter().rev() { self.items.push_front(sub_item); From d8f171a99643e96f0199682c0d088970505e3cbb Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 09:50:32 -0700 Subject: [PATCH 18/48] Apply clippy::manual_while_let_some --- src/book/book.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/book/book.rs b/src/book/book.rs index 3531de38..96c70abc 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -39,9 +39,7 @@ fn create_missing(src_dir: &Path, summary: &Summary) -> Result<()> { .chain(summary.suffix_chapters.iter()) .collect(); - while !items.is_empty() { - let next = items.pop().expect("already checked"); - + while let Some(next) = items.pop() { if let SummaryItem::Link(ref link) = *next { if let Some(ref location) = link.location { let filename = src_dir.join(location); From c3155e264225e088f6ff48c42e93583593a07555 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 09:55:51 -0700 Subject: [PATCH 19/48] Apply clippy::match_like_matches_macro --- tests/rendered_output.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 886b01a4..813f70fd 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -628,10 +628,8 @@ fn edit_url_has_configured_src_dir_edit_url() { } fn remove_absolute_components(path: &Path) -> impl Iterator + '_ { - path.components().skip_while(|c| match c { - Component::Prefix(_) | Component::RootDir => true, - _ => false, - }) + path.components() + .skip_while(|c| matches!(c, Component::Prefix(_) | Component::RootDir)) } /// Checks formatting of summary names with inline elements. From f77c597e013080606719b06b7688ca37a87925e9 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 10:16:26 -0700 Subject: [PATCH 20/48] Update some indirect dependencies --- Cargo.lock | 567 +++++++++++++++++++++++++++++------------------------ 1 file changed, 308 insertions(+), 259 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2414f379..d4e4d601 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,9 +110,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -131,9 +131,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.11.1" +version = "3.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" [[package]] name = "byteorder" @@ -143,15 +143,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cc" -version = "1.0.77" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-if" @@ -204,36 +204,26 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -241,9 +231,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if", ] @@ -265,51 +255,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ "quote", - "syn", -] - -[[package]] -name = "cxx" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "syn 1.0.105", ] [[package]] @@ -342,9 +288,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elasticlunr-rs" @@ -382,6 +328,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "errno-dragonfly" version = "0.1.2" @@ -394,23 +351,23 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] [[package]] name = "filetime" -version = "0.2.19" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e884668cd0c7480504233e951174ddc3b382f7c2666e3b7310b5c4e7b0c37f9" +checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" dependencies = [ "cfg-if", "libc", "redox_syscall", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -458,9 +415,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -468,38 +425,38 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-core", "futures-macro", @@ -512,9 +469,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -522,9 +479,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -546,9 +503,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b91535aa35fea1523ad1b86cb6b53c28e0ae566ba4a460f4457e936cad7c6f" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -608,15 +565,6 @@ dependencies = [ "http", ] -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.2.6" @@ -626,6 +574,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "html5ever" version = "0.26.0" @@ -637,14 +591,14 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn", + "syn 1.0.105", ] [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", @@ -682,9 +636,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.23" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -706,26 +660,25 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] @@ -757,9 +710,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown", @@ -796,24 +749,25 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.3" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "is-terminal" -version = "0.4.1" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.1", "io-lifetimes", - "rustix", - "windows-sys", + "rustix 0.37.19", + "windows-sys 0.48.0", ] [[package]] @@ -827,15 +781,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5" dependencies = [ "wasm-bindgen", ] @@ -868,18 +822,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.138" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" - -[[package]] -name = "link-cplusplus" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" -dependencies = [ - "cc", -] +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "linux-raw-sys" @@ -887,6 +832,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +[[package]] +name = "linux-raw-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" + [[package]] name = "lock_api" version = "0.4.9" @@ -990,9 +941,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" @@ -1013,7 +964,7 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -1043,7 +994,7 @@ dependencies = [ "libc", "mio", "walkdir", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -1077,11 +1028,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi 0.2.6", "libc", ] @@ -1128,15 +1079,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" +checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -1147,9 +1098,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.5.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc8bed3549e0f9b0a2a78bf7c0018237a2cdf085eecbbc048e52612438e4e9d0" +checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" dependencies = [ "thiserror", "ucd-trie", @@ -1157,9 +1108,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.5.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdc078600d06ff90d4ed238f0119d84ab5d43dbaad278b0e33a8820293b32344" +checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" dependencies = [ "pest", "pest_generator", @@ -1167,26 +1118,26 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.5.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a1af60b1c4148bb269006a750cff8e2ea36aff34d2d96cf7be0b14d1bed23c" +checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "pest_meta" -version = "2.5.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fec8605d59fc2ae0c6c1aefc0c7c7a9769732017c0ce07f7a9cfffa7b4404f20" +checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" dependencies = [ "once_cell", "pest", - "sha1", + "sha2", ] [[package]] @@ -1229,22 +1180,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -1305,9 +1256,9 @@ checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" [[package]] name = "predicates-tree" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ff541861505aabf6ea722d2131ee980b8276e10a1297b94e896dd8b621850d" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" dependencies = [ "predicates-core", "termtree", @@ -1327,9 +1278,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -1347,9 +1298,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.21" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" dependencies = [ "proc-macro2", ] @@ -1418,16 +1369,30 @@ checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "rustix" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588" +checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" dependencies = [ "bitflags", - "errno", + "errno 0.2.8", "io-lifetimes", "libc", - "linux-raw-sys", - "windows-sys", + "linux-raw-sys 0.1.4", + "windows-sys 0.42.0", +] + +[[package]] +name = "rustix" +version = "0.37.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +dependencies = [ + "bitflags", + "errno 0.3.1", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.7", + "windows-sys 0.48.0", ] [[package]] @@ -1441,9 +1406,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "same-file" @@ -1466,12 +1431,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" - [[package]] name = "select" version = "0.6.0" @@ -1491,22 +1450,22 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.156" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.156" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -1543,6 +1502,17 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "shlex" version = "1.1.0" @@ -1557,9 +1527,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -1572,9 +1542,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -1582,9 +1552,9 @@ dependencies = [ [[package]] name = "string_cache" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" dependencies = [ "new_debug_unreachable", "once_cell", @@ -1623,6 +1593,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tempfile" version = "3.4.0" @@ -1632,8 +1613,8 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall", - "rustix", - "windows-sys", + "rustix 0.36.7", + "windows-sys 0.42.0", ] [[package]] @@ -1649,47 +1630,47 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] [[package]] name = "terminal_size" -version = "0.2.3" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb20089a8ba2b69debd491f8d2d023761cbf196e999218c591fa1e7e15a21907" +checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" dependencies = [ - "rustix", - "windows-sys", + "rustix 0.37.19", + "windows-sys 0.48.0", ] [[package]] name = "termtree" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -1713,44 +1694,43 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.25.0" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" dependencies = [ "autocfg", "bytes", "libc", - "memchr", "mio", "num_cpus", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "1.8.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "tokio-stream" -version = "0.1.11" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", "pin-project-lite", @@ -1771,9 +1751,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.4" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -1818,18 +1798,18 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", ] [[package]] name = "try-lock" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "tungstenite" @@ -1873,15 +1853,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -1892,12 +1872,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "url" version = "2.3.1" @@ -1988,9 +1962,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1998,24 +1972,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.15", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2023,22 +1997,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb" [[package]] name = "winapi" @@ -2071,19 +2045,52 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.0", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm 0.42.0", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] @@ -2092,42 +2099,84 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "xml5ever" version = "0.17.0" From 4c4ab8a57d7409bcf45f103282a2be1ed98aac7d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 10:53:22 -0700 Subject: [PATCH 21/48] Update clap --- Cargo.lock | 89 +++++++++++++++++++++++++++++++++++++++++++----------- Cargo.toml | 4 +-- 2 files changed, 74 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4e4d601..b6f7c124 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,12 +42,55 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + [[package]] name = "anstyle" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + [[package]] name = "anyhow" version = "1.0.71" @@ -173,36 +216,48 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.29" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +dependencies = [ + "anstream", + "anstyle", "bitflags", "clap_lex", - "is-terminal", "once_cell", "strsim", - "termcolor", "terminal_size", ] [[package]] name = "clap_complete" -version = "4.0.6" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b3c9eae0de7bf8e3f904a5e40612b21fb2e2e566456d177809a48b892d24da" +checksum = "1594fe2312ec4abf402076e407628f5c313e54c32ade058521df4ee34ecac8a8" dependencies = [ "clap", ] [[package]] name = "clap_lex" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" -dependencies = [ - "os_str_bytes", -] +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "core-foundation-sys" @@ -1052,12 +1107,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "os_str_bytes" -version = "6.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" - [[package]] name = "output_vt100" version = "0.1.3" @@ -1889,6 +1938,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index c7db01c5..d773108f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,8 +19,8 @@ rust-version = "1.65" [dependencies] anyhow = "1.0.28" chrono = { version = "0.4", default-features = false, features = ["clock"] } -clap = { version = "4.0.29", features = ["cargo", "wrap_help"] } -clap_complete = "4.0.6" +clap = { version = "4.2.7", features = ["cargo", "wrap_help"] } +clap_complete = "4.2.3" once_cell = "1" env_logger = "0.10.0" handlebars = "4.0" From d94c5f8380f4e21ccc370569e1f171362edabfc6 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 12:01:03 -0700 Subject: [PATCH 22/48] Set minimum versions in Cargo.toml --- Cargo.toml | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d773108f..b06f8a87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,46 +17,46 @@ description = "Creates a book from markdown files" rust-version = "1.65" [dependencies] -anyhow = "1.0.28" -chrono = { version = "0.4", default-features = false, features = ["clock"] } +anyhow = "1.0.71" +chrono = { version = "0.4.24", default-features = false, features = ["clock"] } clap = { version = "4.2.7", features = ["cargo", "wrap_help"] } clap_complete = "4.2.3" -once_cell = "1" +once_cell = "1.17.1" env_logger = "0.10.0" -handlebars = "4.0" -log = "0.4" -memchr = "2.0" -opener = "0.5" -pulldown-cmark = { version = "0.9.1", default-features = false } -regex = "1.5.5" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -shlex = "1" -tempfile = "3.0" -toml = "0.5.1" +handlebars = "4.3.7" +log = "0.4.17" +memchr = "2.5.0" +opener = "0.5.2" +pulldown-cmark = { version = "0.9.2", default-features = false } +regex = "1.8.1" +serde = { version = "1.0.163", features = ["derive"] } +serde_json = "1.0.96" +shlex = "1.1.0" +tempfile = "3.4.0" +toml = "0.5.11" topological-sort = "0.2.2" # Watch feature -notify = { version = "5.0.0", optional = true } +notify = { version = "5.1.0", optional = true } notify-debouncer-mini = { version = "0.2.1", optional = true } ignore = { version = "0.4.20", optional = true } # Serve feature -futures-util = { version = "0.3.4", optional = true } -tokio = { version = "1", features = ["macros", "rt-multi-thread"], optional = true } -warp = { version = "0.3.2", default-features = false, features = ["websocket"], optional = true } +futures-util = { version = "0.3.28", optional = true } +tokio = { version = "1.28.1", features = ["macros", "rt-multi-thread"], optional = true } +warp = { version = "0.3.5", default-features = false, features = ["websocket"], optional = true } # Search feature -elasticlunr-rs = { version = "3.0.0", optional = true } -ammonia = { version = "3", optional = true } +elasticlunr-rs = { version = "3.0.2", optional = true } +ammonia = { version = "3.3.0", optional = true } [dev-dependencies] -assert_cmd = "2.0.7" -predicates = "2" +assert_cmd = "2.0.11" +predicates = "2.1.5" select = "0.6.0" -semver = "1.0" -pretty_assertions = "1.2.1" -walkdir = "2.0" +semver = "1.0.17" +pretty_assertions = "1.3.0" +walkdir = "2.3.3" [features] default = ["watch", "serve", "search"] From db6699dae22a3218593626feb224f6ebf4183ec5 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 12:26:29 -0700 Subject: [PATCH 23/48] Update to 0.4.29 --- CHANGELOG.md | 20 ++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- guide/src/continuous-integration.md | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2318f125..3243efbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## mdBook 0.4.29 +[v0.4.28...v0.4.29](https://github.com/rust-lang/mdBook/compare/v0.4.28...v0.4.29) + +### Changed +- Built-in fonts are no longer copied when `fonts/fonts.css` is overridded in the theme directory. + Additionally, the warning about `copy-fonts` has been removed if `fonts/fonts.css` is specified. + [#2080](https://github.com/rust-lang/mdBook/pull/2080) +- `mdbook init --force` now skips all interactive prompts as intended. + [#2057](https://github.com/rust-lang/mdBook/pull/2057) +- Updated dependencies + [#2063](https://github.com/rust-lang/mdBook/pull/2063) + [#2086](https://github.com/rust-lang/mdBook/pull/2086) + [#2082](https://github.com/rust-lang/mdBook/pull/2082) + [#2084](https://github.com/rust-lang/mdBook/pull/2084) + [#2085](https://github.com/rust-lang/mdBook/pull/2085) + +### Fixed +- Switched from the `gitignore` library to `ignore`. This should bring some improvements with gitignore handling. + [#2076](https://github.com/rust-lang/mdBook/pull/2076) + ## mdBook 0.4.28 [v0.4.27...v0.4.28](https://github.com/rust-lang/mdBook/compare/v0.4.27...v0.4.28) diff --git a/Cargo.lock b/Cargo.lock index b6f7c124..fe815cda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -952,7 +952,7 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.28" +version = "0.4.29" dependencies = [ "ammonia", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index d773108f..b7e36c0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mdbook" -version = "0.4.28" +version = "0.4.29" authors = [ "Mathieu David ", "Michael-F-Bryan ", diff --git a/guide/src/continuous-integration.md b/guide/src/continuous-integration.md index a401221f..2a7357d1 100644 --- a/guide/src/continuous-integration.md +++ b/guide/src/continuous-integration.md @@ -21,7 +21,7 @@ A simple approach would be to use the popular `curl` CLI tool to download the ex ```sh mkdir bin -curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.28/mdbook-v0.4.28-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin +curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.29/mdbook-v0.4.29-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin bin/mdbook build ``` From 1b3922d466b562a1a1a5e213cbfecf7c8d48beb0 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 12:52:42 -0700 Subject: [PATCH 24/48] Fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3243efbc..24bad5b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ [v0.4.28...v0.4.29](https://github.com/rust-lang/mdBook/compare/v0.4.28...v0.4.29) ### Changed -- Built-in fonts are no longer copied when `fonts/fonts.css` is overridded in the theme directory. +- Built-in fonts are no longer copied when `fonts/fonts.css` is overridden in the theme directory. Additionally, the warning about `copy-fonts` has been removed if `fonts/fonts.css` is specified. [#2080](https://github.com/rust-lang/mdBook/pull/2080) - `mdbook init --force` now skips all interactive prompts as intended. From 54f14e89cf88c2fc6367c26e8685fe55a2a002a6 Mon Sep 17 00:00:00 2001 From: zjj Date: Thu, 25 May 2023 12:04:43 +0800 Subject: [PATCH 25/48] Update test_book highlight.md Add missing bash annotation --- test_book/src/languages/highlight.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_book/src/languages/highlight.md b/test_book/src/languages/highlight.md index af0f3400..85a48b0c 100644 --- a/test_book/src/languages/highlight.md +++ b/test_book/src/languages/highlight.md @@ -57,7 +57,7 @@ _start: ## bash -``` +```bash #!/bin/bash ###### CONFIG From a4e206168dee6a3293ab9d3a72a51a430e705f7c Mon Sep 17 00:00:00 2001 From: ImUrX Date: Thu, 9 Feb 2023 03:58:54 -0300 Subject: [PATCH 26/48] Add working heading extension --- guide/src/format/markdown.md | 11 ++++++++++ src/renderer/html_handlebars/hbs_renderer.rs | 21 +++++++++++++++++--- src/utils/mod.rs | 1 + 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/guide/src/format/markdown.md b/guide/src/format/markdown.md index 963a1538..82ef8360 100644 --- a/guide/src/format/markdown.md +++ b/guide/src/format/markdown.md @@ -220,3 +220,14 @@ To enable it, see the [`output.html.curly-quotes`] config option. [tables]: https://github.github.com/gfm/#tables-extension- [task list extension]: https://github.github.com/gfm/#task-list-items-extension- [`output.html.curly-quotes`]: configuration/renderers.md#html-renderer-options + +### Heading attributes { #headingattributes .class1 .class2 } + +Headings can have a custom ID and classes. This let's you maintain the same ID even if you change the heading's text, it also let's you add multiple classes in the heading. + +Example: +```md +# Example heading { #first .class1 .class2 } +``` + +This makes the level 1 heading with the content `Example heading`, ID `first`, and classes `class1` and `class2`. Note that the attributes should be space-separated. diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index ee27fd13..ce2b7137 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -789,8 +789,10 @@ fn make_data( /// Goes through the rendered HTML, making sure all header tags have /// an anchor respectively so people can link to sections directly. fn build_header_links(html: &str) -> String { - static BUILD_HEADER_LINKS: Lazy = - Lazy::new(|| Regex::new(r"(.*?)").unwrap()); + static BUILD_HEADER_LINKS: Lazy = Lazy::new(|| { + Regex::new(r#"(.*?)"#).unwrap() + }); + static IGNORE_CLASS: &'static [&str] = &["menu-title"]; let mut id_counter = HashMap::new(); @@ -800,7 +802,20 @@ fn build_header_links(html: &str) -> String { .parse() .expect("Regex should ensure we only ever get numbers here"); - insert_link_into_header(level, &caps[2], &mut id_counter) + // Ignore .menu-title because now it's getting detected by the regex. + if let Some(classes) = caps.get(3) { + for class in classes.as_str().split(" ") { + if IGNORE_CLASS.contains(&class) { + return caps[0].to_string(); + } + } + } + + insert_link_into_header( + level, + caps.get(2).map(|x| x.as_str()).unwrap_or(&caps[4]), + &mut id_counter, + ) }) .into_owned() } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 9f67deda..9156916e 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -183,6 +183,7 @@ pub fn new_cmark_parser(text: &str, curly_quotes: bool) -> Parser<'_, '_> { opts.insert(Options::ENABLE_FOOTNOTES); opts.insert(Options::ENABLE_STRIKETHROUGH); opts.insert(Options::ENABLE_TASKLISTS); + opts.insert(Options::ENABLE_HEADING_ATTRIBUTES); if curly_quotes { opts.insert(Options::ENABLE_SMART_PUNCTUATION); } From ecdb411711ba1b52d982ce5c060d229da8b8420b Mon Sep 17 00:00:00 2001 From: ImUrX Date: Sun, 12 Feb 2023 04:29:33 -0300 Subject: [PATCH 27/48] fix mistakes --- src/renderer/html_handlebars/hbs_renderer.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index ce2b7137..d28513bd 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -813,7 +813,9 @@ fn build_header_links(html: &str) -> String { insert_link_into_header( level, - caps.get(2).map(|x| x.as_str()).unwrap_or(&caps[4]), + &caps[4], + caps.get(2).map(|x| x.as_str().to_string()), + caps.get(3).map(|x| x.as_str().to_string()), &mut id_counter, ) }) @@ -825,15 +827,19 @@ fn build_header_links(html: &str) -> String { fn insert_link_into_header( level: usize, content: &str, + id: Option, + classes: Option, id_counter: &mut HashMap, ) -> String { - let id = utils::unique_id_from_content(content, id_counter); + let id = id.unwrap_or_else(|| utils::unique_id_from_content(content, id_counter)); + let classes = classes.unwrap_or("".to_string()); format!( - r##"{text}"##, + r##"{text}"##, level = level, id = id, - text = content + text = content, + classes = classes ) } From c8a5adcee9ce27f06a4477fc424075cb3d09af30 Mon Sep 17 00:00:00 2001 From: ImUrX Date: Sun, 12 Feb 2023 05:00:31 -0300 Subject: [PATCH 28/48] fix more mistakes --- src/renderer/html_handlebars/hbs_renderer.rs | 20 ++++++++++++-------- tests/rendered_output.rs | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index d28513bd..a4e65fab 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -792,7 +792,7 @@ fn build_header_links(html: &str) -> String { static BUILD_HEADER_LINKS: Lazy = Lazy::new(|| { Regex::new(r#"(.*?)"#).unwrap() }); - static IGNORE_CLASS: &'static [&str] = &["menu-title"]; + static IGNORE_CLASS: &[&str] = &["menu-title"]; let mut id_counter = HashMap::new(); @@ -835,7 +835,7 @@ fn insert_link_into_header( let classes = classes.unwrap_or("".to_string()); format!( - r##"{text}"##, + r##"{text}"##, level = level, id = id, text = content, @@ -1014,27 +1014,31 @@ mod tests { let inputs = vec![ ( "blah blah

Foo

", - r##"blah blah

Foo

"##, + r##"blah blah

Foo

"##, ), ( "

Foo

", - r##"

Foo

"##, + r##"

Foo

"##, ), ( "

Foo^bar

", - r##"

Foo^bar

"##, + r##"

Foo^bar

"##, ), ( "

", - r##"

"##, + r##"

"##, ), ( "

", - r##"

"##, + r##"

"##, ), ( "

Foo

Foo

", - r##"

Foo

Foo

"##, + r##"

Foo

Foo

"##, + ), + ( + r##"

Foo

"##, + r##"

Foo

"##, ), ]; diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 813f70fd..9fffe7bc 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -105,12 +105,12 @@ fn check_correct_cross_links_in_nested_dir() { assert_contains_strings( first.join("index.html"), - &[r##"

"##], + &[r##"

"##], ); assert_contains_strings( first.join("nested.html"), - &[r##"

"##], + &[r##"

"##], ); } @@ -393,7 +393,7 @@ fn able_to_include_files_in_chapters() { let includes = temp.path().join("book/first/includes.html"); let summary_strings = &[ - r##"

Summary

"##, + r##"

Summary

"##, ">First Chapter", ]; assert_contains_strings(&includes, summary_strings); From 0cb977e603bc4c736bc82baeb9f4bf1f93201f6c Mon Sep 17 00:00:00 2001 From: Uriel Date: Sun, 5 Mar 2023 07:04:26 -0300 Subject: [PATCH 29/48] docs suggestion Co-authored-by: Eric Huss --- guide/src/format/markdown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/src/format/markdown.md b/guide/src/format/markdown.md index 82ef8360..84698ca7 100644 --- a/guide/src/format/markdown.md +++ b/guide/src/format/markdown.md @@ -223,7 +223,7 @@ To enable it, see the [`output.html.curly-quotes`] config option. ### Heading attributes { #headingattributes .class1 .class2 } -Headings can have a custom ID and classes. This let's you maintain the same ID even if you change the heading's text, it also let's you add multiple classes in the heading. +Headings can have a custom HTML ID and classes. This let's you maintain the same ID even if you change the heading's text, it also let's you add multiple classes in the heading. Example: ```md From b141297651f2e89a1466b39af250f0c5e1b363c6 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 28 May 2023 11:31:35 -0700 Subject: [PATCH 30/48] Update documentation for heading attributes --- guide/src/format/markdown.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/guide/src/format/markdown.md b/guide/src/format/markdown.md index 84698ca7..8a92870b 100644 --- a/guide/src/format/markdown.md +++ b/guide/src/format/markdown.md @@ -221,7 +221,7 @@ To enable it, see the [`output.html.curly-quotes`] config option. [task list extension]: https://github.github.com/gfm/#task-list-items-extension- [`output.html.curly-quotes`]: configuration/renderers.md#html-renderer-options -### Heading attributes { #headingattributes .class1 .class2 } +### Heading attributes Headings can have a custom HTML ID and classes. This let's you maintain the same ID even if you change the heading's text, it also let's you add multiple classes in the heading. @@ -231,3 +231,5 @@ Example: ``` This makes the level 1 heading with the content `Example heading`, ID `first`, and classes `class1` and `class2`. Note that the attributes should be space-separated. + +More information can be found in the [heading attrs spec page](https://github.com/raphlinus/pulldown-cmark/blob/master/specs/heading_attrs.txt). From 34e5ef22a099416300b4ba68a714c98539009c54 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 28 May 2023 11:32:31 -0700 Subject: [PATCH 31/48] Don't include empty class attribute. --- src/renderer/html_handlebars/hbs_renderer.rs | 29 ++++++++++++++------ tests/rendered_output.rs | 6 ++-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index a4e65fab..e753dc2e 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -832,10 +832,12 @@ fn insert_link_into_header( id_counter: &mut HashMap, ) -> String { let id = id.unwrap_or_else(|| utils::unique_id_from_content(content, id_counter)); - let classes = classes.unwrap_or("".to_string()); + let classes = classes + .map(|s| format!(" class=\"{s}\"")) + .unwrap_or_default(); format!( - r##"{text}"##, + r##"{text}"##, level = level, id = id, text = content, @@ -1014,28 +1016,39 @@ mod tests { let inputs = vec![ ( "blah blah

Foo

", - r##"blah blah

Foo

"##, + r##"blah blah

Foo

"##, ), ( "

Foo

", - r##"

Foo

"##, + r##"

Foo

"##, ), ( "

Foo^bar

", - r##"

Foo^bar

"##, + r##"

Foo^bar

"##, ), ( "

", - r##"

"##, + r##"

"##, ), ( "

", - r##"

"##, + r##"

"##, ), ( "

Foo

Foo

", - r##"

Foo

Foo

"##, + r##"

Foo

Foo

"##, ), + // id only + ( + r##"

Foo

"##, + r##"

Foo

"##, + ), + // class only + ( + r##"

Foo

"##, + r##"

Foo

"##, + ), + // both id and class ( r##"

Foo

"##, r##"

Foo

"##, diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 9fffe7bc..813f70fd 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -105,12 +105,12 @@ fn check_correct_cross_links_in_nested_dir() { assert_contains_strings( first.join("index.html"), - &[r##"

"##], + &[r##"

"##], ); assert_contains_strings( first.join("nested.html"), - &[r##"

"##], + &[r##"

"##], ); } @@ -393,7 +393,7 @@ fn able_to_include_files_in_chapters() { let includes = temp.path().join("book/first/includes.html"); let summary_strings = &[ - r##"

Summary

"##, + r##"

Summary

"##, ">First Chapter", ]; assert_contains_strings(&includes, summary_strings); From 861197e61cc57239483246034299d6d5a4208108 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 28 May 2023 11:33:24 -0700 Subject: [PATCH 32/48] Add a test to the test_book for custom heading attributes --- test_book/src/individual/heading.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test_book/src/individual/heading.md b/test_book/src/individual/heading.md index df96d74c..f9f4d5b2 100644 --- a/test_book/src/individual/heading.md +++ b/test_book/src/individual/heading.md @@ -13,3 +13,9 @@ ##### Really Small Heading ###### Is it even a heading anymore - heading + +## Custom id {#example-id} + +## Custom class {.class1 .class2} + +## Both id and class {#example-id2 .class1 .class2} From bbc32dff8248c55df1e87030f68cd184300c8351 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 28 May 2023 12:00:00 -0700 Subject: [PATCH 33/48] Update pulldown-cmark to 0.9.3 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe815cda..af394b16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1336,9 +1336,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d9cc634bc78768157b5cbfe988ffcd1dcba95cd2b2f03a88316c08c6d00ed63" +checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" dependencies = [ "bitflags", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 0d4d7481..dd03884f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ handlebars = "4.3.7" log = "0.4.17" memchr = "2.5.0" opener = "0.5.2" -pulldown-cmark = { version = "0.9.2", default-features = false } +pulldown-cmark = { version = "0.9.3", default-features = false } regex = "1.8.1" serde = { version = "1.0.163", features = ["derive"] } serde_json = "1.0.96" From e3be293420665d81aa7b1677aed9ad2f3e557b3c Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 28 May 2023 11:33:58 -0700 Subject: [PATCH 34/48] Add an integration test for heading attributes --- tests/dummy_book/src/SUMMARY.md | 1 + .../src/first/heading-attributes.md | 5 + tests/rendered_output.rs | 19 +- tests/searchindex_fixture.json | 527 ++++++++++++++---- 4 files changed, 433 insertions(+), 119 deletions(-) create mode 100644 tests/dummy_book/src/first/heading-attributes.md diff --git a/tests/dummy_book/src/SUMMARY.md b/tests/dummy_book/src/SUMMARY.md index 49b64a54..f310508b 100644 --- a/tests/dummy_book/src/SUMMARY.md +++ b/tests/dummy_book/src/SUMMARY.md @@ -14,6 +14,7 @@ - [Unicode](first/unicode.md) - [No Headers](first/no-headers.md) - [Duplicate Headers](first/duplicate-headers.md) + - [Heading Attributes](first/heading-attributes.md) - [Second Chapter](second.md) - [Nested Chapter](second/nested.md) diff --git a/tests/dummy_book/src/first/heading-attributes.md b/tests/dummy_book/src/first/heading-attributes.md new file mode 100644 index 00000000..a09a22b6 --- /dev/null +++ b/tests/dummy_book/src/first/heading-attributes.md @@ -0,0 +1,5 @@ +# Heading Attributes {#attrs} + +## Heading with classes {.class1 .class2} + +## Heading with id and classes {#both .class1 .class2} diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 813f70fd..7bc5e7ae 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -35,6 +35,7 @@ const TOC_SECOND_LEVEL: &[&str] = &[ "1.5. Unicode", "1.6. No Headers", "1.7. Duplicate Headers", + "1.8. Heading Attributes", "2.1. Nested Chapter", ]; @@ -766,7 +767,7 @@ mod search { assert_eq!(docs[&some_section]["body"], ""); assert_eq!( docs[&summary]["body"], - "Dummy Book Introduction First Chapter Nested Chapter Includes Recursive Markdown Unicode No Headers Duplicate Headers Second Chapter Nested Chapter Conclusion" + "Dummy Book Introduction First Chapter Nested Chapter Includes Recursive Markdown Unicode No Headers Duplicate Headers Heading Attributes Second Chapter Nested Chapter Conclusion" ); assert_eq!( docs[&summary]["breadcrumbs"], @@ -946,3 +947,19 @@ fn custom_fonts() { &["fonts.css", "myfont.woff"] ); } + +#[test] +fn custom_header_attributes() { + let temp = DummyBook::new().build().unwrap(); + let md = MDBook::load(temp.path()).unwrap(); + md.build().unwrap(); + + let contents = temp.path().join("book/first/heading-attributes.html"); + + let summary_strings = &[ + r##"

Heading Attributes

"##, + r##"

Heading with classes

"##, + r##"

Heading with id and classes

"##, + ]; + assert_contains_strings(&contents, summary_strings); +} diff --git a/tests/searchindex_fixture.json b/tests/searchindex_fixture.json index 3d7062d2..1fcfcdab 100644 --- a/tests/searchindex_fixture.json +++ b/tests/searchindex_fixture.json @@ -23,6 +23,9 @@ "first/duplicate-headers.html#header-text", "first/duplicate-headers.html#header-text-1", "first/duplicate-headers.html#header-text-2", + "first/heading-attributes.html#heading-attributes", + "first/heading-attributes.html#heading-with-classes", + "first/heading-attributes.html#heading-with-id-and-classes", "second.html#second-chapter", "second/nested.html#testing-relative-links-for-the-print-page", "second/nested.html#some-section", @@ -42,7 +45,7 @@ "title": 1 }, "10": { - "body": 19, + "body": 21, "breadcrumbs": 4, "title": 1 }, @@ -112,21 +115,36 @@ "title": 2 }, "23": { + "body": 0, + "breadcrumbs": 6, + "title": 2 + }, + "24": { + "body": 0, + "breadcrumbs": 6, + "title": 2 + }, + "25": { + "body": 0, + "breadcrumbs": 7, + "title": 3 + }, + "26": { "body": 20, "breadcrumbs": 4, "title": 2 }, - "24": { + "27": { "body": 18, "breadcrumbs": 9, "title": 5 }, - "25": { + "28": { "body": 0, "breadcrumbs": 5, "title": 1 }, - "26": { + "29": { "body": 3, "breadcrumbs": 2, "title": 1 @@ -181,7 +199,7 @@ "title": "Introduction" }, "10": { - "body": "Dummy Book Introduction First Chapter Nested Chapter Includes Recursive Markdown Unicode No Headers Duplicate Headers Second Chapter Nested Chapter Conclusion", + "body": "Dummy Book Introduction First Chapter Nested Chapter Includes Recursive Markdown Unicode No Headers Duplicate Headers Heading Attributes Second Chapter Nested Chapter Conclusion", "breadcrumbs": "First Chapter » Includes » Summary", "id": "10", "title": "Summary" @@ -265,27 +283,45 @@ "title": "header-text" }, "23": { - "body": "This makes sure you can insert runnable Rust files. fn main() { println!(\"Hello World!\");\n#\n# // You can even hide lines! :D\n# println!(\"I am hidden! Expand the code snippet to see me\");\n}", - "breadcrumbs": "Second Chapter » Second Chapter", + "body": "", + "breadcrumbs": "First Chapter » Heading Attributes » Heading Attributes", "id": "23", - "title": "Second Chapter" + "title": "Heading Attributes" }, "24": { - "body": "When we link to the first section , it should work on both the print page and the non-print page. A fragment link should work. Link outside . Some image HTML Link", - "breadcrumbs": "Second Chapter » Nested Chapter » Testing relative links for the print page", + "body": "", + "breadcrumbs": "First Chapter » Heading Attributes » Heading with classes", "id": "24", - "title": "Testing relative links for the print page" + "title": "Heading with classes" }, "25": { "body": "", - "breadcrumbs": "Second Chapter » Nested Chapter » Some section", + "breadcrumbs": "First Chapter » Heading Attributes » Heading with id and classes", "id": "25", - "title": "Some section" + "title": "Heading with id and classes" }, "26": { + "body": "This makes sure you can insert runnable Rust files. fn main() { println!(\"Hello World!\");\n#\n# // You can even hide lines! :D\n# println!(\"I am hidden! Expand the code snippet to see me\");\n}", + "breadcrumbs": "Second Chapter » Second Chapter", + "id": "26", + "title": "Second Chapter" + }, + "27": { + "body": "When we link to the first section , it should work on both the print page and the non-print page. A fragment link should work. Link outside . Some image HTML Link", + "breadcrumbs": "Second Chapter » Nested Chapter » Testing relative links for the print page", + "id": "27", + "title": "Testing relative links for the print page" + }, + "28": { + "body": "", + "breadcrumbs": "Second Chapter » Nested Chapter » Some section", + "id": "28", + "title": "Some section" + }, + "29": { "body": "I put <HTML> in here!", "breadcrumbs": "Conclusion » Conclusion", - "id": "26", + "id": "29", "title": "Conclusion" }, "3": { @@ -331,7 +367,7 @@ "title": "Includes" } }, - "length": 27, + "length": 30, "save": true }, "fields": [ @@ -498,6 +534,41 @@ } } } + }, + "t": { + "df": 0, + "docs": {}, + "t": { + "df": 0, + "docs": {}, + "r": { + "df": 0, + "docs": {}, + "i": { + "b": { + "df": 0, + "docs": {}, + "u": { + "df": 0, + "docs": {}, + "t": { + "df": 2, + "docs": { + "10": { + "tf": 1.0 + }, + "23": { + "tf": 1.0 + } + } + } + } + }, + "df": 0, + "docs": {} + } + } + } } }, "b": { @@ -619,7 +690,7 @@ "h": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -821,7 +892,7 @@ "2": { "tf": 1.0 }, - "23": { + "26": { "tf": 1.0 }, "4": { @@ -856,6 +927,29 @@ "df": 0, "docs": {} }, + "l": { + "a": { + "df": 0, + "docs": {}, + "s": { + "df": 0, + "docs": {}, + "s": { + "df": 2, + "docs": { + "24": { + "tf": 1.0 + }, + "25": { + "tf": 1.0 + } + } + } + } + }, + "df": 0, + "docs": {} + }, "o": { "d": { "df": 0, @@ -863,7 +957,7 @@ "e": { "df": 2, "docs": { - "23": { + "26": { "tf": 1.0 }, "4": { @@ -930,7 +1024,7 @@ "10": { "tf": 1.0 }, - "26": { + "29": { "tf": 1.0 } } @@ -1002,7 +1096,7 @@ "d": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } }, @@ -1115,7 +1209,7 @@ "n": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -1156,7 +1250,7 @@ "d": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -1225,7 +1319,7 @@ "0": { "tf": 1.0 }, - "23": { + "26": { "tf": 1.0 }, "4": { @@ -1261,7 +1355,7 @@ "2": { "tf": 1.0 }, - "24": { + "27": { "tf": 1.0 } } @@ -1272,7 +1366,7 @@ "n": { "df": 3, "docs": { - "23": { + "26": { "tf": 1.0 }, "7": { @@ -1346,7 +1440,7 @@ "t": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -1386,8 +1480,21 @@ "e": { "a": { "d": { - "df": 0, - "docs": {}, + "df": 4, + "docs": { + "10": { + "tf": 1.0 + }, + "23": { + "tf": 1.0 + }, + "24": { + "tf": 1.0 + }, + "25": { + "tf": 1.0 + } + }, "e": { "df": 0, "docs": {}, @@ -1451,7 +1558,7 @@ "0": { "tf": 1.0 }, - "26": { + "29": { "tf": 1.0 } } @@ -1469,7 +1576,7 @@ "n": { "df": 2, "docs": { - "23": { + "26": { "tf": 1.0 }, "7": { @@ -1484,7 +1591,7 @@ "e": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -1502,7 +1609,7 @@ "l": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -1511,6 +1618,14 @@ } }, "i": { + "d": { + "df": 1, + "docs": { + "25": { + "tf": 1.0 + } + } + }, "df": 0, "docs": {}, "m": { @@ -1520,7 +1635,7 @@ "g": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -1592,7 +1707,7 @@ "t": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -1728,7 +1843,7 @@ "14": { "tf": 1.4142135623730951 }, - "23": { + "26": { "tf": 1.0 }, "6": { @@ -1739,7 +1854,7 @@ "k": { "df": 1, "docs": { - "24": { + "27": { "tf": 2.23606797749979 } } @@ -1793,7 +1908,7 @@ "t": { "df": 1, "docs": { - "26": { + "29": { "tf": 1.0 } } @@ -1821,7 +1936,7 @@ "n": { "df": 3, "docs": { - "23": { + "26": { "tf": 1.0 }, "7": { @@ -1839,7 +1954,7 @@ "e": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -1968,7 +2083,7 @@ "n": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -2007,7 +2122,7 @@ "d": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -2032,7 +2147,7 @@ "19": { "tf": 1.0 }, - "24": { + "27": { "tf": 1.7320508075688772 } } @@ -2145,7 +2260,7 @@ "t": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.7320508075688772 } }, @@ -2173,7 +2288,7 @@ "o": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -2185,7 +2300,7 @@ "i": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -2211,7 +2326,7 @@ "t": { "df": 1, "docs": { - "26": { + "29": { "tf": 1.0 } } @@ -2247,7 +2362,7 @@ "l": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -2359,7 +2474,7 @@ "l": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -2397,7 +2512,7 @@ }, "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -2422,7 +2537,7 @@ "10": { "tf": 1.0 }, - "23": { + "26": { "tf": 1.0 } } @@ -2443,10 +2558,10 @@ "n": { "df": 4, "docs": { - "24": { + "27": { "tf": 1.0 }, - "25": { + "28": { "tf": 1.0 }, "3": { @@ -2466,7 +2581,7 @@ "e": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -2490,7 +2605,7 @@ "t": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -2781,7 +2896,7 @@ "e": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -2867,7 +2982,7 @@ "17": { "tf": 1.0 }, - "24": { + "27": { "tf": 1.0 }, "6": { @@ -3049,7 +3164,7 @@ "k": { "df": 2, "docs": { - "24": { + "27": { "tf": 1.4142135623730951 }, "8": { @@ -3064,7 +3179,7 @@ "11": { "tf": 4.69041575982343 }, - "23": { + "26": { "tf": 1.0 } } @@ -3259,6 +3374,47 @@ } } } + }, + "t": { + "df": 0, + "docs": {}, + "t": { + "df": 0, + "docs": {}, + "r": { + "df": 0, + "docs": {}, + "i": { + "b": { + "df": 0, + "docs": {}, + "u": { + "df": 0, + "docs": {}, + "t": { + "df": 4, + "docs": { + "10": { + "tf": 1.0 + }, + "23": { + "tf": 1.7320508075688772 + }, + "24": { + "tf": 1.0 + }, + "25": { + "tf": 1.0 + } + } + } + } + }, + "df": 0, + "docs": {} + } + } + } } }, "b": { @@ -3380,7 +3536,7 @@ "h": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -3568,7 +3724,7 @@ "df": 0, "docs": {}, "r": { - "df": 24, + "df": 27, "docs": { "10": { "tf": 2.23606797749979 @@ -3613,12 +3769,21 @@ "tf": 1.0 }, "23": { - "tf": 1.7320508075688772 + "tf": 1.0 }, "24": { - "tf": 1.4142135623730951 + "tf": 1.0 }, "25": { + "tf": 1.0 + }, + "26": { + "tf": 1.7320508075688772 + }, + "27": { + "tf": 1.4142135623730951 + }, + "28": { "tf": 1.4142135623730951 }, "3": { @@ -3671,6 +3836,29 @@ "df": 0, "docs": {} }, + "l": { + "a": { + "df": 0, + "docs": {}, + "s": { + "df": 0, + "docs": {}, + "s": { + "df": 2, + "docs": { + "24": { + "tf": 1.4142135623730951 + }, + "25": { + "tf": 1.4142135623730951 + } + } + } + } + }, + "df": 0, + "docs": {} + }, "o": { "d": { "df": 0, @@ -3678,7 +3866,7 @@ "e": { "df": 2, "docs": { - "23": { + "26": { "tf": 1.0 }, "4": { @@ -3745,7 +3933,7 @@ "10": { "tf": 1.0 }, - "26": { + "29": { "tf": 1.7320508075688772 } } @@ -3817,7 +4005,7 @@ "d": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } }, @@ -3939,7 +4127,7 @@ "n": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -3980,7 +4168,7 @@ "d": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -4049,7 +4237,7 @@ "0": { "tf": 1.0 }, - "23": { + "26": { "tf": 1.0 }, "4": { @@ -4071,7 +4259,7 @@ "df": 0, "docs": {}, "t": { - "df": 22, + "df": 25, "docs": { "10": { "tf": 1.4142135623730951 @@ -4115,9 +4303,18 @@ "22": { "tf": 1.0 }, + "23": { + "tf": 1.0 + }, "24": { "tf": 1.0 }, + "25": { + "tf": 1.0 + }, + "27": { + "tf": 1.0 + }, "3": { "tf": 1.0 }, @@ -4147,7 +4344,7 @@ "n": { "df": 3, "docs": { - "23": { + "26": { "tf": 1.0 }, "7": { @@ -4221,7 +4418,7 @@ "t": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -4261,8 +4458,21 @@ "e": { "a": { "d": { - "df": 0, - "docs": {}, + "df": 4, + "docs": { + "10": { + "tf": 1.0 + }, + "23": { + "tf": 1.7320508075688772 + }, + "24": { + "tf": 1.7320508075688772 + }, + "25": { + "tf": 1.7320508075688772 + } + }, "e": { "df": 0, "docs": {}, @@ -4329,7 +4539,7 @@ "0": { "tf": 1.0 }, - "26": { + "29": { "tf": 1.0 } } @@ -4347,7 +4557,7 @@ "n": { "df": 2, "docs": { - "23": { + "26": { "tf": 1.0 }, "7": { @@ -4362,7 +4572,7 @@ "e": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -4380,7 +4590,7 @@ "l": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -4389,6 +4599,14 @@ } }, "i": { + "d": { + "df": 1, + "docs": { + "25": { + "tf": 1.4142135623730951 + } + } + }, "df": 0, "docs": {}, "m": { @@ -4398,7 +4616,7 @@ "g": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -4470,7 +4688,7 @@ "t": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -4606,7 +4824,7 @@ "14": { "tf": 1.4142135623730951 }, - "23": { + "26": { "tf": 1.0 }, "6": { @@ -4617,7 +4835,7 @@ "k": { "df": 1, "docs": { - "24": { + "27": { "tf": 2.449489742783178 } } @@ -4671,7 +4889,7 @@ "t": { "df": 1, "docs": { - "26": { + "29": { "tf": 1.0 } } @@ -4699,7 +4917,7 @@ "n": { "df": 3, "docs": { - "23": { + "26": { "tf": 1.0 }, "7": { @@ -4717,7 +4935,7 @@ "e": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -4833,10 +5051,10 @@ "10": { "tf": 1.4142135623730951 }, - "24": { + "27": { "tf": 1.0 }, - "25": { + "28": { "tf": 1.0 }, "4": { @@ -4876,7 +5094,7 @@ "n": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -4915,7 +5133,7 @@ "d": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -4940,7 +5158,7 @@ "19": { "tf": 1.0 }, - "24": { + "27": { "tf": 2.0 } } @@ -5053,7 +5271,7 @@ "t": { "df": 1, "docs": { - "24": { + "27": { "tf": 2.0 } }, @@ -5081,7 +5299,7 @@ "o": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -5093,7 +5311,7 @@ "i": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -5119,7 +5337,7 @@ "t": { "df": 1, "docs": { - "26": { + "29": { "tf": 1.0 } } @@ -5158,7 +5376,7 @@ "l": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.4142135623730951 } } @@ -5270,7 +5488,7 @@ "l": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -5308,7 +5526,7 @@ }, "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -5333,13 +5551,13 @@ "10": { "tf": 1.0 }, - "23": { + "26": { "tf": 1.7320508075688772 }, - "24": { + "27": { "tf": 1.0 }, - "25": { + "28": { "tf": 1.0 } } @@ -5360,10 +5578,10 @@ "n": { "df": 4, "docs": { - "24": { + "27": { "tf": 1.0 }, - "25": { + "28": { "tf": 1.4142135623730951 }, "3": { @@ -5383,7 +5601,7 @@ "e": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -5407,7 +5625,7 @@ "t": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -5698,7 +5916,7 @@ "e": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -5784,7 +6002,7 @@ "17": { "tf": 1.4142135623730951 }, - "24": { + "27": { "tf": 1.4142135623730951 }, "6": { @@ -5966,7 +6184,7 @@ "k": { "df": 2, "docs": { - "24": { + "27": { "tf": 1.4142135623730951 }, "8": { @@ -5981,7 +6199,7 @@ "11": { "tf": 4.69041575982343 }, - "23": { + "26": { "tf": 1.0 } } @@ -6061,6 +6279,38 @@ }, "df": 0, "docs": {} + }, + "t": { + "df": 0, + "docs": {}, + "t": { + "df": 0, + "docs": {}, + "r": { + "df": 0, + "docs": {}, + "i": { + "b": { + "df": 0, + "docs": {}, + "u": { + "df": 0, + "docs": {}, + "t": { + "df": 1, + "docs": { + "23": { + "tf": 1.0 + } + } + } + } + }, + "df": 0, + "docs": {} + } + } + } } }, "b": { @@ -6139,7 +6389,7 @@ "2": { "tf": 1.0 }, - "23": { + "26": { "tf": 1.0 }, "4": { @@ -6154,6 +6404,29 @@ "df": 0, "docs": {} }, + "l": { + "a": { + "df": 0, + "docs": {}, + "s": { + "df": 0, + "docs": {}, + "s": { + "df": 2, + "docs": { + "24": { + "tf": 1.0 + }, + "25": { + "tf": 1.0 + } + } + } + } + }, + "df": 0, + "docs": {} + }, "o": { "df": 0, "docs": {}, @@ -6194,7 +6467,7 @@ "s": { "df": 1, "docs": { - "26": { + "29": { "tf": 1.0 } } @@ -6332,8 +6605,18 @@ "e": { "a": { "d": { - "df": 0, - "docs": {}, + "df": 3, + "docs": { + "23": { + "tf": 1.0 + }, + "24": { + "tf": 1.0 + }, + "25": { + "tf": 1.0 + } + }, "e": { "df": 0, "docs": {}, @@ -6388,6 +6671,14 @@ } }, "i": { + "d": { + "df": 1, + "docs": { + "25": { + "tf": 1.0 + } + } + }, "df": 0, "docs": {}, "n": { @@ -6468,7 +6759,7 @@ "k": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -6542,7 +6833,7 @@ "e": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -6575,7 +6866,7 @@ "t": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -6593,7 +6884,7 @@ "l": { "df": 1, "docs": { - "24": { + "27": { "tf": 1.0 } } @@ -6657,7 +6948,7 @@ "d": { "df": 1, "docs": { - "23": { + "26": { "tf": 1.0 } } @@ -6678,7 +6969,7 @@ "n": { "df": 3, "docs": { - "25": { + "28": { "tf": 1.0 }, "3": { @@ -6883,7 +7174,7 @@ "17": { "tf": 1.0 }, - "24": { + "27": { "tf": 1.0 } } From 1db52ff53170a8c3ea28ef248082946da11a256d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 28 May 2023 11:55:56 -0700 Subject: [PATCH 35/48] Fix search for custom heading attributes --- src/renderer/html_handlebars/search.rs | 6 ++++-- tests/rendered_output.rs | 5 +++++ tests/searchindex_fixture.json | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/renderer/html_handlebars/search.rs b/src/renderer/html_handlebars/search.rs index a9e2f5ca..24d62fda 100644 --- a/src/renderer/html_handlebars/search.rs +++ b/src/renderer/html_handlebars/search.rs @@ -138,9 +138,11 @@ fn render_item( in_heading = true; } - Event::End(Tag::Heading(i, ..)) if i as u32 <= max_section_depth => { + Event::End(Tag::Heading(i, id, _classes)) if i as u32 <= max_section_depth => { in_heading = false; - section_id = Some(utils::unique_id_from_content(&heading, &mut id_counter)); + section_id = id + .map(|id| id.to_string()) + .or_else(|| Some(utils::unique_id_from_content(&heading, &mut id_counter))); breadcrumbs.push(heading.clone()); } Event::Start(Tag::FootnoteDefinition(name)) => { diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 7bc5e7ae..7626b9e8 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -755,6 +755,7 @@ mod search { let no_headers = get_doc_ref("first/no-headers.html"); let duplicate_headers_1 = get_doc_ref("first/duplicate-headers.html#header-text-1"); let conclusion = get_doc_ref("conclusion.html#conclusion"); + let heading_attrs = get_doc_ref("first/heading-attributes.html#both"); let bodyidx = &index["index"]["index"]["body"]["root"]; let textidx = &bodyidx["t"]["e"]["x"]["t"]; @@ -786,6 +787,10 @@ mod search { docs[&no_headers]["body"], "Capybara capybara capybara. Capybara capybara capybara. ThisLongWordIsIncludedSoWeCanCheckThatSufficientlyLongWordsAreOmittedFromTheSearchIndex." ); + assert_eq!( + docs[&heading_attrs]["breadcrumbs"], + "First Chapter » Heading Attributes » Heading with id and classes" + ); } // Setting this to `true` may cause issues with `cargo watch`, diff --git a/tests/searchindex_fixture.json b/tests/searchindex_fixture.json index 1fcfcdab..85463028 100644 --- a/tests/searchindex_fixture.json +++ b/tests/searchindex_fixture.json @@ -23,9 +23,9 @@ "first/duplicate-headers.html#header-text", "first/duplicate-headers.html#header-text-1", "first/duplicate-headers.html#header-text-2", - "first/heading-attributes.html#heading-attributes", + "first/heading-attributes.html#attrs", "first/heading-attributes.html#heading-with-classes", - "first/heading-attributes.html#heading-with-id-and-classes", + "first/heading-attributes.html#both", "second.html#second-chapter", "second/nested.html#testing-relative-links-for-the-print-page", "second/nested.html#some-section", From 7df1d8c838c0e21968666b671885ac185a426fd7 Mon Sep 17 00:00:00 2001 From: Jannik Obermann Date: Wed, 23 Feb 2022 01:02:54 +0100 Subject: [PATCH 36/48] Support hidden lines in languages other than Rust Co-Authored-By: thecodewarrior <5467669+thecodewarrior@users.noreply.github.com> --- guide/book.toml | 3 + guide/src/format/configuration/renderers.md | 11 + guide/src/format/mdbook.md | 41 ++- guide/src/format/theme/syntax-highlighting.md | 32 --- src/config.rs | 19 ++ src/renderer/html_handlebars/hbs_renderer.rs | 259 ++++++++++++++---- src/theme/book.js | 2 +- 7 files changed, 273 insertions(+), 94 deletions(-) diff --git a/guide/book.toml b/guide/book.toml index 025efc0b..7ef29f13 100644 --- a/guide/book.toml +++ b/guide/book.toml @@ -17,6 +17,9 @@ edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path editable = true line-numbers = true +[output.html.code.hidelines] +python = "~" + [output.html.search] limit-results = 20 use-boolean-and = true diff --git a/guide/src/format/configuration/renderers.md b/guide/src/format/configuration/renderers.md index e71a9d7b..fd9ad81d 100644 --- a/guide/src/format/configuration/renderers.md +++ b/guide/src/format/configuration/renderers.md @@ -223,6 +223,17 @@ runnable = true # displays a run button for rust code [Ace]: https://ace.c9.io/ +### `[output.html.code]` + +The `[output.html.code]` table provides options for controlling code blocks. + +```toml +[output.html.code] +# A prefix string per language (one or more chars). +# Any line starting with whitespace+prefix is hidden. +hidelines = { python = "~" } +``` + ### `[output.html.search]` The `[output.html.search]` table provides options for controlling the built-in text [search]. diff --git a/guide/src/format/mdbook.md b/guide/src/format/mdbook.md index 62e89843..485e73a3 100644 --- a/guide/src/format/mdbook.md +++ b/guide/src/format/mdbook.md @@ -4,7 +4,6 @@ There is a feature in mdBook that lets you hide code lines by prepending them with a `#` [like you would with Rustdoc][rustdoc-hide]. -This currently only works with Rust language code blocks. [rustdoc-hide]: https://doc.rust-lang.org/stable/rustdoc/documentation-tests.html#hiding-portions-of-the-example @@ -30,6 +29,46 @@ Will render as The code block has an eyeball icon () which will toggle the visibility of the hidden lines. +By default, this only works for code examples that are annotated with `rust`. +However, you can define custom prefixes for other languages by adding a new line-hiding prefix in your `book.toml` with the language name and prefix character(s): + +```toml +[output.html.code.hidelines] +python = "~" +``` + +The prefix will hide any lines that begin with the given prefix. With the python prefix shown above, this: + +```bash +~hidden() +nothidden(): +~ hidden() + ~hidden() + nothidden() +``` + +will render as + +```python +~hidden() +nothidden(): +~ hidden() + ~hidden() + nothidden() +``` + +This behavior can be overridden locally with a different prefix. This has the same effect as above: + +~~~bash +```python,hidelines=!!! +!!!hidden() +nothidden(): +!!! hidden() + !!!hidden() + nothidden() +``` +~~~ + ## Rust Playground Rust language code blocks will automatically get a play button () which will execute the code and display the output just below the code block. diff --git a/guide/src/format/theme/syntax-highlighting.md b/guide/src/format/theme/syntax-highlighting.md index f57540f0..6b33faa3 100644 --- a/guide/src/format/theme/syntax-highlighting.md +++ b/guide/src/format/theme/syntax-highlighting.md @@ -77,38 +77,6 @@ the `theme` folder of your book. Now your theme will be used instead of the default theme. -## Hiding code lines - -There is a feature in mdBook that lets you hide code lines by prepending them -with a `#`. - - -```bash -# fn main() { - let x = 5; - let y = 6; - - println!("{}", x + y); -# } -``` - -Will render as - -```rust -# fn main() { - let x = 5; - let y = 7; - - println!("{}", x + y); -# } -``` - -**At the moment, this only works for code examples that are annotated with -`rust`. Because it would collide with semantics of some programming languages. -In the future, we want to make this configurable through the `book.toml` so that -everyone can benefit from it.** - - ## Improve default theme If you think the default theme doesn't look quite right for a specific language, diff --git a/src/config.rs b/src/config.rs index a58a48bc..4641d1a2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -504,6 +504,8 @@ pub struct HtmlConfig { /// Playground settings. #[serde(alias = "playpen")] pub playground: Playground, + /// Code settings. + pub code: Code, /// Print settings. pub print: Print, /// Don't render section labels. @@ -556,6 +558,7 @@ impl Default for HtmlConfig { additional_js: Vec::new(), fold: Fold::default(), playground: Playground::default(), + code: Code::default(), print: Print::default(), no_section_label: false, search: None, @@ -642,6 +645,22 @@ impl Default for Playground { } } +/// Configuration for tweaking how the the HTML renderer handles code blocks. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(default, rename_all = "kebab-case")] +pub struct Code { + /// A prefix string to hide lines per language (one or more chars). + pub hidelines: HashMap, +} + +impl Default for Code { + fn default() -> Code { + Code { + hidelines: HashMap::new(), + } + } +} + /// Configuration of the search functionality of the HTML renderer. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(default, rename_all = "kebab-case")] diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index e753dc2e..0681806d 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -1,5 +1,5 @@ use crate::book::{Book, BookItem}; -use crate::config::{BookConfig, Config, HtmlConfig, Playground, RustEdition}; +use crate::config::{BookConfig, Code, Config, HtmlConfig, Playground, RustEdition}; use crate::errors::*; use crate::renderer::html_handlebars::helpers; use crate::renderer::{RenderContext, Renderer}; @@ -110,7 +110,12 @@ impl HtmlHandlebars { debug!("Render template"); let rendered = ctx.handlebars.render("index", &ctx.data)?; - let rendered = self.post_process(rendered, &ctx.html_config.playground, ctx.edition); + let rendered = self.post_process( + rendered, + &ctx.html_config.playground, + &ctx.html_config.code, + ctx.edition, + ); // Write to file debug!("Creating {}", filepath.display()); @@ -121,8 +126,12 @@ impl HtmlHandlebars { ctx.data.insert("path_to_root".to_owned(), json!("")); ctx.data.insert("is_index".to_owned(), json!(true)); let rendered_index = ctx.handlebars.render("index", &ctx.data)?; - let rendered_index = - self.post_process(rendered_index, &ctx.html_config.playground, ctx.edition); + let rendered_index = self.post_process( + rendered_index, + &ctx.html_config.playground, + &ctx.html_config.code, + ctx.edition, + ); debug!("Creating index.html from {}", ctx_path); utils::fs::write_file(&ctx.destination, "index.html", rendered_index.as_bytes())?; } @@ -182,8 +191,12 @@ impl HtmlHandlebars { data_404.insert("title".to_owned(), json!(title)); let rendered = handlebars.render("index", &data_404)?; - let rendered = - self.post_process(rendered, &html_config.playground, ctx.config.rust.edition); + let rendered = self.post_process( + rendered, + &html_config.playground, + &html_config.code, + ctx.config.rust.edition, + ); let output_file = get_404_output_file(&html_config.input_404); utils::fs::write_file(destination, output_file, rendered.as_bytes())?; debug!("Creating 404.html ✓"); @@ -195,11 +208,13 @@ impl HtmlHandlebars { &self, rendered: String, playground_config: &Playground, + code_config: &Code, edition: Option, ) -> String { let rendered = build_header_links(&rendered); let rendered = fix_code_blocks(&rendered); let rendered = add_playground_pre(&rendered, playground_config, edition); + let rendered = hide_lines(&rendered, code_config); rendered } @@ -583,8 +598,12 @@ impl Renderer for HtmlHandlebars { debug!("Render template"); let rendered = handlebars.render("index", &data)?; - let rendered = - self.post_process(rendered, &html_config.playground, ctx.config.rust.edition); + let rendered = self.post_process( + rendered, + &html_config.playground, + &html_config.code, + ctx.config.rust.edition, + ); utils::fs::write_file(destination, "print.html", rendered.as_bytes())?; debug!("Creating print.html ✓"); @@ -887,53 +906,50 @@ fn add_playground_pre( let classes = &caps[2]; let code = &caps[3]; - if classes.contains("language-rust") { - if (!classes.contains("ignore") + if classes.contains("language-rust") + && ((!classes.contains("ignore") && !classes.contains("noplayground") && !classes.contains("noplaypen") && playground_config.runnable) - || classes.contains("mdbook-runnable") - { - let contains_e2015 = classes.contains("edition2015"); - let contains_e2018 = classes.contains("edition2018"); - let contains_e2021 = classes.contains("edition2021"); - let edition_class = if contains_e2015 || contains_e2018 || contains_e2021 { - // the user forced edition, we should not overwrite it - "" - } else { - match edition { - Some(RustEdition::E2015) => " edition2015", - Some(RustEdition::E2018) => " edition2018", - Some(RustEdition::E2021) => " edition2021", - None => "", - } - }; - - // wrap the contents in an external pre block - format!( - "
{}
", - classes, - edition_class, - { - let content: Cow<'_, str> = if playground_config.editable - && classes.contains("editable") - || text.contains("fn main") - || text.contains("quick_main!") - { - code.into() - } else { - // we need to inject our own main - let (attrs, code) = partition_source(code); - - format!("# #![allow(unused)]\n{}#fn main() {{\n{}#}}", attrs, code) - .into() - }; - hide_lines(&content) - } - ) + || classes.contains("mdbook-runnable")) + { + let contains_e2015 = classes.contains("edition2015"); + let contains_e2018 = classes.contains("edition2018"); + let contains_e2021 = classes.contains("edition2021"); + let edition_class = if contains_e2015 || contains_e2018 || contains_e2021 { + // the user forced edition, we should not overwrite it + "" } else { - format!("{}", classes, hide_lines(code)) - } + match edition { + Some(RustEdition::E2015) => " edition2015", + Some(RustEdition::E2018) => " edition2018", + Some(RustEdition::E2021) => " edition2021", + None => "", + } + }; + + // wrap the contents in an external pre block + format!( + "
{}
", + classes, + edition_class, + { + let content: Cow<'_, str> = if playground_config.editable + && classes.contains("editable") + || text.contains("fn main") + || text.contains("quick_main!") + { + code.into() + } else { + // we need to inject our own main + let (attrs, code) = partition_source(code); + + format!("# #![allow(unused)]\n{}#fn main() {{\n{}#}}", attrs, code) + .into() + }; + content + } + ) } else { // not language-rust, so no-op text.to_owned() @@ -942,7 +958,53 @@ fn add_playground_pre( .into_owned() } -fn hide_lines(content: &str) -> String { +fn hide_lines(html: &str, code_config: &Code) -> String { + let regex = Regex::new(r##"((?s)]?class="([^"]+)".*?>(.*?))"##).unwrap(); + let language_regex = Regex::new(r"\blanguage-(\w+)\b").unwrap(); + let hidelines_regex = Regex::new(r"\bhidelines=(\S+)").unwrap(); + regex + .replace_all(html, |caps: &Captures<'_>| { + let text = &caps[1]; + let classes = &caps[2]; + let code = &caps[3]; + + if classes.contains("language-rust") { + format!( + "{}", + classes, + hide_lines_rust(code) + ) + } else { + // First try to get the prefix from the code block + let hidelines_capture = hidelines_regex.captures(classes); + let hidelines_prefix = match &hidelines_capture { + Some(capture) => Some(&capture[1]), + None => { + // Then look up the prefix by language + let language_capture = language_regex.captures(classes); + match &language_capture { + Some(capture) => { + code_config.hidelines.get(&capture[1]).map(|p| p.as_str()) + } + None => None, + } + } + }; + + match hidelines_prefix { + Some(prefix) => format!( + "{}", + classes, + hide_lines_with_prefix(code, prefix) + ), + None => text.to_owned(), + } + } + }) + .into_owned() +} + +fn hide_lines_rust(content: &str) -> String { static BORING_LINES_REGEX: Lazy = Lazy::new(|| Regex::new(r"^(\s*)#(.?)(.*)$").unwrap()); let mut result = String::with_capacity(content.len()); @@ -975,6 +1037,26 @@ fn hide_lines(content: &str) -> String { result } +fn hide_lines_with_prefix(content: &str, prefix: &str) -> String { + let mut result = String::with_capacity(content.len()); + for line in content.lines() { + if line.trim_start().starts_with(prefix) { + let pos = line.find(prefix).unwrap(); + let (ws, rest) = (&line[..pos], &line[pos + prefix.len()..]); + + result += ""; + result += ws; + result += rest; + result += "\n"; + result += ""; + continue; + } + result += line; + result += "\n"; + } + result +} + fn partition_source(s: &str) -> (String, String) { let mut after_header = false; let mut before = String::new(); @@ -1010,6 +1092,7 @@ struct RenderItemContext<'a> { #[cfg(test)] mod tests { use super::*; + use pretty_assertions::assert_eq; #[test] fn original_build_header_links() { @@ -1065,17 +1148,17 @@ mod tests { fn add_playground() { let inputs = [ ("x()", - "
#![allow(unused)]\nfn main() {\nx()\n}
"), + "
# #![allow(unused)]\n#fn main() {\nx()\n#}
"), ("fn main() {}", "
fn main() {}
"), ("let s = \"foo\n # bar\n\";", - "
let s = \"foo\n bar\n\";
"), - ("let s = \"foo\n ## bar\n\";", "
let s = \"foo\n # bar\n\";
"), + ("let s = \"foo\n ## bar\n\";", + "
let s = \"foo\n ## bar\n\";
"), ("let s = \"foo\n # bar\n#\n\";", - "
let s = \"foo\n bar\n\n\";
"), + "
let s = \"foo\n # bar\n#\n\";
"), ("let s = \"foo\n # bar\n\";", - "let s = \"foo\n bar\n\";"), + "let s = \"foo\n # bar\n\";"), ("#![no_std]\nlet s = \"foo\";\n #[some_attr]", "
#![no_std]\nlet s = \"foo\";\n #[some_attr]
"), ]; @@ -1095,7 +1178,7 @@ mod tests { fn add_playground_edition2015() { let inputs = [ ("x()", - "
#![allow(unused)]\nfn main() {\nx()\n}
"), + "
# #![allow(unused)]\n#fn main() {\nx()\n#}
"), ("fn main() {}", "
fn main() {}
"), ("fn main() {}", @@ -1119,7 +1202,7 @@ mod tests { fn add_playground_edition2018() { let inputs = [ ("x()", - "
#![allow(unused)]\nfn main() {\nx()\n}
"), + "
# #![allow(unused)]\n#fn main() {\nx()\n#}
"), ("fn main() {}", "
fn main() {}
"), ("fn main() {}", @@ -1143,7 +1226,7 @@ mod tests { fn add_playground_edition2021() { let inputs = [ ("x()", - "
#![allow(unused)]\nfn main() {\nx()\n}
"), + "
# #![allow(unused)]\n#fn main() {\nx()\n#}
"), ("fn main() {}", "
fn main() {}
"), ("fn main() {}", @@ -1163,4 +1246,60 @@ mod tests { assert_eq!(&*got, *should_be); } } + + #[test] + fn hide_lines_language_rust() { + let inputs = [ + ( + "
\n# #![allow(unused)]\n#fn main() {\nx()\n#}
", + "
\n#![allow(unused)]\nfn main() {\nx()\n}
",), + ( + "
fn main() {}
", + "
fn main() {}
",), + ( + "
let s = \"foo\n # bar\n\";
", + "
let s = \"foo\n bar\n\";
",), + ( + "
let s = \"foo\n ## bar\n\";
", + "
let s = \"foo\n # bar\n\";
",), + ( + "
let s = \"foo\n # bar\n#\n\";
", + "
let s = \"foo\n bar\n\n\";
",), + ( + "let s = \"foo\n # bar\n\";", + "let s = \"foo\n bar\n\";",), + ( + "
#![no_std]\nlet s = \"foo\";\n #[some_attr]
", + "
#![no_std]\nlet s = \"foo\";\n #[some_attr]
",), + ]; + for (src, should_be) in &inputs { + let got = hide_lines(src, &Code::default()); + assert_eq!(&*got, *should_be); + } + } + + #[test] + fn hide_lines_language_other() { + let inputs = [ + ( + "~hidden()\nnothidden():\n~ hidden()\n ~hidden()\n nothidden()", + "hidden()\nnothidden():\n hidden()\n hidden()\n nothidden()\n",), + ( + "!!!hidden()\nnothidden():\n!!! hidden()\n !!!hidden()\n nothidden()", + "hidden()\nnothidden():\n hidden()\n hidden()\n nothidden()\n",), + ]; + for (src, should_be) in &inputs { + let got = hide_lines( + src, + &Code { + hidelines: { + let mut map = HashMap::new(); + map.insert("python".to_string(), "~".to_string()); + map + }, + }, + ); + assert_eq!(&*got, *should_be); + } + } } diff --git a/src/theme/book.js b/src/theme/book.js index f2516be7..ff3650eb 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -179,7 +179,7 @@ function playground_text(playground, hidden = true) { // even if highlighting doesn't apply code_nodes.forEach(function (block) { block.classList.add('hljs'); }); - Array.from(document.querySelectorAll("code.language-rust")).forEach(function (block) { + Array.from(document.querySelectorAll("code.hljs")).forEach(function (block) { var lines = Array.from(block.querySelectorAll('.boring')); // If no lines were hidden, return From 1441fe0b9152daeb2b86f47a153206fa2aa565cc Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 28 May 2023 13:50:21 -0700 Subject: [PATCH 37/48] Explicitly document the `hidelines` key. --- guide/src/format/configuration/renderers.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/guide/src/format/configuration/renderers.md b/guide/src/format/configuration/renderers.md index fd9ad81d..4e1c49da 100644 --- a/guide/src/format/configuration/renderers.md +++ b/guide/src/format/configuration/renderers.md @@ -234,6 +234,9 @@ The `[output.html.code]` table provides options for controlling code blocks. hidelines = { python = "~" } ``` +- **hidelines:** A table that defines how [hidden code lines](../mdbook.md#hiding-code-lines) work for each language. + The key is the language and the value is a string that will cause code lines starting with that prefix to be hidden. + ### `[output.html.search]` The `[output.html.search]` table provides options for controlling the built-in text [search]. From 5572d3d4de1870968bff55c2ee8ca81839f1255e Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 28 May 2023 13:50:34 -0700 Subject: [PATCH 38/48] Expand on hidelines documentation. --- guide/src/format/mdbook.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/guide/src/format/mdbook.md b/guide/src/format/mdbook.md index 485e73a3..2872b250 100644 --- a/guide/src/format/mdbook.md +++ b/guide/src/format/mdbook.md @@ -2,10 +2,11 @@ ## Hiding code lines -There is a feature in mdBook that lets you hide code lines by prepending them -with a `#` [like you would with Rustdoc][rustdoc-hide]. +There is a feature in mdBook that lets you hide code lines by prepending them with a specific prefix. -[rustdoc-hide]: https://doc.rust-lang.org/stable/rustdoc/documentation-tests.html#hiding-portions-of-the-example +For the Rust language, you can use the `#` character as a prefix which will hide lines [like you would with Rustdoc][rustdoc-hide]. + +[rustdoc-hide]: https://doc.rust-lang.org/stable/rustdoc/write-documentation/documentation-tests.html#hiding-portions-of-the-example ```bash # fn main() { @@ -27,7 +28,7 @@ Will render as # } ``` -The code block has an eyeball icon () which will toggle the visibility of the hidden lines. +When you tap or hover the mouse over the code block, there will be an eyeball icon () which will toggle the visibility of the hidden lines. By default, this only works for code examples that are annotated with `rust`. However, you can define custom prefixes for other languages by adding a new line-hiding prefix in your `book.toml` with the language name and prefix character(s): @@ -59,7 +60,7 @@ nothidden(): This behavior can be overridden locally with a different prefix. This has the same effect as above: -~~~bash +~~~markdown ```python,hidelines=!!! !!!hidden() nothidden(): From c9cfe22fd60462726db58bde8266be052aaa5de7 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 28 May 2023 13:51:30 -0700 Subject: [PATCH 39/48] Apply some code style changes. --- src/renderer/html_handlebars/hbs_renderer.rs | 23 +++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 0681806d..709aa066 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -892,15 +892,15 @@ fn fix_code_blocks(html: &str) -> String { .into_owned() } +static CODE_BLOCK_RE: Lazy = + Lazy::new(|| Regex::new(r##"((?s)]?class="([^"]+)".*?>(.*?))"##).unwrap()); + fn add_playground_pre( html: &str, playground_config: &Playground, edition: Option, ) -> String { - static ADD_PLAYGROUND_PRE: Lazy = - Lazy::new(|| Regex::new(r##"((?s)]?class="([^"]+)".*?>(.*?))"##).unwrap()); - - ADD_PLAYGROUND_PRE + CODE_BLOCK_RE .replace_all(html, |caps: &Captures<'_>| { let text = &caps[1]; let classes = &caps[2]; @@ -958,11 +958,12 @@ fn add_playground_pre( .into_owned() } +/// Modifies all `` blocks to convert "hidden" lines and to wrap them in +/// a ``. fn hide_lines(html: &str, code_config: &Code) -> String { - let regex = Regex::new(r##"((?s)]?class="([^"]+)".*?>(.*?))"##).unwrap(); let language_regex = Regex::new(r"\blanguage-(\w+)\b").unwrap(); let hidelines_regex = Regex::new(r"\bhidelines=(\S+)").unwrap(); - regex + CODE_BLOCK_RE .replace_all(html, |caps: &Captures<'_>| { let text = &caps[1]; let classes = &caps[2]; @@ -981,13 +982,9 @@ fn hide_lines(html: &str, code_config: &Code) -> String { Some(capture) => Some(&capture[1]), None => { // Then look up the prefix by language - let language_capture = language_regex.captures(classes); - match &language_capture { - Some(capture) => { - code_config.hidelines.get(&capture[1]).map(|p| p.as_str()) - } - None => None, - } + language_regex.captures(classes).and_then(|capture| { + code_config.hidelines.get(&capture[1]).map(|p| p.as_str()) + }) } }; From d2bcd04133b9c7768a5b9afb06e7d474c1c278ee Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 28 May 2023 14:54:05 -0700 Subject: [PATCH 40/48] Update to 0.4.30 --- CHANGELOG.md | 17 +++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- guide/src/continuous-integration.md | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24bad5b7..b6138236 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## mdBook 0.4.30 +[v0.4.29...v0.4.30](https://github.com/rust-lang/mdBook/compare/v0.4.29...v0.4.30) + +### Added +- Added support for heading attributes. + Attributes are specified in curly braces just after the heading text. + An HTML ID can be specified with `#` and classes with `.`. + For example: `## My heading {#custom-id .class1 .class2}` + [#2013](https://github.com/rust-lang/mdBook/pull/2013) +- Added support for hidden code lines for languages other than Rust. + The `output.html.code.hidelines` table allows you to define the prefix character that will be used to hide code lines based on the language. + [#2093](https://github.com/rust-lang/mdBook/pull/2093) + +### Fixed +- Fixed a few minor markdown rendering issues. + [#2092](https://github.com/rust-lang/mdBook/pull/2092) + ## mdBook 0.4.29 [v0.4.28...v0.4.29](https://github.com/rust-lang/mdBook/compare/v0.4.28...v0.4.29) diff --git a/Cargo.lock b/Cargo.lock index af394b16..31e43fb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -952,7 +952,7 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.29" +version = "0.4.30" dependencies = [ "ammonia", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index dd03884f..e37f962a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mdbook" -version = "0.4.29" +version = "0.4.30" authors = [ "Mathieu David ", "Michael-F-Bryan ", diff --git a/guide/src/continuous-integration.md b/guide/src/continuous-integration.md index 2a7357d1..9ff94c21 100644 --- a/guide/src/continuous-integration.md +++ b/guide/src/continuous-integration.md @@ -21,7 +21,7 @@ A simple approach would be to use the popular `curl` CLI tool to download the ex ```sh mkdir bin -curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.29/mdbook-v0.4.29-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin +curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.30/mdbook-v0.4.30-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin bin/mdbook build ``` From 3c7795cf44d4845bb2a944d1cf9c63d6e3e5a118 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 7 Jun 2023 18:47:15 +0200 Subject: [PATCH 41/48] main branch is not always "master" these days --- guide/src/format/configuration/renderers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guide/src/format/configuration/renderers.md b/guide/src/format/configuration/renderers.md index 4e1c49da..7e743014 100644 --- a/guide/src/format/configuration/renderers.md +++ b/guide/src/format/configuration/renderers.md @@ -150,9 +150,9 @@ The following configuration options are available: - **edit-url-template:** Edit url template, when provided shows a "Suggest an edit" button (which looks like ) for directly jumping to editing the currently viewed page. For e.g. GitHub projects set this to - `https://github.com///edit/master/{path}` or for + `https://github.com///edit//{path}` or for Bitbucket projects set it to - `https://bitbucket.org///src/master/{path}?mode=edit` + `https://bitbucket.org///src//{path}?mode=edit` where {path} will be replaced with the full path of the file in the repository. - **input-404:** The name of the markdown file used for missing files. From 1ef8d70ac466cf12772eb0cb74d6b2feed4b64f1 Mon Sep 17 00:00:00 2001 From: Em Zhan Date: Sat, 17 Jun 2023 21:40:39 -0500 Subject: [PATCH 42/48] Avoid menu border flash during page navigation Partially addresses #443 --- src/theme/book.js | 7 ++++--- src/theme/index.hbs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/theme/book.js b/src/theme/book.js index ff3650eb..1911b118 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -676,13 +676,14 @@ function playground_text(playground, hidden = true) { }, { passive: true }); })(); (function controllBorder() { - menu.classList.remove('bordered'); - document.addEventListener('scroll', function () { + function updateBorder() { if (menu.offsetTop === 0) { menu.classList.remove('bordered'); } else { menu.classList.add('bordered'); } - }, { passive: true }); + } + updateBorder(); + document.addEventListener('scroll', updateBorder, { passive: true }); })(); })(); diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 6f3948c6..195e41bc 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -115,7 +115,7 @@
{{> header}} -