diff --git a/Cargo.lock b/Cargo.lock index d405e56..d444440 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1277,7 +1277,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "snekdown" -version = "0.29.0" +version = "0.29.1" dependencies = [ "asciimath-rs 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index e42eecd..fd88df2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "snekdown" -version = "0.29.0" +version = "0.29.1" authors = ["trivernis "] edition = "2018" license-file = "LICENSE" diff --git a/README.md b/README.md index 1b12c4c..4313e8a 100644 --- a/README.md +++ b/README.md @@ -168,11 +168,15 @@ included-bibliography = ["mybib.toml"] included-glossary = ["myglossary.toml"] # if external sources (images, stylesheets, MathJax) -# should be embedded into the document (default true) +# should be embedded into the document (default: true) embed-external = true -# If SmartArrows should be used (default true) +# If SmartArrows should be used (default: true) smart-arrows = true + +# Includes a MathJax script tag in the document to render MathML in chromium. +# (default: true) +include-math-jax = true ``` The `[Section]` keys are not relevant as the structure gets flattened before the values are read. diff --git a/src/format/html/to_html.rs b/src/format/html/to_html.rs index c7f90c0..d351c3e 100644 --- a/src/format/html/to_html.rs +++ b/src/format/html/to_html.rs @@ -1,7 +1,7 @@ use crate::elements::*; use crate::format::html::html_writer::HTMLWriter; use crate::format::PlaceholderTemplate; -use crate::references::configuration::keys::{EMBED_EXTERNAL, META_LANG}; +use crate::references::configuration::keys::{EMBED_EXTERNAL, INCLUDE_MATHJAX, META_LANG}; use crate::references::configuration::Value; use crate::references::glossary::{GlossaryDisplay, GlossaryReference}; use crate::references::templates::{Template, TemplateVariable}; @@ -103,10 +103,6 @@ impl ToHtml for MetadataValue { impl ToHtml for Document { fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> { let downloads = Arc::clone(&self.downloads); - let mathjax = downloads - .lock() - .unwrap() - .add_download(MATHJAX_URL.to_string()); if let Some(Value::Bool(embed)) = self .config .get_entry(EMBED_EXTERNAL) @@ -138,17 +134,6 @@ impl ToHtml for Document { writer.write(path)?; writer.write("/>".to_string())?; writer.write("".to_string())?; - - if let Some(data) = std::mem::replace(&mut mathjax.lock().unwrap().data, None) { - writer.write("".to_string())?; - } else { - writer.write(format!( - "", - MATHJAX_URL - ))?; - } writer.write("".to_string())?; @@ -157,6 +142,17 @@ impl ToHtml for Document { let mut stylesheet = stylesheet.lock().unwrap(); let data = std::mem::replace(&mut stylesheet.data, None); if let Some(data) = data { + if self + .config + .get_entry(INCLUDE_MATHJAX) + .and_then(|e| e.get().as_bool()) + .unwrap_or(true) + { + writer.write(format!( + "", + MATHJAX_URL + ))?; + } writer.write("".to_string())?; diff --git a/src/references/configuration/keys.rs b/src/references/configuration/keys.rs index 0fccd57..6f96465 100644 --- a/src/references/configuration/keys.rs +++ b/src/references/configuration/keys.rs @@ -8,3 +8,4 @@ pub const IMP_BIBLIOGRAPHY: &str = "included-bibliography"; pub const IMP_GLOSSARY: &str = "included-glossary"; pub const EMBED_EXTERNAL: &str = "embed-external"; pub const SMART_ARROWS: &str = "smart-arrows"; +pub const INCLUDE_MATHJAX: &str = "include-math-jax";