From b228c9e6c0988d270f5b9531595002be03984756 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Oct 2020 23:59:04 -0700 Subject: fix links w/o href --- src/epub.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/epub.rs') diff --git a/src/epub.rs b/src/epub.rs index 5551e3e..9c53551 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -193,15 +193,14 @@ fn render(n: Node, c: &mut Chapter) { "hr" => c.text.push_str("\n* * *\n"), "img" => c.text.push_str("\n[IMG]\n"), "a" => { - if let Some(url) = n.attribute("href") { - if url.starts_with("http") { - // TODO open in browser - c.render_text(n) - } else { + match n.attribute("href") { + // TODO open external urls in browser + Some(url) if !url.starts_with("http") => { let start = c.text.len(); c.render(n, Attribute::Underlined, Attribute::NoUnderline); c.links.push((start, c.text.len(), url.to_string())); } + _ => c.render_text(n) } } "em" => c.render(n, Attribute::Italic, Attribute::NoItalic), -- cgit v1.2.3