emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Brett Viren <bv@bnl.gov>
To: "François Pinard" <pinard@iro.umontreal.ca>
Cc: emacs-orgmode@gnu.org
Subject: Re: Parsing Org-mode in Python
Date: Wed, 08 Jan 2014 10:42:17 -0500	[thread overview]
Message-ID: <ir48uuqxyxy.fsf@lycastus.phy.bnl.gov> (raw)
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")

[-- Attachment #1: Type: text/plain, Size: 1629 bytes --]

François Pinard <pinard@iro.umontreal.ca> writes:

> Brett Viren <bv@bnl.gov> 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 #2: Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2014-01-08 15:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-22 16:37 Converting org-mode/org-contacts to VCard (importing to Android) Karl Voit
2013-11-22 16:54 ` Rüdiger Sonderfeld
2013-11-22 17:09   ` Karl Voit
2013-11-23  0:00     ` Rüdiger Sonderfeld
2013-11-24 13:06       ` Implementing Org-mode tools in languages other than ELISP (was: Converting org-mode/org-contacts to VCard (importing to Android)) Karl Voit
2014-01-04 14:58         ` Implementing Org-mode tools in languages other than ELISP Bastien
2014-01-04 16:43           ` François Pinard
2014-01-05 16:43             ` Daniel Clemente
2014-01-06 10:44               ` Parsing Org-mode in Python (was: Implementing Org-mode tools in languages other than ELISP) Karl Voit
2014-01-07  2:33                 ` Parsing Org-mode in Python François Pinard
2014-01-07 16:09                 ` Brett Viren
2014-01-08 12:33                   ` François Pinard
2014-01-08 15:42                     ` Brett Viren [this message]
2014-01-08 16:11                       ` François Pinard
2014-01-09  4:13                       ` Daniel Clemente
2014-01-09 14:13                         ` Brett Viren
2014-01-07  1:47               ` Implementing Org-mode tools in languages other than ELISP François Pinard
2013-11-23  8:36     ` Converting org-mode/org-contacts to VCard (importing to Android) Feng Shu
2013-11-23  8:29 ` Feng Shu

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=ir48uuqxyxy.fsf@lycastus.phy.bnl.gov \
    --to=bv@bnl.gov \
    --cc=emacs-orgmode@gnu.org \
    --cc=pinard@iro.umontreal.ca \
    /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).