forked from mirrors/org-mode
ox: Implement `org-export-table-row-in-header-p'
* lisp/ox.el (org-export-table-row-in-header-p): New function. (org-export-table-row-starts-header-p, org-export-table-row-ends-header-p): Use new function. * testing/lisp/test-ox.el (test-org-export/table-row-in-header-p): New test.
This commit is contained in:
parent
81906c52ae
commit
d47f66d6d0
27
lisp/ox.el
27
lisp/ox.el
|
@ -4434,9 +4434,10 @@ code."
|
||||||
;; `org-export-table-cell-ends-colgroup-p',
|
;; `org-export-table-cell-ends-colgroup-p',
|
||||||
;; `org-export-table-row-starts-rowgroup-p',
|
;; `org-export-table-row-starts-rowgroup-p',
|
||||||
;; `org-export-table-row-ends-rowgroup-p',
|
;; `org-export-table-row-ends-rowgroup-p',
|
||||||
;; `org-export-table-row-starts-header-p' and
|
;; `org-export-table-row-starts-header-p',
|
||||||
;; `org-export-table-row-ends-header-p' indicate position of current
|
;; `org-export-table-row-ends-header-p' and
|
||||||
;; row or cell within the table.
|
;; `org-export-table-row-in-header-p' indicate position of current row
|
||||||
|
;; or cell within the table.
|
||||||
|
|
||||||
(defun org-export-table-has-special-column-p (table)
|
(defun org-export-table-has-special-column-p (table)
|
||||||
"Non-nil when TABLE has a special column.
|
"Non-nil when TABLE has a special column.
|
||||||
|
@ -4790,21 +4791,25 @@ INFO is a plist used as a communication channel."
|
||||||
(car (org-element-contents table-row)) info)))
|
(car (org-element-contents table-row)) info)))
|
||||||
(or (memq 'bottom borders) (memq 'below borders)))))
|
(or (memq 'bottom borders) (memq 'below borders)))))
|
||||||
|
|
||||||
|
(defun org-export-table-row-in-header-p (table-row info)
|
||||||
|
"Non-nil when TABLE-ROW is located within table's header.
|
||||||
|
INFO is a plist used as a communication channel. Always return
|
||||||
|
nil for special rows and rows separators."
|
||||||
|
(and (org-export-table-has-header-p
|
||||||
|
(org-export-get-parent-table table-row) info)
|
||||||
|
(eql (org-export-table-row-group table-row info) 1)))
|
||||||
|
|
||||||
(defun org-export-table-row-starts-header-p (table-row info)
|
(defun org-export-table-row-starts-header-p (table-row info)
|
||||||
"Non-nil when TABLE-ROW is the first table header's row.
|
"Non-nil when TABLE-ROW is the first table header's row.
|
||||||
INFO is a plist used as a communication channel."
|
INFO is a plist used as a communication channel."
|
||||||
(and (org-export-table-has-header-p
|
(and (org-export-table-row-in-header-p table-row info)
|
||||||
(org-export-get-parent-table table-row) info)
|
(org-export-table-row-starts-rowgroup-p table-row info)))
|
||||||
(org-export-table-row-starts-rowgroup-p table-row info)
|
|
||||||
(= (org-export-table-row-group table-row info) 1)))
|
|
||||||
|
|
||||||
(defun org-export-table-row-ends-header-p (table-row info)
|
(defun org-export-table-row-ends-header-p (table-row info)
|
||||||
"Non-nil when TABLE-ROW is the last table header's row.
|
"Non-nil when TABLE-ROW is the last table header's row.
|
||||||
INFO is a plist used as a communication channel."
|
INFO is a plist used as a communication channel."
|
||||||
(and (org-export-table-has-header-p
|
(and (org-export-table-row-in-header-p table-row info)
|
||||||
(org-export-get-parent-table table-row) info)
|
(org-export-table-row-ends-rowgroup-p table-row info)))
|
||||||
(org-export-table-row-ends-rowgroup-p table-row info)
|
|
||||||
(= (org-export-table-row-group table-row info) 1)))
|
|
||||||
|
|
||||||
(defun org-export-table-row-number (table-row info)
|
(defun org-export-table-row-number (table-row info)
|
||||||
"Return TABLE-ROW number.
|
"Return TABLE-ROW number.
|
||||||
|
|
|
@ -2912,6 +2912,25 @@ Another text. (ref:text)
|
||||||
(if (org-export-table-row-ends-rowgroup-p row info) 'yes 'no))
|
(if (org-export-table-row-ends-rowgroup-p row info) 'yes 'no))
|
||||||
info)))))
|
info)))))
|
||||||
|
|
||||||
|
(ert-deftest test-org-export/table-row-in-header-p ()
|
||||||
|
"Test `org-export-table-row-in-header-p' specifications."
|
||||||
|
;; Standard test. Separators are always nil.
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
'(yes no no)
|
||||||
|
(org-test-with-parsed-data "| a |\n|---|\n| b |"
|
||||||
|
(org-element-map tree 'table-row
|
||||||
|
(lambda (row)
|
||||||
|
(if (org-export-table-row-in-header-p row info) 'yes 'no)) info))))
|
||||||
|
;; Nil when there is no header.
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
'(no no)
|
||||||
|
(org-test-with-parsed-data "| a |\n| b |"
|
||||||
|
(org-element-map tree 'table-row
|
||||||
|
(lambda (row)
|
||||||
|
(if (org-export-table-row-in-header-p row info) 'yes 'no)) info)))))
|
||||||
|
|
||||||
(ert-deftest test-org-export/table-row-starts-header-p ()
|
(ert-deftest test-org-export/table-row-starts-header-p ()
|
||||||
"Test `org-export-table-row-starts-header-p' specifications."
|
"Test `org-export-table-row-starts-header-p' specifications."
|
||||||
;; 1. Only the row starting the first row group starts the table
|
;; 1. Only the row starting the first row group starts the table
|
||||||
|
|
Loading…
Reference in New Issue