aboutsummaryrefslogtreecommitdiff
path: root/src
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 /src
parentstyle(response): format style (diff)
downloadseptember-8ac6d02386955ad00a809cbaaf60f029b12ccdcc.tar.xz
september-8ac6d02386955ad00a809cbaaf60f029b12ccdcc.zip
fix(to_html): messy markdown to html conversion
Diffstat (limited to 'src')
-rw-r--r--src/gemini_to_html.rs31
1 files changed, 7 insertions, 24 deletions
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");
+ }
}
}