Ihor Radchenko <[email protected]> writes: > Christian Moe <[email protected]> writes: > >> Line breaks are not preserved by default in verse blocks in ODT export. >> >> To reproduce, export to ODT: >> ... > > Fixed, on main. > https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=f675b19e9
Thanks! The line breaks are back. But so are spurious spaces at the beginning of verse lines (after the first). With my minimal example: Is all that we see or seem But a dream within a dream? It's the newlines after the <text:line-break/> in ODT xml that get turned into spaces. I attach a tentative fix for org-odt-verse-block, inserting another nested replace-regexp-in-string to remove newlines after line breaks. I first tried a more minimal change, replacing the $ in the last regexp with [\n], but then the last line didn't get a line break, and there was no spacing to the next paragraph. (Arguably, a line break after the last line isn't meaningful, and instead it's the default OrgVerse ODT style that should be changed to add space below the block. But at this point, changing this behavior would probably mess with some document layouts.) Regards, Christian
>From ca611724a46766c21107a3469a32b889d2ba4f18 Mon Sep 17 00:00:00 2001 From: Christian Moe <[email protected]> Date: Sat, 7 Feb 2026 16:15:33 +0100 Subject: [PATCH] org-odt-verse-block: Remove added leading spaces * lisp/ox-odt.el (org-odt-verse-block): Remove newlines in ODT XML after 'text:line-break' tags, because they add leading spaces. --- lisp/ox-odt.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index ccab1d280..d63888fa2 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -3782,9 +3782,12 @@ contextual information." (replace-regexp-in-string ;; Replace leading tabs and spaces. "^[ \t]+" #'org-odt--encode-tabs-and-spaces - ;; Add line breaks to each line of verse. - (replace-regexp-in-string - "\\(<text:line-break/>\\)?[ \t]*$" "<text:line-break/>" contents)))) + (replace-regexp-in-string + ;; Remove newlines after line breaks. + "<text:line-break/>[\n]" "<text:line-break/>" + (replace-regexp-in-string + ;; Add line breaks to each line of verse. + "\\(<text:line-break/>\\)?[ \t]*$" "<text:line-break/>" contents))))) -- 2.43.0
