Open suliveevil opened 1 year ago
Thanks @suliveevil. will get back to you on this. As some level this is blocked by #8 from my end. It would be great if eventually d2 supports pngs. SVG's just don't play as well with emacs. I think I can get it to work, but I need to fix #8 first
confirmed repeatability
Browser renders correctly:
This a more general issue with imagemagik and svgs convert input.svg output.png
reproduces the issue.
The way I see it, there are two fixes:
Or we may should find another tool to convert svg to png?
yea...possible. i'll need to look into it and get back on this.
referencing here https://github.com/andorsk/d2-mode/issues/8
since this is an emacs related issue, I don't see an easy way around this without saying "upgrade your emacs", however I have added support for a complementing method at #19 , which allows you to open up the browser directly from emacs through the new supported commands:
(defvar d2-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-c") 'd2-compile)
(define-key map (kbd "C-c C-f") 'd2-compile-file)
(define-key map (kbd "C-c C-b") 'd2-compile-buffer)
(define-key map (kbd "C-c C-r") 'd2-compile-region)
(define-key map (kbd "C-c C-h") 'd2-compile-file-and-browse)
(define-key map (kbd "C-c C-j") 'd2-compile-buffer-and-browse)
(define-key map (kbd "C-c C-k") 'd2-compile-region-and-browse)
(define-key map (kbd "C-c C-o") 'd2-open-browser)
(define-key map (kbd "C-x C-o") 'd2-view-current-svg)
(define-key map (kbd "C-c C-d") 'd2-open-doc)
map))
This allows the browser to render the svg, which should work pretty well.
d2 is able to convert to png, e.g. d2 input.d2 out.png
. i'm not 100% sure it would work in this context though, as it involves using headless browsers.
we also ran into some subpar svg rendering when building the Obsidian integration. we got around this by base64 encoding the SVGs. didn't end up going with that in the end, but it did work