Merge pull request #17 from philwrenn/dev

Removed unwrap to prevent unexpected panic.
This commit is contained in:
Kenneth Gitere 2021-06-06 09:23:01 +03:00 committed by GitHub
commit 751b5702fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1609,13 +1609,8 @@ impl Readability {
// // class name "comment", etc), and turn divs into P tags where they have been // // class name "comment", etc), and turn divs into P tags where they have been
// // used inappropriately (as in, where they contain no other block level elements.) // // used inappropriately (as in, where they contain no other block level elements.)
let mut elements_to_score: Vec<NodeRef> = Vec::new(); let mut elements_to_score: Vec<NodeRef> = Vec::new();
let mut node = Some( let mut node = self.root_node.select_first("html")
self.root_node .ok().map(|n| n.as_node().clone());
.select_first("html")
.unwrap()
.as_node()
.clone(),
);
while let Some(node_ref) = node { while let Some(node_ref) = node {
let node_elem = node_ref.as_element().unwrap(); let node_elem = node_ref.as_element().unwrap();