emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals-release/org 118da7d 3/4: element: Fix table.el tables p


From: Stefan Monnier
Subject: [elpa] externals-release/org 118da7d 3/4: element: Fix table.el tables parsing
Date: Tue, 22 Dec 2020 16:13:09 -0500 (EST)

branch: externals-release/org
commit 118da7d280a5fe474fc2b5a4e2d48ce5f910a29b
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>

    element: Fix table.el tables parsing
    
    * lisp/org-element.el (org-element--current-element): Fix regexp
    matching a non-data-line.  Use rx.
    
    Reported-by: Nick Dokos <ndokos@gmail.com>
    <http://lists.gnu.org/r/emacs-orgmode/2020-12/msg00561.html>
---
 lisp/org-element.el | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 2ad557d..8e09e32 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3950,13 +3950,24 @@ element it has to parse."
             ((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]*$")
+                 ;; quick.  Hence, we consider a table.el table is at
+                 ;; least one rule, any number of data lines
+                 ;; (starting with a vertical bar), and another rule.
+                 (let ((rule-regexp
+                        (rx (zero-or-more (any " \t"))
+                            "+"
+                            (one-or-more (one-or-more "-") "+")
+                            (zero-or-more (any " \t"))
+                            eol))
+                       (non-table.el-data-line
+                        (rx bol
+                            (zero-or-more (any " \t"))
+                            (or eol (not (any "| \t")))))
                        (next (line-beginning-position 2)))
                    (and (looking-at rule-regexp)
                         (save-excursion
-                          (forward-line)
-                          (re-search-forward "^[ \t]*\\($\\|[^|]\\)" limit t)
+                          (end-of-line)
+                          (re-search-forward non-table.el-data-line limit t)
                           (and (> (line-beginning-position) next)
                                (org-match-line rule-regexp))))))
              (org-element-table-parser limit affiliated))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]