From 982a11aa77c8c69bc14365c63e1a83cc7e3402d0 Mon Sep 17 00:00:00 2001 From: ChrisJr404 Date: Wed, 6 May 2026 17:55:25 -0400 Subject: [PATCH 1/3] Rename no-section-label to section-label-toc Closes #2761. The previous `no-section-label` config key was a negative flag whose default was `false`, which made the meaning awkward to reason about (double negative). Rename it to `section-label-toc` with a default of `true`, preserving the existing behavior of showing numeric section labels in the table of contents. The `-toc` suffix anticipates a possible future `section-label-title` flag for #2760. Per @ehuss in #2761, this is a clean rename for 0.5 with no deprecation shim. The existing `HtmlConfig::Default` impl is updated to set the new field to `true`. With `deny_unknown_fields`, books that still set `no-section-label` will fail the deserialize with a message that lists `section-label-toc` among the expected fields. --- crates/mdbook-core/src/config.rs | 6 +++--- crates/mdbook-html/src/html_handlebars/hbs_renderer.rs | 2 +- crates/mdbook-html/src/html_handlebars/helpers/toc.rs | 4 ++-- guide/src/format/configuration/renderers.md | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) 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. From 3212b99b9812b14a458fd20536d9c6225b856552 Mon Sep 17 00:00:00 2001 From: ChrisJr404 Date: Thu, 7 May 2026 07:38:56 -0400 Subject: [PATCH 2/3] chore(mdbook-core): bump to 0.6.0 for HtmlConfig field rename cargo-semver-checks correctly flags removing the no_section_label field as a major-version-required change. Bump mdbook-core (and the workspace dep pin) to 0.6.0 so the rename is properly versioned. --- Cargo.toml | 2 +- crates/mdbook-core/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 From 956dd64fb14996e4f8058a1e7be9f93aea6068d0 Mon Sep 17 00:00:00 2001 From: ChrisJr404 Date: Thu, 7 May 2026 12:02:39 -0400 Subject: [PATCH 3/3] chore: update Cargo.lock for mdbook-core 0.6.0 --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",