emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: "Juan Manuel Macías" <maciaschain@posteo.net>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: [patch] ox-latex.el: fix blank lines behavior in verse block
Date: Sat, 12 Aug 2023 07:56:36 +0000	[thread overview]
Message-ID: <877cq04rt7.fsf@localhost> (raw)
In-Reply-To: <87ttt59zsx.fsf@posteo.net>

Juan Manuel Macías <maciaschain@posteo.net> writes:

> How about this (pre-)patch? With the `:literal' attr., the content of the
> block is exported "as is", with all manual formatting preserved.

Looks reasonable in general.
Of course, we will also need to document the new attribute.

> I have made some modifications in the horizontal and vertical spaces (in
> case :literal is used)...

Makes sense to me.

> +         (vwidth (if (not lit)
> +		     (if versewidth (format "\\settowidth{\\versewidth}{%s}\n" versewidth) "")
> +		   ""))

Can just do (if (and versewidth (not lit)) (format ...) "")

> +         (linreset (if (not lit)
> +		       (if lin "\n\\poemlines{0}" "")
> +		     "")))

(if (and lin (not lit)) ...)

>      (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?

> +		    (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.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2023-08-12  8:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-06 12:03 [patch] ox-latex.el: fix blank lines behavior in verse block Juan Manuel Macías
2023-08-07 11:40 ` Ihor Radchenko
2023-08-07 17:23   ` Juan Manuel Macías
2023-08-09  7:57     ` Ihor Radchenko
2023-08-09  8:41       ` Juan Manuel Macías
2023-08-10  9:27         ` Ihor Radchenko
2023-08-10 10:39           ` Juan Manuel Macías
2023-08-11 10:00             ` Ihor Radchenko
2023-08-11 18:52               ` Juan Manuel Macías
2023-08-12  7:56                 ` Ihor Radchenko [this message]
2023-08-12 11:28                   ` Juan Manuel Macías
2023-08-13  8:06                     ` Ihor Radchenko
2023-08-14 20:10                   ` Juan Manuel Macías
2023-08-15 10:08                     ` Ihor Radchenko
2023-08-15 11:50                       ` Juan Manuel Macías
2023-08-15 11:53                         ` Ihor Radchenko
2023-08-15 14:25                           ` Juan Manuel Macías
2023-08-16  8:10                             ` Ihor Radchenko
2023-08-16 14:10                               ` Juan Manuel Macías
2023-08-17 10:35                                 ` Ihor Radchenko
2023-08-17 20:17                                   ` Juan Manuel Macías
2023-08-18  8:44                                     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877cq04rt7.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=maciaschain@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).