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)); data.insert("mathjax_support".to_owned(), json!(true));
} else if html_config.mathjax.enable { } else if html_config.mathjax.enable {
data.insert("mathjax_enable".to_owned(), json!(true)); data.insert("mathjax_enable".to_owned(), json!(true));
data.insert( if let Some(ref source) = html_config.mathjax.source {
"mathjax_source".to_owned(), if source.starts_with("/") {
json!(html_config.mathjax.source), 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( data.insert(
"mathjax_config".to_owned(), "mathjax_config".to_owned(),
json!(html_config.mathjax.config), json!(html_config.mathjax.config),

View File

@ -67,9 +67,13 @@
}; };
</script> </script>
{{/if}} {{/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> <script id="MathJax-script" async src="{{ mathjax_source }}/{{ mathjax_config }}.js"></script>
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/if}}
</head> </head>
<body> <body>
<div id="body-container"> <div id="body-container">