From: Ihor Radchenko <yantar92@posteo.net>
To: Max Nikulin <manikulin@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Trailing whitespace after export snippets without a transcoder
Date: Sun, 28 Apr 2024 11:19:58 +0000 [thread overview]
Message-ID: <871q6ploo1.fsf@localhost> (raw)
In-Reply-To: <v0dcoq$h8v$1@ciao.gmane.io>
Max Nikulin <manikulin@gmail.com> writes:
> On 23/04/2024 02:01, Ihor Radchenko wrote:
>> For example, consider an HTML exporter that aligns tags nicely and
>> keeps blank lines between markup blocks for readability. If we
>> remove such blank lines unconditionally, it will be problematic.
>
> I consider that just newlines are enough to make HTML markup human
> readable. I believe blank lines appear in HTML due to conditional
> constructs interpreted by various template engines and almost nobody
> cares concerning actual formatting in such cases.
I looked further, and it turns out that Org export is already overriding
the blank lines produced by the exporters.
In particular, we have
((memq type '(nil org-data plain-text raw)) results)
;; Append the same white space between elements or objects
;; as in the original buffer, and call appropriate filters.
(t
(org-export-filter-apply-functions
(plist-get info (intern (format ":filter-%s" type)))
(let ((blank (or (org-element-post-blank data) 0)))
(if (eq (org-element-class data parent) 'object)
(concat results (make-string blank ?\s))
(concat (org-element-normalize-string results)
(make-string blank ?\n))))
info))
For now, we only override newlines between elements, not objects.
For objects (but not plain-text), we unconditionally append :post-blank.
I conclude that it is actually OK to go a step further and cleanup
newlines after objects, before appending the post-blank.
Same for plain-text.
>> I guess that I can change the condition to not include trailing space
>> from (rx whitespace eol) to (rx (any " \t|) eol).
>
> One more time I forgot that neither \n nor non-breakable space are
> included into post-blank.
> I think, more permissive regexp may be used. At least it should accept
> newlines and any space after it
>
> (rx (any " \t" eol) (zero-or-more whitespace) eos)
I see how special case for \n is useful. Not should about non-breakable
space.
> Moreover, post-blank of the pruned object may be ignored when the
> following element starts with spaces other than purely zero width ones.
This can never happen, AFAIK.
All the spaces after any object become a part of its :post-blank
attribute.
> My feeling is that extensive test suite is required. It would be easier
> to review what cases are not handled yet.
May you summarize various examples that should be considered?
--
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>
next prev parent reply other threads:[~2024-04-28 11:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-22 0:04 Inline comments ypuntot
2023-06-22 1:50 ` Max Nikulin
2023-06-28 15:51 ` [PATCH] org-faq.org: " Max Nikulin
2023-06-29 10:47 ` Ihor Radchenko
2023-06-30 10:34 ` Max Nikulin
2023-07-01 10:48 ` Ihor Radchenko
2023-08-06 18:34 ` Bastien Guerry
2023-07-01 15:24 ` Ihor Radchenko
2023-07-02 5:46 ` Org FAQ design (Re: [PATCH] org-faq.org: Inline comments) Max Nikulin
2023-07-08 5:48 ` [PATCH v2] org-faq.org: Inline comments Max Nikulin
2023-07-08 9:31 ` Ihor Radchenko
2023-07-10 16:09 ` Max Nikulin
2023-09-01 11:28 ` Ihor Radchenko
2024-04-15 12:17 ` Ihor Radchenko
2024-04-17 14:44 ` Max Nikulin
2024-04-20 11:14 ` Trailing whitespace after export snippets without a transcoder (was: [PATCH v2] org-faq.org: Inline comments) Ihor Radchenko
2024-04-20 15:02 ` Trailing whitespace after export snippets without a transcoder Max Nikulin
2024-04-21 13:00 ` Ihor Radchenko
2024-04-22 10:45 ` Max Nikulin
2024-04-22 19:01 ` Ihor Radchenko
2024-04-25 10:54 ` Max Nikulin
2024-04-28 11:19 ` Ihor Radchenko [this message]
2024-05-19 10:04 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871q6ploo1.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=manikulin@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.