From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id +E3kG4SMz2Q0agAASxT56A (envelope-from ) for ; Sun, 06 Aug 2023 14:05:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id mBoKG4SMz2QTQQEAG6o9tA (envelope-from ) for ; Sun, 06 Aug 2023 14:05:24 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9C22863DEA for ; Sun, 6 Aug 2023 14:05:23 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=UUAcof8X; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1691323524; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=r42T9LEW+Snpu7vXe4gd4AstoRkwhozrA+ptlVdOMxE=; b=NrAxOfsklcYdHMDRFCgSxg2tsQm+f1vY1eUsHxBpE0x2a0uWQ9Aetx24TVh/L5cFPbz4fG cbKKVjbHYJ6/GxQ3f6fx0LWoqR/m32Uol+d1fC30XyeNsI6YeGac3mytGmRTl2T4j9LuN9 SDNVzXbIB5lN2+n9kqnI531Ds5b2hJI53Bz04+M0MjqsWnpYoSVk9PHb2Rp1buRO/eL44e Jh7R9QebU/2a3sIf0D2NGwEGb+e4y8XBDaqKSnR7802PBWVntABOY0KleDef91B6C6scI+ BSI6jZpo00DftTllcv5nVfChSWsiQKzDq3qi4THahDjlR0QwhMFy/0UsN+SUpw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1691323524; a=rsa-sha256; cv=none; b=Beq0keQ4RqSMnOjwoaoDj+39yrcYOTFFjOWx6SUt6ENAA8A1njq7Zx/cAyFW9b2SKTih/D aSe+uHtVbrSVFABtKRTnAkOh8mactnmC7rgdyapm89JiCGKRZiq0DPez59bd6nqXyo/A8D PpBGc/JBKr7oZ+HNRyWSkDHkli5HgUR3559t5DKsRnLi8CGpS0oD/i7KuI4NE0lstJ1OPZ mME1ctx6ngYq+BtIkk43XAqr5ULF2Wc+kh8YyJsGLEz5foKk5WL2tmZDL98UZPu9ft2Ilf 11OdA4WiMqItzMkNVcZUD1KWSr0H2yrg0028D4jk87oELa9kzE0cTySvJBsUZQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=UUAcof8X; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qScUp-00029Z-6A; Sun, 06 Aug 2023 08:04:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qScUW-0001uN-NF for emacs-orgmode@gnu.org; Sun, 06 Aug 2023 08:04:14 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qScUO-0006My-4g for emacs-orgmode@gnu.org; Sun, 06 Aug 2023 08:04:07 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id D7C9E240027 for ; Sun, 6 Aug 2023 14:04:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1691323440; bh=g5YHYv4HgzkTy4OL/T2T5ZjhRmRqKNiyBZMFA8kKAcM=; h=From:To:Subject:Date:Message-ID:MIME-Version:From; b=UUAcof8XL+ZBRbVydux2VDJ6p9nzjUSMVrpuCBmnmBD6bze/sjW+2OwHbFHnPQA+s 90Goxt2UU9uYR8LayOmNcDpa9acNhlP8K3i/EyzYbfEtkwM4/Gi9YKB/1Z8nlnmXmR mNt13oP5YN4pLw4bXlZUaz/SlViDvcbsjMwGUTDvbjKCFViGk1SHrt03dNT+YQbVho vpVtxo2CTgyYMbceZhmwv7Mpm2fkqZEvM9nN1c4Gnz4Hzsw++pJ/dIWg2yZ/9k0GDc r0DBt9hjztPiyYnMb6mqUp+KJ2aTObuaDrvNRmL+CkfH3lLOguFeoKJvARmnsEsmqn HG38Hv6ZPx0Fw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RJdQm3QcDz6tvr for ; Sun, 6 Aug 2023 14:04:00 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [patch] ox-latex.el: fix blank lines behavior in verse block Date: Sun, 06 Aug 2023 12:03:58 +0000 Message-ID: <87tttcml75.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 9C22863DEA X-Migadu-Scanner: mx0.migadu.com X-Migadu-Spam-Score: -9.83 X-Spam-Score: -9.83 X-TUID: OkQNe8K0EoIH --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Rationale for this patch: the treatment of blank lines in `org-latex-verse-block' is inconsistent with the syntax of the `verse' environment, both the one that includes LaTeX and the one provided by the `verse' package as a replacement for the former. Currently, each blank line is exported to LaTeX as an explicit vertical space: \vspace*{1em}. This can return unexpected results. For example, this: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 #+begin_verse =E2=94=82 =E2=94=82 lorem =E2=94=82 ipsum =E2=94=82 dolor |=20 =E2=94=82 #+end_verse =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 is exported to LaTeX as: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 \begin{verse} =E2=94=82 \vspace*{1em} =E2=94=82 lorem\\[0pt] =E2=94=82 ipsum\\[0pt] =E2=94=82 dolor\\[0pt] =E2=94=82 \vspace*{1em} =E2=94=82 \end{verse} =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 In the LaTeX `verse' environment, spaces before and after the content are not taken into account. As for the separation between stanzas, this is marked with at least one blank line between the stanzas, as in normal paragraphs (not with an explicit vertical space). Also it is not necessar y that the last verse of each stanza ends with the linebreak mark `\\'. So, after this patch: =E2=80=A2 Any blank line before and/or after the content is removed; =E2=80=A2 One or more blank lines between stanzas are exported as a single = blank line, leaving the previous final verse without the linebreak mark `\\'; =E2=80=A2 When verse numbering is enabled via the `:lines' attribute (for t= he `verse' package), the last verses of each stanza are marked with `\\!', according to the verse package syntax (this was not necessary with the previous behavior). This way, the `verse' block is exported to LaTeX with the correct syntax. This also brings the advantage of being able to globally control the spacing between stanzas via the verse package=E2=80=99s \stanzaskip com= mand. Example: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 #+begin_verse =E2=94=82 Lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 =E2=94=82 Lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 =E2=94=82 Lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 #+end_verse =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 LaTeX: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 \begin{verse} =E2=94=82 Lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor =E2=94=82 =E2=94=82 Lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor =E2=94=82 =E2=94=82 Lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor\\[0pt] =E2=94=82 \end{verse} =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 And with verse numbers: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 #+ATTR_LaTeX: :lines 5 =E2=94=82 #+begin_verse =E2=94=82 Lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 =E2=94=82 Lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 =E2=94=82 Lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 lorem ipsum dolor =E2=94=82 #+end_verse =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 LaTeX: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 \begin{verse} =E2=94=82 \poemlines{5} =E2=94=82 Lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor\\! =E2=94=82 =E2=94=82 Lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor\\! =E2=94=82 =E2=94=82 Lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor\\[0pt] =E2=94=82 lorem ipsum dolor\\[0pt] =E2=94=82 \end{verse} =E2=94=82 \poemlines{0} =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 N.B.: the `\\[0pt]' mark of the last verse does not affect the final result. Best regards, Juan Manuel -- Juan Manuel Mac=C3=ADas https://juanmanuelmacias.com https://lunotipia.juanmanuelmacias.com https://gnutas.juanmanuelmacias.com --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-ox-latex.el-fix-blank-lines-behavior-in-verse-b.patch >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 --=-=-=--