Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed May 23, 2023
1 parent 1c891bf commit ef0a0a1
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/site/mdbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ const THEME_INDEX_HBS_PATH: &str = "index.hbs";
const THEME_INDEX_HBS: &str = include_str!("../../oranda-css/mdbook-theme/index.hbs");

const THEME_HIGHLIGHT_CSS_PATH: &str = "highlight.css";
const THEMES: &[(&str, &str)] = &[("MaterialTheme", include_str!("../../oranda-css/mdbook-theme/highlight-js-themes/base16-material.css"))];
const THEMES: &[(&str, &str)] = &[(
"MaterialTheme",
include_str!("../../oranda-css/mdbook-theme/highlight-js-themes/base16-material.css"),
)];

/// Build and write mdbook to the dist dir
pub fn build_mdbook(dist: &Utf8Path, book_cfg: &MdBookConfig, syntax_theme: &SyntaxTheme) -> Result<()> {
pub fn build_mdbook(
dist: &Utf8Path,
book_cfg: &MdBookConfig,
syntax_theme: &SyntaxTheme,
) -> Result<()> {
Message::new(MessageType::Info, "Building mdbook...").print();
tracing::info!("Building mdbook...");

Expand Down Expand Up @@ -90,13 +97,16 @@ fn init_theme_files(theme_dir: &Utf8Path, syntax_theme: &SyntaxTheme) -> Result<
}

let theme_name = syntax_theme.as_str();
let highlight_theme = THEMES.iter().find_map(|(name, contents)| {
if *name == theme_name {
Some(*contents)
} else {
None
}
}).expect("failed to find highlightjs syntax theme for mdbook!?");
let highlight_theme = THEMES
.iter()
.find_map(|(name, contents)| {
if *name == theme_name {
Some(*contents)
} else {
None
}
})
.expect("failed to find highlightjs syntax theme for mdbook!?");

let files = vec![
(THEME_GENERAL_CSS_PATH, THEME_GENERAL_CSS),
Expand All @@ -113,7 +123,6 @@ fn init_theme_files(theme_dir: &Utf8Path, syntax_theme: &SyntaxTheme) -> Result<
LocalAsset::create_dir_all(theme_dir.as_str())?;
LocalAsset::write_new_all(contents, path)?;
}


Ok(())
}
Expand Down

0 comments on commit ef0a0a1

Please sign in to comment.