, remove that
if let Some(article) = readme_dom
.select(&Selector::parse("article").unwrap())
.next()
{
readme_html = article.inner_html().to_string();
}
let title = if let Some(title_el) = readme_dom
// github wraps their h1s in a
.select(&Selector::parse("div:has(h1)").unwrap())
.next()
{
// if the readme starts with an h1, remove it
let title_html = title_el.html().trim().to_string();
if readme_html.starts_with(&title_html) {
readme_html = readme_html[title_html.len()..].to_string();
}
title_el.text().collect::()
} else {
dom.select(
&Selector::parse("main #repository-container-header strong[itemprop='name'] > a")
.unwrap(),
)
.next()?
.text()
.collect::()
};
Some(html! {
a href=(url) {
h1 { (title) }
}
div.infobox-github-readme {
(PreEscaped(readme_html))
}
})
}