diff --git a/crates/mdbook-core/src/config.rs b/crates/mdbook-core/src/config.rs index d5746971b2..1a49f02e53 100644 --- a/crates/mdbook-core/src/config.rs +++ b/crates/mdbook-core/src/config.rs @@ -297,6 +297,7 @@ pub struct BookConfig { /// An optional description for the book. pub description: Option, /// Location of the book source relative to the book's root directory. + #[serde(skip_serializing_if = "is_default_src")] pub src: PathBuf, /// The main language of the book. pub language: Option, @@ -305,6 +306,11 @@ pub struct BookConfig { pub text_direction: Option, } +/// Helper for serde serialization. +fn is_default_src(src: &PathBuf) -> bool { + src == Path::new("src") +} + impl Default for BookConfig { fn default() -> BookConfig { BookConfig { diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index bf225a4da6..852f1a2fb3 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -28,7 +28,6 @@ All done, no errors... str![[r#" [book] authors = [] -src = "src" language = "en" "#]], @@ -94,7 +93,6 @@ All done, no errors... str![[r#" [book] authors = [] -src = "src" language = "en" "#]], @@ -128,7 +126,6 @@ All done, no errors... [book] title = "Example title" authors = [] -src = "src" language = "en" "#]], diff --git a/tests/testsuite/renderer.rs b/tests/testsuite/renderer.rs index 9f2ee0100a..a04ff0e3ec 100644 --- a/tests/testsuite/renderer.rs +++ b/tests/testsuite/renderer.rs @@ -188,7 +188,6 @@ fn backends_receive_render_context_via_stdin() { "authors": [], "description": null, "language": "en", - "src": "src", "text-direction": null, "title": null },