From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Clemente Subject: Re: Parsing Org-mode in Python Date: Thu, 09 Jan 2014 11:13:15 +0700 Message-ID: <87ha9diyhw.wl%n142857@gmail.com> References: <2013-11-22T17-28-29@devnull.Karl-Voit.at> <3414130.xOGDSAomuL@descartes> <2013-11-22T17-57-08@devnull.Karl-Voit.at> <81482742.cUeHUGJmrV@descartes> <2013-11-24T13-29-07@devnull.Karl-Voit.at> <878uuvssi8.fsf@bzg.ath.cx> <87fvp3snof.fsf@iro.umontreal.ca> <87zjnaidlz.wl%n142857@gmail.com> <2014-01-06T11-23-40@devnull.Karl-Voit.at> <87k3easlf6.fsf@iro.umontreal.ca> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W16zn-00071q-3f for emacs-orgmode@gnu.org; Wed, 08 Jan 2014 23:13:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W16zh-0004fb-Q1 for emacs-orgmode@gnu.org; Wed, 08 Jan 2014 23:13:27 -0500 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]:40429) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W16zh-0004fV-HZ for emacs-orgmode@gnu.org; Wed, 08 Jan 2014 23:13:21 -0500 Received: by mail-pa0-f51.google.com with SMTP id fa1so2763751pad.38 for ; Wed, 08 Jan 2014 20:13:20 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Brett Viren Cc: =?ISO-8859-1?Q?Fran=E7ois?= Pinard , emacs-orgmode@gnu.org El Wed, 08 Jan 2014 10:42:17 -0500 Brett Viren va escriure: > > http://lists.gnu.org/archive/html/emacs-orgmode/2013-12/msg00415.html > > In any case, here is the salient chunk: > > #+BEGIN_SRC elisp > (require 'json) > (let* ((tree (org-element-parse-buffer 'object nil))) > (org-element-map tree (append org-element-all-elements > org-element-all-objects '(plain-text)) > (lambda (x) > (if (org-element-property :parent x) > (org-element-put-property x :parent "none")) > (if (org-element-property :structure x) > (org-element-put-property x :structure "none")) > )) > (write-region > (json-encode tree) > nil "foo.dat")) > #+END_SRC > I like this very much. This output is much easier to parse than the source .org file, and it's still using the original Elisp parser (so you don't need a Python parser). I hope ox-json.el gets into org-mode some day. Are there already Python parsers for it? 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).