You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ob-d2 enables Org-Babel support for evaluating D2 code.
It was created based on the usage of ob-ditaa.
The D2 code is compiled via the d2 command.
#+BEGIN_SRC d2 :file hello.png
x -> y: hello world
#+END_SRC
Language Specific Header Arguments
In addition to the normal header arguments for Babel, ob-d2 uses the :flags header to pass additional flags to the d2 command.
:file is required since the output of D2 is an image.
Additional Examples
All examples are courtesy of Terrastruct, Inc. who published them in their D2 documentation.
Flags to specify theme and sketch format
#+BEGIN_SRC d2 :file flags.png :flags -t 101 -s
High Mem Instance -> EC2 <- High CPU Instance: Hosted By
#+END_SRC
Complex example
#+BEGIN_SRC d2 :file complex.png
clouds: {
aws: {
load_balancer -> api
api -> db
}
gcloud: {
auth -> db
}
gcloud -> aws
}
#+END_SRC
Configuration
ob-d2 is available from Melpa.
You can install it directly via package-install if you have Melpa in your package archives.
After installation, you can (require 'ob-d2) and enable D2 as a supported language in org-mode by adding it to org-babel-load-languages.
For example, something like: