Skip to content

Commit 2cc4321

Browse files
committed
MathJax: Path to root
If `source` starts with `/` interpret it relative to output dir.
1 parent 123c2b6 commit 2cc4321

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
@@ -654,10 +654,15 @@ fn make_data(
654654
data.insert("mathjax_support".to_owned(), json!(true));
655655
} else if html_config.mathjax.enable {
656656
data.insert("mathjax_enable".to_owned(), json!(true));
657-
data.insert(
658-
"mathjax_source".to_owned(),
659-
json!(html_config.mathjax.source),
660-
);
657+
if let Some(ref source) = html_config.mathjax.source {
658+
if source.starts_with("/") {
659+
data.insert("mathjax_root".to_owned(), json!(true));
660+
let (_, relative_source) = source.split_at(1);
661+
data.insert("mathjax_source".to_owned(), json!(relative_source));
662+
} else {
663+
data.insert("mathjax_source".to_owned(), json!(source));
664+
}
665+
}
661666
data.insert(
662667
"mathjax_config".to_owned(),
663668
json!(html_config.mathjax.config),

src/theme/index.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@
6868
};
6969
</script>
7070
{{/if}}
71+
{{#if mathjax_root}}
72+
<script id="MathJax-script" async src="{{ path_to_root }}{{ mathjax_source }}/{{ mathjax_config }}.js"></script>
73+
{{else}}
7174
<script id="MathJax-script" async src="{{ mathjax_source }}/{{ mathjax_config }}.js"></script>
7275
{{/if}}
7376
{{/if}}
77+
{{/if}}
7478
</head>
7579
<body>
7680
<!-- Provide site root to javascript -->

0 commit comments

Comments
 (0)