in rust/src/main.rs [156:198]
fn inside_props(node: NodeRef) {
// Post order traversal
for child in node.children() {
inside_props(child.clone());
}
if let kuchiki::NodeData::Element(x) = node.data() {
let mut x_attr = (x.attributes).borrow_mut();
// Remove empty and not item-related attributes
for (key, value) in x_attr.clone().map.into_iter() {
if !(key.local.starts_with("item")
|| key.local.starts_with("content")
|| key.local.starts_with("date"))
{
x_attr.remove(key.local);
} else {
if value.value.len() < 1 {
x_attr.remove(key.local);
}
}
}
// Remove media tags
if x.name.local.contains("svg")
|| x.name.local.contains("img")
|| x.name.local.contains("hatul")
|| x.name.local.contains("input")
|| x.name.local.contains("button")
|| x.name.local.contains("link")
{
for child in node.children() {
node.insert_after(child)
}
node.detach();
}
// Clean the text elements
} else if let kuchiki::NodeData::Text(x) = node.data() {
let mut clean: String = x.borrow().to_string();
clean = clean_text(clean);
x.replace(clean.clone());
}
}