aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-02-04 08:35:16 +0000
committerFuwn <[email protected]>2023-02-04 08:35:16 +0000
commita31013f24f895acf7f133a59e29b52f4ca6ab093 (patch)
treec929796baf144e8d223528b1cfdf5b110fdf8caa /src
parentfeat: mathjax (diff)
downloadseptember-a31013f24f895acf7f133a59e29b52f4ca6ab093.tar.xz
september-a31013f24f895acf7f133a59e29b52f4ca6ab093.zip
feat: mathjax latex rendering
Diffstat (limited to 'src')
-rw-r--r--src/gemini_to_html.rs13
-rw-r--r--src/response.rs10
2 files changed, 19 insertions, 4 deletions
diff --git a/src/gemini_to_html.rs b/src/gemini_to_html.rs
index ec19cec..ee723b7 100644
--- a/src/gemini_to_html.rs
+++ b/src/gemini_to_html.rs
@@ -20,7 +20,14 @@ use std::env::var;
use germ::ast::Node;
use gmi::url::Url;
-use markly::to_html;
+
+fn to_html(text: &str) -> String {
+ if text.contains('$') {
+ text.to_string()
+ } else {
+ markly::to_html(text)
+ }
+}
fn link_from_host_href(url: &Url, href: &str) -> String {
format!(
@@ -64,7 +71,9 @@ pub fn gemini_to_html(
href = link_from_host_href(url, &href);
}
- if var("PROXY_BY_DEFAULT").unwrap_or_else(|_| "true".to_string()).to_lowercase()
+ if var("PROXY_BY_DEFAULT")
+ .unwrap_or_else(|_| "true".to_string())
+ .to_lowercase()
== "true"
&& href.contains("gemini://")
&& !surface
diff --git a/src/response.rs b/src/response.rs
index ce1ad4c..547cf12 100644
--- a/src/response.rs
+++ b/src/response.rs
@@ -156,9 +156,15 @@ pub async fn default(
));
}
- if var("MATHJAX").unwrap_or_else(|_| "true".to_string()).to_lowercase() == "true" {
+ if var("MATHJAX")
+ .unwrap_or_else(|_| "true".to_string())
+ .to_lowercase()
+ == "true"
+ {
html_context.push_str(
- "<script type=\"#text/javascript\" id=\"MathJax-script\" async src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js\"></script>",
+ r#"<script type="text/javascript" id="MathJax-script" async
+ src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
+ </script>"#,
);
}