MathJax: Path to root

If `source` starts with `/` interpret it relative to output dir.
This commit is contained in:
Konstantin Podsvirov 2022-11-05 13:04:37 +03:00
parent 48808bfb75
commit 4c20ab4248
2 changed files with 13 additions and 4 deletions

View File

@ -681,10 +681,15 @@ fn make_data(
data.insert("mathjax_support".to_owned(), json!(true));
} else if html_config.mathjax.enable {
data.insert("mathjax_enable".to_owned(), json!(true));
data.insert(
"mathjax_source".to_owned(),
json!(html_config.mathjax.source),
);
if let Some(ref source) = html_config.mathjax.source {
if source.starts_with("/") {
data.insert("mathjax_root".to_owned(), json!(true));
let (_, relative_source) = source.split_at(1);
data.insert("mathjax_source".to_owned(), json!(relative_source));
} else {
data.insert("mathjax_source".to_owned(), json!(source));
}
}
data.insert(
"mathjax_config".to_owned(),
json!(html_config.mathjax.config),

View File

@ -67,9 +67,13 @@
};
</script>
{{/if}}
{{#if mathjax_root}}
<script id="MathJax-script" async src="{{ path_to_root }}{{ mathjax_source }}/{{ mathjax_config }}.js"></script>
{{else}}
<script id="MathJax-script" async src="{{ mathjax_source }}/{{ mathjax_config }}.js"></script>
{{/if}}
{{/if}}
{{/if}}
</head>
<body>
<div id="body-container">