Skip to content

Commit

Permalink
Config to toggle the run button on codeblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Shogo Takata committed May 25, 2021
1 parent 3c2b8cd commit 9e9d7c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,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 {
Expand All @@ -631,6 +633,7 @@ impl Default for Playground {
copyable: true,
copy_js: true,
line_numbers: false,
runnable: true,
}
}
}
Expand Down Expand Up @@ -773,6 +776,7 @@ mod tests {
copyable: true,
copy_js: true,
line_numbers: false,
runnable: true,
};
let html_should_be = HtmlConfig {
curly_quotes: true,
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,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");
Expand Down

0 comments on commit 9e9d7c1

Please sign in to comment.