From b85c3035fef8c572e4e8953ef8ace55e2e77b771 Mon Sep 17 00:00:00 2001 From: Shogo Takata Date: Tue, 25 May 2021 12:26:43 +0900 Subject: [PATCH] Config to toggle the run button on codeblocks --- src/config.rs | 4 ++++ src/renderer/html_handlebars/hbs_renderer.rs | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index daeccbd0..181aad66 100644 --- a/src/config.rs +++ b/src/config.rs @@ -630,6 +630,8 @@ pub struct Playground { pub copy_js: bool, /// Display line numbers on playground snippets. Default: `false`. pub line_numbers: bool, + /// Display the run button. Default: `true` + pub runnable: bool, } impl Default for Playground { @@ -639,6 +641,7 @@ impl Default for Playground { copyable: true, copy_js: true, line_numbers: false, + runnable: true, } } } @@ -781,6 +784,7 @@ mod tests { copyable: true, copy_js: true, line_numbers: false, + runnable: true, }; let html_should_be = HtmlConfig { curly_quotes: true, diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 69dc3124..045d536e 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -828,7 +828,8 @@ fn add_playground_pre( if classes.contains("language-rust") { if (!classes.contains("ignore") && !classes.contains("noplayground") - && !classes.contains("noplaypen")) + && !classes.contains("noplaypen") + && playground_config.runnable) || classes.contains("mdbook-runnable") { let contains_e2015 = classes.contains("edition2015");