[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Verse block and separations
From: |
Juan Manuel Macías |
Subject: |
Re: Verse block and separations |
Date: |
Wed, 19 Oct 2022 11:24:35 +0000 |
Max Nikulin writes:
> I still prefer to avoid replacement of latex newlines back to empty
> string. Though I am really happy with the following code, I expected a
> more concise snippet. Unit tests may found bugs in it.
>
> (let ((contents "\n\n 0 \n\n\na b\nc d e \n\n\nf g \n h i\n\n"))
> ;; Strip leading newlines.
> (setq contents
> (replace-regexp-in-string
> (rx string-start (1+ (0+ blank) ?\n)) ""
> contents 'fixed-case 'literal))
> ;; Add explicit line breaks and strip trailing spaces.
> (setq contents
> (replace-regexp-in-string
> (rx (0+ blank) ?\n
> (optional (group (1+ (0+ blank) ?\n)))
> (optional (group (0+ blank) (not (any blank ?\n)))))
> (lambda (m)
> (let ((par (match-string 1 m))
> (next (match-string 2 m)))
> (if next
> (concat (if par "\n\n" "\\\\\n")
> next)
> "")))
> contents 'fixed-case 'literal))
> ;; Indented lines.
> (replace-regexp-in-string
> (rx line-start (1+ blank))
> (lambda (m) (format "\\hspace*{%dem}" (length m)))
> contents 'fixed-case 'literal))
>
> Feel free to use it for inspiration during your work on a patch.
OK, thanks a lot. (BTW, I have yet to reply to some interesting things
you mention in this thread about the verse environment).
- [bug] `org-latex-line-break-safe' breaks the export of verse blocks to LaTeX, Juan Manuel Macías, 2022/10/15
- Line breaks and brackets in LaTeX export (was: [bug] `org-latex-line-break-safe' breaks the export of verse blocks to LaTeX), Juan Manuel Macías, 2022/10/16
- Re: Line breaks and brackets in LaTeX export, Juan Manuel Macías, 2022/10/17
- Re: Line breaks and brackets in LaTeX export, Max Nikulin, 2022/10/17
- Re: Line breaks and brackets in LaTeX export, Juan Manuel Macías, 2022/10/17
- Re: Line breaks and brackets in LaTeX export, Ihor Radchenko, 2022/10/18
- Re: Line breaks and brackets in LaTeX export, Juan Manuel Macías, 2022/10/18