mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 19:37:52 +00:00
Introduced org-lparse-org-table-to-list-table
* contrib/lisp/org-lparse.el (org-lparse-org-table-to-list-table): New. Factored out from `org-lparse-do-format-org-table'. (org-lparse-do-format-org-table): Use `org-lparse-org-table-to-list-table'.
This commit is contained in:
parent
a0769aaebb
commit
098ed2d03f
|
@ -1321,6 +1321,30 @@ version."
|
||||||
;; Following variables are defined in org-table.el
|
;; Following variables are defined in org-table.el
|
||||||
(defvar org-table-number-fraction)
|
(defvar org-table-number-fraction)
|
||||||
(defvar org-table-number-regexp)
|
(defvar org-table-number-regexp)
|
||||||
|
(defun org-lparse-org-table-to-list-table (lines &optional splice)
|
||||||
|
"Convert org-table to list-table.
|
||||||
|
LINES is a list of the form (ROW1 ROW2 ROW3 ...) where each
|
||||||
|
element is a `string' representing a single row of org-table.
|
||||||
|
Thus each ROW has vertical separators \"|\" separating the table
|
||||||
|
fields. A ROW could also be a row-group separator of the form
|
||||||
|
\"|---...|\". Return a list of the form (ROW1 ROW2 ROW3
|
||||||
|
...). ROW could either be symbol `:hrule' or a list of the
|
||||||
|
form (FIELD1 FIELD2 FIELD3 ...) as appropriate."
|
||||||
|
(let (line lines-1)
|
||||||
|
(cond
|
||||||
|
(splice
|
||||||
|
(while (setq line (pop lines))
|
||||||
|
(unless (string-match "^[ \t]*|-" line)
|
||||||
|
(push (org-split-string line "[ \t]*|[ \t]*") lines-1))))
|
||||||
|
(t
|
||||||
|
(while (setq line (pop lines))
|
||||||
|
(cond
|
||||||
|
((string-match "^[ \t]*|-" line)
|
||||||
|
(when lines
|
||||||
|
(push :hrule lines-1)))
|
||||||
|
(t
|
||||||
|
(push (org-split-string line "[ \t]*|[ \t]*") lines-1))))))
|
||||||
|
(nreverse lines-1)))
|
||||||
|
|
||||||
(defun org-lparse-do-format-org-table (lines &optional splice)
|
(defun org-lparse-do-format-org-table (lines &optional splice)
|
||||||
"Format a org-type table into backend-specific code.
|
"Format a org-type table into backend-specific code.
|
||||||
|
@ -1338,7 +1362,6 @@ for formatting. This is required for the DocBook exporter."
|
||||||
;; Check if the table has a marking column. If yes remove the
|
;; Check if the table has a marking column. If yes remove the
|
||||||
;; column and the special lines
|
;; column and the special lines
|
||||||
(setq lines (org-table-clean-before-export lines)))
|
(setq lines (org-table-clean-before-export lines)))
|
||||||
|
|
||||||
(let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
|
(let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
|
||||||
(caption (and caption (org-xml-encode-org-text caption)))
|
(caption (and caption (org-xml-encode-org-text caption)))
|
||||||
(label (org-find-text-property-in-string 'org-label (car lines)))
|
(label (org-find-text-property-in-string 'org-label (car lines)))
|
||||||
|
@ -1359,14 +1382,12 @@ for formatting. This is required for the DocBook exporter."
|
||||||
org-lparse-table-begin-marker
|
org-lparse-table-begin-marker
|
||||||
(org-lparse-table-style 'org-table)
|
(org-lparse-table-style 'org-table)
|
||||||
org-lparse-table-is-styled)
|
org-lparse-table-is-styled)
|
||||||
|
(setq lines (org-lparse-org-table-to-list-table lines splice))
|
||||||
(cond
|
(cond
|
||||||
(splice
|
(splice
|
||||||
(setq org-lparse-table-is-styled nil)
|
(setq org-lparse-table-is-styled nil)
|
||||||
(while (setq line (pop lines))
|
(while (setq line (pop lines))
|
||||||
(unless (string-match "^[ \t]*|-" line)
|
(insert (org-lparse-format-table-row line) "\n")))
|
||||||
(insert
|
|
||||||
(org-lparse-format-table-row
|
|
||||||
(org-split-string line "[ \t]*|[ \t]*")) "\n"))))
|
|
||||||
(t
|
(t
|
||||||
(setq org-lparse-table-is-styled t)
|
(setq org-lparse-table-is-styled t)
|
||||||
(org-lparse-begin 'TABLE caption label attributes)
|
(org-lparse-begin 'TABLE caption label attributes)
|
||||||
|
@ -1374,12 +1395,10 @@ for formatting. This is required for the DocBook exporter."
|
||||||
(org-lparse-begin-table-rowgroup head)
|
(org-lparse-begin-table-rowgroup head)
|
||||||
(while (setq line (pop lines))
|
(while (setq line (pop lines))
|
||||||
(cond
|
(cond
|
||||||
((string-match "^[ \t]*|-" line)
|
((equal line :hrule)
|
||||||
(when lines (org-lparse-begin-table-rowgroup)))
|
(org-lparse-begin-table-rowgroup))
|
||||||
(t
|
(t
|
||||||
(insert
|
(insert (org-lparse-format-table-row line) "\n"))))
|
||||||
(org-lparse-format-table-row
|
|
||||||
(org-split-string line "[ \t]*|[ \t]*")) "\n"))))
|
|
||||||
(org-lparse-end 'TABLE-ROWGROUP)
|
(org-lparse-end 'TABLE-ROWGROUP)
|
||||||
(org-lparse-end-table)))))
|
(org-lparse-end-table)))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue