#mdbook #svg #markdown #ascii #bob

app mdbook-svgbob

SvgBob mdbook preprocessor which swaps code-blocks with neat SVG

4 releases

0.2.1 Dec 14, 2022
0.2.0 Nov 18, 2022
0.1.1 Apr 12, 2020
0.1.0 Apr 11, 2020

#599 in Text processing

Download history 2462/week @ 2024-01-02 1509/week @ 2024-01-09 2271/week @ 2024-01-16 2010/week @ 2024-01-23 1380/week @ 2024-01-30 1810/week @ 2024-02-06 1652/week @ 2024-02-13 1812/week @ 2024-02-20 1906/week @ 2024-02-27 2649/week @ 2024-03-05 954/week @ 2024-03-12 1701/week @ 2024-03-19 614/week @ 2024-03-26 1218/week @ 2024-04-02 1455/week @ 2024-04-09 1542/week @ 2024-04-16

5,162 downloads per month

MPL-2.0 license

30KB
294 lines

Svgbob plugin for mdbook

Svgbob-based preprocessor for mdbook transform your ascii diagrams into a svg.

This renders a code-block marked bob into neat svg diagrams and inline it into the output.

Usage

Firstly add the following to your book's manifest file (usually book.toml)

[preprocessor.svgbob] # all fields by default

See config for more information.

Add some ascii graphics:

chapter_1.md

```bob
    0       3
     *-------*      +y
  1 /|    2 /|       ^
   *-------* |       |
   | |4    | |7      | ◄╮
   | *-----|-*     ⤹ +-----> +x
   |/      |/       / ⤴
   *-------*       v
  5       6      +z
```

Build your book and open:

mdbook build
open book/index.html

Config

Default preprocessor config:

[preprocessor.svgbob]
# svgbob configuration:
# doc: https://docs.rs/svgbob/latest/svgbob/struct.Settings.html
# default values: https://github.com/ivanceras/svgbob/blob/master/packages/svgbob/src/settings.rs#L29-L38
font_size = 14
font_family = "Iosevka Fixed, monospace"
fill_color = "black"
background = "transparent"               # default overridden, differs from svgbob's default
stroke_color = "var(--fg)"               # default overridden, differs from svgbob's default
stroke_width = 2.0
scale = 8.0
enhance_circuitries = true
include_backdrop = true
include_styles = true
include_defs = true
merge_line_with_shapes = false

# preprocessor configuration:
code_block = "bob"                       # render only code-blocks marked as "bob", e.g.: ```bob

All properties are optional.

See svgbob's settings doc and default values.


For more information about mdbook see mdbook manual, svgbob spec and editor.

Contribution

Contributions are appreciated. Don't hesitate to participate to discussions in the issues, propose new features and ask for help.

Useful hint for one-command builds crate + book:

  1. add command to the manifest:
# book.toml

[preprocessor.svgbob]
command = "cargo run --manifest-path /path/to/mdbook-svgbob/Cargo.toml --quiet"
  1. So then you only need to rebuild the book. Run something like this:
RUST_LOG=mdbook_svgbob=trace mdbook build

Dependencies

~22–34MB
~535K SLoC