Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CloudFlare CDN request #1256

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +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)?;
if html_config.mathjax_support {
write_file(destination, "mathjax.js", &theme.mathjax_js)?;
}
write_file(
destination,
"FontAwesome/css/font-awesome.css",
Expand Down
2 changes: 1 addition & 1 deletion src/theme/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

{{#if mathjax_support}}
<!-- MathJax -->
<script async type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script async type="text/javascript" src="{{ path_to_root }}mathjax.js?config=TeX-AMS-MML_HTMLorMML"></script>
{{/if}}
</head>
<body>
Expand Down
19 changes: 19 additions & 0 deletions src/theme/mathjax.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/theme/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -62,6 +63,7 @@ pub struct Theme {
pub ayu_highlight_css: Vec<u8>,
pub highlight_js: Vec<u8>,
pub clipboard_js: Vec<u8>,
pub mathjax_js: Vec<u8>,
}

impl Theme {
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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(),
}
}
}
Expand Down Expand Up @@ -219,6 +223,7 @@ mod tests {
"highlight.css",
"ayu-highlight.css",
"clipboard.min.js",
"mathjax.js",
];

let temp = TempFileBuilder::new().prefix("mdbook-").tempdir().unwrap();
Expand Down Expand Up @@ -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);
Expand Down