From: Brett Viren <firstname.lastname@example.org>
To: Daniel Clemente <email@example.com>
Cc: "François Pinard" <firstname.lastname@example.org>, email@example.com
Subject: Re: Parsing Org-mode in Python
Date: Thu, 09 Jan 2014 09:13:39 -0500 [thread overview]
Message-ID: <firstname.lastname@example.org> (raw)
In-Reply-To: <email@example.com> (Daniel Clemente's message of "Thu, 09 Jan 2014 11:13:15 +0700")
[-- Attachment #1: Type: text/plain, Size: 2138 bytes --]
Daniel Clemente <firstname.lastname@example.org> writes:
> Are there already Python parsers for it?
Parsing generic JSON is fairly trivial in Python.
data = json.dumps(open('file.json').read())
The resulting "data" is then a bunch of Python lists and/or dicts
matching whatever structure was output from org and is in the .json
file. The schema in these three contexts are (will be) identical.
At this point, Pythonistas can do what they want with "data". Although,
as I mentioned, I'd like to put another layer on this "raw" data
structure which expresses/enforces the org schema as understood by the
org-exporter. If I can figure out how to dump a representation of this
schema from org I'll express it as a set of generated
collections.namedtuple instances. We'll see.
> Should ox-json's output be as raw as possible (e.g. what your code
> produces now) or transformed to simpler JSON?
> (I think both formats should coexist).
I suppose there may be a usefulness to "winnow down" the structure. One
thing I'm thinking about here is the narrowing done to support the "blog
From anywhere" feature of Karl's lazyblorg mentioned in this thread.
That can be done either on the emacs side or Python side (or both, in
principle). However, my intention is to do as little modification of
the org document structure on the emacs-side in order to preserve
details that may possibly be interesting on the Python-side in the
future. Also, I'm still learning LISP but know Python fairly well so
would rather do as much processing as possible on the Python side. :)
So far the only thing I see that needs to be stripped is the :parent
property (and the :structure, which really should be resolved as a copy
instead of being stripped) which cause the emacs-side data structure to
become a Circular Object and thus break the emacs JSON dumper.
I just noticed that Python's JSON dumper can do this kind of stripping
implicitly and in general. It might be nice if someone were to add such
a feature to the emacs JSON dumper but I don't plan to try this.
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2014-01-09 14:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-22 16:37 Converting org-mode/org-contacts to VCard (importing to Android) Karl Voit
2013-11-22 16:54 ` Rüdiger Sonderfeld
2013-11-22 17:09 ` Karl Voit
2013-11-23 0:00 ` Rüdiger Sonderfeld
2013-11-24 13:06 ` Implementing Org-mode tools in languages other than ELISP (was: Converting org-mode/org-contacts to VCard (importing to Android)) Karl Voit
2014-01-04 14:58 ` Implementing Org-mode tools in languages other than ELISP Bastien
2014-01-04 16:43 ` François Pinard
2014-01-05 16:43 ` Daniel Clemente
2014-01-06 10:44 ` Parsing Org-mode in Python (was: Implementing Org-mode tools in languages other than ELISP) Karl Voit
2014-01-07 2:33 ` Parsing Org-mode in Python François Pinard
2014-01-07 16:09 ` Brett Viren
2014-01-08 12:33 ` François Pinard
2014-01-08 15:42 ` Brett Viren
2014-01-08 16:11 ` François Pinard
2014-01-09 4:13 ` Daniel Clemente
2014-01-09 14:13 ` Brett Viren [this message]
2014-01-07 1:47 ` Implementing Org-mode tools in languages other than ELISP François Pinard
2013-11-23 8:36 ` Converting org-mode/org-contacts to VCard (importing to Android) Feng Shu
2013-11-23 8:29 ` Feng Shu
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:
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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
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).