emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [BUG] No newline at end of exported HTML file [9.6.6 (release_9.6.6


From: Ihor Radchenko
Subject: Re: [BUG] No newline at end of exported HTML file [9.6.6 (release_9.6.6 @ /Applications/MacPorts/Emacs.app/Contents/Resources/lisp/org/)]
Date: Tue, 10 Oct 2023 11:21:51 +0000

Ihor Radchenko <yantar92@posteo.net> writes:

> AFAIU, `require-final-newline' is t by default, except binary data.
> Also, Org export is not designed to generate binary output.
> So, it should be OK to ensure the final newline manually, in
> `org-export-to-file' - to minimize possible breakage.

See the attached tentative patch.
I am not merging it yet upstream (onto bugfix) in case if there are
objections.

>From 5bfe7dd32fb10af0540b271d1de27849507cb6d3 Mon Sep 17 00:00:00 2001
Message-ID: 
<5bfe7dd32fb10af0540b271d1de27849507cb6d3.1696936855.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Tue, 10 Oct 2023 14:19:53 +0300
Subject: [PATCH] * lisp/ox.el (org-export-to-file): Ensure final newline

The newline were added by default in the past, before d7a55bbd5.
Continue to add it to avoid changed behavior.

Reported-by: YE <yet@ego.team>
Link: https://orgmode.org/list/87wmvwklnq.fsf@localhost
---
 lisp/ox.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lisp/ox.el b/lisp/ox.el
index 94cc5a228..b63507606 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -6691,6 +6691,11 @@   (defun org-latex-export-to-latex
                     ',ext-plist)))
               (with-temp-buffer
                 (insert output)
+                 ;; Ensure final newline.  This is what was done
+                 ;; historically, when we used `write-file'.
+                 ;; Note that adding a newline is only safe for
+                 ;; non-binary data.
+                 (unless (bolp) (insert "\n"))
                 (let ((coding-system-for-write ',encoding))
                   (write-region (point-min) (point-max) ,file)))
               (or (ignore-errors (funcall ',post-process ,file)) ,file)))
@@ -6698,6 +6703,11 @@   (defun org-latex-export-to-latex
                        backend subtreep visible-only body-only ext-plist)))
           (with-temp-buffer
             (insert output)
+            ;; Ensure final newline.  This is what was done
+            ;; historically, when we used `write-file'.
+            ;; Note that adding a newline is only safe for
+            ;; non-binary data.
+            (unless (bolp) (insert "\n"))
             (let ((coding-system-for-write encoding))
              (write-region (point-min) (point-max) file)))
           (when (and (org-export--copy-to-kill-ring-p) (org-string-nw-p 
output))
-- 
2.42.0

-- 
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]