aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2020-10-03 23:59:04 -0700
committerJames Campos <james.r.campos@gmail.com>2020-10-03 23:59:04 -0700
commitb228c9e6c0988d270f5b9531595002be03984756 (patch)
treef8838e57f3b0ee3c674a2d3fc3133c5f2f6ead6d /src
parent8b68a6527d0c25c0461141ba09b350e460776936 (diff)
downloadbk-b228c9e6c0988d270f5b9531595002be03984756.tar.gz
fix links w/o href
Diffstat (limited to 'src')
-rw-r--r--src/epub.rs9
1 files changed, 4 insertions, 5 deletions
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),