Function: org-odt--translate-list-tables
org-odt--translate-list-tables is a byte-compiled function defined in
ox-odt.el.gz.
Signature
(org-odt--translate-list-tables TREE BACKEND INFO)
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-odt.el.gz
;;;; List tables
;; Lists that are marked with attribute `:list-table' are called as
;; list tables. They will be rendered as a table within the exported
;; document.
;; Consider an example. The following list table
;;
;; #+attr_odt :list-table t
;; - Row 1
;; - 1.1
;; - 1.2
;; - 1.3
;; - Row 2
;; - 2.1
;; - 2.2
;; - 2.3
;;
;; will be exported as though it were an Org table like the one show
;; below.
;;
;; | Row 1 | 1.1 | 1.2 | 1.3 |
;; | Row 2 | 2.1 | 2.2 | 2.3 |
;;
;; Note that org-tables are NOT multi-line and each line is mapped to
;; a unique row in the exported document. So if an exported table
;; needs to contain a single paragraph (with copious text) it needs to
;; be typed up in a single line. Editing such long lines using the
;; table editor will be a cumbersome task. Furthermore inclusion of
;; multi-paragraph text in a table cell is well-nigh impossible.
;;
;; A LIST-TABLE circumvents above problems.
;;
;; Note that in the example above the list items could be paragraphs
;; themselves and the list can be arbitrarily deep.
;;
;; Inspired by following thread:
;; https://lists.gnu.org/r/emacs-orgmode/2011-03/msg01101.html
;; Translate lists to tables
(defun org-odt--translate-list-tables (tree _backend info)
(org-element-map tree 'plain-list
(lambda (l1-list)
(when (org-export-read-attribute :attr_odt l1-list :list-table)
;; Replace list with table.
(org-element-set
l1-list
;; Build replacement table.
(apply 'org-element-adopt
(list 'table '(:type org :attr_odt (":style \"GriddedTable\"")))
(org-element-map l1-list 'item
(lambda (l1-item)
(let* ((l1-item-contents (org-element-contents l1-item))
l1-item-leading-text l2-list)
;; Remove Level-2 list from the Level-item. It
;; will be subsequently attached as table-cells.
(let ((cur l1-item-contents) prev)
(while (and cur (not (org-element-type-p
(car cur) 'plain-list)))
(setq prev cur)
(setq cur (cdr cur)))
(when prev
(setcdr prev nil)
(setq l2-list (car cur)))
(setq l1-item-leading-text l1-item-contents))
;; Level-1 items start a table row.
(apply 'org-element-adopt
(list 'table-row (list :type 'standard))
;; Leading text of level-1 item define
;; the first table-cell.
(apply 'org-element-adopt
(list 'table-cell nil)
l1-item-leading-text)
;; Level-2 items define subsequent
;; table-cells of the row.
(org-element-map l2-list 'item
(lambda (l2-item)
(apply 'org-element-adopt
(list 'table-cell nil)
(org-element-contents l2-item)))
info nil 'item))))
info nil 'item))))
nil)
info)
tree)