diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index 4d4adc029..c2ef8b8ac 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -3262,8 +3262,11 @@ All special rows will be ignored during export." (mapc (lambda (cell) (let ((value (org-element-contents cell))) + ;; Since VALUE is a secondary string, the following + ;; checks avoid expanding it with `org-export-data'. (cond ((not value)) ((and (not (cdr value)) + (stringp (car value)) (string-match "\\`<[lrc]?\\([0-9]+\\)?>\\'" (car value))) (setq special-row-p 'cookie)) @@ -3313,13 +3316,15 @@ same column as TABLE-CELL, or nil." ((org-export-table-row-is-special-p row info) (let ((value (org-element-contents (elt (org-element-contents row) column)))) - (cond - ((not value)) - ((and (not (cdr value)) - (string-match "\\`<[lrc]?\\([0-9]+\\)?>\\'" (car value)) - (match-string 1 (car value))) + ;; The following checks avoid expanding unnecessarily the + ;; cell with `org-export-data' + (when (and value + (not (cdr value)) + (stringp (car value)) + (string-match "\\`<[lrc]?\\([0-9]+\\)?>\\'" (car value)) + (match-string 1 (car value))) (setq cookie-width - (string-to-number (match-string 1 (car value)))))))) + (string-to-number (match-string 1 (car value))))))) ;; Ignore table rules. ((eq (org-element-property :type row) 'rule)))) (org-element-contents table)) @@ -3352,13 +3357,15 @@ Possible values are `left', `right' and `center'." ((org-export-table-row-is-special-p row info) (let ((value (org-element-contents (elt (org-element-contents row) column)))) - (cond - ((not value)) - ((and (not (cdr value)) - (string-match "\\`<\\([lrc]\\)?\\([0-9]+\\)?>\\'" - (car value)) - (match-string 1 (car value))) - (setq cookie-align (match-string 1 (car value))))))) + ;; Since VALUE is a secondary string, the following checks + ;; avoid useless expansion through `org-export-data'. + (when (and value + (not (cdr value)) + (stringp (car value)) + (string-match "\\`<\\([lrc]\\)?\\([0-9]+\\)?>\\'" + (car value)) + (match-string 1 (car value))) + (setq cookie-align (match-string 1 (car value)))))) ;; Ignore table rules. ((eq (org-element-property :type row) 'rule)) ;; In a standard row, check if cell's contents are expressing @@ -3366,9 +3373,10 @@ Possible values are `left', `right' and `center'." ;; Though, don't bother if an alignment cookie has already ;; defined cell's alignment. ((not cookie-align) - (let ((value (org-element-interpret-data + (let ((value (org-export-data (org-element-contents - (elt (org-element-contents row) column))))) + (elt (org-element-contents row) column)) + info))) (incf total-cells) (when (string-match org-table-number-regexp value) (incf number-cells)))))) diff --git a/testing/lisp/test-org-export.el b/testing/lisp/test-org-export.el index 244d0df2d..82002e2fb 100644 --- a/testing/lisp/test-org-export.el +++ b/testing/lisp/test-org-export.el @@ -724,8 +724,8 @@ Another text. (ref:text) (org-element-map (org-element-parse-buffer) 'table 'identity nil 'first-match))))) -(ert-deftest test-org-export/special-row () - "Test if special rows in a table are properly recognized." +(ert-deftest test-org-export/table-row-is-special-p () + "Test `org-export-table-row-is-special-p' specifications." ;; 1. A row is special if it has a special marking character in the ;; special column. (org-test-with-parsed-data "| ! | 1 |" @@ -746,7 +746,7 @@ Another text. (ref:text) (org-export-table-row-is-special-p (org-element-map tree 'table-row 'identity nil 'first-match) info))) ;; 4. Everything else isn't considered as special. - (org-test-with-parsed-data "| a | | c |" + (org-test-with-parsed-data "| \alpha | | c |" (should-not (org-export-table-row-is-special-p (org-element-map tree 'table-row 'identity nil 'first-match) info))) @@ -894,7 +894,7 @@ Another text. (ref:text) (org-test-with-temp-text " | text | | some text | -| 12345 |" +| \alpha |" (let* ((tree (org-element-parse-buffer)) (info `(:parse-tree ,tree))) (should