Skip to content

Commit 9e9d7c1

Browse files
author
Shogo Takata
committed
Config to toggle the run button on codeblocks
1 parent 3c2b8cd commit 9e9d7c1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ pub struct Playground {
622622
pub copy_js: bool,
623623
/// Display line numbers on playground snippets. Default: `false`.
624624
pub line_numbers: bool,
625+
/// Display the run button. Default: `true`
626+
pub runnable: bool,
625627
}
626628

627629
impl Default for Playground {
@@ -631,6 +633,7 @@ impl Default for Playground {
631633
copyable: true,
632634
copy_js: true,
633635
line_numbers: false,
636+
runnable: true,
634637
}
635638
}
636639
}
@@ -773,6 +776,7 @@ mod tests {
773776
copyable: true,
774777
copy_js: true,
775778
line_numbers: false,
779+
runnable: true,
776780
};
777781
let html_should_be = HtmlConfig {
778782
curly_quotes: true,

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,8 @@ fn add_playground_pre(
826826
if classes.contains("language-rust") {
827827
if (!classes.contains("ignore")
828828
&& !classes.contains("noplayground")
829-
&& !classes.contains("noplaypen"))
829+
&& !classes.contains("noplaypen")
830+
&& playground_config.runnable)
830831
|| classes.contains("mdbook-runnable")
831832
{
832833
let contains_e2015 = classes.contains("edition2015");

0 commit comments

Comments
 (0)