Rename config from no-copy-fonts to copy-fonts

This commit is contained in:
Aphek 2020-05-19 03:09:25 -03:00
parent 2c26c65f4d
commit 122c988477
4 changed files with 33 additions and 10 deletions

View File

@ -177,7 +177,7 @@ The following configuration options are available:
that occur in code blocks and code spans. Defaults to `false`. that occur in code blocks and code spans. Defaults to `false`.
- **mathjax-support:** Adds support for [MathJax](mathjax.md). Defaults to - **mathjax-support:** Adds support for [MathJax](mathjax.md). Defaults to
`false`. `false`.
- **no-copy-fonts:** Prevents fonts.css and respective font files from being copied. Defaults to `false`. - **copy-fonts:** Copies fonts.css and respective font files to the output directory and use them in the default theme. Defaults to `true`.
- **google-analytics:** If you use Google Analytics, this option lets you enable - **google-analytics:** If you use Google Analytics, this option lets you enable
it by simply specifying your ID in the configuration file. it by simply specifying your ID in the configuration file.
- **additional-css:** If you need to slightly change the appearance of your book - **additional-css:** If you need to slightly change the appearance of your book
@ -253,7 +253,7 @@ default-theme = "light"
preferred-dark-theme = "navy" preferred-dark-theme = "navy"
curly-quotes = true curly-quotes = true
mathjax-support = false mathjax-support = false
no-copy-fonts = false copy-fonts = true
google-analytics = "123456" google-analytics = "123456"
additional-css = ["custom.css", "custom2.css"] additional-css = ["custom.css", "custom2.css"]
additional-js = ["custom.js"] additional-js = ["custom.js"]

View File

@ -475,7 +475,7 @@ pub enum RustEdition {
} }
/// Configuration for the HTML renderer. /// Configuration for the HTML renderer.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")] #[serde(default, rename_all = "kebab-case")]
pub struct HtmlConfig { pub struct HtmlConfig {
/// The theme directory, if specified. /// The theme directory, if specified.
@ -489,8 +489,8 @@ pub struct HtmlConfig {
pub curly_quotes: bool, pub curly_quotes: bool,
/// Should mathjax be enabled? /// Should mathjax be enabled?
pub mathjax_support: bool, pub mathjax_support: bool,
/// Prevents fonts.css and respective font files from being copied. /// Whether to fonts.css and respective font files to the output directory.
pub no_copy_fonts: bool, pub copy_fonts: bool,
/// An optional google analytics code. /// An optional google analytics code.
pub google_analytics: Option<String>, pub google_analytics: Option<String>,
/// Additional CSS stylesheets to include in the rendered page's `<head>`. /// Additional CSS stylesheets to include in the rendered page's `<head>`.
@ -521,6 +521,29 @@ pub struct HtmlConfig {
pub livereload_url: Option<String>, pub livereload_url: Option<String>,
} }
impl Default for HtmlConfig {
fn default() -> HtmlConfig {
HtmlConfig {
theme: None,
default_theme: None,
preferred_dark_theme: None,
curly_quotes: false,
mathjax_support: false,
copy_fonts: true,
google_analytics: None,
additional_css: Vec::new(),
additional_js: Vec::new(),
fold: Fold::default(),
playpen: Playpen::default(),
no_section_label: false,
search: None,
git_repository_url: None,
git_repository_icon: None,
livereload_url: None,
}
}
}
impl HtmlConfig { impl HtmlConfig {
/// Returns the directory of theme from the provided root directory. If the /// Returns the directory of theme from the provided root directory. If the
/// directory is not present it will append the default directory of "theme" /// directory is not present it will append the default directory of "theme"

View File

@ -179,7 +179,7 @@ impl HtmlHandlebars {
"FontAwesome/fonts/FontAwesome.ttf", "FontAwesome/fonts/FontAwesome.ttf",
theme::FONT_AWESOME_TTF, theme::FONT_AWESOME_TTF,
)?; )?;
if !html_config.no_copy_fonts { if html_config.copy_fonts {
write_file(destination, "fonts/fonts.css", theme::fonts::CSS)?; write_file(destination, "fonts/fonts.css", theme::fonts::CSS)?;
for (file_name, contents) in theme::fonts::OPEN_SANS.iter() { for (file_name, contents) in theme::fonts::OPEN_SANS.iter() {
write_file(destination, file_name, contents)?; write_file(destination, file_name, contents)?;
@ -455,8 +455,8 @@ fn make_data(
data.insert("mathjax_support".to_owned(), json!(true)); data.insert("mathjax_support".to_owned(), json!(true));
} }
if html_config.no_copy_fonts { if html_config.copy_fonts {
data.insert("no_copy_fonts".to_owned(), json!(true)); data.insert("copy_fonts".to_owned(), json!(true));
} }
// Add check to see if there is an additional style // Add check to see if there is an additional style

View File

@ -24,9 +24,9 @@
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
{{#unless no_copy_fonts}} {{#if copy_fonts}}
<link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css"> <link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css">
{{/unless}} {{/if}}
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="{{ path_to_root }}highlight.css"> <link rel="stylesheet" href="{{ path_to_root }}highlight.css">