From 0c8a352567333d0d743b5235b68e9cd5d513f615 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Sun, 6 Aug 2023 12:42:36 +0200 Subject: [PATCH] lisp/ox-latex.el: fix blank lines behavior in verse block export. * (org-latex-verse-block): now the treatment of blank lines is consistent with the syntax of the LaTeX `verse' environment, and the one provided by the `verse' package. --- lisp/ox-latex.el | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 31cad1dc4..26827537a 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -4128,20 +4128,28 @@ contextual information." verse-block ;; In a verse environment, add a line break to each newline ;; character and change each white space at beginning of a line - ;; into a space of 1 em. Also change each blank line with - ;; a vertical space of 1 em. + ;; into a space of 1 em. One or more blank lines between lines + ;; are exported as a single blank line. (format "%s\\begin{verse}%s\n%s\\end{verse}%s" vwidth attr (replace-regexp-in-string "^[ \t]+" (lambda (m) (format "\\hspace*{%dem}" (length m))) (replace-regexp-in-string - (concat "^[ \t]*" (regexp-quote org-latex-line-break-safe) "$") - "\\vspace*{1em}" + (concat "\\(" + (regexp-quote org-latex-line-break-safe) + "\n\\)" + "\\(^[ \t]*" + (regexp-quote org-latex-line-break-safe) + "\n" + "\\)+") + (if lin "\\\\!\n\n" "\n\n") (replace-regexp-in-string "\\([ \t]*\\\\\\\\\\)?[ \t]*\n" (concat org-latex-line-break-safe "\n") - contents nil t) + ;; Remove any blank lines before and after CONTENTS. + (concat (org-trim contents t) "\n") + nil t) nil t) nil t) linreset) -- 2.41.0