emacs-orgmode
[Top][All Lists]
Advanced

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

[BUG] org-element-paragraph-separate is not accurate when detecting tabl


From: Ihor Radchenko
Subject: [BUG] org-element-paragraph-separate is not accurate when detecting table.el tables (was: Some Issues I Encountered While Developing Metanote)
Date: Tue, 12 Sep 2023 08:23:12 +0000

note meta <metanote.team@gmail.com> writes:

> 2. About Paragraph
>
>    #+begin_example
> +--+
> +--+
> +this is a paragraph+
> +this is a paragraph+
>    #+end_example
>
> There should be only one paragraph above, but it's parsed as two:
>
> (org-data nil (section (:begin 1 :end 55 :contents-begin 1 :contents-end 55
> :post-blank 0 :post-affiliated 1 :parent #0) (paragraph (:begin 1 :end 6
> :contents-begin 1 :contents-end 6 :post-blank 0 :post-affiliated 1 :parent
> #1)) (paragraph (:begin 6 :end 55 :contents-begin 6 :contents-end 55
> :post-blank 0 :post-affiliated 6 :parent #1))))

Confirmed.
`org-element-paragraph-separate', which is used to determine paragraph
boundaries incorrectly detects the above +--+ as table.el table
boundary. It matches

^[ \t]*\+\(?:-+\+)+[ \t]*$

while the actual criteria to match table.el tables is much more complex:

   ;; There is no strict definition of a table.el
   ;; table.  Try to prevent false positive while being
   ;; quick.
   (let ((rule-regexp
          (rx (zero-or-more (any " \t"))
              "+"
              (one-or-more (one-or-more "-") "+")
              (zero-or-more (any " \t"))
              eol))
         (non-table.el-line
          (rx bol
              (zero-or-more (any " \t"))
              (or eol (not (any "+| \t")))))
         (next (line-beginning-position 2)))
     ;; Start with a full rule.
     (and
      (looking-at-p rule-regexp)
      (< next limit) ;no room for a table.el table
      (save-excursion
        (end-of-line)
        (cond
         ;; Must end with a full rule.
         ((not (re-search-forward non-table.el-line limit 'move))
          (if (bolp) (forward-line -1) (forward-line 0))
          (looking-at-p 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-p rule-regexp))))))

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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