1 unstable release
Uses new Rust 2024
new 0.1.0 | Mar 29, 2025 |
---|
#37 in #tabs
375KB
366 lines
mdbook-langtabs
An mdBook preprocessor that creates language tabs for code examples.
Features
- Switch between language examples without scrolling
- Automatic language icons via Devicon
- Remembers selected language preference
Installation
cargo install mdbook-langtabs
Or install the current development version:
cargo install --git https://github.com/nx10/mdbook-langtabs
Setup
Either use the automatic installer:
mdbook-langtabs install /path/to/your/book
Or manually:
- Add to your
book.toml
:
[preprocessor.langtabs]
command = "mdbook-langtabs"
[output.html]
additional-css = ["langtabs.css"]
additional-js = ["langtabs.js"]
- Copy
langtabs.css
andlangtabs.js
to your book's root directory.
Usage
Wrap your code blocks with the special comments:
<!-- langtabs-start -->
```rust
fn main() {
println!("Hello from Rust!");
}
```
```python
def main():
print("Hello from Python!")
```
```javascript
function main() {
console.log("Hello from JavaScript!");
}
```
<!-- langtabs-end -->
This creates tabbed code examples that readers can switch between, as shown in the demo above.
License
MIT
Dependencies
~16–28MB
~420K SLoC