org-element
is a new module for org-mode
, I think it is good for parse org file, and don't want to parse it by old way with match-string. but after play with it for some hours, I have to admit I don't have enough experience with org-mode, so could masters give me some clues, thanks very much!
My requirement is simple, I want to get all headlines and content.
* headline
:PROPERTIES
** subheadline
content1
** subheadline
content2
based on @YoungFrog's prompt:
get all headlines:
(let ((parsetree (org-element-parse-buffer 'headline)))
(org-element-map parsetree 'headline
(lambda (hl) (org-element-property :title hl))))
get all contents:
(let ((parsetree (org-element-parse-buffer 'paragraph)))
(org-element-map parsetree 'paragraph
(lambda (hl) (org-element-interpret-data hl))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With