From abfc3009fcc1c658113f91e98aac43541dfe538b Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Thu, 26 Jul 2018 17:49:40 -0400 Subject: [PATCH] Add a "noplaypen" class for rust code samples. This class will supress the "play" button in the html backend (which you can also do with the "ignore" class), but it will still let the code be tested via `mdbook test` (which is not possible with the "ignore" class). This is useful for code examples that don't really do much (and so the user doesn't gain much from running them), but as an author you still want to test them to guard against syntax errors and typos and the like. --- src/renderer/html_handlebars/hbs_renderer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 469f8ef4..e07c9901 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -580,7 +580,9 @@ fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String { let classes = &caps[2]; let code = &caps[3]; - if (classes.contains("language-rust") && !classes.contains("ignore")) + if (classes.contains("language-rust") + && !classes.contains("ignore") + && !classes.contains("noplaypen")) || classes.contains("mdbook-runnable") { // wrap the contents in an external pre block