Plugins case study: mdBook preprocessors
5 months ago
- #Rust
- #plugins
- #mdBook
- mdBook is a tool for creating books from Markdown files, popular in the Rust ecosystem.
- It supports a plugin mechanism for modifying book output, usable with any programming language.
- Plugins can be registered in the book.toml file and are executed as sub-processes.
- Discovery is explicit, requiring plugins to be listed in the configuration.
- Registration involves invoking the plugin twice to check support and process the book.
- Hooks are coarse-grained, processing the entire book in JSON format.
- Rust plugins have access to additional utilities via the Preprocessor trait.
- Renderers (backends) process the book similarly to preprocessors but produce final output like HTML.