Skip to content

Generate d2 diagrams within Emacs org-mode babel

License

Notifications You must be signed in to change notification settings

dmacvicar/ob-d2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

ob-d2

Generate d2 diagrams using org-mode and org-babel.

Setup

  1. install d2
  2. Until the package is in melpa, you can use straight or similar:
(use-package ob-d2
  :straight (:type git :host github :repo "dmacvicar/ob-d2")
  :defer t)
  1. Add d2 to org-babel-load-languages or specify :commands (org-babel-execute:d2) when loading it.
    (org-babel-do-load-languages
        'org-babel-load-languages
        '((d2 . t)
          (scheme . t)
          (your-other-langs . t)))
        
  2. Open org-mode buffer and create an org-babel source block:
    #+begin_src d2 :file test.png
     A-->B: Works!
    #+end_src
        
    A-->B: Works!
        
  3. Exporting the org-mode document or invoking the org-babel-execute-src-block function to generate diagram.

Supported properties

file - Output file. It should be either svg or png.

theme - Theme of the chart (number). See available themes.

layout - Layout engine (default is “dagre”)

About

Generate d2 diagrams within Emacs org-mode babel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published