#mdbook #preprocessor #code-block

app mdbook-codeblocks

A mdbook preprocessor to prepend customizable vignette to code blocks

16 releases

0.1.17 Nov 26, 2024
0.1.15 May 21, 2024
0.1.14 Mar 16, 2024
0.1.12 Dec 6, 2023
0.1.9 Jul 18, 2023

#370 in Text processing

Download history 19/week @ 2024-09-20 1/week @ 2024-09-27 1/week @ 2024-10-04 112/week @ 2024-11-08 30/week @ 2024-11-15 122/week @ 2024-11-22 20/week @ 2024-11-29

284 downloads per month

MIT/Apache

26KB
387 lines

mdbook-codeblocks

build crates.io

A preprocessor for mdbook which prepend a vignette above code blocks.

usage

First you need to install the pre-processor by running the following command.

cargo install mdbook-codeblocks

Next you need to add the preprocessor to your book.toml. Customization is at its early stage, but you can already define language's custom icon, label, color and link:

[book]
authors = ["Roms1383"]
title = "Code blocks preprocessor example"

[output.html]

[preprocessor.codeblocks]
renderers = ["html"]
cpp = { color = "#FFFF99", link = "https://wiki.redmodding.org/red4ext" }
redscript = { color = "tomato", link = "https://wiki.redmodding.org/redscript" }
rust = { color = "#ac4313", link = "https://github.com/jac3km4/red4ext-rs" }
lua = { link = "https://wiki.redmodding.org/cyber-engine-tweaks" }
swift = { label = "Swift code snippet", color = "skyblue" }

Here's what it will produce:

example

You can actually find it in example folder.

⚠️ also, do not forget to embed FontAwesome css, see example/theme/head.hbs.

roadmap

This tool is very rudimentary, but contributions are welcomed!

Especially for the HTML/CSS :)

Likewise it only supports a small subset of 5 languages so far, please add more!

attribution

This tool uses icons from FontAwesome by default.

Dependencies

~13–24MB
~353K SLoC