summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-11-26 19:50:08 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-11-26 19:50:08 +0100
commitd228909d15b08878a967b3505171b218cfbd15f2 (patch)
tree33cfcde7569bc95fb180d9877d70095d279a8000
parentf33fa994b987717db3276c661a45be38c204af4c (diff)
downloadorg-mode-d228909d15b08878a967b3505171b218cfbd15f2.tar.gz
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.
-rw-r--r--lisp/org-element.el13
1 files changed, 12 insertions, 1 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index cdb574e..78b1851 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -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))