summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-04-09 15:13:59 (GMT)
committer Bastien Guerry <bzg@altern.org>2013-04-09 15:13:59 (GMT)
commit1ebac8923c7fb13427688a93e51ac64720a834ea (patch)
tree33f6740a69f39c4e2b8dd19e5af0be19648a36f1
parent3fef0415fb58bdc93938d6a24db6c48ae282e339 (diff)
parent5f4831556836148c1074929a754cbe6a1cb18b82 (diff)
downloadorg-mode-1ebac8923c7fb13427688a93e51ac64720a834ea.zip
org-mode-1ebac8923c7fb13427688a93e51ac64720a834ea.tar.gz
Merge branch 'master' of orgmode.org:org-mode
-rw-r--r--lisp/org-element.el2
-rw-r--r--lisp/ox.el23
-rw-r--r--testing/lisp/test-ox.el29
3 files changed, 46 insertions, 8 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index e09d2cb..73d0b46 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3393,7 +3393,7 @@ LIMIT bounds the search.
Return value is a cons cell whose CAR is `table-cell' and CDR is
beginning position."
- (when (looking-at "[ \t]*.*?[ \t]+|") (cons 'table-cell (point))))
+ (when (looking-at "[ \t]*.*?[ \t]*|") (cons 'table-cell (point))))
;;;; Target
diff --git a/lisp/ox.el b/lisp/ox.el
index 22da0b3..7f33755 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -4640,6 +4640,21 @@ INFO is a plist used as a communication channel."
(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)
+ "Return TABLE-ROW number.
+INFO is a plist used as a communication channel. Return value is
+zero-based and ignores separators. The function returns nil for
+special colums and separators."
+ (when (and (eq (org-element-property :type table-row) 'standard)
+ (not (org-export-table-row-is-special-p table-row info)))
+ (let ((number 0))
+ (org-element-map (org-export-get-parent-table table-row) 'table-row
+ (lambda (row)
+ (cond ((eq row table-row) number)
+ ((eq (org-element-property :type row) 'standard)
+ (incf number) nil)))
+ info 'first-match))))
+
(defun org-export-table-dimensions (table info)
"Return TABLE dimensions.
@@ -4677,13 +4692,7 @@ function returns nil for other cells."
(eq (car (org-element-contents table-row)) table-cell)))
(cons
;; Row number.
- (let ((row-count 0))
- (org-element-map table 'table-row
- (lambda (row)
- (cond ((eq (org-element-property :type row) 'rule) nil)
- ((eq row table-row) row-count)
- (t (incf row-count) nil)))
- info 'first-match))
+ (org-export-table-row-number (org-export-get-parent table-cell) info)
;; Column number.
(let ((col-count 0))
(org-element-map table-row 'table-cell
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index d023845..6203f8b 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -1911,6 +1911,35 @@ Another text. (ref:text)
(mapcar (lambda (row) (org-export-table-row-group row info))
(org-element-map tree 'table-row 'identity))))))
+(ert-deftest test-org-export/table-row-number ()
+ "Test `org-export-table-row-number' specifications."
+ ;; Standard test. Number is 0-indexed.
+ (should
+ (equal '(0 1)
+ (org-test-with-parsed-data "| a | b | c |\n| d | e | f |"
+ (org-element-map tree 'table-row
+ (lambda (row) (org-export-table-row-number row info)) info))))
+ ;; Number ignores separators.
+ (should
+ (equal '(0 1)
+ (org-test-with-parsed-data "
+| a | b | c |
+|---+---+---|
+| d | e | f |"
+ (org-element-map tree 'table-row
+ (lambda (row) (org-export-table-row-number row info)) info))))
+ ;; Number ignores special rows.
+ (should
+ (equal '(0 1)
+ (org-test-with-parsed-data "
+| / | < | > |
+| | b | c |
+|---+-----+-----|
+| | <c> | <c> |
+| | e | f |"
+ (org-element-map tree 'table-row
+ (lambda (row) (org-export-table-row-number row info)) info)))))
+
(ert-deftest test-org-export/table-cell-width ()
"Test `org-export-table-cell-width' specifications."
;; 1. Width is primarily determined by width cookies. If no cookie