From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id uDERCpyA3mSkBwEASxT56A (envelope-from ) for ; Thu, 17 Aug 2023 22:18:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 6FT1CZyA3mQNPgEAauVa8A (envelope-from ) for ; Thu, 17 Aug 2023 22:18:36 +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 1A8E8589E3 for ; Thu, 17 Aug 2023 22:18:35 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=fKn2JrRJ; 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=1692303516; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=mXhkjXDwsQmnPO8Z1cREYyvAFJhA9+Wv8/vg7e9Z0ps=; b=O/CH9rx2BWON9gEiot1jobzyesBjpqwnatApwDIUhq3bEbV0hOmykyvzyOJfewQ52GnR65 9UqR5hw0kKP1yc7jDwfmkBPJiDaYztALBMi2BLFc32eGea3qN9Kfl+RoNzhtVEPWOIeg3m A21Oy0rK4foubA7FsxvidjerXIiJvJtsa0ZsVjt1xmDC0koNV7te9mBNwHRmjSQrU3Wl9F no4OMM6/VVDcHzb67BSlkLt6qGYGyvnhj5ZtyB/hiZ6hMysLsZlUwTEhYJywQ3b4Y8wM8n xYfs2SfQamYiyxrJjx7w0roRGOTlaaccAM779ervjJQNDuJNbNmAG/DjlaiYkw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=fKn2JrRJ; 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-Seal: i=1; s=key1; d=yhetil.org; t=1692303516; a=rsa-sha256; cv=none; b=VnC2Ry1W/uvgX7FPxsixHnggvhMYyylOsJCmYz37ZyO+sbtQhQ4weBfPx1dcv4OfQ0Q1QG vk7WcEqMGNUih/eZtCC7BeNw6D/oE3aMMVn8ra4LPfJLDwjplA2gssgRPmaJjm1YcrFGaP HLUreB5iUKULh9M3uNsJmQwLCo634tXsiaFQs1Yqodl9mmccTu6h0bXuL9ePjgX2dxWRgh 1kEI+ootjVTiJGgHo/7DFQHJxOpfr4EhKdG7dbsktpS/N4+SJ10UO1+vUbZn7pwSgS/XHN lqEAD92z6BqyFl6i9aV68xB4mt1t/L6q3SRJ57gIVXCk5lnDRmJiqjGS5Z8zTQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWjRC-0002L8-Oz; Thu, 17 Aug 2023 16:17:46 -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 1qWjR9-0002Kd-2h for emacs-orgmode@gnu.org; Thu, 17 Aug 2023 16:17:44 -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 1qWjR5-0004aZ-Bf for emacs-orgmode@gnu.org; Thu, 17 Aug 2023 16:17:42 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 877FF240029 for ; Thu, 17 Aug 2023 22:17:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1692303455; bh=nWgTklz9VOJ6SmvTUvAgthtGkaBRBmyQbFX82K7yqEk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=fKn2JrRJRlyjkU6tsIzcqADto06lNharEEkCKMvKmovt6ZMEI2orU7PqXrTzBPTkm wIaQh9twurptrHZ/7FLFC4eepbLyPRBqCp8RggJaFmErxuBnMGIKE3lo3IEX50H3yT +wLc6tVw5gIOzQ06gHwVJtVU4a4YQm9mX7hpbWEWEuTgyCsEvcsGUY3bwKqtf9boag 2P1L8lKu9uxew9/chAJnhu5ha+gKayNlqsuUMS3QRtueouYSGgrlVbh5cD7MpSDeOi nm48KZIMnXJpLA8gUXy6awpCoC7Y/tR2D3Ee7MVW+e9impHdoyxfKhZXBi+5N1LtNw ssFDkhonKDGyw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RRbsB6qwfz9rxL; Thu, 17 Aug 2023 22:17:34 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: Ihor Radchenko Cc: orgmode Subject: Re: [patch] ox-latex.el: fix blank lines behavior in verse block In-Reply-To: <87leeaq7mt.fsf@localhost> (Ihor Radchenko's message of "Thu, 17 Aug 2023 10:35:06 +0000") References: <87tttcml75.fsf@posteo.net> <87edkf6px1.fsf@localhost> <87350ug413.fsf@posteo.net> <87o7jgejhl.fsf@localhost> <87pm3wfvzx.fsf@posteo.net> <87il9nb62q.fsf@localhost> <871qgbb2q6.fsf@posteo.net> <874jl5526t.fsf@localhost> <87ttt59zsx.fsf@posteo.net> <877cq04rt7.fsf@localhost> <87edk5crle.fsf@posteo.net> <87r0o4ipms.fsf@localhost> <87edk4jzii.fsf@posteo.net> <87350kr06o.fsf@localhost> <874jl0jsba.fsf@posteo.net> <87fs4jpfuz.fsf@localhost> <87bkf7qdrk.fsf@posteo.net> <87leeaq7mt.fsf@localhost> Date: Thu, 17 Aug 2023 20:17:32 +0000 Message-ID: <877cpta0f7.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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.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=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-Spam-Score: -6.89 X-Spam-Score: -6.89 X-Migadu-Queue-Id: 1A8E8589E3 X-Migadu-Scanner: mx1.migadu.com X-TUID: /LC9b3HjFcS3 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ihor Radchenko writes: > Thanks! > >> * (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. If the `:literal' attribute is >> used, all blank lines are preserved and exported as > > Please use double space between sentences and start sentences with > capital letter. > >> +- =3D:literal=3D :: With value t, all blank lines are preserved and >> + exported as =3D\vspace*{\baselineskip}=3D, including the blank lines >> + before or after contents. Note that without the =3D:literal=3D >> + attribute, one or more blank lines between stanzas are exported as a >> + single blank line, and any blank lines before or after the content >> + are removed, which is more consistent with the syntax of the LaTeX >> + `verse' environment, and the one provided by the `verse' package. >> + If the =3Dverse=3D package is loaded, the vertical spacing between all >> + stanzas can be controlled by the global length =3D\stanzaskip=3D (see >> + https://www.ctan.org/pkg/verse). > > s/`verse'/=3Dverse=3D/ >=20=20=20 > And you need to update `test-ox-latex/verse' test - it is currently faili= ng. Sorry for the typos... Here goes the corrected patch again, with the updated test. --=20 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-Add-the-literal-attribute-to-verse-.patch >From bd956aa947e080ef10aa851f339414dc1cda1baf Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Mon, 14 Aug 2023 21:48:58 +0200 Subject: [PATCH] lisp/ox-latex.el: Add the `:literal' attribute to verse block. * (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. If the `:literal' attribute is used, all blank lines are preserved and exported as `\vspace*{\baselineskip}', including the blank lines before or after contents. The rx code has been suggested by Ihor Radchenko, to improve readability. * doc/org-manual.org (Verse blocks in LaTeX export): The new feature is documented. * testing/lisp/test-ox-latex.el (test-ox-latex/verse): Updated. --- doc/org-manual.org | 18 ++++++++++++++---- lisp/ox-latex.el | 36 ++++++++++++++++++++++++++--------- testing/lisp/test-ox-latex.el | 8 ++++---- 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index e59efc417..ce0521dee 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -14425,10 +14425,10 @@ The LaTeX export backend converts horizontal rules by the specified #+cindex: verse blocks, in @LaTeX{} export #+cindex: @samp{ATTR_LATEX}, keyword -The LaTeX export backend accepts four attributes for verse blocks: -=:lines=, =:center=, =:versewidth= and =:latexcode=. The three first -require the external LaTeX package =verse.sty=, which is an extension -of the standard LaTeX environment. +The LaTeX export backend accepts five attributes for verse blocks: +=:lines=, =:center=, =:versewidth=, =:latexcode= and =:literal=. The +three first require the external LaTeX package =verse.sty=, which is +an extension of the standard LaTeX environment. - =:lines= :: To add marginal verse numbering. Its value is an integer, the sequence in which the verses should be numbered. @@ -14440,6 +14440,16 @@ of the standard LaTeX environment. verse. - =:latexcode= :: It accepts any arbitrary LaTeX code that can be included within a LaTeX =verse= environment. +- =:literal= :: With value t, all blank lines are preserved and + exported as =\vspace*{\baselineskip}=, including the blank lines + before or after contents. Note that without the =:literal= + attribute, one or more blank lines between stanzas are exported as a + single blank line, and any blank lines before or after the content + are removed, which is more consistent with the syntax of the LaTeX + `verse' environment, and the one provided by the =verse= package. + If the =verse= package is loaded, the vertical spacing between all + stanzas can be controlled by the global length =\stanzaskip= (see + https://www.ctan.org/pkg/verse). A complete example with Shakespeare's first sonnet: diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 31cad1dc4..d11e3befa 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -4116,10 +4116,11 @@ contextual information." (let* ((lin (org-export-read-attribute :attr_latex verse-block :lines)) (latcode (org-export-read-attribute :attr_latex verse-block :latexcode)) (cent (org-export-read-attribute :attr_latex verse-block :center)) + (lit (org-export-read-attribute :attr_latex verse-block :literal)) (attr (concat - (if cent "[\\versewidth]" "") - (if lin (format "\n\\poemlines{%s}" lin) "") - (if latcode (format "\n%s" latcode) ""))) + (if cent "[\\versewidth]" "") + (if lin (format "\n\\poemlines{%s}" lin) "") + (if latcode (format "\n%s" latcode) ""))) (versewidth (org-export-read-attribute :attr_latex verse-block :versewidth)) (vwidth (if versewidth (format "\\settowidth{\\versewidth}{%s}\n" versewidth) "")) (linreset (if lin "\n\\poemlines{0}" ""))) @@ -4128,20 +4129,37 @@ 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 normal space, calculated with `\fontdimen2\font'. One + ;; or more blank lines between lines are exported as a single + ;; blank line. If the `:lines' attribute is used, the last + ;; verse of each stanza ends with the string `\\!', according to + ;; the syntax of the `verse' package. The separation between + ;; stanzas can be controlled with the length `\stanzaskip', of + ;; the aforementioned package. If the `:literal' attribute is + ;; used, all blank lines are preserved and exported as + ;; `\vspace*{\baselineskip}', including the blank lines before + ;; or after CONTENTS. (format "%s\\begin{verse}%s\n%s\\end{verse}%s" vwidth attr (replace-regexp-in-string - "^[ \t]+" (lambda (m) (format "\\hspace*{%dem}" (length m))) + "^[ \t]+" (lambda (m) (format "\\hspace*{%d\\fontdimen2\\font}" (length m))) (replace-regexp-in-string - (concat "^[ \t]*" (regexp-quote org-latex-line-break-safe) "$") - "\\vspace*{1em}" + (if (not lit) + (rx-to-string + `(seq (group ,org-latex-line-break-safe "\n") + (1+ (group line-start (0+ space) ,org-latex-line-break-safe "\n")))) + (concat "^[ \t]*" (regexp-quote org-latex-line-break-safe) "$")) + (if (not lit) + (if lin "\\\\!\n\n" "\n\n") + "\\vspace*{\\baselineskip}") (replace-regexp-in-string "\\([ \t]*\\\\\\\\\\)?[ \t]*\n" (concat org-latex-line-break-safe "\n") - contents nil t) + (if (not lit) + (concat (org-trim contents t) "\n") + contents) + nil t) nil t) nil t) linreset) diff --git a/testing/lisp/test-ox-latex.el b/testing/lisp/test-ox-latex.el index adb3a60ea..79ef8793b 100644 --- a/testing/lisp/test-ox-latex.el +++ b/testing/lisp/test-ox-latex.el @@ -61,11 +61,11 @@ lorem ipsum dolor (search-forward "\\begin{verse} lorem ipsum dolor\\\\[0pt] +lorem ipsum dolor + lorem ipsum dolor\\\\[0pt] -\\vspace*{1em} -lorem ipsum dolor\\\\[0pt] -lorem ipsum dolor\\\\[0pt] -\\vspace*{1em} +lorem ipsum dolor + lorem ipsum dolor\\\\[0pt] lorem ipsum dolor\\\\[0pt] \\end{verse}")))) -- 2.41.0 --=-=-=--