From 2c6c97e3a466c9c7194585e3073240a8429feea9 Mon Sep 17 00:00:00 2001 From: Shreyas Minocha Date: Sat, 13 Jun 2020 13:15:49 +0530 Subject: [PATCH 1/4] Remove MathJax-related CF request --- src/theme/index.hbs | 4 ++-- src/theme/mathjax.js | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/theme/mathjax.js diff --git a/src/theme/index.hbs b/src/theme/index.hbs index e8a92dd098..555ba38bbb 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -40,7 +40,7 @@ {{#if mathjax_support}} - + {{/if}} @@ -241,7 +241,7 @@ window.playpen_line_numbers = true; {{/if}} - + {{#if playpen_copyable}} + {{/if}} From 65bf12ba1474f75689d25e32e7946174dfdb06a0 Mon Sep 17 00:00:00 2001 From: Shreyas Minocha Date: Thu, 9 Jul 2020 10:21:01 +0530 Subject: [PATCH 3/4] Attempt to add code to handle mathjax.js --- src/renderer/html_handlebars/hbs_renderer.rs | 1 + src/theme/mod.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index fa576998f1..be4e3c9caf 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -203,6 +203,7 @@ impl HtmlHandlebars { write_file(destination, "ayu-highlight.css", &theme.ayu_highlight_css)?; write_file(destination, "highlight.js", &theme.highlight_js)?; write_file(destination, "clipboard.min.js", &theme.clipboard_js)?; + write_file(destination, "mathjax.js", &theme.mathjax_js)?; write_file( destination, "FontAwesome/css/font-awesome.css", diff --git a/src/theme/mod.rs b/src/theme/mod.rs index a1ee18affd..4c270c79e2 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -29,6 +29,7 @@ pub static TOMORROW_NIGHT_CSS: &[u8] = include_bytes!("tomorrow-night.css"); pub static HIGHLIGHT_CSS: &[u8] = include_bytes!("highlight.css"); pub static AYU_HIGHLIGHT_CSS: &[u8] = include_bytes!("ayu-highlight.css"); pub static CLIPBOARD_JS: &[u8] = include_bytes!("clipboard.min.js"); +pub static MATHJAX_JS: &[u8] = include_bytes!("mathjax.js"); pub static FONT_AWESOME: &[u8] = include_bytes!("FontAwesome/css/font-awesome.min.css"); pub static FONT_AWESOME_EOT: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.eot"); pub static FONT_AWESOME_SVG: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.svg"); @@ -62,6 +63,7 @@ pub struct Theme { pub ayu_highlight_css: Vec, pub highlight_js: Vec, pub clipboard_js: Vec, + pub mathjax_js: Vec, } impl Theme { @@ -93,6 +95,7 @@ impl Theme { ), (theme_dir.join("highlight.js"), &mut theme.highlight_js), (theme_dir.join("clipboard.min.js"), &mut theme.clipboard_js), + (theme_dir.join("mathjax.js"), &mut theme.mathjax_js), (theme_dir.join("highlight.css"), &mut theme.highlight_css), ( theme_dir.join("tomorrow-night.css"), @@ -161,6 +164,7 @@ impl Default for Theme { ayu_highlight_css: AYU_HIGHLIGHT_CSS.to_owned(), highlight_js: HIGHLIGHT_JS.to_owned(), clipboard_js: CLIPBOARD_JS.to_owned(), + mathjax_js: MATHJAX_JS.to_owned(), } } } @@ -219,6 +223,7 @@ mod tests { "highlight.css", "ayu-highlight.css", "clipboard.min.js", + "mathjax.js", ]; let temp = TempFileBuilder::new().prefix("mdbook-").tempdir().unwrap(); @@ -248,6 +253,7 @@ mod tests { ayu_highlight_css: Vec::new(), highlight_js: Vec::new(), clipboard_js: Vec::new(), + mathjax_js: Vec::new(), }; assert_eq!(got, empty); From f9f98b5a9c6fda0f2f807ec934407671fd1a37f5 Mon Sep 17 00:00:00 2001 From: Shreyas Minocha Date: Thu, 9 Jul 2020 10:44:14 +0530 Subject: [PATCH 4/4] Restrict copying of mathjax.js --- src/renderer/html_handlebars/hbs_renderer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index be4e3c9caf..abcf58174a 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -203,7 +203,9 @@ impl HtmlHandlebars { write_file(destination, "ayu-highlight.css", &theme.ayu_highlight_css)?; write_file(destination, "highlight.js", &theme.highlight_js)?; write_file(destination, "clipboard.min.js", &theme.clipboard_js)?; - write_file(destination, "mathjax.js", &theme.mathjax_js)?; + if html_config.mathjax_support { + write_file(destination, "mathjax.js", &theme.mathjax_js)?; + } write_file( destination, "FontAwesome/css/font-awesome.css",