1
0
Fork 0
mirror of https://gitlab.com/news-flash/article_scraper.git synced 2025-07-09 00:45:31 +02:00

fix turning div's into p's

This commit is contained in:
Jan Lukas Gernert 2023-03-04 17:41:14 +01:00
parent d93f5c9677
commit daa5543c4e
2 changed files with 32 additions and 21 deletions

View file

@ -249,6 +249,9 @@ impl Util {
}
pub fn is_whitespace(node: &Node) -> bool {
let content = node.get_content();
let tag_name = node.get_name().to_uppercase();
let is_text_node = node
.get_type()
.map(|t| t == NodeType::TextNode)
@ -258,8 +261,7 @@ impl Util {
.map(|t| t == NodeType::ElementNode)
.unwrap_or(false);
(is_text_node && node.get_content().trim().is_empty())
|| (is_element_node && node.get_name().to_uppercase() == "BR")
(is_text_node && content.trim().is_empty()) || (is_element_node && tag_name == "BR")
}
pub fn remove_and_next(node: &mut Node) -> Option<Node> {