#widgets #interactive #directory #file #renders

bin+lib mdbook-files

Preprocessor for mdbook which renders files from a directory as an interactive widget

2 unstable releases

0.2.0 Dec 29, 2023
0.1.0 Dec 16, 2023

#1611 in Text processing

MIT license

310KB
404 lines

mdbook-files

docs.rs status Crates.io version

Preprocessor for mdBook which renders files from a directory as an interactive widget, with syntax highlighting.

Example of mdbook-files

Example

You can run the example by launching mdbook in the example directory in this repository.

mdbook serve

Usage

Install mdbook-files using cargo:

cargo install mdbook-files

Put the following into your book.toml:

[preprocessor.files]
prefix = "examples"

The prefix is a path, relative to which files are to be included. It is mandatory to give a prefix. Every include path in the book must be within this prefix.

You will also need to add the style.css from this repository to your list of extra CSS files:

[output.html]
additional-css = ["style.css"]

To use it, add something like this to your book:

```files
title = "Files in subfolder"
paths = ["subfolder/**"]
```

This will produce a widget with all files in examples/subfolder, with the given title. The content of this is a TOML document which contains configuration.

License

MIT.

Dependencies

~16–28MB
~416K SLoC