I've been trying to get the content of the paragraph element unsuccessfully using org-element-contents
, is there something I am missing here?
I have a org document as follows:
* world
** China
*** Music
About music
*** Dance
About dance
** Japan
*** Technology
About technology
*** Movies
About movies
The elisp code lives in the same document(sorry, :( I haven't spent proper time learning elisp yet!):
#+BEGIN_SRC emacs-lisp :exports results :results none
; https://emacs.stackexchange.com/questions/53359/org-mode-headings-to-org-table
(defun goto-header()
(org-back-to-heading)
(org-end-of-meta-data t)
)
(defun create_table ()
(let
((rows))
(org-map-entries
(lambda ()
(let*
((el (org-element-at-point)))
(let* (
(title (org-element-property :title el))
)
(forward-line)
(setq desc (org-element-contents (org-element-at-point)))
(previous-line)
(push (list title desc) rows))))
"LEVEL=3"
'tree)
(setq rows (nreverse rows))
(setq rows (append (list '(title topic) 'hline) rows))
(goto-header)
(insert (concat (orgtbl-to-orgtbl rows nil) "\n"))
)
)
(defun create_tables ()
(org-map-entries #'create_table "LEVEL=2")
)
(create_tables)
#+END_SRC
It makes the following change to the document:
* world
** China
| title | topic |
|---------+-------|
| Music | nil |
| (Dance) | nil |
*** Music
About music
*** Dance
About dance
** Japan
| title | topic |
|------------+-------|
| Technology | nil |
| (Movies) | nil |
*** Technology
About technology
*** Movies
About movies
So the next two things I want is to the paragraph text to be in the topic
column and and then to remove the headings. But currently I am struggling to get the contents of the paragraph. What am I missing here?
The usecase for this is I am trying to export my elfeed-org config into nice HTML tables.