Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vaelatern/mdbook-d2-go
https://github.com/vaelatern/mdbook-d2-go
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/vaelatern/mdbook-d2-go
- Owner: Vaelatern
- License: other
- Created: 2023-01-11T09:48:45.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-10T19:29:17.000Z (4 months ago)
- Last Synced: 2024-11-23T07:29:42.819Z (3 months ago)
- Language: Go
- Size: 105 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mdbook-d2-go
Tiny preprocessor that uses [`d2`](https://github.com/terrastruct/d2) as a library to inline processed SVG in your [mdBook](https://rust-lang.github.io/mdBook/) documents.
## Quickstart
`go build`
then copy the file to your `$PATH` so `mdBook` can find it
Or you can `docker build . -t mdbook-d2-go` and put a `COPY --from=mdbook-d2-go:latest /mdbook-d2-go .` in whatever Dockerfile runs the `mdBook` code.
In your `book.toml`:
```
[preprocessor.d2-go]
layout = "elk"
theme_id = 0
```Check out the `example-with-d2` folder for a working mdbook example.
### Keeping SVGs skinny
Your SVGs will be full size when loaded in mdbook by default.
Fortunately, a small mdbook theme fixes it:
```
$ cat theme/head.hbssvg {
width: inherit;
height: inherit;
}```
## Known bugs
- Currently the SVG generated by `d2` claims the element id `d2-svg` suggesting that two or more of these on the same page may lead to misbehaviours.
- Width may overflow
- The layout engine is not configurable despite most of the plumbing being there## License
OpenBSD-style ISC