Skip to content

Commit abfc300

Browse files
committed
Add a "noplaypen" class for rust code samples.
This class will supress the "play" button in the html backend (which you can also do with the "ignore" class), but it will still let the code be tested via `mdbook test` (which is not possible with the "ignore" class). This is useful for code examples that don't really do much (and so the user doesn't gain much from running them), but as an author you still want to test them to guard against syntax errors and typos and the like.
1 parent 028c8b0 commit abfc300

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,9 @@ fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String {
580580
let classes = &caps[2];
581581
let code = &caps[3];
582582

583-
if (classes.contains("language-rust") && !classes.contains("ignore"))
583+
if (classes.contains("language-rust")
584+
&& !classes.contains("ignore")
585+
&& !classes.contains("noplaypen"))
584586
|| classes.contains("mdbook-runnable")
585587
{
586588
// wrap the contents in an external pre block

0 commit comments

Comments
 (0)