Brett Viren <b...@bnl.gov> writes: > Has anyone written any new-style exporter which will produce a common > markup/data language format like JSON or YAML? I'm looking for > something that fully preserves the original org document structure and > does no semantic interpretation along the way. > > What I really want is to parse arbitrary org files in Python. I've > looked at the entries at worg's "org-tool" node which do this but they > seem out of date or make assumptions about what org elements exist or > their URLs are not loading (NEO). If any of that's a misrepresentation > please correct me. > > In any case, using org's own exporter to produce JSON or YAML and then > relying on these format's Python modules for parsing seems like the best > way to go to let me author in org and process in Python. > > I'm not very good with elisp (which is why I want to get org data into > Python) but I guess I can have a go at making such a "shunt" exporter. > Before I try, I just wanted to check if someone had this wheel already > spinning. > > Thanks, > -Brett.
You can use `org-element-parse-buffer' to convert an Emacs Buffer to a structured Emacs Lisp object. At that point you can use existing tools for converting lisp to JSON or YAML. I've used cl-json for Common Lisp, I would imagine something similar exists for Emacs Lisp. -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D