aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-04-17 06:19:59 +0000
committerFuwn <[email protected]>2023-04-17 06:20:09 +0000
commit8ac6d02386955ad00a809cbaaf60f029b12ccdcc (patch)
tree979c375d3939bbe981189f3d15674b425e1b4648
parentstyle(response): format style (diff)
downloadseptember-8ac6d02386955ad00a809cbaaf60f029b12ccdcc.tar.xz
september-8ac6d02386955ad00a809cbaaf60f029b12ccdcc.zip
fix(to_html): messy markdown to html conversion
-rw-r--r--Cargo.toml5
-rw-r--r--src/gemini_to_html.rs31
2 files changed, 8 insertions, 28 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 7371e54..2022cd3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
[package]
name = "september"
-version = "0.2.4"
+version = "0.2.5"
authors = ["Fuwn <[email protected]>"]
edition = "2021"
description = "A simple and efficient Gemini-to-HTTP proxy."
@@ -34,9 +34,6 @@ log = "0.4.16"
# Environment Variables
dotenv = "0.15.0"
-# Markdown to HTML
-markly = "0.3.0"
-
[build-dependencies]
# Environment Variables
vergen = "7.0.0"
diff --git a/src/gemini_to_html.rs b/src/gemini_to_html.rs
index f4ab38b..593f9dd 100644
--- a/src/gemini_to_html.rs
+++ b/src/gemini_to_html.rs
@@ -21,25 +21,6 @@ use std::env::var;
use germ::ast::Node;
use gmi::url::Url;
-fn to_html(text: &str) -> String {
- let html = if text.contains('$') {
- text.to_string()
- } else {
- markly::to_html(text)
- };
-
- if (html.ends_with("</p>") || html.ends_with("</p>\n"))
- && html.starts_with("<p>")
- {
- html
- .trim_start_matches("<p>")
- .trim_end_matches("</p>")
- .to_string()
- } else {
- html
- }
-}
-
fn link_from_host_href(url: &Url, href: &str) -> String {
format!(
"gemini://{}{}{}",
@@ -69,7 +50,7 @@ pub fn gemini_to_html(
for node in ast {
match node {
- Node::Text(text) => html.push_str(&format!("<p>{}</p>", to_html(text))),
+ Node::Text(text) => html.push_str(&format!("<p>{text}</p>")),
Node::Link { to, text } => {
let mut href = to.clone();
let mut surface = false;
@@ -148,24 +129,26 @@ pub fn gemini_to_html(
3 => "h3",
_ => "p",
},
- to_html(text),
+ text,
));
}
Node::List(items) => html.push_str(&format!(
"<ul>{}</ul>",
items
.iter()
- .map(|i| format!("<li>{}</li>", to_html(i)))
+ .map(|i| format!("<li>{i}</li>"))
.collect::<Vec<String>>()
.join("\n")
)),
Node::Blockquote(text) => {
- html.push_str(&format!("<blockquote>{}</blockquote>", to_html(text)));
+ html.push_str(&format!("<blockquote>{text}</blockquote>"));
}
Node::PreformattedText { text, .. } => {
html.push_str(&format!("<pre>{text}</pre>"));
}
- Node::Whitespace => {}
+ Node::Whitespace => {
+ println!("i am white");
+ }
}
}