Function: org-man-table--org-table

org-man-table--org-table is a byte-compiled function defined in ox-man.el.gz.

Signature

(org-man-table--org-table TABLE CONTENTS INFO)

Documentation

Return appropriate Man code for an Org table.

TABLE is the table type element to transcode. CONTENTS is its contents, as a string. INFO is a plist used as a communication channel.

This function assumes TABLE has org as its :type attribute.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-man.el.gz
(defun org-man-table--org-table (table contents info)
  "Return appropriate Man code for an Org table.

TABLE is the table type element to transcode.  CONTENTS is its
contents, as a string.  INFO is a plist used as a communication
channel.

This function assumes TABLE has `org' as its `:type' attribute."
  (let* ((attr (org-export-read-attribute :attr_man table))
         (caption (and (not (plist-get attr :disable-caption))
		       (org-man--caption/label-string table info)))
         (divider (if (plist-get attr :divider) "|" " "))

         ;; Determine alignment string.
         (alignment (org-man-table--align-string divider table info))
         ;; Extract others display options.

         (lines (org-split-string contents "\n"))

         (attr-list
	  (delq nil
		(list
		 (and (plist-get attr :expand) "expand")
		 (let ((placement (plist-get attr :placement)))
		   (cond ((string= placement 'center) "center")
			 ((string= placement 'left) nil)
			 ((plist-get info :man-tables-centered) "center")
			 (t "")))
		 (or (plist-get attr :boxtype) "box"))))

         (title-line  (plist-get attr :title-line))
         (long-cells (plist-get attr :long-cells))

         (table-format (concat
                        (format "%s" (or (car attr-list) "" ))
                        (or
                         (let ((output-list '()))
                           (when (cdr attr-list)
                             (dolist (attr-item (cdr attr-list))
			       (setq output-list (concat output-list  (format ",%s" attr-item)))))
                           output-list)
                         "")))

	 (first-line (when lines (org-split-string (car lines) "\t"))))
    ;; Prepare the final format string for the table.


    (cond
     ;; Others.
     (lines (concat ".TS\n " table-format ";\n"

                    (format "%s.\n"
                            (let ((final-line ""))
                              (when title-line
                                (dotimes (_ (length first-line))
                                  (setq final-line (concat final-line "cb" divider))))

                              (setq final-line (concat final-line "\n"))

                              (if alignment
                                  (setq final-line (concat final-line alignment))
                                (dotimes (_ (length first-line))
                                  (setq final-line (concat final-line "c" divider))))
                              final-line ))

                    (format "%s.TE\n"
                            (let ((final-line "")
                                  (long-line "")
                                  (lines (org-split-string contents "\n")))

                              (dolist (line-item lines)
                                (setq long-line "")

                                (if long-cells
                                    (progn
                                      (if (string= line-item "_")
                                          (setq long-line (format "%s\n" line-item))
                                        ;; else string =
                                        (let ((cell-item-list (org-split-string line-item "\t")))
                                          (dolist (cell-item cell-item-list)

                                            (cond  ((eq cell-item (car (last cell-item-list)))
                                                    (setq long-line (concat long-line
                                                                            (format "T{\n%s\nT}\t\n"  cell-item ))))
                                                   (t
                                                    (setq long-line (concat long-line
                                                                            (format "T{\n%s\nT}\t"  cell-item ))))))
					  long-line))
				      ;; else long cells
				      (setq final-line (concat final-line long-line )))

                                  (setq final-line (concat final-line line-item "\n"))))
                              final-line))

                    (and caption (format ".TB \"%s\"" caption)))))))