emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Parsing Org-mode in Python


From: Daniel Clemente
Subject: Re: [O] Parsing Org-mode in Python
Date: Thu, 09 Jan 2014 11:13:15 +0700
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Gojō) APEL/10.8 EasyPG/1.0.0 Emacs/23.4 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

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).
  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]