EDIT: Updated code because I had misunderstood what the headings should be, and to switch to s-join
because apparently @lap's version of Emacs doesn't have string-join
from subr-x
(s-join
and string-join
take their arguments in opposite order!).
EDIT: Last fix: OP is using an older version of Org Mode and the parsed table includes the symbol hline
to indicate the position of horizontal lines, so we remq
them away.
You can name the table and then use a :var
declaration in a source
block and Org Mode will parse the table for you!
#+NAME: laps-table
|H1 |H2 |H3 |
|------+------+------|
|text11|text12|text13|
|text21|text22|text23|
|... |... |... |
|textN1|textN2|textN3|
|--------------------|
#+BEGIN_SRC emacs-lisp :var tbl=laps-table
(require 's)
(let ((headings (car tbl)))
(s-join
"\n"
(mapcar
(lambda (row)
(concat
(format "* %s\n- " (car row))
(s-join
"\n- "
(cl-map 'list
(lambda (hd x) (concat hd ": " x))
headings row))))
(remq 'hline (cdr tbl)))))
#+END_SRC
Running the source block results in the following:
#+RESULTS:
#+begin_example
* text11
- H1: text11
- H2: text12
- H3: text13
* text21
- H1: text21
- H2: text22
- H3: text23
* ...
- H1: ...
- H2: ...
- H3: ...
* textN1
- H1: textN1
- H2: textN2
- H3: textN3
#+end_example