emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: note meta <metanote.team@gmail.com>
Cc: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <87jzsviyvj.fsf@localhost> (raw)
In-Reply-To: <CAMCUW+vYVv6OsvoJ+_mC8Gajygp0f+fCPOOThhhHa58aeo3eNQ@mail.gmail.com>

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>


  parent reply	other threads:[~2023-09-12  8:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 12:04 Some Issues I Encountered While Developing Metanote note meta
2023-09-12  8:16 ` Ihor Radchenko
     [not found]   ` <CAMCUW+utUvpwkjzP4wcBLfwsuoV-8VN=v05xuZKj57jSq_k8RA@mail.gmail.com>
2023-09-12 10:10     ` Ihor Radchenko
2023-09-12  8:23 ` Ihor Radchenko [this message]
2023-09-12  8:43 ` Ihor Radchenko
2023-09-12  8:54 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87jzsviyvj.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=metanote.team@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).