From 139c3d96fc7ee8cd29f2c704913e8f57ea84f867 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 23 Sep 2020 17:54:10 -0700 Subject: check all non-text nodes for ids --- src/epub.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/epub.rs') diff --git a/src/epub.rs b/src/epub.rs index 2df924c..25d4cd6 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -176,6 +176,10 @@ fn render(n: Node, c: &mut Chapter) { return; } + if let Some(id) = n.attribute("id") { + c.frag.push((id.to_string(), c.text.len())); + } + match n.tag_name().name() { "br" => c.text.push('\n'), "hr" => c.text.push_str("\n* * *\n"), @@ -185,8 +189,6 @@ fn render(n: Node, c: &mut Chapter) { let start = c.text.len(); c.render(n, Attribute::Underlined, Attribute::NoUnderline); c.links.push((start, c.text.len(), url.to_string())); - } else if let Some(id) = n.attribute("id") { - c.frag.push((id.to_string(), c.text.len())); } } "em" => c.render(n, Attribute::Italic, Attribute::NoItalic), -- cgit v1.2.3