mdbook_exercises/lib.rs
1//! # mdbook-exercises
2//!
3//! A preprocessor for [mdBook](https://rust-lang.github.io/mdBook/) that adds
4//! interactive exercise blocks with hints, solutions, and test execution.
5//!
6//! ## Library Usage
7//!
8//! Use `mdbook-exercises` as a library to parse exercise markdown files:
9//!
10//! ````rust
11//! use mdbook_exercises::{parse_exercise, ParsedExercise};
12//!
13//! let markdown = r#"
14//! # Exercise: Hello World
15//!
16//! ::: exercise
17//! id: hello-world
18//! difficulty: beginner
19//! :::
20//!
21//! Write a greeting function.
22//!
23//! ::: starter
24//! ```rust
25//! fn greet() { todo!() }
26//! ```
27//! :::
28//! "#;
29//!
30//! let parsed = parse_exercise(markdown).expect("Failed to parse");
31//! match parsed {
32//! ParsedExercise::Code(exercise) => {
33//! assert_eq!(exercise.metadata.id, "hello-world");
34//! }
35//! ParsedExercise::UseCase(_) => panic!("Expected code exercise"),
36//! }
37//! ````
38//!
39//! ## Feature Flags
40//!
41//! - `default` - Full mdBook preprocessor
42//! - `preprocessor` - mdBook integration (requires `render`)
43//! - `render` - HTML rendering
44//! - (no features) - Parser only, minimal dependencies
45
46pub mod parser;
47pub mod types;
48
49#[cfg(feature = "render")]
50pub mod render;
51
52#[cfg(feature = "preprocessor")]
53pub mod preprocessor;
54
55// Re-export main types for convenience
56pub use parser::{parse_exercise, ParseError};
57pub use types::*;
58
59#[cfg(feature = "render")]
60pub use render::{render_exercise, render_exercise_with_config, RenderError};