emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] ox-latex.el: fix blank lines behavior in verse block


From: Ihor Radchenko
Subject: Re: [patch] ox-latex.el: fix blank lines behavior in verse block
Date: Sat, 12 Aug 2023 07:56:36 +0000

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 via email to

[Prev in Thread] Current Thread [Next in Thread]