#material-design #mdbook #material #design #markdown #ui

bin+lib mdbook-admonish

A preprocessor for mdbook to add Material Design admonishments

28 stable releases

1.18.0 Jun 20, 2024
1.17.0 May 24, 2024
1.15.0 Dec 30, 2023
1.14.0 Nov 16, 2023
1.4.0 Feb 21, 2022

#72 in Text processing

Download history 843/week @ 2024-07-30 1614/week @ 2024-08-06 1874/week @ 2024-08-13 812/week @ 2024-08-20 1235/week @ 2024-08-27 938/week @ 2024-09-03 1066/week @ 2024-09-10 1323/week @ 2024-09-17 1800/week @ 2024-09-24 768/week @ 2024-10-01 1420/week @ 2024-10-08 1313/week @ 2024-10-15 1147/week @ 2024-10-22 1546/week @ 2024-10-29 1753/week @ 2024-11-05 1527/week @ 2024-11-12

6,206 downloads per month

MIT license

140KB
3.5K SLoC

mdbook-admonish

Latest version docs.rs

A preprocessor for mdbook to add Material Design admonishments, based on the mkdocs-material implementation.

It turns this:

```admonish info
A beautifully styled message.
```

into this:

Simple Message

Examples

Read the documentation here, to see the actual examples in action. You can see the source in the ./book subdirectory.

Projects using mdbook-admonish include:

Usage

Use any fenced code-block as you normally would, but annotate it with admonish <admonition type>:

```admonish example
My example is the best!
```

Best Example

See the reference page for a list of supported admonitions. You'll find:

  • info
  • warning
  • danger
  • example

and quite a few more!

You can also leave out the admonition type altogether, in which case it will default to note:

```admonish
A plain note.
```

Plain Note

Additional Options

See the mdbook-admonish book for additional options, such as:

  • Custom titles
  • Custom styling
  • Collapsible blocks

Installation

Install the tool:

cargo install mdbook-admonish

# If you get compilation/installation errors, try a locked installation
cargo install mdbook-admonish --locked

Then let mdbook-admonish add the required files and configuration:

# Note: this may need to be rerun for new minor versions of mdbook-admonish
# see the 'Semantic Versioning' section below for details.
mdbook-admonish install path/to/your/book

# optionally, specify a directory where CSS files live, relative to the book root
mdbook-admonish install --css-dir ./assets/css .

This will add the following configuration to your book.toml:

[preprocessor.admonish]
command = "mdbook-admonish"

[output.html]
additional-css = ["./mdbook-admonish.css"]

and copy the file mdbook-admonish.css into your book's directory.

Then, build your book as usual:

mdbook path/to/book

Reproducible builds

For a reproducible build suitable for use in CI or scripts, please:

  • Pin to a specific version
  • Install with lockfile dependencies
  • Always install the latest CSS assets
cargo install mdbook-admonish --vers "1.5.0" --locked
mdbook-admonish install path/to/your/book

The Minimum Supported Rust Version (MSRV) is documented in Cargo.toml, and noted in the CHANGELOG.md. We aims to support around six months of stable Rust.

Updates

Please note, when updating your version of mdbook-admonish, updated styles will not be applied unless you rerun mdbook-admonish install to update the additional CSS files in your book.

mdbook will fail the build if you require newer assets than you have installed:

2022-04-26 12:27:52 [INFO] (mdbook::book): Book building has started
ERROR:
  Incompatible assets installed: required mdbook-admonish assets version '^2.0.0', but found '1.0.0'.
  Please run `mdbook-admonish install` to update installed assets.
2022-04-26 12:27:52 [ERROR] (mdbook::utils): Error: The "admonish" preprocessor exited unsuccessfully with exit status: 1 status

If you want to update across minor versions without breakage, you should always run mdbook-admonish install.

Process included files

You can ensure that content inlined with {{#include}} is also processed by setting the after option:

[preprocessor.admonish]
after = ["links"]

This will expand include directives, before expanding admonish blocks.

Semantic Versioning

Guarantees provided are as follows:

Development

See CONTRIBUTING.md for guidelines on developing.

Thanks

This utility is heavily drawn from and inspired by other projects, namely:

The licences for these projects are included in the licences folder.

Dependencies

~13–24MB
~359K SLoC