From 1cacef025de3bf9e3d6620d68a4d60ac37b61f33 Mon Sep 17 00:00:00 2001 From: josh rotenberg Date: Tue, 28 Dec 2021 21:00:06 -0800 Subject: [PATCH 01/49] check for the index.html file first --- src/cmd/build.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index d1c66302..e9112f9b 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -2,6 +2,7 @@ use crate::{get_book_dir, open}; use clap::{App, ArgMatches, SubCommand}; use mdbook::errors::Result; use mdbook::MDBook; +use std::path::Path; // Create clap subcommand arguments pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> { @@ -32,6 +33,12 @@ pub fn execute(args: &ArgMatches) -> Result<()> { if args.is_present("open") { // FIXME: What's the right behaviour if we don't use the HTML renderer? + let path = book.build_dir_for("html").join("index.html"); + if !Path::new(&path).exists() { + error!("Need a more descriptive error here: {:?}", path); + std::process::exit(1); + } + open(book.build_dir_for("html").join("index.html")); } From b0511f408d72113b74494f49120fcaf79262284f Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 4 Jan 2022 10:18:39 -0800 Subject: [PATCH 02/49] Update to 0.4.15 --- CHANGELOG.md | 10 ++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- guide/src/continuous-integration.md | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83e7818f..9b3b6a2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## mdBook 0.4.15 +[5eb7d46...68a5c09](https://github.com/rust-lang/mdBook/compare/5eb7d46...68a5c09) + +### Changed +- Major update to expand the documentation located at . + [#1709](https://github.com/rust-lang/mdBook/pull/1709) + [#1710](https://github.com/rust-lang/mdBook/pull/1710) +- Updated the markdown parser with various fixes for common-mark compliance. + [#1712](https://github.com/rust-lang/mdBook/pull/1712) + ## mdBook 0.4.14 [ffa8284...c9b6be8](https://github.com/rust-lang/mdBook/compare/ffa8284...c9b6be8) diff --git a/Cargo.lock b/Cargo.lock index 7d45fac9..b44d152d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -839,7 +839,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "mdbook" -version = "0.4.14" +version = "0.4.15" dependencies = [ "ammonia", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 0d7751cd..e61f74a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mdbook" -version = "0.4.14" +version = "0.4.15" authors = [ "Mathieu David ", "Michael-F-Bryan ", diff --git a/guide/src/continuous-integration.md b/guide/src/continuous-integration.md index baf510be..3503445f 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.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin +curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.15/mdbook-v0.4.15-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin bin/mdbook build ``` From 526a0394b00b9acdf371b14571086eeb1187313e Mon Sep 17 00:00:00 2001 From: klensy Date: Thu, 6 Jan 2022 20:35:13 +0300 Subject: [PATCH 03/49] don't use additional features for pulldown-cmark --- Cargo.lock | 10 ---------- Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b44d152d..b85c0ce1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -473,15 +473,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getopts" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" -dependencies = [ - "unicode-width", -] - [[package]] name = "getrandom" version = "0.1.16" @@ -1272,7 +1263,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acd16514d1af5f7a71f909a44ef253cdb712a376d7ebc8ae4a471a9be9743548" dependencies = [ "bitflags", - "getopts", "memchr", "unicase", ] diff --git a/Cargo.toml b/Cargo.toml index e61f74a0..eef90de7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ lazy_static = "1.0" log = "0.4" memchr = "2.0" opener = "0.5" -pulldown-cmark = "0.9.0" +pulldown-cmark = { version = "0.9", default-features = false } regex = "1.0.0" serde = "1.0" serde_derive = "1.0" From a226de38b6258b570f286520878955537d28ea2f Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Thu, 13 Jan 2022 18:01:42 -0600 Subject: [PATCH 04/49] ci: use new cargo fmt option --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd3c7558..39624230 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,4 +48,4 @@ jobs: - uses: actions/checkout@master - name: Install Rust run: rustup update stable && rustup default stable && rustup component add rustfmt - - run: cargo fmt -- --check + - run: cargo fmt --check From 7b1241d0f287e07a0056834020726f5a1e69f5a8 Mon Sep 17 00:00:00 2001 From: Daniel Morawetz Date: Mon, 17 Jan 2022 18:03:52 +0100 Subject: [PATCH 05/49] Revert "Make page-break not configurable" This reverts commit 0eb23efd44c96d79c96161648a6c286dbc7424c1. --- src/config.rs | 7 ++++++- src/renderer/html_handlebars/hbs_renderer.rs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index bf4aabbb..daeccbd0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -592,11 +592,16 @@ impl HtmlConfig { pub struct Print { /// Whether print support is enabled. pub enable: bool, + /// Insert page breaks between chapters. Default: `true`. + pub page_break: bool, } impl Default for Print { fn default() -> Self { - Self { enable: true } + Self { + enable: true, + page_break: true, + } } } diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index e8da5b4a..69dc3124 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -56,7 +56,7 @@ impl HtmlHandlebars { let fixed_content = utils::render_markdown_with_path(&ch.content, ctx.html_config.curly_quotes, Some(path)); - if !ctx.is_index { + if !ctx.is_index && ctx.html_config.print.page_break { // Add page break between chapters // See https://developer.mozilla.org/en-US/docs/Web/CSS/break-before and https://developer.mozilla.org/en-US/docs/Web/CSS/page-break-before // Add both two CSS properties because of the compatibility issue From 9e6217871e8f7b7580703c4f0cd99938ee0a3e19 Mon Sep 17 00:00:00 2001 From: Daniel Morawetz Date: Mon, 17 Jan 2022 18:07:22 +0100 Subject: [PATCH 06/49] add page-break option to docs --- guide/src/format/configuration/renderers.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guide/src/format/configuration/renderers.md b/guide/src/format/configuration/renderers.md index a29265e4..1aa1eef9 100644 --- a/guide/src/format/configuration/renderers.md +++ b/guide/src/format/configuration/renderers.md @@ -173,10 +173,12 @@ By default, mdBook will include an icon on the top right of the book (which look ```toml [output.html.print] enable = true # include support for printable output +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`. ### `[output.html.fold]` From 4206739492a3a8f2eda3d3dd6352a3392cf05643 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 18 Jan 2022 16:01:23 +0100 Subject: [PATCH 07/49] Update pulldown-cmark version --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b85c0ce1..42d6983e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1258,9 +1258,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acd16514d1af5f7a71f909a44ef253cdb712a376d7ebc8ae4a471a9be9743548" +checksum = "34f197a544b0c9ab3ae46c359a7ec9cbbb5c7bf97054266fecb7ead794a181d6" dependencies = [ "bitflags", "memchr", diff --git a/Cargo.toml b/Cargo.toml index eef90de7..e0aef886 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ lazy_static = "1.0" log = "0.4" memchr = "2.0" opener = "0.5" -pulldown-cmark = { version = "0.9", default-features = false } +pulldown-cmark = { version = "0.9.1", default-features = false } regex = "1.0.0" serde = "1.0" serde_derive = "1.0" From c5c8f1a6d3701c7e9673cf5e70874654db40fa0a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 23 Jan 2022 00:01:10 -0800 Subject: [PATCH 08/49] Update semver dev-dependency in nop-preprocessor example to 1.0 --- Cargo.lock | 16 ++-------------- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 42d6983e..ffec902d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1454,21 +1454,9 @@ dependencies = [ [[package]] name = "semver" -version = "0.11.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] +checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "serde" diff --git a/Cargo.toml b/Cargo.toml index e0aef886..61b23e1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ ammonia = { version = "3", optional = true } assert_cmd = "1" predicates = "2" select = "0.5" -semver = "0.11.0" +semver = "1.0" pretty_assertions = "0.6" walkdir = "2.0" From 81d661c4f193b67f69aa5698e0367c5d1386ec7b Mon Sep 17 00:00:00 2001 From: ilslv Date: Fri, 11 Feb 2022 12:33:22 +0300 Subject: [PATCH 09/49] Fix no initial title consuming events. --- src/book/summary.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/book/summary.rs b/src/book/summary.rs index 1ade05ec..2427a3a2 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -536,6 +536,10 @@ impl<'a> SummaryParser<'a> { // Skip a HTML element such as a comment line. Some(Event::Html(_)) => {} // Otherwise, no title. + Some(ev) => { + self.back(ev); + return None; + } _ => return None, } } @@ -647,6 +651,15 @@ mod tests { assert_eq!(got, should_be); } + #[test] + fn no_initial_title() { + let src = "[Link]()"; + let mut parser = SummaryParser::new(src); + + assert!(parser.parse_title().is_none()); + assert!(matches!(parser.next_event(), Some(Event::Start(Tag::Paragraph)))); + } + #[test] fn parse_title_with_styling() { let src = "# My **Awesome** Summary"; From 6c4974b5c6415c7ad6ac124af5e0a3b49de96259 Mon Sep 17 00:00:00 2001 From: ilslv Date: Fri, 11 Feb 2022 12:42:54 +0300 Subject: [PATCH 10/49] Fmt --- src/book/summary.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/book/summary.rs b/src/book/summary.rs index 2427a3a2..b5a740c2 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -657,7 +657,10 @@ mod tests { let mut parser = SummaryParser::new(src); assert!(parser.parse_title().is_none()); - assert!(matches!(parser.next_event(), Some(Event::Start(Tag::Paragraph)))); + assert!(matches!( + parser.next_event(), + Some(Event::Start(Tag::Paragraph)), + )); } #[test] From b73d02fb8c058f0f29c2b10a40906e1b8beff8b5 Mon Sep 17 00:00:00 2001 From: ilslv Date: Fri, 11 Feb 2022 12:50:22 +0300 Subject: [PATCH 11/49] Remove colon to satisfy msrv --- src/book/summary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/book/summary.rs b/src/book/summary.rs index b5a740c2..4bb8e969 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -659,7 +659,7 @@ mod tests { assert!(parser.parse_title().is_none()); assert!(matches!( parser.next_event(), - Some(Event::Start(Tag::Paragraph)), + Some(Event::Start(Tag::Paragraph)) )); } From 972c61fa76d0bd972538a762cd62afca4c917a33 Mon Sep 17 00:00:00 2001 From: Tom Milligan Date: Fri, 18 Feb 2022 15:27:24 +0000 Subject: [PATCH 12/49] search: fix anchor ids for duplicate headers --- src/renderer/html_handlebars/hbs_renderer.rs | 11 +- src/renderer/html_handlebars/search.rs | 3 +- src/utils/mod.rs | 57 +- tests/dummy_book/src/SUMMARY.md | 1 + .../dummy_book/src/first/duplicate-headers.md | 9 + tests/rendered_output.rs | 10 +- tests/searchindex_fixture.json | 600 ++++++++++++++---- 7 files changed, 554 insertions(+), 137 deletions(-) create mode 100644 tests/dummy_book/src/first/duplicate-headers.md diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 69dc3124..c4c2862d 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -768,16 +768,7 @@ fn insert_link_into_header( content: &str, id_counter: &mut HashMap, ) -> String { - let raw_id = utils::id_from_content(content); - - let id_count = id_counter.entry(raw_id.clone()).or_insert(0); - - let id = match *id_count { - 0 => raw_id, - other => format!("{}-{}", raw_id, other), - }; - - *id_count += 1; + let id = utils::unique_id_from_content(content, id_counter); format!( r##"{text}"##, diff --git a/src/renderer/html_handlebars/search.rs b/src/renderer/html_handlebars/search.rs index 39b59800..5dd063da 100644 --- a/src/renderer/html_handlebars/search.rs +++ b/src/renderer/html_handlebars/search.rs @@ -97,6 +97,7 @@ fn render_item( breadcrumbs.push(chapter.name.clone()); + let mut id_counter = HashMap::new(); while let Some(event) = p.next() { match event { Event::Start(Tag::Heading(i, ..)) if i as u32 <= max_section_depth => { @@ -120,7 +121,7 @@ fn render_item( } Event::End(Tag::Heading(i, ..)) if i as u32 <= max_section_depth => { in_heading = false; - section_id = Some(utils::id_from_content(&heading)); + section_id = Some(utils::unique_id_from_content(&heading, &mut id_counter)); breadcrumbs.push(heading.clone()); } Event::Start(Tag::FootnoteDefinition(name)) => { diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 44494a8b..cf213264 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -9,6 +9,7 @@ use regex::Regex; use pulldown_cmark::{html, CodeBlockKind, CowStr, Event, Options, Parser, Tag}; use std::borrow::Cow; +use std::collections::HashMap; use std::fmt::Write; use std::path::Path; @@ -44,6 +45,8 @@ pub fn normalize_id(content: &str) -> String { /// Generate an ID for use with anchors which is derived from a "normalised" /// string. +// This function should be made private when the deprecation expires. +#[deprecated(since = "0.4.16", note = "use unique_id_from_content instead")] pub fn id_from_content(content: &str) -> String { let mut content = content.to_string(); @@ -59,10 +62,30 @@ pub fn id_from_content(content: &str) -> String { // Remove spaces and hashes indicating a header let trimmed = content.trim().trim_start_matches('#').trim(); - normalize_id(trimmed) } +/// Generate an ID for use with anchors which is derived from a "normalised" +/// string. +/// +/// Each ID returned will be unique, if the same `id_counter` is provided on +/// each call. +pub fn unique_id_from_content(content: &str, id_counter: &mut HashMap) -> String { + let id = { + #[allow(deprecated)] + id_from_content(content) + }; + + // If we have headers with the same normalized id, append an incrementing counter + let id_count = id_counter.entry(id.clone()).or_insert(0); + let unique_id = match *id_count { + 0 => id, + id_count => format!("{}-{}", id, id_count), + }; + *id_count += 1; + unique_id +} + /// Fix links to the correct location. /// /// This adjusts links, such as turning `.md` extensions to `.html`. @@ -332,8 +355,9 @@ more text with spaces } } - mod html_munging { - use super::super::{id_from_content, normalize_id}; + #[allow(deprecated)] + mod id_from_content { + use super::super::id_from_content; #[test] fn it_generates_anchors() { @@ -361,6 +385,10 @@ more text with spaces ); assert_eq!(id_from_content("## Über"), "Über"); } + } + + mod html_munging { + use super::super::{normalize_id, unique_id_from_content}; #[test] fn it_normalizes_ids() { @@ -379,5 +407,28 @@ more text with spaces assert_eq!(normalize_id("한국어"), "한국어"); assert_eq!(normalize_id(""), ""); } + + #[test] + fn it_generates_unique_ids_from_content() { + // Same id if not given shared state + assert_eq!( + unique_id_from_content("## 中文標題 CJK title", &mut Default::default()), + "中文標題-cjk-title" + ); + assert_eq!( + unique_id_from_content("## 中文標題 CJK title", &mut Default::default()), + "中文標題-cjk-title" + ); + + // Different id if given shared state + let mut id_counter = Default::default(); + assert_eq!(unique_id_from_content("## Über", &mut id_counter), "Über"); + assert_eq!( + unique_id_from_content("## 中文標題 CJK title", &mut id_counter), + "中文標題-cjk-title" + ); + assert_eq!(unique_id_from_content("## Über", &mut id_counter), "Über-1"); + assert_eq!(unique_id_from_content("## Über", &mut id_counter), "Über-2"); + } } } diff --git a/tests/dummy_book/src/SUMMARY.md b/tests/dummy_book/src/SUMMARY.md index e12e1254..49b64a54 100644 --- a/tests/dummy_book/src/SUMMARY.md +++ b/tests/dummy_book/src/SUMMARY.md @@ -13,6 +13,7 @@ - [Markdown](first/markdown.md) - [Unicode](first/unicode.md) - [No Headers](first/no-headers.md) + - [Duplicate Headers](first/duplicate-headers.md) - [Second Chapter](second.md) - [Nested Chapter](second/nested.md) diff --git a/tests/dummy_book/src/first/duplicate-headers.md b/tests/dummy_book/src/first/duplicate-headers.md new file mode 100644 index 00000000..83522b44 --- /dev/null +++ b/tests/dummy_book/src/first/duplicate-headers.md @@ -0,0 +1,9 @@ +# Duplicate headers + +This page validates behaviour of duplicate headers. + +# Header Text + +# Header Text + +# header-text diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 5ec6e64b..f3d11d53 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -35,6 +35,7 @@ const TOC_SECOND_LEVEL: &[&str] = &[ "1.4. Markdown", "1.5. Unicode", "1.6. No Headers", + "1.7. Duplicate Headers", "2.1. Nested Chapter", ]; @@ -633,11 +634,12 @@ mod search { let some_section = get_doc_ref("first/index.html#some-section"); let summary = get_doc_ref("first/includes.html#summary"); 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 bodyidx = &index["index"]["index"]["body"]["root"]; let textidx = &bodyidx["t"]["e"]["x"]["t"]; - assert_eq!(textidx["df"], 2); + assert_eq!(textidx["df"], 5); assert_eq!(textidx["docs"][&first_chapter]["tf"], 1.0); assert_eq!(textidx["docs"][&introduction]["tf"], 1.0); @@ -646,7 +648,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 Second Chapter Nested Chapter Conclusion" + "Dummy Book Introduction First Chapter Nested Chapter Includes Recursive Markdown Unicode No Headers Duplicate Headers Second Chapter Nested Chapter Conclusion" ); assert_eq!( docs[&summary]["breadcrumbs"], @@ -657,6 +659,10 @@ mod search { docs[&no_headers]["breadcrumbs"], "First Chapter » No Headers" ); + assert_eq!( + docs[&duplicate_headers_1]["breadcrumbs"], + "First Chapter » Duplicate Headers » Header Text" + ); assert_eq!( docs[&no_headers]["body"], "Capybara capybara capybara. Capybara capybara capybara." diff --git a/tests/searchindex_fixture.json b/tests/searchindex_fixture.json index 32c44a1b..9c349b6b 100644 --- a/tests/searchindex_fixture.json +++ b/tests/searchindex_fixture.json @@ -19,6 +19,10 @@ "first/markdown.html#tasklisks", "first/unicode.html#unicode-stress-tests", "first/no-headers.html", + "first/duplicate-headers.html#duplicate-headers", + "first/duplicate-headers.html#header-text", + "first/duplicate-headers.html#header-text-1", + "first/duplicate-headers.html#header-text-2", "second.html#second-chapter", "second/nested.html#testing-relative-links-for-the-print-page", "second/nested.html#some-section", @@ -38,7 +42,7 @@ "title": 1 }, "10": { - "body": 17, + "body": 19, "breadcrumbs": 4, "title": 1 }, @@ -83,8 +87,8 @@ "title": 2 }, "19": { - "body": 20, - "breadcrumbs": 4, + "body": 5, + "breadcrumbs": 6, "title": 2 }, "2": { @@ -93,16 +97,36 @@ "title": 2 }, "20": { + "body": 0, + "breadcrumbs": 6, + "title": 2 + }, + "21": { + "body": 0, + "breadcrumbs": 6, + "title": 2 + }, + "22": { + "body": 0, + "breadcrumbs": 6, + "title": 2 + }, + "23": { + "body": 20, + "breadcrumbs": 4, + "title": 2 + }, + "24": { "body": 18, "breadcrumbs": 9, "title": 5 }, - "21": { + "25": { "body": 0, "breadcrumbs": 5, "title": 1 }, - "22": { + "26": { "body": 3, "breadcrumbs": 2, "title": 1 @@ -157,7 +181,7 @@ "title": "Introduction" }, "10": { - "body": "Dummy Book Introduction First Chapter Nested Chapter Includes Recursive Markdown Unicode No Headers Second Chapter Nested Chapter Conclusion", + "body": "Dummy Book Introduction First Chapter Nested Chapter Includes Recursive Markdown Unicode No Headers Duplicate Headers Second Chapter Nested Chapter Conclusion", "breadcrumbs": "First Chapter » Includes » Summary", "id": "10", "title": "Summary" @@ -211,10 +235,10 @@ "title": "First Chapter" }, "19": { - "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": "This page validates behaviour of duplicate headers.", + "breadcrumbs": "First Chapter » Duplicate Headers » Duplicate headers", "id": "19", - "title": "Second Chapter" + "title": "Duplicate headers" }, "2": { "body": "more text.", @@ -223,21 +247,45 @@ "title": "First Chapter" }, "20": { - "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 » Duplicate Headers » Header Text", "id": "20", - "title": "Testing relative links for the print page" + "title": "Header Text" }, "21": { "body": "", - "breadcrumbs": "Second Chapter » Nested Chapter » Some section", + "breadcrumbs": "First Chapter » Duplicate Headers » Header Text", "id": "21", - "title": "Some section" + "title": "Header Text" }, "22": { + "body": "", + "breadcrumbs": "First Chapter » Duplicate Headers » header-text", + "id": "22", + "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", + "id": "23", + "title": "Second Chapter" + }, + "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", + "id": "24", + "title": "Testing relative links for the print page" + }, + "25": { + "body": "", + "breadcrumbs": "Second Chapter » Nested Chapter » Some section", + "id": "25", + "title": "Some section" + }, + "26": { "body": "I put <HTML> in here!", "breadcrumbs": "Conclusion » Conclusion", - "id": "22", + "id": "26", "title": "Conclusion" }, "3": { @@ -283,7 +331,7 @@ "title": "Includes" } }, - "length": 23, + "length": 27, "save": true }, "fields": [ @@ -478,6 +526,38 @@ "e": { "df": 0, "docs": {}, + "h": { + "a": { + "df": 0, + "docs": {}, + "v": { + "df": 0, + "docs": {}, + "i": { + "df": 0, + "docs": {}, + "o": { + "df": 0, + "docs": {}, + "u": { + "df": 0, + "docs": {}, + "r": { + "df": 1, + "docs": { + "19": { + "tf": 1.0 + } + } + } + } + } + } + } + }, + "df": 0, + "docs": {} + }, "t": { "df": 0, "docs": {}, @@ -539,7 +619,7 @@ "h": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -738,10 +818,10 @@ "18": { "tf": 1.0 }, - "19": { + "2": { "tf": 1.0 }, - "2": { + "23": { "tf": 1.0 }, "4": { @@ -783,7 +863,7 @@ "e": { "df": 2, "docs": { - "19": { + "23": { "tf": 1.0 }, "4": { @@ -850,7 +930,7 @@ "10": { "tf": 1.0 }, - "22": { + "26": { "tf": 1.0 } } @@ -922,7 +1002,7 @@ "d": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } }, @@ -947,6 +1027,29 @@ } } } + }, + "p": { + "df": 0, + "docs": {}, + "l": { + "df": 0, + "docs": {}, + "i": { + "c": { + "df": 2, + "docs": { + "10": { + "tf": 1.0 + }, + "19": { + "tf": 1.4142135623730951 + } + } + }, + "df": 0, + "docs": {} + } + } } } }, @@ -1012,7 +1115,7 @@ "n": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -1053,7 +1156,7 @@ "d": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -1122,7 +1225,7 @@ "0": { "tf": 1.0 }, - "19": { + "23": { "tf": 1.0 }, "4": { @@ -1158,7 +1261,7 @@ "2": { "tf": 1.0 }, - "20": { + "24": { "tf": 1.0 } } @@ -1169,7 +1272,7 @@ "n": { "df": 3, "docs": { - "19": { + "23": { "tf": 1.0 }, "7": { @@ -1243,7 +1346,7 @@ "t": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -1289,9 +1392,21 @@ "df": 0, "docs": {}, "r": { - "df": 1, + "df": 5, "docs": { "10": { + "tf": 1.4142135623730951 + }, + "19": { + "tf": 1.4142135623730951 + }, + "20": { + "tf": 1.0 + }, + "21": { + "tf": 1.0 + }, + "22": { "tf": 1.0 } } @@ -1336,7 +1451,7 @@ "0": { "tf": 1.0 }, - "22": { + "26": { "tf": 1.0 } } @@ -1354,7 +1469,7 @@ "n": { "df": 2, "docs": { - "19": { + "23": { "tf": 1.0 }, "7": { @@ -1369,7 +1484,7 @@ "e": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -1387,7 +1502,7 @@ "l": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -1405,7 +1520,7 @@ "g": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -1477,7 +1592,7 @@ "t": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -1613,7 +1728,7 @@ "14": { "tf": 1.4142135623730951 }, - "19": { + "23": { "tf": 1.0 }, "6": { @@ -1624,7 +1739,7 @@ "k": { "df": 1, "docs": { - "20": { + "24": { "tf": 2.23606797749979 } } @@ -1678,7 +1793,7 @@ "t": { "df": 1, "docs": { - "22": { + "26": { "tf": 1.0 } } @@ -1706,7 +1821,7 @@ "n": { "df": 3, "docs": { - "19": { + "23": { "tf": 1.0 }, "7": { @@ -1724,7 +1839,7 @@ "e": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -1853,7 +1968,7 @@ "n": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -1892,7 +2007,7 @@ "d": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -1912,9 +2027,12 @@ "df": 0, "docs": {}, "e": { - "df": 1, + "df": 2, "docs": { - "20": { + "19": { + "tf": 1.0 + }, + "24": { "tf": 1.7320508075688772 } } @@ -2027,7 +2145,7 @@ "t": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.7320508075688772 } }, @@ -2055,7 +2173,7 @@ "o": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -2067,7 +2185,7 @@ "i": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -2093,7 +2211,7 @@ "t": { "df": 1, "docs": { - "22": { + "26": { "tf": 1.0 } } @@ -2129,7 +2247,7 @@ "l": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -2241,7 +2359,7 @@ "l": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -2279,7 +2397,7 @@ }, "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -2304,7 +2422,7 @@ "10": { "tf": 1.0 }, - "19": { + "23": { "tf": 1.0 } } @@ -2325,10 +2443,10 @@ "n": { "df": 4, "docs": { - "20": { + "24": { "tf": 1.0 }, - "21": { + "25": { "tf": 1.0 }, "3": { @@ -2348,7 +2466,7 @@ "e": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -2372,7 +2490,7 @@ "t": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -2663,7 +2781,7 @@ "e": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -2749,7 +2867,7 @@ "17": { "tf": 1.0 }, - "20": { + "24": { "tf": 1.0 }, "6": { @@ -2762,13 +2880,22 @@ "df": 0, "docs": {}, "t": { - "df": 2, + "df": 5, "docs": { "1": { "tf": 1.0 }, "2": { "tf": 1.0 + }, + "20": { + "tf": 1.0 + }, + "21": { + "tf": 1.0 + }, + "22": { + "tf": 1.0 } } } @@ -2866,6 +2993,30 @@ } } }, + "v": { + "a": { + "df": 0, + "docs": {}, + "l": { + "df": 0, + "docs": {}, + "i": { + "d": { + "df": 1, + "docs": { + "19": { + "tf": 1.0 + } + } + }, + "df": 0, + "docs": {} + } + } + }, + "df": 0, + "docs": {} + }, "w": { "a": { "df": 0, @@ -2898,7 +3049,7 @@ "k": { "df": 2, "docs": { - "20": { + "24": { "tf": 1.4142135623730951 }, "8": { @@ -2913,7 +3064,7 @@ "11": { "tf": 4.69041575982343 }, - "19": { + "23": { "tf": 1.0 } } @@ -3136,6 +3287,38 @@ "e": { "df": 0, "docs": {}, + "h": { + "a": { + "df": 0, + "docs": {}, + "v": { + "df": 0, + "docs": {}, + "i": { + "df": 0, + "docs": {}, + "o": { + "df": 0, + "docs": {}, + "u": { + "df": 0, + "docs": {}, + "r": { + "df": 1, + "docs": { + "19": { + "tf": 1.0 + } + } + } + } + } + } + } + }, + "df": 0, + "docs": {} + }, "t": { "df": 0, "docs": {}, @@ -3197,7 +3380,7 @@ "h": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -3385,7 +3568,7 @@ "df": 0, "docs": {}, "r": { - "df": 20, + "df": 24, "docs": { "10": { "tf": 2.23606797749979 @@ -3415,15 +3598,27 @@ "tf": 1.4142135623730951 }, "19": { - "tf": 1.7320508075688772 + "tf": 1.0 }, "2": { "tf": 1.7320508075688772 }, "20": { - "tf": 1.4142135623730951 + "tf": 1.0 }, "21": { + "tf": 1.0 + }, + "22": { + "tf": 1.0 + }, + "23": { + "tf": 1.7320508075688772 + }, + "24": { + "tf": 1.4142135623730951 + }, + "25": { "tf": 1.4142135623730951 }, "3": { @@ -3483,7 +3678,7 @@ "e": { "df": 2, "docs": { - "19": { + "23": { "tf": 1.0 }, "4": { @@ -3550,7 +3745,7 @@ "10": { "tf": 1.0 }, - "22": { + "26": { "tf": 1.7320508075688772 } } @@ -3622,7 +3817,7 @@ "d": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } }, @@ -3647,6 +3842,38 @@ } } } + }, + "p": { + "df": 0, + "docs": {}, + "l": { + "df": 0, + "docs": {}, + "i": { + "c": { + "df": 5, + "docs": { + "10": { + "tf": 1.0 + }, + "19": { + "tf": 2.0 + }, + "20": { + "tf": 1.0 + }, + "21": { + "tf": 1.0 + }, + "22": { + "tf": 1.0 + } + } + }, + "df": 0, + "docs": {} + } + } } } }, @@ -3712,7 +3939,7 @@ "n": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -3753,7 +3980,7 @@ "d": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -3822,7 +4049,7 @@ "0": { "tf": 1.0 }, - "19": { + "23": { "tf": 1.0 }, "4": { @@ -3844,7 +4071,7 @@ "df": 0, "docs": {}, "t": { - "df": 18, + "df": 22, "docs": { "10": { "tf": 1.4142135623730951 @@ -3873,12 +4100,24 @@ "18": { "tf": 1.4142135623730951 }, + "19": { + "tf": 1.0 + }, "2": { "tf": 1.7320508075688772 }, "20": { "tf": 1.0 }, + "21": { + "tf": 1.0 + }, + "22": { + "tf": 1.0 + }, + "24": { + "tf": 1.0 + }, "3": { "tf": 1.0 }, @@ -3908,7 +4147,7 @@ "n": { "df": 3, "docs": { - "19": { + "23": { "tf": 1.0 }, "7": { @@ -3982,7 +4221,7 @@ "t": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -4028,13 +4267,25 @@ "df": 0, "docs": {}, "r": { - "df": 2, + "df": 6, "docs": { "10": { - "tf": 1.0 + "tf": 1.4142135623730951 }, "18": { "tf": 1.0 + }, + "19": { + "tf": 2.0 + }, + "20": { + "tf": 1.7320508075688772 + }, + "21": { + "tf": 1.7320508075688772 + }, + "22": { + "tf": 1.7320508075688772 } } } @@ -4078,7 +4329,7 @@ "0": { "tf": 1.0 }, - "22": { + "26": { "tf": 1.0 } } @@ -4096,7 +4347,7 @@ "n": { "df": 2, "docs": { - "19": { + "23": { "tf": 1.0 }, "7": { @@ -4111,7 +4362,7 @@ "e": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -4129,7 +4380,7 @@ "l": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -4147,7 +4398,7 @@ "g": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -4219,7 +4470,7 @@ "t": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -4355,7 +4606,7 @@ "14": { "tf": 1.4142135623730951 }, - "19": { + "23": { "tf": 1.0 }, "6": { @@ -4366,7 +4617,7 @@ "k": { "df": 1, "docs": { - "20": { + "24": { "tf": 2.449489742783178 } } @@ -4420,7 +4671,7 @@ "t": { "df": 1, "docs": { - "22": { + "26": { "tf": 1.0 } } @@ -4448,7 +4699,7 @@ "n": { "df": 3, "docs": { - "19": { + "23": { "tf": 1.0 }, "7": { @@ -4466,7 +4717,7 @@ "e": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -4582,10 +4833,10 @@ "10": { "tf": 1.4142135623730951 }, - "20": { + "24": { "tf": 1.0 }, - "21": { + "25": { "tf": 1.0 }, "4": { @@ -4625,7 +4876,7 @@ "n": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -4664,7 +4915,7 @@ "d": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -4684,9 +4935,12 @@ "df": 0, "docs": {}, "e": { - "df": 1, + "df": 2, "docs": { - "20": { + "19": { + "tf": 1.0 + }, + "24": { "tf": 2.0 } } @@ -4799,7 +5053,7 @@ "t": { "df": 1, "docs": { - "20": { + "24": { "tf": 2.0 } }, @@ -4827,7 +5081,7 @@ "o": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -4839,7 +5093,7 @@ "i": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -4865,7 +5119,7 @@ "t": { "df": 1, "docs": { - "22": { + "26": { "tf": 1.0 } } @@ -4904,7 +5158,7 @@ "l": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.4142135623730951 } } @@ -5016,7 +5270,7 @@ "l": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -5054,7 +5308,7 @@ }, "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -5079,13 +5333,13 @@ "10": { "tf": 1.0 }, - "19": { + "23": { "tf": 1.7320508075688772 }, - "20": { + "24": { "tf": 1.0 }, - "21": { + "25": { "tf": 1.0 } } @@ -5106,10 +5360,10 @@ "n": { "df": 4, "docs": { - "20": { + "24": { "tf": 1.0 }, - "21": { + "25": { "tf": 1.4142135623730951 }, "3": { @@ -5129,7 +5383,7 @@ "e": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -5153,7 +5407,7 @@ "t": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -5444,7 +5698,7 @@ "e": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -5530,7 +5784,7 @@ "17": { "tf": 1.4142135623730951 }, - "20": { + "24": { "tf": 1.4142135623730951 }, "6": { @@ -5543,13 +5797,22 @@ "df": 0, "docs": {}, "t": { - "df": 2, + "df": 5, "docs": { "1": { "tf": 1.0 }, "2": { "tf": 1.0 + }, + "20": { + "tf": 1.4142135623730951 + }, + "21": { + "tf": 1.4142135623730951 + }, + "22": { + "tf": 1.4142135623730951 } } } @@ -5647,6 +5910,30 @@ } } }, + "v": { + "a": { + "df": 0, + "docs": {}, + "l": { + "df": 0, + "docs": {}, + "i": { + "d": { + "df": 1, + "docs": { + "19": { + "tf": 1.0 + } + } + }, + "df": 0, + "docs": {} + } + } + }, + "df": 0, + "docs": {} + }, "w": { "a": { "df": 0, @@ -5679,7 +5966,7 @@ "k": { "df": 2, "docs": { - "20": { + "24": { "tf": 1.4142135623730951 }, "8": { @@ -5694,7 +5981,7 @@ "11": { "tf": 4.69041575982343 }, - "19": { + "23": { "tf": 1.0 } } @@ -5849,10 +6136,10 @@ "18": { "tf": 1.0 }, - "19": { + "2": { "tf": 1.0 }, - "2": { + "23": { "tf": 1.0 }, "4": { @@ -5907,7 +6194,7 @@ "s": { "df": 1, "docs": { - "22": { + "26": { "tf": 1.0 } } @@ -5941,6 +6228,26 @@ } } } + }, + "p": { + "df": 0, + "docs": {}, + "l": { + "df": 0, + "docs": {}, + "i": { + "c": { + "df": 1, + "docs": { + "19": { + "tf": 1.0 + } + } + }, + "df": 0, + "docs": {} + } + } } } }, @@ -6022,6 +6329,39 @@ "h": { "df": 0, "docs": {}, + "e": { + "a": { + "d": { + "df": 0, + "docs": {}, + "e": { + "df": 0, + "docs": {}, + "r": { + "df": 4, + "docs": { + "19": { + "tf": 1.0 + }, + "20": { + "tf": 1.0 + }, + "21": { + "tf": 1.0 + }, + "22": { + "tf": 1.0 + } + } + } + } + }, + "df": 0, + "docs": {} + }, + "df": 0, + "docs": {} + }, "i": { "d": { "d": { @@ -6128,7 +6468,7 @@ "k": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -6202,7 +6542,7 @@ "e": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -6235,7 +6575,7 @@ "t": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -6253,7 +6593,7 @@ "l": { "df": 1, "docs": { - "20": { + "24": { "tf": 1.0 } } @@ -6317,7 +6657,7 @@ "d": { "df": 1, "docs": { - "19": { + "23": { "tf": 1.0 } } @@ -6338,7 +6678,7 @@ "n": { "df": 3, "docs": { - "21": { + "25": { "tf": 1.0 }, "3": { @@ -6543,8 +6883,26 @@ "17": { "tf": 1.0 }, + "24": { + "tf": 1.0 + } + } + } + }, + "x": { + "df": 0, + "docs": {}, + "t": { + "df": 3, + "docs": { "20": { "tf": 1.0 + }, + "21": { + "tf": 1.0 + }, + "22": { + "tf": 1.0 } } } From 50bad7f9838740ac8619d552136d11f6411f8800 Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Tue, 22 Feb 2022 18:00:41 +0200 Subject: [PATCH 13/49] style: add missing word --- guide/src/for_developers/preprocessors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/src/for_developers/preprocessors.md b/guide/src/for_developers/preprocessors.md index 0054f242..1ac46256 100644 --- a/guide/src/for_developers/preprocessors.md +++ b/guide/src/for_developers/preprocessors.md @@ -61,7 +61,7 @@ The `chapter.content` is just a string which happens to be markdown. While it's entirely possible to use regular expressions or do a manual find & replace, you'll probably want to process the input into something more computer-friendly. The [`pulldown-cmark`][pc] crate implements a production-quality event-based -Markdown parser, with the [`pulldown-cmark-to-cmark`][pctc] allowing you to +Markdown parser, with the [`pulldown-cmark-to-cmark`][pctc] crate allowing you to translate events back into markdown text. The following code block shows how to remove all emphasis from markdown, From 917df6e97d79bc3f4c6250cfd1b6b6160a7127de Mon Sep 17 00:00:00 2001 From: Dylan DPC Date: Wed, 9 Mar 2022 08:04:50 +0100 Subject: [PATCH 14/49] update regex --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ffec902d..bf6c881d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1390,9 +1390,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ "aho-corasick", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 61b23e1d..6e225ea6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ log = "0.4" memchr = "2.0" opener = "0.5" pulldown-cmark = { version = "0.9.1", default-features = false } -regex = "1.0.0" +regex = "1.5.5" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" From 6899d9402725e411c696e0c1942e3230ab4e0e01 Mon Sep 17 00:00:00 2001 From: Clark Date: Sat, 19 Mar 2022 04:38:16 +0800 Subject: [PATCH 15/49] livereload uses host&port of current page; livereload works with a HTTPS site --- src/cmd/serve.rs | 5 ++--- src/config.rs | 14 +++++++------- src/renderer/html_handlebars/hbs_renderer.rs | 7 +++++-- src/theme/index.hbs | 6 ++++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index c5394f8a..b4782575 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -62,11 +62,10 @@ pub fn execute(args: &ArgMatches) -> Result<()> { let address = format!("{}:{}", hostname, port); - let livereload_url = format!("ws://{}/{}", address, LIVE_RELOAD_ENDPOINT); let update_config = |book: &mut MDBook| { book.config - .set("output.html.livereload-url", &livereload_url) - .expect("livereload-url update failed"); + .set("output.html.live-reload-endpoint", &LIVE_RELOAD_ENDPOINT) + .expect("live-reload-endpoint update failed"); if let Some(dest_dir) = args.value_of("dest-dir") { book.config.build.build_dir = dest_dir.into(); } diff --git a/src/config.rs b/src/config.rs index daeccbd0..6423100e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -531,16 +531,16 @@ pub struct HtmlConfig { pub cname: Option, /// Edit url template, when set shows a "Suggest an edit" button for /// directly jumping to editing the currently viewed page. - /// Contains {path} that is replaced with chapter source file path + /// Contains {path} that is replaced with chapter source file path[[[[ pub edit_url_template: Option, - /// This is used as a bit of a workaround for the `mdbook serve` command. - /// Basically, because you set the websocket port from the command line, the - /// `mdbook serve` command needs a way to let the HTML renderer know where - /// to point livereloading at, if it has been enabled. + /// Endpoint of websocket, for livereload usage. Value loaded from .toml file + /// is ignored, because our code overrides this field with the value [`LIVE_RELOAD_ENDPOINT`] + /// + /// [`LIVE_RELOAD_ENDPOINT`]: cmd::serve::LIVE_RELOAD_ENDPOINT /// /// This config item *should not be edited* by the end user. #[doc(hidden)] - pub livereload_url: Option, + pub live_reload_endpoint: Option, /// The mapping from old pages to new pages/URLs to use when generating /// redirects. pub redirect: HashMap, @@ -569,7 +569,7 @@ impl Default for HtmlConfig { input_404: None, site_url: None, cname: None, - livereload_url: None, + live_reload_endpoint: None, redirect: HashMap::new(), } } diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 69dc3124..f9f19a46 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -606,8 +606,11 @@ fn make_data( if theme.favicon_svg.is_some() { data.insert("favicon_svg".to_owned(), json!("favicon.svg")); } - if let Some(ref livereload) = html_config.livereload_url { - data.insert("livereload".to_owned(), json!(livereload)); + if let Some(ref live_reload_endpoint) = html_config.live_reload_endpoint { + data.insert( + "live_reload_endpoint".to_owned(), + json!(live_reload_endpoint), + ); } let default_theme = match html_config.default_theme { diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 966eedbc..18d984a2 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -219,10 +219,12 @@ - {{#if livereload}} + {{#if live_reload_endpoint}}