org-element: Be more strict when looking for table.el tables

* lisp/org-element.el (org-element--current-element): Increase number
  of checks to avoid more false positive.

In particular "+-+" is not recognized anymore as a table.el table.
This commit is contained in:
Nicolas Goaziou 2018-11-26 19:50:08 +01:00
parent f33fa994b9
commit d228909d15
1 changed files with 12 additions and 1 deletions

View File

@ -3912,7 +3912,18 @@ element it has to parse."
((looking-at "%%(")
(org-element-diary-sexp-parser limit affiliated))
;; Table.
((looking-at "[ \t]*\\(|\\|\\+\\(-+\\+\\)+[ \t]*$\\)")
((or (looking-at "[ \t]*|")
;; There is no strict definition of a table.el
;; table. Try to prevent false positive while being
;; quick.
(let ((rule-regexp "[ \t]*\\+\\(-+\\+\\)+[ \t]*$")
(next (line-beginning-position 2)))
(and (looking-at rule-regexp)
(save-excursion
(forward-line)
(re-search-forward "^[ \t]*\\($\\|[^|]\\)" limit t)
(and (> (line-beginning-position) next)
(org-match-line rule-regexp))))))
(org-element-table-parser limit affiliated))
;; List.
((looking-at (org-item-re))