[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Org mode and "shunt" exporters?

From: Eric Schulte
Subject: Re: [O] Org mode and "shunt" exporters?
Date: Fri, 13 Dec 2013 12:29:18 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

This should work in a recent Emacs.

    (require 'json)
    (defun org-as-json-to-file (&optional path)
      "Export the current Org-mode buffer as JSON to the supplied PATH."
      (interactive "Fwrite to file: ")
      (let ((tree (org-element-parse-buffer)))
        (org-element-map tree
            (append org-element-all-objects org-element-all-elements)
          (lambda (el) (org-element-put-property el :parent nil)))
        (with-temp-file path
          (insert (json-encode tree)))))

Eric Schulte
PGP: 0x614CA05D

reply via email to

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