Expand description
§mdbook-exercises
A preprocessor for mdBook that adds interactive exercise blocks with hints, solutions, and test execution.
§Library Usage
Use mdbook-exercises as a library to parse exercise markdown files:
use mdbook_exercises::{parse_exercise, ParsedExercise};
let markdown = r#"
::: exercise
id: hello-world
difficulty: beginner
:::
Write a greeting function.
::: starter
```rust
fn greet() { todo!() }
```
:::
"#;
let parsed = parse_exercise(markdown).expect("Failed to parse");
match parsed {
ParsedExercise::Code(exercise) => {
assert_eq!(exercise.metadata.id, "hello-world");
}
ParsedExercise::UseCase(_) => panic!("Expected code exercise"),
}§Feature Flags
default- Full mdBook preprocessorpreprocessor- mdBook integration (requiresrender)render- HTML rendering- (no features) - Parser only, minimal dependencies
Re-exports§
pub use parser::parse_exercise;pub use parser::ParseError;pub use render::render_exercise;pub use render::render_exercise_with_config;pub use render::RenderError;pub use types::*;
Modules§
- parser
- Parser for exercise markdown with directive blocks.
- preprocessor
- mdBook preprocessor integration.
- render
- HTML rendering for exercises.
- types
- Core types for representing parsed exercises.