Skip to content

Commit b85c303

Browse files
Shogo TakataShogo Takata
Shogo Takata
authored and
Shogo Takata
committed
Config to toggle the run button on codeblocks
1 parent fa0f9df commit b85c303

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
@@ -630,6 +630,8 @@ pub struct Playground {
630630
pub copy_js: bool,
631631
/// Display line numbers on playground snippets. Default: `false`.
632632
pub line_numbers: bool,
633+
/// Display the run button. Default: `true`
634+
pub runnable: bool,
633635
}
634636

635637
impl Default for Playground {
@@ -639,6 +641,7 @@ impl Default for Playground {
639641
copyable: true,
640642
copy_js: true,
641643
line_numbers: false,
644+
runnable: true,
642645
}
643646
}
644647
}
@@ -781,6 +784,7 @@ mod tests {
781784
copyable: true,
782785
copy_js: true,
783786
line_numbers: false,
787+
runnable: true,
784788
};
785789
let html_should_be = HtmlConfig {
786790
curly_quotes: true,

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,8 @@ fn add_playground_pre(
828828
if classes.contains("language-rust") {
829829
if (!classes.contains("ignore")
830830
&& !classes.contains("noplayground")
831-
&& !classes.contains("noplaypen"))
831+
&& !classes.contains("noplaypen")
832+
&& playground_config.runnable)
832833
|| classes.contains("mdbook-runnable")
833834
{
834835
let contains_e2015 = classes.contains("edition2015");

0 commit comments

Comments
 (0)