Feature: Migrates to MathJax version 3 and supports setting different configuration files (defaults to 'tex-mml-chtml').
This commit is contained in:
parent
59d3717159
commit
80dc6c69ba
|
@ -99,6 +99,7 @@ default-theme = "light"
|
||||||
preferred-dark-theme = "navy"
|
preferred-dark-theme = "navy"
|
||||||
curly-quotes = true
|
curly-quotes = true
|
||||||
mathjax-support = false
|
mathjax-support = false
|
||||||
|
mathjax-config = "tex-mml-chtml"
|
||||||
copy-fonts = true
|
copy-fonts = true
|
||||||
additional-css = ["custom.css", "custom2.css"]
|
additional-css = ["custom.css", "custom2.css"]
|
||||||
additional-js = ["custom.js"]
|
additional-js = ["custom.js"]
|
||||||
|
@ -126,6 +127,8 @@ 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`.
|
||||||
|
- **mathjax-config:** The [configuration file](https://docs.mathjax.org/en/latest/web/components/combined.html)
|
||||||
|
used by MathJax. Defaults to `tex-mml-chtml`.
|
||||||
- **copy-fonts:** (**Deprecated**) If `true` (the default), mdBook uses its built-in fonts which are copied to the output directory.
|
- **copy-fonts:** (**Deprecated**) If `true` (the default), mdBook uses its built-in fonts which are copied to the output directory.
|
||||||
If `false`, the built-in fonts will not be used.
|
If `false`, the built-in fonts will not be used.
|
||||||
This option is deprecated. If you want to define your own custom fonts,
|
This option is deprecated. If you want to define your own custom fonts,
|
||||||
|
|
|
@ -530,6 +530,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,
|
||||||
|
/// The configuration file used by MathJax, defaults to 'tex-mml-chtml'.
|
||||||
|
pub mathjax_config: Option<String>,
|
||||||
/// Whether to fonts.css and respective font files to the output directory.
|
/// Whether to fonts.css and respective font files to the output directory.
|
||||||
pub copy_fonts: bool,
|
pub copy_fonts: bool,
|
||||||
/// An optional google analytics code.
|
/// An optional google analytics code.
|
||||||
|
@ -592,6 +594,7 @@ impl Default for HtmlConfig {
|
||||||
preferred_dark_theme: None,
|
preferred_dark_theme: None,
|
||||||
curly_quotes: false,
|
curly_quotes: false,
|
||||||
mathjax_support: false,
|
mathjax_support: false,
|
||||||
|
mathjax_config: Some(String::from("tex-mml-chtml")),
|
||||||
copy_fonts: true,
|
copy_fonts: true,
|
||||||
google_analytics: None,
|
google_analytics: None,
|
||||||
additional_css: Vec::new(),
|
additional_css: Vec::new(),
|
||||||
|
|
|
@ -667,6 +667,10 @@ fn make_data(
|
||||||
if html_config.mathjax_support {
|
if html_config.mathjax_support {
|
||||||
data.insert("mathjax_support".to_owned(), json!(true));
|
data.insert("mathjax_support".to_owned(), json!(true));
|
||||||
}
|
}
|
||||||
|
data.insert(
|
||||||
|
"mathjax_config".to_owned(),
|
||||||
|
json!(html_config.mathjax_config.clone().unwrap_or_default()),
|
||||||
|
);
|
||||||
|
|
||||||
// This `matches!` checks for a non-empty file.
|
// This `matches!` checks for a non-empty file.
|
||||||
if html_config.copy_fonts || matches!(theme.fonts_css.as_deref(), Some([_, ..])) {
|
if html_config.copy_fonts || matches!(theme.fonts_css.as_deref(), Some([_, ..])) {
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
{{#if mathjax_support}}
|
{{#if mathjax_support}}
|
||||||
<!-- MathJax -->
|
<!-- MathJax -->
|
||||||
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
<script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/{{ mathjax_config }}.js"></script>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</head>
|
</head>
|
||||||
<body class="sidebar-visible no-js">
|
<body class="sidebar-visible no-js">
|
||||||
|
|
Loading…
Reference in New Issue