From 04ff12a20644c31e225b3b4648e530dc69bab25a Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 13 Aug 2025 18:03:25 -0700 Subject: [PATCH 1/3] Fix copy/paste error in resource error message --- crates/mdbook-html/src/html_handlebars/helpers/resources.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/mdbook-html/src/html_handlebars/helpers/resources.rs b/crates/mdbook-html/src/html_handlebars/helpers/resources.rs index 01b9738f12..f3cf9cd497 100644 --- a/crates/mdbook-html/src/html_handlebars/helpers/resources.rs +++ b/crates/mdbook-html/src/html_handlebars/helpers/resources.rs @@ -23,7 +23,7 @@ impl HelperDef for ResourceHelper { ) -> Result<(), RenderError> { let param = h.param(0).and_then(|v| v.value().as_str()).ok_or_else(|| { RenderErrorReason::Other( - "Param 0 with String type is required for theme_option helper.".to_owned(), + "Param 0 with String type is required for resource helper.".to_owned(), ) })?; From 76c5b6967a4703d7789c6b3a45efd8d1621c4b51 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 13 Aug 2025 18:03:57 -0700 Subject: [PATCH 2/3] Remove default_theme comment I don't remember why I added this comment. The default_theme is definitely still used. --- crates/mdbook-html/src/html_handlebars/hbs_renderer.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs b/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs index 1c7f01001b..05eb61ff03 100644 --- a/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs +++ b/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs @@ -558,7 +558,6 @@ fn make_data( ); } - // TODO: remove default_theme in 0.5, it is not needed. let default_theme = match html_config.default_theme { Some(ref theme) => theme.to_lowercase(), None => "light".to_string(), From 9fce4ad74c05ae071627abb5fd536daccff3f517 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 13 Aug 2025 18:04:12 -0700 Subject: [PATCH 3/3] Remove theme_option This helper is no longer used. --- .../src/html_handlebars/hbs_renderer.rs | 2 - .../src/html_handlebars/helpers/mod.rs | 1 - .../src/html_handlebars/helpers/theme.rs | 38 ------------------- 3 files changed, 41 deletions(-) delete mode 100644 crates/mdbook-html/src/html_handlebars/helpers/theme.rs diff --git a/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs b/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs index 05eb61ff03..f7404c53f3 100644 --- a/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs +++ b/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs @@ -271,8 +271,6 @@ impl HtmlHandlebars { no_section_label: html_config.no_section_label, }), ); - // TODO: remove theme_option in 0.5, it is not needed. - handlebars.register_helper("theme_option", Box::new(helpers::theme::theme_option)); } fn emit_redirects( diff --git a/crates/mdbook-html/src/html_handlebars/helpers/mod.rs b/crates/mdbook-html/src/html_handlebars/helpers/mod.rs index 720704f3e1..963e8f10af 100644 --- a/crates/mdbook-html/src/html_handlebars/helpers/mod.rs +++ b/crates/mdbook-html/src/html_handlebars/helpers/mod.rs @@ -1,3 +1,2 @@ pub(crate) mod resources; -pub(crate) mod theme; pub(crate) mod toc; diff --git a/crates/mdbook-html/src/html_handlebars/helpers/theme.rs b/crates/mdbook-html/src/html_handlebars/helpers/theme.rs deleted file mode 100644 index 120a8d2ff4..0000000000 --- a/crates/mdbook-html/src/html_handlebars/helpers/theme.rs +++ /dev/null @@ -1,38 +0,0 @@ -use handlebars::{ - Context, Handlebars, Helper, Output, RenderContext, RenderError, RenderErrorReason, -}; -use log::trace; - -pub(crate) fn theme_option( - h: &Helper<'_>, - _r: &Handlebars<'_>, - ctx: &Context, - rc: &mut RenderContext<'_, '_>, - out: &mut dyn Output, -) -> Result<(), RenderError> { - trace!("theme_option (handlebars helper)"); - - let param = h.param(0).and_then(|v| v.value().as_str()).ok_or_else(|| { - RenderErrorReason::ParamTypeMismatchForName( - "theme_option", - "0".to_owned(), - "string".to_owned(), - ) - })?; - - let default_theme = rc.evaluate(ctx, "@root/default_theme")?; - let default_theme_name = default_theme.as_json().as_str().ok_or_else(|| { - RenderErrorReason::ParamTypeMismatchForName( - "theme_option", - "default_theme".to_owned(), - "string".to_owned(), - ) - })?; - - out.write(param)?; - if param.to_lowercase() == default_theme_name.to_lowercase() { - out.write(" (default)")?; - } - - Ok(()) -}