diff --git a/Cargo.toml b/Cargo.toml index f525ef5..5e464f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,11 @@ categories = [] edition = "2018" [dependencies] -regex = "1" -url = "2.1" -html5ever = "0.24" -lazy_static = "1.4" +regex = "1" +url = "2.1" +html5ever = "0.25" +markup5ever_rcdom = "0.1" +lazy_static = "1.4" [dependencies.reqwest] version = "0.10" diff --git a/src/dom.rs b/src/dom.rs index 6b2e53a..14e6e97 100644 --- a/src/dom.rs +++ b/src/dom.rs @@ -1,7 +1,7 @@ use std::rc::Rc; use html5ever::tendril::StrTendril; -use html5ever::rcdom::NodeData::{Element, Text}; -use html5ever::rcdom::{Handle, Node}; +use markup5ever_rcdom::NodeData::{Element, Text}; +use markup5ever_rcdom::{Handle, Node}; use html5ever::Attribute; use std::str::FromStr; diff --git a/src/extractor.rs b/src/extractor.rs index 191f4ea..a3eb123 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -2,7 +2,7 @@ use std::io::Read; use std::collections::BTreeMap; use std::path::Path; use std::cell::Cell; -use html5ever::rcdom::{RcDom}; +use markup5ever_rcdom::{RcDom, SerializableHandle}; use html5ever::{parse_document, serialize}; use html5ever::tendril::stream::TendrilSink; use std::default::Default; @@ -72,10 +72,10 @@ pub fn extract(input: &mut R, url: &Url) -> Result where R: R } let mut bytes = vec![]; - let node = top_candidate.node.clone(); + let node = &top_candidate.node; scorer::clean(&mut dom, Path::new(id), node.clone(), url, &candidates); - serialize(&mut bytes, &node, Default::default()).ok(); + serialize(&mut bytes, &SerializableHandle::from(node.clone()), Default::default()).ok(); let content = String::from_utf8(bytes).unwrap_or_default(); let mut text: String = String::new(); diff --git a/src/scorer.rs b/src/scorer.rs index dcf3eda..f55d3fe 100644 --- a/src/scorer.rs +++ b/src/scorer.rs @@ -6,16 +6,16 @@ use url::Url; use regex::Regex; use lazy_static::lazy_static; use html5ever::tree_builder::TreeSink; -use html5ever::rcdom::Node; -use html5ever::rcdom::NodeData::{Element, Text}; -use html5ever::rcdom::Handle; -use html5ever::rcdom::NodeData::{ +use markup5ever_rcdom::Node; +use markup5ever_rcdom::NodeData::{Element, Text}; +use markup5ever_rcdom::Handle; +use markup5ever_rcdom::NodeData::{ Document, Doctype, Comment, ProcessingInstruction }; -use html5ever:: rcdom::RcDom; +use markup5ever_rcdom::RcDom; use html5ever::{QualName, LocalName}; use html5ever::tree_builder::{NodeOrText, ElementFlags}; use html5ever::{ns, namespace_url};