oz icon indicating copy to clipboard operation
oz copied to clipboard

Org-mode

Open joinr opened this issue 6 years ago • 5 comments

Adding org support as an option (in addition to existing markdown) would be useful.

joinr avatar Jan 26 '19 20:01 joinr

Hi @joinr. Thanks for posting this issue.

As I mentioned on slack, I don't use emacs, and am probably not the best person to be working on this, but I think it's a great idea, and encourage you or any one else interested to put forward a proposal.

Thanks again.

metasoarous avatar Jan 28 '19 11:01 metasoarous

I use vega-lite with org mode.

The main idea is to do this 3 steps to include a vega lite spec in a org mode file:

a) In a "clojure" block:

  1. Specify the "spec"
  2. Convert spec to json and write to disk
(def spec ....
(spit "spec.vl"
 (json/generate-string spec))

b) In a following "shell block":

  • convert the json to a svg file using the command line utils
#+BEGIN_SRC shell
vl2svg spec.vl  spec.svg
#+END_SRC

c) Include the "svg" file into org mode via

 [[file:spec.svg]]

behrica avatar Feb 22 '19 08:02 behrica

@behrica is right - i was able to use vega charts in org-more by relaying on vega-cli tool. You even don't need oz for that.Here is example for reference

vladkotu avatar Jan 24 '20 16:01 vladkotu

Although @behrica's work-flows works, I wish to be able to write spec in Clojure via Oz, and automatically get the svg file generated and embedded in org-mode buffer. The desired work-flow should be similar to the code block of plantuml.

For example,

#+BEGIN_SRC oz :exports :file ./from-vega-lite.svg
spec in Clojure via oz
#+END_SRC

You may find some examples of how convenient to specify diagram with plantuml with org-mode's code block.

With this support, I will be able to use org as markdown syntax to write document with oz for vega-lite specification, without manually handling the generation of vega-lite figure generation and embedding the generated file.

yubrshen avatar Dec 17 '21 16:12 yubrshen

Hey @yubrshen.

Right now, you could do something equivalent to what @behrica suggests by using oz.core/export!. For svg, this will try to use graalvm to render (without having to install the vega-cli using npm or whatever), but for jpg you need canvas, which I don't think graalvm supports yet (though I'd love for someone to prove me wrong on this). This reduces the steps in your org-mode files to 2 instead of 3. You would still need to include the file into org-mode the way @behrica describes (step c).

If there's a way to facilitate a one step process in org-mode, I'm more than happy to accommodate that. I just don't know enough about org-mode to be of much help sorting out that side of it.

The other thing I would really like to support in Oz is ingest of org-mode files and interpretation as hiccup. Perhaps we can even extend Oz's notion of parallelized clj code execution, so that you could use Oz's notebook functionality with org-mode files. I don't know how much control org-mode gives you over what sort of output formats/templates are available, but Oz is quite flexible in this regard, and only becoming more capable. So perhaps it would be useful to have a flexible rendering system (static site generation, pdf documents, etc) for org-mode files?

Happy to discuss more if anything like that makes sense.

Thanks again

metasoarous avatar Dec 17 '21 20:12 metasoarous