mdbook_uplot 0.2.0

mdbook preprocessor for interactive uPlot charts
docs.rs failed to build mdbook_uplot-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: mdbook_uplot-0.1.0

mdbook-uplot

An mdbook preprocessor for embedding interactive uPlot charts in your book.

Write chart data as fenced ```uplot code blocks in your markdown and mdbook-uplot renders them as interactive charts.

Live documentation and examples

Preview

Installation

Shell (macOS/Linux)

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/n1ght-hunter/mdbook_uplot/releases/latest/download/mdbook_uplot-installer.sh | sh

PowerShell (Windows)

powershell -ExecutionPolicy ByPass -c "irm https://github.com/n1ght-hunter/mdbook_uplot/releases/latest/download/mdbook_uplot-installer.ps1 | iex"

cargo-binstall

cargo binstall mdbook_uplot

From crates.io

cargo install mdbook_uplot

Setup

Run the install command to configure your book:

mdbook-uplot install path/to/book

This adds [preprocessor.uplot] to book.toml, registers the JS/CSS assets, and writes asset files. Assets are kept up to date automatically on every mdbook build.

Usage

Use a fenced code block with the uplot language tag:

```uplot
{
  "type": "line",
  "labels": ["Jan", "Feb", "Mar", "Apr", "May"],
  "datasets": [
    { "label": "Revenue", "data": [30, 45, 38, 52, 48], "color": "#1f77b4" },
    { "label": "Costs", "data": [20, 25, 22, 30, 28], "color": "#ff7f0e" }
  ]
}
```

You can also reference an external JSON file instead of inlining data:

```uplot
{ "data": "path/to/data.json" }
```

Paths are resolved relative to the chapter's source directory.

Chart types

Set "type" to one of: "bar" (default), "line", "area", or "scatter".

Features

Feature Example
Axis labels "axes": { "x": "Month", "y": "Revenue" }
Value formatting "format": { "prefix": "$", "suffix": "k", "decimals": 1 }
Tooltip options "tooltip": false or { "all": true }
Legend control "legend": { "show": false } or { "live": true }
Code display "code": false, or { "position": "side" }, "above", "below"
Editable playground "editable": true — live JSON editor with syntax highlighting
Custom height "height": 250
uPlot pass-through "opts": { "scales": { "y": { "range": [0, 100] } } }
Dark theme Automatically adapts to coal, navy, and ayu themes

See the documentation book for full details, live examples, and the customization reference.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

Licensed under either of

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.