diff --git a/Cargo.lock b/Cargo.lock index 20ccbc8101..063302ca38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1078,7 +1078,7 @@ version = "0.0.0" [[package]] name = "mdbook-core" -version = "0.5.2" +version = "0.6.0" dependencies = [ "anyhow", "regex", diff --git a/Cargo.toml b/Cargo.toml index ff8766c268..8419d9f205 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ hex = "0.4.3" html5ever = "0.39.0" indexmap = "2.14.0" ignore = "0.4.25" -mdbook-core = { path = "crates/mdbook-core", version = "0.5.2" } +mdbook-core = { path = "crates/mdbook-core", version = "0.6.0" } mdbook-driver = { path = "crates/mdbook-driver", version = "0.5.2" } mdbook-html = { path = "crates/mdbook-html", version = "0.5.2" } mdbook-markdown = { path = "crates/mdbook-markdown", version = "0.5.2" } diff --git a/crates/mdbook-core/Cargo.toml b/crates/mdbook-core/Cargo.toml index f1aada8282..6a77eb46ac 100644 --- a/crates/mdbook-core/Cargo.toml +++ b/crates/mdbook-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mdbook-core" -version = "0.5.2" +version = "0.6.0" description = "The base support library for mdbook, intended for internal use only" edition.workspace = true license.workspace = true diff --git a/crates/mdbook-core/src/config.rs b/crates/mdbook-core/src/config.rs index b2c6862c30..3994002dc4 100644 --- a/crates/mdbook-core/src/config.rs +++ b/crates/mdbook-core/src/config.rs @@ -476,8 +476,8 @@ pub struct HtmlConfig { pub code: Code, /// Print settings. pub print: Print, - /// Don't render section labels. - pub no_section_label: bool, + /// Render numeric section labels in the table of contents. + pub section_label_toc: bool, /// Search settings. If `None`, the default will be used. pub search: Option, /// Git repository url. If `None`, the git button will not be shown. @@ -536,7 +536,7 @@ impl Default for HtmlConfig { playground: Playground::default(), code: Code::default(), print: Print::default(), - no_section_label: false, + section_label_toc: true, search: None, git_repository_url: None, git_repository_icon: None, diff --git a/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs b/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs index 8edac3cace..263d356634 100644 --- a/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs +++ b/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs @@ -228,7 +228,7 @@ impl HtmlHandlebars { handlebars.register_helper( "toc", Box::new(helpers::toc::RenderToc { - no_section_label: html_config.no_section_label, + section_label_toc: html_config.section_label_toc, }), ); handlebars.register_helper("fa", Box::new(helpers::fontawesome::fa_helper)); diff --git a/crates/mdbook-html/src/html_handlebars/helpers/toc.rs b/crates/mdbook-html/src/html_handlebars/helpers/toc.rs index baee73f6d3..b1f2cad5d3 100644 --- a/crates/mdbook-html/src/html_handlebars/helpers/toc.rs +++ b/crates/mdbook-html/src/html_handlebars/helpers/toc.rs @@ -9,7 +9,7 @@ use std::{cmp::Ordering, collections::BTreeMap}; // Handlebars helper to construct TOC #[derive(Clone, Copy)] pub(crate) struct RenderToc { - pub no_section_label: bool, + pub section_label_toc: bool, } impl HelperDef for RenderToc { @@ -134,7 +134,7 @@ impl HelperDef for RenderToc { } }; - if !self.no_section_label { + if self.section_label_toc { // Section does not necessarily exist if let Some(section) = item.get("section") { out.write("")?; diff --git a/guide/src/format/configuration/renderers.md b/guide/src/format/configuration/renderers.md index 22dfd425fb..0d1abb10e4 100644 --- a/guide/src/format/configuration/renderers.md +++ b/guide/src/format/configuration/renderers.md @@ -103,7 +103,7 @@ admonitions = true mathjax-support = false additional-css = ["custom.css", "custom2.css"] additional-js = ["custom.js"] -no-section-label = false +section-label-toc = true git-repository-url = "https://github.com/rust-lang/mdBook" git-repository-icon = "fab-github" edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}" @@ -138,9 +138,9 @@ The following configuration options are available: - **additional-js:** If you need to add some behaviour to your book without removing the current behaviour, you can specify a set of JavaScript files that will be loaded alongside the default one. -- **no-section-label:** mdBook by defaults adds numeric section labels in the table of - contents column. For example, "1.", "2.1". Set this option to true to disable - those labels. Defaults to `false`. +- **section-label-toc:** mdBook by default adds numeric section labels in the table + of contents column. For example, "1.", "2.1". Set this option to `false` to + disable those labels. Defaults to `true`. - **git-repository-url:** A url to the git repository for the book. If provided an icon link will be output in the menu bar of the book. - **git-repository-icon:** The Font Awesome icon class to use for the git repository link. Defaults to `fab-github` which looks like . If you are not using GitHub, another option to consider is `fas-code-fork` which looks like . The start of the string should be `fa-` for regular icons, `fas-` for solid icons, or `fab-` for brand icons. See the [free icon set](https://fontawesome.com/v6/search) for the available icons.