Open uliw opened 1 year ago
I don't think it would be that difficult. https://github.com/arnm/ob-mermaid/blob/master/ob-mermaid.el is an example of this working. We can put it on the feature map.
Happy to help testing
@uliw it actually might be already supported 😆
Can you check if this works for you and is sufficient for your use case?
it mostly works! I get the following error:
/bin/bash: line 1: ~/.local/bin/d2: No such file or directory
even so
$ ls -al ~/.local/bin/d2
-rwxr-xr-x 1 user user 38493010 Jan 11 14:14 /home/uliw/.local/bin/d2
shows that the file is there (and calling it directly is working ok).
Setting d2 location explicitly resolved the issue.
Some practicalities:
#+attr_org: width: 300
. Is there a way to add this line in front of the image?The image size problem can be circumvented by setting this in the startup file
(setq org-image-actual-width (list 550))
Which will apply the above value unless another value is set for given image
Hey @uliw , thanks1 re: the
it mostly works! I get the following error:
/bin/bash: line 1: ~/.local/bin/d2: No such file or directory
even so
$ ls -al ~/.local/bin/d2 -rwxr-xr-x 1 user user 38493010 Jan 11 14:14 /home/uliw/.local/bin/d2
shows that the file is there (and calling it directly is working ok).
Setting d2 location explicitly resolved the issue.
Some practicalities:
- depending on the input file, the png can be rather large, which completely bogs down the org buffer (probably a bug in org). Org-mode allows to set a rendering size via
#+attr_org: width: 300
. Is there a way to add this line in front of the image?- Is there a way to specify the layout engine in the src block arguments?
yea...hmm...maybe the "~" is not resolving correctly?
Re: the width, yea...there are options we can add. I need to check the d2 apis to see if there is a way to do it via the cli. If so, we can add another arg, :width
which would resolve that.
Hi! There's https://github.com/xcapaldi/ob-d2 that helps rendering d2 in org-mode.
Here's a hack I use to control size of an image while exporting to LaTeX that might help you automate #+attr_org:
Put this somewhere at the beginning of the file:
#+NAME: attr_wrap
#+BEGIN_SRC sh :var data="" :var width="\\textwidth" height="200" :results output :exports none
echo "#+ATTR_LATEX: :width $width :height $height"
echo "$data"
#+END_SRC
Example of usage:
#+BEGIN_SRC d2 :file complex.png :post attr_wrap(width=200, height=500, data=*this*) :results drawer
clouds: {
aws: {
load_balancer -> api
api -> db
}
gcloud: {
auth -> db
}
gcloud -> aws
}
#+END_SRC
#+RESULTS:
:results:
#+ATTR_LATEX: :width 200 :height 500
[[file:complex.png]]
:end:
Would it be difficult to enable org-mode src-code block support similar to plantuml?