diff --git a/Cargo.lock b/Cargo.lock index c33b2b2..b96d822 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1117,7 +1117,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "snekdown" -version = "0.22.0" +version = "0.22.1" dependencies = [ "asciimath-rs 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index bb70444..eaea0ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "snekdown" -version = "0.22.0" +version = "0.22.1" authors = ["trivernis "] edition = "2018" license-file = "LICENSE" diff --git a/src/format/html.rs b/src/format/html.rs index 3b94a58..5d24967 100644 --- a/src/format/html.rs +++ b/src/format/html.rs @@ -363,23 +363,22 @@ impl ToHtml for Image { } } if let Some(description) = self.url.description.clone() { + let description = description + .iter() + .fold("".to_string(), |a, b| format!("{} {}", a, b.to_html())); minify( format!( "
\ - \ - {2}\ + \ + {}\ \ - \ + \
", encode_attribute(self.url.url.as_str()), url, - encode_attribute( - description - .iter() - .fold("".to_string(), |a, b| format!("{}{}", a, b.to_html())) - .as_str() - ), - style + encode_attribute(description.as_str()), + style, + description ) .as_str(), ) diff --git a/src/parser/inline.rs b/src/parser/inline.rs index 58ca8ee..d8ecf51 100644 --- a/src/parser/inline.rs +++ b/src/parser/inline.rs @@ -7,6 +7,7 @@ use crate::references::configuration::keys::BIB_REF_DISPLAY; use crate::references::templates::{GetTemplateVariables, Template, TemplateVariable}; use crate::Parser; use std::collections::HashMap; +use std::path::PathBuf; use std::sync::{Arc, RwLock}; pub(crate) trait ParseInline { @@ -140,11 +141,15 @@ impl ParseInline for Parser { self.ctm.seek_one()?; self.ctm.seek_any(&INLINE_WHITESPACE)?; - let url = self + let mut url = self .ctm .get_string_until_any_or_rewind(&[URL_CLOSE], &[LB], start_index)?; self.ctm.seek_one()?; + let url_path = PathBuf::from(url.clone()); + if url_path.exists() { + url = self.transform_path(url).to_str().unwrap().to_string() + } if description.len() > 0 { Ok(Url::new(Some(description), url))