From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 0GENJT1u12SS4QAASxT56A (envelope-from ) for ; Sat, 12 Aug 2023 13:34:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id sHXTJD1u12QtBwEA9RJhRA (envelope-from ) for ; Sat, 12 Aug 2023 13:34:21 +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 2D9BA31AAC for ; Sat, 12 Aug 2023 13:34:21 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=D05qBgFM; 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=1691840061; a=rsa-sha256; cv=none; b=FDV0R4Ml4sUyGNGSSq+XGEQ9Ui0Pqg4PwZRWwzc2IA2r7fwbv+dCDF5e3ogydGC2FvgPXM rkvubPwerUEzhqw06OWND0cdfKsQ09+27hyzsRimD8VMiaizYayNsR86RAaOBmMtEp+jlE im7vPcWseB+3x8v56nEvZBppKQhh3RXb12z5oFCdOelRDFSE1LYy4UIR14+2yNt89w9Puy rzu8xdb1Zg9wr4AdIKA3a7OnYDImbhXC6MCUf1kZ5A/kjg3JNaymjEjCD2JXuzQVvRWPPN pP0CCpOUqoROWDL8fB8GEPrz75FU8qbs6xR84H4s7GwbRtdcLoUf42fbZSYG7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1691840061; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=rDKJqS2Q2+IViqZ5l6YG3zztLWCoEU3wZLRkWBjZsp4=; b=Ih/GGQ2IfsLSXDBBfc7IrXuvpMCws1pfQaR+f5csGEwV/tETOtYv/x7hRWBqID7h/H39H/ A8e35Ahsn6QUvo1C4Yk8W/cO037VnMrzAjkmPkueWNRC2D2PWKfCayuJrqCmInB6CiUpMB HMR1uojhGINPgU+irV1jCiH5vcrzSKa4zuIy1yLqz/zfd+G8uR7gaxnsrjcEhq4E4CfNBi GcDo/GFMGmAr2LquK5FaOyzJdNisIfbO1viwZ+0bC01S4LTkMAvdAfLo9RvkgC1YSo6Ar3 S4zMhs5BbJeQLCq62Td7jnt5eYAQvuurLahuErCdxGUGQYzmRJrYQ8gSmLdy1g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=D05qBgFM; 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 1qUmnD-0000sp-5e; Sat, 12 Aug 2023 07:28:27 -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 1qUmnB-0000sU-1n for emacs-orgmode@gnu.org; Sat, 12 Aug 2023 07:28:25 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qUmn8-0006eA-Rg for emacs-orgmode@gnu.org; Sat, 12 Aug 2023 07:28:24 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 45B03240103 for ; Sat, 12 Aug 2023 13:28:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1691839700; bh=Q5O/LLKQCw3h7ke2J3R+MUK5u8atq2nENpE5UTc7ikQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=D05qBgFMawDcFTWC584oUHHO6gz8D6+jUvmf3EeKANFPC7+db8OWoiSbgcXRkd9ck nfMZpxgHDZ9F7+1XXR+w6eeaVfyDwhb+I9iLWUC4RYPuxYCnstXMJs5X5rhz5kYpMd +ooYdORM5dGAO8DE3IKqunLkK5XTC2rZBM8hEy71EkjrQg1yfxfVzTbbUmMo0WKraR 35I5NZbvUHgfx66LXFRdgNdoJZkaWdyCJ7oKz2SbGe1I1sERGTy+R1tiULTTNZ9EJo auVtH+gPjH6TLh6/AMDa3PBVrKCkA31HriAB/RvLl8koVUiU/NeuORqnlVe8YuHJLk cYVYpOoZHCoFw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RNJLq5fSQz9rxG; Sat, 12 Aug 2023 13:28:19 +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: <877cq04rt7.fsf@localhost> (Ihor Radchenko's message of "Sat, 12 Aug 2023 07:56:36 +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> Date: Sat, 12 Aug 2023 11:28:17 +0000 Message-ID: <87ttt4jy9a.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.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: -9.72 X-Migadu-Scanner: mx2.migadu.com X-Migadu-Queue-Id: 2D9BA31AAC X-Spam-Score: -9.72 X-TUID: G/XFwqVJ3tMf Ihor Radchenko writes: > Juan Manuel Mac=C3=ADas writes: >> + (vwidth (if (not lit) >> + (if versewidth (format "\\settowidth{\\versewidth}{%s}\n" versew= idth) "") >> + "")) > > Can just do (if (and versewidth (not lit)) (format ...) "") > >> + (linreset (if (not lit) >> + (if lin "\n\\poemlines{0}" "") >> + ""))) > > (if (and lin (not lit)) ...) Thanks for the suggestions. Yes, it's simpler that way. >> (concat >> (org-latex--wrap-label >> 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. >> - (format "%s\\begin{verse}%s\n%s\\end{verse}%s" >> + ;; into a normal space, calculated with `\fontdimen2\font'. >> + ;; One or more blank lines between lines are exported as a >> + ;; single blank line. If the `:literal' attribute is used, >> + ;; CONTENTS is exported as is, with no environment, preserving >> + ;; line breaks and vertical and horizontal spaces. >> + (format (if (not lit) >> + "%s\\begin{verse}%s\n%s\\end{verse}%s" >> + "%s%s\n%s%s") > > In the case of lit vwidth and attr are always empty. So, you are > inserting an extra newline in front. Is it intentional? I used that procedure because an extra blank line before (in the LaTeX code) it has no effect in LaTeX compilation. And in case the :literal attribute is present, vertical spaces are achieved by explicit \vspace*{}. One or more empty lines before it just marks the beginning of a new paragraph. Naturally, if :literal is used the rest of attributes are meaningless because they are intended for the verse environment. They can even give some error in the compilation. So I opted to disable them with the mere presence of :literal, leaving them 'empty' (so as not to manipulate the function further). >> + (concat "\\(" >> + (regexp-quote org-latex-line-break-safe) >> + "\n\\)" >> + "\\(^[ \t]*" >> + (regexp-quote org-latex-line-break-safe) >> + "\n" >> + "\\)+") >> + (concat "^[ \t]*" (regexp-quote org-latex-line-break-safe) "$")) > > May also use rx for better readability. I remember that I tried rx a while ago and found it very useful and comfortable, but then I haven't done anything with it. The fact is that over time I have ended up getting used to suffering from the classic regexp and it is hard for me to get out of there :-). Of course, with rx it would be clearer but I would have to refresh my memory. --=20 Juan Manuel Mac=C3=ADas https://juanmanuelmacias.com https://lunotipia.juanmanuelmacias.com https://gnutas.juanmanuelmacias.com