Skip to content

strip out references to rustdoc's custom favicon #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/utils/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ fn extract_from_rcdom(dom: &RcDom) -> Result<(Handle, Handle)> {

let head = head.ok_or_else(|| err_msg("couldn't find <head> tag in rustdoc output"))?;
let body = body.ok_or_else(|| err_msg("couldn't find <body> tag in rustdoc output"))?;

{
head.children.borrow_mut().retain(|node| {
match node.data {
NodeData::Element { ref name, ref attrs, .. } => {
// `<link rel="shortcut icon">` is rustdoc's custom favicon, but we want to
// use our own, so ditch it so browsers request the favicon at the domain root
// instead
!(name.local == *"link" &&
attrs.borrow()
.iter()
.any(|attr| {
attr.name.local == *"rel" &&
&*attr.value == "shortcut icon"
}))
}
_ => true,
}
});
}

Ok((head, body))
}

Expand Down