org-odt-plain-text: Fix when text contains leading spaces

* lisp/ox-odt.el (org-odt-plain-text): Do not count leading spaces
twice.

Reported-by: Damien Cassou <damien@cassou.me>
Link: https://orgmode.org/list/87v8i3y135.fsf@cassou.me
This commit is contained in:
Ihor Radchenko 2023-04-11 12:25:13 +02:00
parent 56dd046da8
commit 60ce29dc41
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 8 additions and 2 deletions

View File

@ -2923,17 +2923,23 @@ 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
;; FIXME: The unnecessary spacing 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)
(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))))
(insert
(substring
output
(length leading)
(pcase (length trailing)
(0 nil)
(n (- n)))))
;; Unfill, retaining leading/trailing space.
(let ((fill-column most-positive-fixnum))
(fill-region (point-min) (point-max)))