diff options
| author | Fuwn <[email protected]> | 2024-05-27 01:55:40 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-05-27 01:55:40 -0700 |
| commit | 0d094272c3a8de00daf2b871e65c2b82db6d140b (patch) | |
| tree | 3bf843f594a8a9f620997806baa46fb0a769b54d /src/modules | |
| parent | fix(web): escape september and kineto proxy information (diff) | |
| download | locus-0d094272c3a8de00daf2b871e65c2b82db6d140b.tar.xz locus-0d094272c3a8de00daf2b871e65c2b82db6d140b.zip | |
feat(web): image parsing
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/web.rs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/modules/web.rs b/src/modules/web.rs index b0d6b40..d730370 100644 --- a/src/modules/web.rs +++ b/src/modules/web.rs @@ -127,13 +127,17 @@ To visit the web version of this exact page, <https://fuwn.me/web>, you would vi )); } "h1" if !in_proxy_information => { - contents.push(format!("# {}\n\n", tag.inner_text(parser))); + contents.push(format!( + "{}# {}\n\n", + if contents.is_empty() { "\n" } else { "" }, + tag.inner_text(parser) + )); } "h2" if !in_proxy_information => { - contents.push(format!("## {}\n\n", tag.inner_text(parser))); + contents.push(format!("\n## {}\n\n", tag.inner_text(parser))); } "h3" if !in_proxy_information => { - contents.push(format!("### {}\n\n", tag.inner_text(parser))); + contents.push(format!("\n### {}\n\n", tag.inner_text(parser))); } "pre" if !in_proxy_information => { contents.push(format!("```\n{}```\n", tag.inner_text(parser))); @@ -144,6 +148,19 @@ To visit the web version of this exact page, <https://fuwn.me/web>, you would vi "li" if !in_proxy_information => { contents.push(format!("* {}\n", tag.inner_text(parser))); } + "img" if !in_proxy_information => { + contents.push(format!( + "=> {} {}\n\n", + tag.attributes().get("src").flatten().map_or( + "A parse error occurred in this location.".to_string(), + |src| src.as_utf8_str().to_string() + ), + tag.attributes().get("alt").flatten().map_or( + "A parse error occurred in this location.".to_string(), + |alt| alt.as_utf8_str().to_string() + ), + )); + } "html" | "head" | "script" | "link" | "title" | "body" | "ul" | "style" if !in_proxy_information => {} |