diff --git a/src/config.rs b/src/config.rs index 2ede0c2f92..f628e96d80 100644 --- a/src/config.rs +++ b/src/config.rs @@ -313,6 +313,7 @@ impl<'de> serde::Deserialize<'de> for Config { } warn_on_invalid_fields(&raw); + warn_on_invalid_fields_in_book_section(&raw); use serde::de::Error; let mut table = match raw { @@ -389,6 +390,28 @@ fn warn_on_invalid_fields(table: &Value) { } } +fn warn_on_invalid_fields_in_book_section(table: &Value) { + let valid_items = [ + "title", + "authors", + "description", + "src", + "language", + "text-direction", + ]; + if let Some(book) = table.get("book") { + let table = book.as_table().expect("root.book must be a table"); + for item in table.keys() { + if !valid_items.contains(&item.as_str()) { + warn!( + "Invalid field {:?} in the [book] section of book.toml", + &item + ); + } + } + } +} + fn is_legacy_format(table: &Value) -> bool { let legacy_items = [ "title",