From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brett Viren Subject: Re: Parsing Org-mode in Python Date: Wed, 08 Jan 2014 10:42:17 -0500 Message-ID: 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 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W0vHK-0000HU-72 for emacs-orgmode@gnu.org; Wed, 08 Jan 2014 10:42:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W0vHE-0003K3-Ea for emacs-orgmode@gnu.org; Wed, 08 Jan 2014 10:42:46 -0500 Received: from smtpgw.bnl.gov ([2620:10a:0:3::30]:10405 helo=iron3.sec.bnl.local) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W0vHE-0003Bi-9Q for emacs-orgmode@gnu.org; Wed, 08 Jan 2014 10:42:40 -0500 In-Reply-To: <87k3easlf6.fsf@iro.umontreal.ca> (=?utf-8?Q?=22Fran=C3=A7ois?= Pinard"'s message of "Wed, 08 Jan 2014 07:33:17 -0500") 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: =?utf-8?Q?Fran=C3=A7ois?= Pinard Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Fran=C3=A7ois Pinard writes: > Brett Viren writes: > >> http://permalink.gmane.org/gmane.emacs.orgmode/79838 > > This yields: > > ,---- > | Not Found > |=20 > | The requested URL /gmane.emacs.orgmode/79838 was not found on this serv= er. > `---- 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)=20 (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)=20 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!=20=20 =2DBrett. --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlLNcdoACgkQEixH2Z0dKCwpTgCeJz4ci4kwYh+rqZBzL9A+cNyV ShcAoJ18m/7s0T8QqIy599qS4078gO4X =UoFr -----END PGP SIGNATURE----- --=-=-=--