[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Org mode and "shunt" exporters?
From: |
Eric Schulte |
Subject: |
Re: [O] Org mode and "shunt" exporters? |
Date: |
Thu, 12 Dec 2013 12:24:01 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Here's a quick shot at using Common Lisp's cl-json package as a bridge
between Emacs-lisp and JSON. The Org-mode file with necessary the code
is attached (it requires a running lisp process w/cl-json loaded), as
well as it's json conversion.
#+Title: Org to JSON
Use Common Lisp as a bridge between Org-mode and JSON.
A three step process.
1. First we'll define an Emacs Lisp function to write an Org-mode
buffer to a file as Emacs Lisp.
#+begin_src emacs-lisp
(defun write-org-to-emacs-lisp-file (&optional path)
(interactive "Foutput file: ")
(cl-flet ((obj-to-path (obj path)
(with-temp-file path
(prin1 obj (current-buffer)))))
(obj-to-path (org-element-parse-buffer) path)))
#+end_src
2. Small hack to fix the circular =:parent= issue.
#+begin_src sh :var path="/tmp/org-to-json.el" :results none
sed 's/#[0-9]\+/:not-the-parent/g' -i $path
#+end_src
3. Finally use Common Lisp to read the hacked up Emacs Lisp and use
[[http://common-lisp.net/projects/cl-json][cl-json]] to print that as JSON.
#+name: emacs-lisp-to-json
#+headers: :var in-path="/tmp/org-to-json.el"
#+headers: :var out-path="/tmp/org-to-json.json"
#+begin_src lisp :results none
(with-open-file (in in-path)
(with-open-file (out out-path :direction :output)
(cl-json:encode-json (read in) out)))
#+end_src
org-to-json.json
Description: application/json
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
- Re: [O] Org mode and "shunt" exporters?, (continued)
- Re: [O] Org mode and "shunt" exporters?, Eric Schulte, 2013/12/05
- Re: [O] Org mode and "shunt" exporters?, Brett Viren, 2013/12/09
- Re: [O] Org mode and "shunt" exporters?, Nicolas Goaziou, 2013/12/09
- Re: [O] Org mode and "shunt" exporters?, Brett Viren, 2013/12/13
- Re: [O] Org mode and "shunt" exporters?, Nicolas Goaziou, 2013/12/13
- Re: [O] Org mode and "shunt" exporters?, Eric Schulte, 2013/12/13
- Re: [O] Org mode and "shunt" exporters?, Brett Viren, 2013/12/13
Re: [O] Org mode and "shunt" exporters?, John Kitchin, 2013/12/06
- Re: [O] Org mode and "shunt" exporters?, Brett Viren, 2013/12/12
- Re: [O] Org mode and "shunt" exporters?, John Kitchin, 2013/12/12
- Re: [O] Org mode and "shunt" exporters?,
Eric Schulte <=
- Re: [O] Org mode and "shunt" exporters?, Aaron Ecay, 2013/12/12
- Re: [O] Org mode and "shunt" exporters?, Matt Price, 2013/12/12
- Re: [O] Org mode and "shunt" exporters?, John Kitchin, 2013/12/12
- Re: [O] Org mode and "shunt" exporters?, Brett Viren, 2013/12/13