Config to toggle the run button on codeblocks

This commit is contained in:
Shogo Takata 2021-05-25 12:26:43 +09:00 committed by Shogo Takata
parent fa0f9df497
commit b85c3035fe
No known key found for this signature in database
GPG Key ID: 93C92BE128D78ED2
2 changed files with 6 additions and 1 deletions

View File

@ -630,6 +630,8 @@ pub struct Playground {
pub copy_js: bool, pub copy_js: bool,
/// Display line numbers on playground snippets. Default: `false`. /// Display line numbers on playground snippets. Default: `false`.
pub line_numbers: bool, pub line_numbers: bool,
/// Display the run button. Default: `true`
pub runnable: bool,
} }
impl Default for Playground { impl Default for Playground {
@ -639,6 +641,7 @@ impl Default for Playground {
copyable: true, copyable: true,
copy_js: true, copy_js: true,
line_numbers: false, line_numbers: false,
runnable: true,
} }
} }
} }
@ -781,6 +784,7 @@ mod tests {
copyable: true, copyable: true,
copy_js: true, copy_js: true,
line_numbers: false, line_numbers: false,
runnable: true,
}; };
let html_should_be = HtmlConfig { let html_should_be = HtmlConfig {
curly_quotes: true, curly_quotes: true,

View File

@ -828,7 +828,8 @@ fn add_playground_pre(
if classes.contains("language-rust") { if classes.contains("language-rust") {
if (!classes.contains("ignore") if (!classes.contains("ignore")
&& !classes.contains("noplayground") && !classes.contains("noplayground")
&& !classes.contains("noplaypen")) && !classes.contains("noplaypen")
&& playground_config.runnable)
|| classes.contains("mdbook-runnable") || classes.contains("mdbook-runnable")
{ {
let contains_e2015 = classes.contains("edition2015"); let contains_e2015 = classes.contains("edition2015");