From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brett Viren Subject: Re: Org mode and "shunt" exporters? Date: Fri, 13 Dec 2013 13:26:57 -0500 Message-ID: References: <87zjoe7mf2.fsf@gmail.com> <87k3fdu7dm.fsf@gmail.com> 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]:40254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrXSV-0004ed-AH for emacs-orgmode@gnu.org; Fri, 13 Dec 2013 13:27:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrXSP-0006Rm-02 for emacs-orgmode@gnu.org; Fri, 13 Dec 2013 13:27:31 -0500 Received: from smtpgw.bnl.gov ([2620:10a:0:3::30]:4235 helo=iron3.sec.bnl.local) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrXSO-0006II-Rn for emacs-orgmode@gnu.org; Fri, 13 Dec 2013 13:27:24 -0500 In-Reply-To: <87k3fdu7dm.fsf@gmail.com> (Nicolas Goaziou's message of "Mon, 09 Dec 2013 20:55:17 +0100") 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: Nicolas Goaziou Cc: emacs-orgmode@gnu.org, Eric Schulte --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Nicolas Goaziou writes: > You can walk the tree, e.g. with `org-element-map', and remove > all :parent references if you don't need them. I figured out how to follow this advice. I can even make valid JSON From=20the filtered parse tree by handing it to Edward O'Conner's json.el (link in example below). However this method only works for a very simple org document. I'm successfully filtering out the :parent properties of (most of) the elements but as soon as my document produces a plain text element like: #("Text" 0 4 (:parent #1)) then two problems occcur: First, I'm simply failing to see how to set this :parent property to nil like I do with the others.=20=20 Second, json.el throws a "Bad JSON Object" error. I tried assuming that the problem was it doesn't know what to do with this substring form. Naively, I tried to follow some other recent advice in another thread about using substring-no-properties to strip out the meta data from the plain text elements. But this apparently is a net no-op as I suspect that the org-element-set-contents then puts them right back. I feel like I'm pretty close. Any more advice? Thanks, =2DBrett. #+TITLE: The Title. Blah blah blah. * A heading. This uses http://edward.oconnor.cx/2006/03/json.el - foo - bar - baz #+BEGIN_SRC elisp (require 'json) (let* ((tree (org-element-parse-buffer 'object nil))) (org-element-map tree org-element-all-elements=20 (lambda (x)=20 (if (org-element-property :parent x) (org-element-put-property x :parent nil)) ;; (if (eq (org-element-type x) 'plain-text) ;; (org-element-set-contents x (substring-no-properties=20 ;; (org-element-contents x)))) )) (write-region ;(json-encode tree)=20 (prin1-to-string tree) nil "foo.txt")) #+END_SRC #+RESULTS: --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlKrUXEACgkQEixH2Z0dKCzNkgCfQS/6U46YaCF3i4ex1dmEcWZ7 D8MAoJxmVl+wOylznN8rjDmqg18Plzto =J4ve -----END PGP SIGNATURE----- --=-=-=--