[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trailing whitespace after export snippets without a transcoder
From: |
Ihor Radchenko |
Subject: |
Re: Trailing whitespace after export snippets without a transcoder |
Date: |
Sun, 28 Apr 2024 11:19:58 +0000 |
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>
- Re: [PATCH v2] org-faq.org: Inline comments, Ihor Radchenko, 2024/04/15
- Re: [PATCH v2] org-faq.org: Inline comments, Max Nikulin, 2024/04/17
- Trailing whitespace after export snippets without a transcoder (was: [PATCH v2] org-faq.org: Inline comments), Ihor Radchenko, 2024/04/20
- Re: Trailing whitespace after export snippets without a transcoder, Max Nikulin, 2024/04/20
- Re: Trailing whitespace after export snippets without a transcoder, Ihor Radchenko, 2024/04/21
- Re: Trailing whitespace after export snippets without a transcoder, Max Nikulin, 2024/04/22
- Re: Trailing whitespace after export snippets without a transcoder, Ihor Radchenko, 2024/04/22
- Re: Trailing whitespace after export snippets without a transcoder, Max Nikulin, 2024/04/25
- Re: Trailing whitespace after export snippets without a transcoder,
Ihor Radchenko <=