1.4.1 • Published 1 year ago
d2-filter v1.4.1
d2-filter
d2-filter is a pandoc filter that adds D2 syntax
diagrams in markdown documents.
Example
~~~{.d2 pad=20}
x -> y
~~~
Usage
# Installation
npm i -g d2-filter
# Unix
pandoc -F d2-filter test.md -o test.pdf
# Windows
pandoc -F d2-filter.cmd test.md -o test.pdfIf using with Quarto, you can use quarto-d2 to avoid issues with pandoc filters.
Configuration
Using attributes of the fenced code block, you can specify:
- Theme
- Example:
{.d2 theme="Grape soda"}. - Default:
0orNeutral default - Values: Run
d2 themesfor possible options.
- Example:
- Layout engine
- Example:
{.d2 layout=elk}. - Default:
dagre - Values: Run
d2 layoutfor possible options.
- Example:
- Image format
- Example:
{.d2 format=png} - Default:
svg - Values:
svg,png,pdf
- Example:
- Sketch
- Example:
{.d2 sketch=true} - Default:
false
- Example:
- Image padding
- Example:
{.d2 pad=0} - Default:
100
- Example:
- Folder
- Example:
{.d2 folder=img} - Default: no folder as image is encoded to data URI on
imgtag
- Example:
- Filename
- Example:
{.d2 filename="test"} - Default:
diagram-N folderattribute is required to save file locally
- Example:
- Pandoc caption
- Example:
{.d2 caption="This is a test image"} - Default: empty string
- Example:
- Pandoc image attributes
- Example:
{.d2 width=30 height=20px} - Default: empty array
- Values: See pandoc's
link_attributesextension - Note that
#idand.classattributes are not supported, but any key-value attributes should work
- Example:
Credits
License
MIT