diff options
| author | Fuwn <[email protected]> | 2024-04-02 08:18:42 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-04-02 08:18:42 +0000 |
| commit | 17f0c90587220e59106973c69cf172f638ca4b27 (patch) | |
| tree | 58d1fac5fc5de333fefb51187ab4bcc26dfcd29e /src | |
| parent | docs(readme): move configuration to file (diff) | |
| download | september-17f0c90587220e59106973c69cf172f638ca4b27.tar.xz september-17f0c90587220e59106973c69cf172f638ca4b27.zip | |
feat(html): silent image embedding option
Diffstat (limited to 'src')
| -rw-r--r-- | src/html.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/html.rs b/src/html.rs index ebe31d9..b86c496 100644 --- a/src/html.rs +++ b/src/html.rs @@ -112,7 +112,7 @@ pub fn from_gemini( } } - if var("EMBED_IMAGES").is_ok() { + if let Ok(embed_images) = var("EMBED_IMAGES") { if let Some(extension) = std::path::Path::new(&href).extension() { if extension == "png" || extension == "jpg" @@ -121,11 +121,16 @@ pub fn from_gemini( || extension == "webp" || extension == "svg" { + if embed_images == "1" { + html.push_str(&format!( + "<p><a href=\"{}\">{}</a> <i>Embedded below</i></p>\n", + href, + safe(&text.clone().unwrap_or_default()), + )); + } + html.push_str(&format!( - "<p><a href=\"{}\">{}</a> <i>Embedded below</i></p>\n<p><img \ - src=\"{}\" alt=\"{}\" /></p>\n", - href, - safe(&text.clone().unwrap_or_default()), + "<p><img src=\"{}\" alt=\"{}\" /></p>\n", safe(&href), safe(&text.clone().unwrap_or_default()) )); |