From: Eric Schulte <schulte.eric@gmail.com>
To: John Kitchin <jkitchin@andrew.cmu.edu>
Cc: Brett Viren <bv@bnl.gov>,
"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Org mode and "shunt" exporters?
Date: Thu, 12 Dec 2013 12:24:01 -0700 [thread overview]
Message-ID: <87txedna9a.fsf@gmail.com> (raw)
In-Reply-To: <CAJ51ETrm1-s69e-FoNw=R4BkVc-u1rTnF0tn6oj3j1Jqh26HEg@mail.gmail.com> (John Kitchin's message of "Thu, 12 Dec 2013 12:22:38 -0500")
[-- Attachment #1: Type: text/plain, Size: 244 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-to-json.org --]
[-- Type: text/x-org, Size: 1192 bytes --]
#+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
[-- Attachment #3: org-to-json.json --]
[-- Type: application/json, Size: 4421 bytes --]
[-- Attachment #4: Type: text/plain, Size: 63 bytes --]
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
next prev parent reply other threads:[~2013-12-12 19:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 20:30 Org mode and "shunt" exporters? Brett Viren
2013-12-06 2:10 ` Eric Schulte
2013-12-09 17:38 ` Brett Viren
2013-12-09 19:55 ` Nicolas Goaziou
2013-12-13 18:26 ` Brett Viren
2013-12-13 19:05 ` Nicolas Goaziou
2013-12-13 19:29 ` Eric Schulte
2013-12-13 23:06 ` Brett Viren
2013-12-06 13:02 ` John Kitchin
2013-12-12 16:30 ` Brett Viren
2013-12-12 17:22 ` John Kitchin
2013-12-12 19:24 ` Eric Schulte [this message]
2013-12-12 19:50 ` Aaron Ecay
2013-12-12 19:58 ` Matt Price
2013-12-13 2:53 ` John Kitchin
2013-12-13 19:02 ` Brett Viren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87txedna9a.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=bv@bnl.gov \
--cc=emacs-orgmode@gnu.org \
--cc=jkitchin@andrew.cmu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).