org-element: Fix table parsing with missing final bar

* lisp/org-element.el (org-element-table-cell-parser,
  org-element-table-cell-successor): Recognize cell even when last
  vertical bar is missing.

* testing/lisp/test-org-element.el (test-org-element/table-cell-parser):
  Add test.

Thanks to Thorsten Jolitz for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/84713
This commit is contained in:
Nicolas Goaziou 2014-04-08 18:46:41 +02:00
parent 0820d002cb
commit 728661309e
2 changed files with 7 additions and 2 deletions

View file

@ -3467,7 +3467,7 @@ CONTENTS is the contents of the object."
Return a list whose CAR is `table-cell' and CDR is a plist
containing `:begin', `:end', `:contents-begin', `:contents-end'
and `:post-blank' keywords."
(looking-at "[ \t]*\\(.*?\\)[ \t]*|")
(looking-at "[ \t]*\\(.*?\\)[ \t]*\\(?:|\\|$\\)")
(let* ((begin (match-beginning 0))
(end (match-end 0))
(contents-begin (match-beginning 1))
@ -3489,7 +3489,7 @@ CONTENTS is the contents of the cell, or nil."
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

View file

@ -1922,8 +1922,13 @@ Outside list"
(ert-deftest test-org-element/table-cell-parser ()
"Test `table-cell' parser."
;; Regular table cell.
(should
(org-test-with-temp-text "| a |"
(org-element-map (org-element-parse-buffer) 'table-cell 'identity)))
;; Last vertical bar may be omitted.
(should
(org-test-with-temp-text "| a "
(org-element-map (org-element-parse-buffer) 'table-cell 'identity))))