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: Brett Viren
Subject: Re: [O] Parsing Org-mode in Python
Date: Wed, 08 Jan 2014 10:42:17 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

François Pinard <address@hidden> writes:

> Brett Viren <address@hidden> writes:
>
>>   http://permalink.gmane.org/gmane.emacs.orgmode/79838
>
> This yields:
>
> ,----
> | Not Found
> | 
> | The requested URL /gmane.emacs.orgmode/79838 was not found on this server.
> `----

Huh, maybe a transient failure?  It's there for me right now.  Here is
the same message from GNU's archive:

  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

This test is meant to run from inside an org-mode buffer which itself
provides the fodder for the test.  But, it shows the steps that I'll
need to integrate into some new org export mechanism.  The important
part is nulling out the :parent and :structure (and maybe others?)
properties in order to break their circular references.  The heavy
lifting is all in org-element-parse-buffer and json-encode.

>> At the end of the day one will have a DOM-style data structure
>> representing the initial org document.
>
> Keep me (us!) posted! :-)

Definitely!  
-Brett.

Attachment: pgpz73osTSz1o.pgp
Description: PGP signature


reply via email to

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