This commit is contained in:
Petr Zahradník 2025-01-18 19:04:22 +00:00 committed by GitHub
commit 16494d50b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 3 deletions

View file

@ -206,10 +206,26 @@ pub fn run(args: Args) -> anyhow::Result<()> {
stdout.write_all(buffer.as_bytes())?;
}
let html = match &page.article_body.html {
Some(html) => Cow::Borrowed(html),
None => {
warn!("Article without article_body.html field");
if let Some(filter) = args.passthrough {
match filter {
ArticleFilter::Error | ArticleFilter::Panic => {
stdout.write_all(buffer.as_bytes())?
}
_ => {}
}
}
continue;
}
};
let article_output = if args.no_simplify {
Ok(Cow::Borrowed(&page.article_body.html))
Ok(html)
} else {
html::process_str(&page.article_body.html, &page.in_language.identifier).map(Cow::Owned)
html::process_str(&html, &page.in_language.identifier).map(Cow::Owned)
};
match article_output {

View file

@ -61,7 +61,7 @@ pub struct Wikidata {
pub struct ArticleBody {
// TODO: Look into RawValue to lazily parse/allocate this:
// https://docs.rs/serde_json/latest/serde_json/value/struct.RawValue.html
pub html: String,
pub html: Option<String>,
}
#[allow(dead_code)] // TODO: Reevaluate fields.