From bcc092454d52f4e96569bff7dcfd824fb52f040d Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 4 Feb 2023 07:10:41 +0000 Subject: feat: mathjax --- Cargo.toml | 2 +- README.md | 10 ++++++++++ src/gemini_to_html.rs | 2 +- src/response.rs | 6 ++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a2ed987..885a60d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "september" -version = "0.2.1" +version = "0.2.2" authors = ["Fuwn "] edition = "2021" description = "A simple and efficient Gemini-to-HTTP proxy." diff --git a/README.md b/README.md index fbec19a..ee65daa 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,16 @@ A comma-seperated list of paths to treat as plain text routes. PLAIN_TEXT_ROUTE=/robots.txt,/license.txt ``` +### `MATHJAX` + +Enable MathJax support for rendering LaTeX. + +Defaults to `false`. + +```dotenv +MATHJAX=true +``` + ## Styling Want to give your website a shiny new look? Try using one of sources diff --git a/src/gemini_to_html.rs b/src/gemini_to_html.rs index ea09336..ec19cec 100644 --- a/src/gemini_to_html.rs +++ b/src/gemini_to_html.rs @@ -64,7 +64,7 @@ pub fn gemini_to_html( href = link_from_host_href(url, &href); } - if var("PROXY_BY_DEFAULT").unwrap_or_else(|_| "true".to_string()) + 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 bd79024..ce1ad4c 100644 --- a/src/response.rs +++ b/src/response.rs @@ -156,6 +156,12 @@ pub async fn default( )); } + if var("MATHJAX").unwrap_or_else(|_| "true".to_string()).to_lowercase() == "true" { + html_context.push_str( + "", + ); + } + // Add a title to HTML response html_context.push_str(&format!("{gemini_title}")); html_context.push_str(""); -- cgit v1.2.3