org-odt-plain-text: Fix stripping spaces around plain-text segments

* lisp/ox-odt.el (org-odt-plain-text): Do not strip whitespace around
individual plain-text objects.

Reported-by: András Simonyi <andras.simonyi@gmail.com>
Link: https://orgmode.org/list/CAOWRwxC2MTqAmXVXtLJi39f=KEC-6tmWJ6XC3OMTXqvC2hC_xw@mail.gmail.com
This commit is contained in:
Ihor Radchenko 2022-10-26 12:33:55 +08:00
parent e022a0cea1
commit bb40848458
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 12 additions and 4 deletions

View File

@ -2920,13 +2920,21 @@ contextual information."
;; not be desired in scripts that do not separate words with
;; spaces (for example, Han script). `fill-region' is able to
;; handle such situations.
;; FIXME: The unnecessary spaced may still remain when a newline
;; is at a boundary between Org objects (e.g. italics markup
;; followed by newline).
(setq output
(with-temp-buffer
(insert output)
;; Unfill.
(let ((fill-column (point-max)))
(fill-region (point-min) (point-max)))
(buffer-string))))
(save-match-data
(let ((leading (and (string-match (rx bos (1+ blank)) output)
(match-string 0 output)))
(trailing (and (string-match (rx (1+ blank) eos) output)
(match-string 0 output))))
;; Unfill, retaining leading/trailing space.
(let ((fill-column (point-max)))
(fill-region (point-min) (point-max)))
(concat leading (buffer-string) trailing))))))
;; Return value.
output))