emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Bruno Barbier <brubar.cs@gmail.com>
Cc: YE <yet@ego.team>, Max Nikulin <manikulin@gmail.com>,
	emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <87lecaafjk.fsf@localhost> (raw)
In-Reply-To: <87wmvwklnq.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ox.el-org-export-to-file-Ensure-final-newline.patch --]
[-- Type: text/x-patch, Size: 1914 bytes --]

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


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
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	other threads:[~2023-10-10 11:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06 15:53 [BUG] No newline at end of exported HTML file [9.6.6 (release_9.6.6 @ /Applications/MacPorts/Emacs.app/Contents/Resources/lisp/org/)] YE
2023-10-07  8:27 ` Ihor Radchenko
2023-10-08 19:40   ` YE
2023-10-09 11:29     ` Ihor Radchenko
2023-10-09 11:41       ` Max Nikulin
2023-10-09 11:46         ` Ihor Radchenko
2023-10-09 11:53           ` Max Nikulin
2023-10-09 12:06             ` Ihor Radchenko
2023-10-09 12:23   ` Bruno Barbier
2023-10-09 12:47     ` Ihor Radchenko
2023-10-10 11:21       ` Ihor Radchenko [this message]
2023-10-11  8:10         ` YE
2023-10-15  8:14           ` 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=87lecaafjk.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=brubar.cs@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    --cc=yet@ego.team \
    /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).