mdbook-repl 0.2.8

A rust based mdbook preprocessor that allows you to execute code in your mdbook without any server. Python, Typescript, Javascript etc.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use mdbook::Config;

pub fn get_config_bool(config: &Config, key: &str, default: bool) -> bool {
    config
        .get(format!("preprocessor.repl.{}", key).as_str())
        .and_then(|v| v.as_bool())
        .unwrap_or(default.to_owned())
}

pub fn get_config_string(config: &Config, key: &str, default: &str) -> String {
    config
        .get(format!("preprocessor.repl.{}", key).as_str())
        .and_then(|v| v.as_str())
        .unwrap_or(default)
        .to_string()
}