element: Improve table.el tables dectection
* lisp/org-element.el (org-element--current-element): Limit possible false positives.
This commit is contained in:
parent
118da7d280
commit
97f1d8e340
|
@ -3950,26 +3950,37 @@ element it has to parse."
|
||||||
((or (looking-at "[ \t]*|")
|
((or (looking-at "[ \t]*|")
|
||||||
;; There is no strict definition of a table.el
|
;; There is no strict definition of a table.el
|
||||||
;; table. Try to prevent false positive while being
|
;; table. Try to prevent false positive while being
|
||||||
;; quick. Hence, we consider a table.el table is at
|
;; quick.
|
||||||
;; least one rule, any number of data lines
|
|
||||||
;; (starting with a vertical bar), and another rule.
|
|
||||||
(let ((rule-regexp
|
(let ((rule-regexp
|
||||||
(rx (zero-or-more (any " \t"))
|
(rx (zero-or-more (any " \t"))
|
||||||
"+"
|
"+"
|
||||||
(one-or-more (one-or-more "-") "+")
|
(one-or-more (one-or-more "-") "+")
|
||||||
(zero-or-more (any " \t"))
|
(zero-or-more (any " \t"))
|
||||||
eol))
|
eol))
|
||||||
(non-table.el-data-line
|
(non-table.el-line
|
||||||
(rx bol
|
(rx bol
|
||||||
(zero-or-more (any " \t"))
|
(zero-or-more (any " \t"))
|
||||||
(or eol (not (any "| \t")))))
|
(or eol (not (any "+| \t")))))
|
||||||
(next (line-beginning-position 2)))
|
(next (line-beginning-position 2)))
|
||||||
(and (looking-at rule-regexp)
|
;; Start with a full rule.
|
||||||
(save-excursion
|
(and
|
||||||
(end-of-line)
|
(looking-at rule-regexp)
|
||||||
(re-search-forward non-table.el-data-line limit t)
|
(< next limit) ;no room for a table.el table
|
||||||
(and (> (line-beginning-position) next)
|
(save-excursion
|
||||||
(org-match-line rule-regexp))))))
|
(end-of-line)
|
||||||
|
(cond
|
||||||
|
;; Must end with a full rule.
|
||||||
|
((not (re-search-forward non-table.el-line limit 'move))
|
||||||
|
(beginning-of-line)
|
||||||
|
(looking-at rule-regexp))
|
||||||
|
;; Ignore pseudo-tables with a single
|
||||||
|
;; rule.
|
||||||
|
((= next (line-beginning-position))
|
||||||
|
nil)
|
||||||
|
;; Must end with a full rule.
|
||||||
|
(t
|
||||||
|
(forward-line -1)
|
||||||
|
(looking-at rule-regexp)))))))
|
||||||
(org-element-table-parser limit affiliated))
|
(org-element-table-parser limit affiliated))
|
||||||
;; List.
|
;; List.
|
||||||
((looking-at (org-item-re))
|
((looking-at (org-item-re))
|
||||||
|
|
Loading…
Reference in New Issue