diff --git a/src/config.rs b/src/config.rs index 181aad66..6ed1e895 100644 --- a/src/config.rs +++ b/src/config.rs @@ -815,6 +815,22 @@ mod tests { assert_eq!(got.html_config().unwrap(), html_should_be); } + #[test] + fn disable_runnable() { + let src = r#" + [book] + title = "Some Book" + description = "book book book" + authors = ["Shogo Takata"] + + [output.html.playground] + runnable = false + "#; + + let got = Config::from_str(src).unwrap(); + assert_eq!(got.html_config().unwrap().playground.runnable, false); + } + #[test] fn edition_2015() { let src = r#" diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 5ec6e64b..cd511ccf 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -17,6 +17,7 @@ use std::ffi::OsStr; use std::fs; use std::io::Write; use std::path::{Component, Path, PathBuf}; +use std::str::FromStr; use tempfile::Builder as TempFileBuilder; use walkdir::{DirEntry, WalkDir}; @@ -150,6 +151,25 @@ fn rendered_code_has_playground_stuff() { assert_contains_strings(book_js, &[".playground"]); } +#[test] +fn rendered_code_does_not_have_playground_stuff_in_html_when_disabled_in_config() { + let temp = DummyBook::new().build().unwrap(); + let config = Config::from_str( + " + [output.html.playground] + runnable = false + ", + ) + .unwrap(); + let md = MDBook::load_with_config(temp.path(), config).unwrap(); + md.build().unwrap(); + + let nested = temp.path().join("book/first/nested.html"); + let playground_class = vec![r#"class="playground""#]; + + assert_doesnt_contain_strings(nested, &playground_class); +} + #[test] fn anchors_include_text_between_but_not_anchor_comments() { let temp = DummyBook::new().build().unwrap();