Revert "use of mathml instead of katex"

This reverts commit 22b68f549e.
This commit is contained in:
Mylloon 2023-04-22 02:39:41 +02:00
parent 3a8f046404
commit 687250cb35
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
5 changed files with 39 additions and 17 deletions

7
Cargo.lock generated
View file

@ -859,7 +859,6 @@ dependencies = [
"chrono",
"comrak",
"glob",
"latex2mathml",
"minify-html",
"ramhorns",
"reqwest",
@ -1271,12 +1270,6 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388"
[[package]]
name = "latex2mathml"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678cf5bdb3ba63a264e6e0c9eee36538ca1d2da0afa4dd801c1f96309e710765"
[[package]]
name = "lazy_static"
version = "1.4.0"

View file

@ -20,6 +20,5 @@ serde_yaml = "0.9"
minify-html = "0.10.8"
glob = "0.3.1"
comrak = "0.18"
latex2mathml = "0.2.3"
reqwest = { version = "0.11", features = ["json"] }
chrono = "0.4.24"

View file

@ -18,6 +18,7 @@ pub struct FileMetadata {
#[derive(Content)]
pub struct Metadata {
pub info: FileMetadata,
pub math: bool,
pub mermaid: bool,
pub syntax_highlight: bool,
}
@ -53,7 +54,7 @@ pub fn get_options() -> ComrakOptions {
github_pre_lang: false,
full_info_string: true,
width: 0, // 0 mean disabled?
unsafe_: true,
unsafe_: false, // could be true? change by metadata could be good for compatibility
escape: false, // may change in the future?
list_style: ListStyleType::Dash,
sourcepos: false,
@ -64,11 +65,8 @@ pub fn get_options() -> ComrakOptions {
pub fn read(raw_text: &str) -> File {
let arena = Arena::new();
// LaTeX conversion to MathML
let text = latex2mathml::replace(raw_text).unwrap_or_default();
let options = get_options();
let root = parse_document(&arena, &text, &options);
let root = parse_document(&arena, raw_text, &options);
// Find metadata
let metadata = get_metadata(root);

View file

@ -2,7 +2,31 @@
<a href="/blog">Retour à la liste des posts</a>
</footer>
{{#data}} {{#post}} {{#metadata}} {{#mermaid}}
{{#data}} {{#post}} {{#metadata}} {{#math}}
<!-- KaTeX -->
<script
defer
src="//cdn.jsdelivr.net/npm/katex@0.16.6/dist/katex.min.js"
integrity="sha384-j/ZricySXBnNMJy9meJCtyXTKMhIJ42heyr7oAdxTDBy/CYA9hzpMo+YTNV5C+1X"
crossorigin="anonymous"
></script>
<script
defer
src="//cdn.jsdelivr.net/npm/katex@0.16.6/dist/contrib/auto-render.min.js"
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
crossorigin="anonymous"
onload="renderMathInElement(document.body);"
></script>
<script>
window.addEventListener("load", () => {
for (let item of document.getElementsByClassName("language-math")) {
katex.render(item.textContent, item, {
displayMode: item.classList.contains("math-display"),
});
}
});
</script>
{{/math}} {{#mermaid}}
<!-- Mermaid diagrams -->
<script type="module">
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";

View file

@ -39,7 +39,15 @@
<meta content="/icons/apple-touch-icon.png" property="og:image" />
<meta content="#43B581" data-react-helmet="true" name="theme-color" />
{{#data}} {{#post}} {{#metadata}} {{#syntax_highlight}}
{{#data}} {{#post}} {{#metadata}} {{#math}}
<!-- KaTeX -->
<link
rel="stylesheet"
href="//cdn.jsdelivr.net/npm/katex@0.16.6/dist/katex.min.css"
integrity="sha384-mXD7x5S50Ko38scHSnD4egvoExgMPbrseZorkbE49evAfv9nNcbrXJ8LLNsDgh9d"
crossorigin="anonymous"
/>
{{/math}} {{#syntax_highlight}}
<!-- Syntax highligthing -->
<link
rel="stylesheet"