From: Brett Viren <bv@bnl.gov>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: emacs-orgmode@gnu.org, Eric Schulte <schulte.eric@gmail.com>
Subject: Re: Org mode and "shunt" exporters?
Date: Fri, 13 Dec 2013 13:26:57 -0500 [thread overview]
Message-ID: <ir48uvoobda.fsf@lycastus.phy.bnl.gov> (raw)
In-Reply-To: <87k3fdu7dm.fsf@gmail.com> (Nicolas Goaziou's message of "Mon, 09 Dec 2013 20:55:17 +0100")
[-- Attachment #1: Type: text/plain, Size: 1961 bytes --]
Hi,
Nicolas Goaziou <n.goaziou@gmail.com> 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 the 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.
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,
-Brett.
#+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
(lambda (x)
(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
;; (org-element-contents x))))
))
(write-region
;(json-encode tree)
(prin1-to-string tree)
nil "foo.txt"))
#+END_SRC
#+RESULTS:
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2013-12-13 18:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 20:30 Org mode and "shunt" exporters? Brett Viren
2013-12-06 2:10 ` Eric Schulte
2013-12-09 17:38 ` Brett Viren
2013-12-09 19:55 ` Nicolas Goaziou
2013-12-13 18:26 ` Brett Viren [this message]
2013-12-13 19:05 ` Nicolas Goaziou
2013-12-13 19:29 ` Eric Schulte
2013-12-13 23:06 ` Brett Viren
2013-12-06 13:02 ` John Kitchin
2013-12-12 16:30 ` Brett Viren
2013-12-12 17:22 ` John Kitchin
2013-12-12 19:24 ` Eric Schulte
2013-12-12 19:50 ` Aaron Ecay
2013-12-12 19:58 ` Matt Price
2013-12-13 2:53 ` John Kitchin
2013-12-13 19:02 ` Brett Viren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ir48uvoobda.fsf@lycastus.phy.bnl.gov \
--to=bv@bnl.gov \
--cc=emacs-orgmode@gnu.org \
--cc=n.goaziou@gmail.com \
--cc=schulte.eric@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).