From 614944ba1ac5502c7648747363674b8d45bfaaf7 Mon Sep 17 00:00:00 2001 Message-Id: <614944ba1ac5502c7648747363674b8d45bfaaf7.1665234699.git.yantar92@gmail.com> From: Ihor Radchenko Date: Sat, 8 Oct 2022 21:08:47 +0800 Subject: [PATCH] ox-odt: Fix newlines replaced by spaces in Han script * lisp/ox-odt.el (org-odt-plain-text): Use `fill-region' to unfill the paragraphs with newlines accounting for scripts without spaces between words. Reported-by: James Harkins Link: https://orgmode.org/list/sbhnlv$4t1$1@ciao.gmane.io --- lisp/ox-odt.el | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 208a39d9d..c989d2014 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -2903,9 +2903,20 @@ (defun org-odt-plain-text (text info) (setq output (replace-regexp-in-string (car pair) (cdr pair) output t nil)))) ;; Handle break preservation if required. - (when (plist-get info :preserve-breaks) - (setq output (replace-regexp-in-string - "\\(\\\\\\\\\\)?[ \t]*\n" "" output t))) + (if (plist-get info :preserve-breaks) + (setq output (replace-regexp-in-string + "\\(\\\\\\\\\\)?[ \t]*\n" "" output t)) + ;; OpenDocument schema recognizes newlines as spaces, which may + ;; not be desired in scripts that do not separate words with + ;; spaces (for example, Han script). `fill-region' is able to + ;; handle such situations. + (setq output + (with-temp-buffer + (insert output) + ;; Unfill. + (let ((fill-column (point-max))) + (fill-region (point-min) (point-max))) + (buffer-string)))) ;; Return value. output)) -- 2.35.1