Implement support for custom LaTeX markers and MathJax integration
This commit is contained in:
parent
27dab4a5e5
commit
5925dd3bfa
|
@ -268,17 +268,40 @@ fn generate_module(
|
||||||
timestamp: timestamp.as_secs().to_string(),
|
timestamp: timestamp.as_secs().to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let rendered_content = convert_latex_markers(
|
||||||
|
inject_math_library(
|
||||||
|
module.render().expect("Module documentation template rendering"),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
(
|
(
|
||||||
search_indexes,
|
search_indexes,
|
||||||
DocFile {
|
DocFile {
|
||||||
path: PathBuf::from(format!("{}.html", module.module_name)),
|
path: PathBuf::from(format!("{}.html", module.module_name)),
|
||||||
content: module
|
content: rendered_content,
|
||||||
.render()
|
|
||||||
.expect("Module documentation template rendering"),
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn convert_latex_markers(input: String) -> String {
|
||||||
|
input.replace("#[", "\\(")
|
||||||
|
.replace("]#", "\\)")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn inject_math_library(html: String) -> String {
|
||||||
|
let mathjax_script = r#"
|
||||||
|
<script type="text/javascript" id="MathJax-script" async
|
||||||
|
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
MathJax.typeset();
|
||||||
|
</script>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
html.replace("</head>", &format!("{}\n</head>", mathjax_script))
|
||||||
|
}
|
||||||
|
|
||||||
fn generate_static_assets(search_indexes: Vec<SearchIndex>) -> Vec<DocFile> {
|
fn generate_static_assets(search_indexes: Vec<SearchIndex>) -> Vec<DocFile> {
|
||||||
let mut assets: Vec<DocFile> = vec![];
|
let mut assets: Vec<DocFile> = vec![];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue