Skip to content

Commit 4c20ab4

Browse files
committed
MathJax: Path to root
If `source` starts with `/` interpret it relative to output dir.
1 parent 48808bf commit 4c20ab4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,15 @@ fn make_data(
681681
data.insert("mathjax_support".to_owned(), json!(true));
682682
} else if html_config.mathjax.enable {
683683
data.insert("mathjax_enable".to_owned(), json!(true));
684-
data.insert(
685-
"mathjax_source".to_owned(),
686-
json!(html_config.mathjax.source),
687-
);
684+
if let Some(ref source) = html_config.mathjax.source {
685+
if source.starts_with("/") {
686+
data.insert("mathjax_root".to_owned(), json!(true));
687+
let (_, relative_source) = source.split_at(1);
688+
data.insert("mathjax_source".to_owned(), json!(relative_source));
689+
} else {
690+
data.insert("mathjax_source".to_owned(), json!(source));
691+
}
692+
}
688693
data.insert(
689694
"mathjax_config".to_owned(),
690695
json!(html_config.mathjax.config),

src/theme/index.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,13 @@
6767
};
6868
</script>
6969
{{/if}}
70+
{{#if mathjax_root}}
71+
<script id="MathJax-script" async src="{{ path_to_root }}{{ mathjax_source }}/{{ mathjax_config }}.js"></script>
72+
{{else}}
7073
<script id="MathJax-script" async src="{{ mathjax_source }}/{{ mathjax_config }}.js"></script>
7174
{{/if}}
7275
{{/if}}
76+
{{/if}}
7377
</head>
7478
<body>
7579
<div id="body-container">

0 commit comments

Comments
 (0)