emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ox: fix comment exported as a blank line
@ 2022-06-01  5:30 Phil Estival
  2022-06-01  5:43 ` [PATCH] test-ox: no superfluous newline in exported comments Phil Estival
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Phil Estival @ 2022-06-01  5:30 UTC (permalink / raw)
  To: emacs-orgmode


* lisp/ox.el (org-export--skip-p): no longer export single-line
comments as blank lines which did break paragraphs in two.

TINYCHANGE
---
  lisp/ox.el | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 9a8e63046..2c50fba0c 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -1756,7 +1756,7 @@ not exported."
          (before (or (org-element-property :post-blank previous) 0))
          (after (or (org-element-property :post-blank datum) 0)))
         (when previous
-     (org-element-put-property previous :post-blank (max before after 1))))
+     (org-element-put-property previous :post-blank (max before after 0))))
       t)
      (clock (not (plist-get options :with-clocks)))
      (drawer
-- 
2.31.GIT




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] test-ox: no superfluous newline in exported comments
  2022-06-01  5:30 [PATCH] ox: fix comment exported as a blank line Phil Estival
@ 2022-06-01  5:43 ` Phil Estival
  2022-06-01 11:48 ` [PATCH] ox: fix comment exported as a blank line Max Nikulin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Phil Estival @ 2022-06-01  5:43 UTC (permalink / raw)
  To: emacs-orgmode


* testing/lisp/test-ox.el (test-org-export/comments) test updated
according to behavior change when exporting a comment:
a single line of comment no longer insert a blank line

TINYCHANGE
---
  testing/lisp/test-ox.el | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index 28f950813..42e2a3d44 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -2049,7 +2049,7 @@ comments removal."
  Para2"
          (org-export-as (org-test-default-backend)))))
    (should
-   (equal "Para1\n\nPara2\n"
+   (equal "Para1\nPara2\n"
        (org-test-with-temp-text
            "Para1
  # Comment
-- 
2.31.GIT




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ox: fix comment exported as a blank line
  2022-06-01  5:30 [PATCH] ox: fix comment exported as a blank line Phil Estival
  2022-06-01  5:43 ` [PATCH] test-ox: no superfluous newline in exported comments Phil Estival
@ 2022-06-01 11:48 ` Max Nikulin
  2022-06-02  5:02   ` Phil Estival
  2022-06-01 13:14 ` Kaushal Modi
  2022-07-04 11:47 ` Ihor Radchenko
  3 siblings, 1 reply; 7+ messages in thread
From: Max Nikulin @ 2022-06-01 11:48 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Phil Estival

On 01/06/2022 12:30, Phil Estival wrote:
> 
> * lisp/ox.el (org-export--skip-p): no longer export single-line
> comments as blank lines which did break paragraphs in two.

Phil, thank you for your attempt to improve handling of paragraph during 
export, there are enough various gotchas. Are the purpose of your patch 
the following?

#+begin_src elisp
   (org-export-string-as "Line 1.\n# comment\nLine 2." 'latex t)
#+end_src

#+RESULTS:
: Line 1.
: Line 2.

If so, unfortunately, you took a wrong direction, consider

#+begin_src elisp
   (org-export-string-as "Paragraph 1.\n# comment\nParagraph 2." 'html t)
#+end_src

#+RESULTS:
: <p>
: Paragraph 1.
: </p>
: <p>
: Paragraph 2.</p>

So there are still 2 separate paragraphs. It is necessary to either 
modify org-element parser or to apply a filter before passing AST to 
exporters. Last time it was discussed in

Ihor Radchenko. Merging paragraphs separated by comment lines during 
export (was: About 'inline special blocks') Thu, 26 May 2022 10:54:34 
+0800. https://list.orgmode.org/875ylt6m1h.fsf@localhost

Notice that accordingly to
https://orgmode.org/worg/dev/org-syntax.html
comment (that is "element") can not be a part of a paragraph. So current 
behavior is intentional. In your next patch fixing a test "Para1" and 
"Para2" are meaningful names assuming paragraphs. If behavior is changed 
"Line1" and "Line2" should be less confusing.

If you are interested in other cases when org paragraph is not the same 
as exported LaTeX one, see the following thread:

Max Nikulin. Comments break up a paragraph when writing 
one-setence-per-line. Sun, 3 Oct 2021 18:34:10 +0700. 
https://list.orgmode.org/sjc4fk$76r$1@ciao.gmane.io


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ox: fix comment exported as a blank line
  2022-06-01  5:30 [PATCH] ox: fix comment exported as a blank line Phil Estival
  2022-06-01  5:43 ` [PATCH] test-ox: no superfluous newline in exported comments Phil Estival
  2022-06-01 11:48 ` [PATCH] ox: fix comment exported as a blank line Max Nikulin
@ 2022-06-01 13:14 ` Kaushal Modi
  2022-07-04 11:47 ` Ihor Radchenko
  3 siblings, 0 replies; 7+ messages in thread
From: Kaushal Modi @ 2022-06-01 13:14 UTC (permalink / raw)
  To: Phil Estival; +Cc: emacs-org list

On Wed, Jun 1, 2022 at 1:32 AM Phil Estival <pe@7d.nz> wrote:
>
>
> * lisp/ox.el (org-export--skip-p): no longer export single-line
> comments as blank lines which did break paragraphs in two.

This is a pretty big breaking change. In your next PATCH email, I see
that you are also modifying the test that ensures that a comment line
gets parsed as a paragraph break.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ox: fix comment exported as a blank line
  2022-06-01 11:48 ` [PATCH] ox: fix comment exported as a blank line Max Nikulin
@ 2022-06-02  5:02   ` Phil Estival
  2022-06-02 16:09     ` Max Nikulin
  0 siblings, 1 reply; 7+ messages in thread
From: Phil Estival @ 2022-06-02  5:02 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode


Le 01/06/2022 à 13:48, Max Nikulin wrote :
> On 01/06/2022 12:30, Phil Estival wrote:
>>
>> * lisp/ox.el (org-export--skip-p): no longer export single-line
>> comments as blank lines which did break paragraphs in two.
> unfortunately, you took a wrong direction
> If you are interested in other cases when org paragraph is not the same
> as exported LaTeX one, see the following thread:
>
> Max Nikulin. Comments break up a paragraph when writing
> one-setence-per-line. Sun, 3 Oct 2021 18:34:10 +0700.
> https://list.orgmode.org/sjc4fk$76r$1@ciao.gmane.io


Max,

Right, thanks for the clarifications.

A hook at pre-export stage to filter out the
line-comments is one correct way to get an output
compliant with different backends. Yet the removal
of comments may provide an AST different from the
one of the emacs buffer.

 >> However there [are] users in this thread who
 >> expect that "# " or "#+latex:" should not be
 >> "element" and should be a part of surrounding
 >> paragraph.

That's an interesting idea.  This would add an
attribute to the previous element.

If we keep speculating on that, the rendering path
would change. It would have to consider this
property too when showing or hiding elements.

And it would require additional function to
reallocate this attribute like a node.

And this would probably break some conceptual
integrity.

The org spec is correct to handle the comments the
way it does. As I see it now, that's the only
possible attempts to reconcile the behaviors of
different backends.

Still, the writing experience is much improved
when comments are allowed inside paragraphs
without disrupting the publication, and this
definitely worth a few modifications.


Phil



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ox: fix comment exported as a blank line
  2022-06-02  5:02   ` Phil Estival
@ 2022-06-02 16:09     ` Max Nikulin
  0 siblings, 0 replies; 7+ messages in thread
From: Max Nikulin @ 2022-06-02 16:09 UTC (permalink / raw)
  To: Phil Estival; +Cc: emacs-orgmode

On 02/06/2022 12:02, Phil Estival wrote:
> Still, the writing experience is much improved
> when comments are allowed inside paragraphs
> without disrupting the publication, and this
> definitely worth a few modifications.

There are at least a couple of workarounds for inline comments, however 
some care is required to not add a spurious blank line (I think, 
ox-latex should strip blank lines from paragraphs).

Maxim Nikulin. Re: Comments break up a paragraph when writing 
one-setence-per-line. Sun, 18 Jul 2021 15:21:39 +0700. 
https://list.orgmode.org/sd0oak$k5h$1@ciao.gmane.io

#+macro: comment

Another test
{{{comment(some text
)}}} with macro comment.

or

Export snippets
@@c: a comment
@@ may be used with any non-existing backend name.


I believe that comments breaking paragraphs is an unnecessary pitfall. 
While comments are not passed to exporters there are should be no great 
problems besides users who rely on current behavior. I am unsure how 
many of them do it intentionally. Attributes and other keywords are more 
tricky case, but rather independent of comments.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ox: fix comment exported as a blank line
  2022-06-01  5:30 [PATCH] ox: fix comment exported as a blank line Phil Estival
                   ` (2 preceding siblings ...)
  2022-06-01 13:14 ` Kaushal Modi
@ 2022-07-04 11:47 ` Ihor Radchenko
  3 siblings, 0 replies; 7+ messages in thread
From: Ihor Radchenko @ 2022-07-04 11:47 UTC (permalink / raw)
  To: Phil Estival; +Cc: emacs-orgmode

Phil Estival <pe@7d.nz> writes:

> * lisp/ox.el (org-export--skip-p): no longer export single-line
> comments as blank lines which did break paragraphs in two.
>
> TINYCHANGE

I think that this change may be useful in general. `org-export--skip-p'
is sometimes too rigid.

However, the proposed feature should probably be added as a
customization that is not enabled by default.

Best,
Ihor


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-04 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-01  5:30 [PATCH] ox: fix comment exported as a blank line Phil Estival
2022-06-01  5:43 ` [PATCH] test-ox: no superfluous newline in exported comments Phil Estival
2022-06-01 11:48 ` [PATCH] ox: fix comment exported as a blank line Max Nikulin
2022-06-02  5:02   ` Phil Estival
2022-06-02 16:09     ` Max Nikulin
2022-06-01 13:14 ` Kaushal Modi
2022-07-04 11:47 ` Ihor Radchenko

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).