org-latex-verse-block: Fix regression from 3f60acff7

* lisp/ox-latex.el (org-latex-verse-block): Fix logic replacing sole
paragraph breaks according to the new template.
* testing/lisp/test-ox-latex.el: New test file.
(org-test-with-exported-text): New macro for testing export.
(test-ox-latex/verse): New test.
* mk/default.mk (BTEST_RE): Select the new test by default.

Reported-by: Juan Manuel Macías <maciaschain@posteo.net>
Link: https://orgmode.org/list/875ygk6a8z.fsf@posteo.net
This commit is contained in:
Ihor Radchenko 2022-10-16 11:14:06 +08:00
parent 4b010e8dc3
commit 5fa66c7ffc
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
3 changed files with 77 additions and 2 deletions

View File

@ -4105,7 +4105,8 @@ contextual information."
(replace-regexp-in-string
"^[ \t]+" (lambda (m) (format "\\hspace*{%dem}" (length m)))
(replace-regexp-in-string
"^[ \t]*\\\\\\\\$" "\\vspace*{1em}"
(concat "^[ \t]*" (regexp-quote org-latex-line-break-safe) "$")
"\\vspace*{1em}"
(replace-regexp-in-string
"\\([ \t]*\\\\\\\\\\)?[ \t]*\n"
(concat org-latex-line-break-safe "\n")

View File

@ -72,7 +72,7 @@ REPRO_ARGS ?=
req-ob-lang = --eval '(require '"'"'ob-$(ob-lang))'
lst-ob-lang = ($(ob-lang) . t)
req-extra = --eval '(require '"'"'$(req))'
BTEST_RE ?= \\(org\\|ob\\)
BTEST_RE ?= \\(org\\|ob\\|ox\\)
BTEST_LOAD = \
--eval '(add-to-list '"'"'load-path (concat default-directory "lisp"))' \
--eval '(add-to-list '"'"'load-path (concat default-directory "testing"))'

View File

@ -0,0 +1,74 @@
;;; test-ox-latex.el --- tests for ox-latex.el -*- lexical-binding: t; -*-
;; Copyright (C) 2022 Ihor Radchenko
;; Author: Ihor Radchenko <yantar92@posteo.net>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Tests checking validity of Org LaTeX export output.
;;; Code:
(require 'ox-latex nil t)
(unless (featurep 'ox-latex)
(signal 'missing-test-dependency "org-export-latex"))
(defmacro org-test-with-exported-text (backend source &rest body)
"Run BODY in export buffer for SOURCE string via BACKEND."
(declare (indent 2))
`(org-test-with-temp-text ,source
(let ((export-buffer (generate-new-buffer "Org temporary export")))
(unwind-protect
(progn
(org-export-to-buffer ,backend export-buffer)
(with-current-buffer export-buffer
,@body))
(kill-buffer export-buffer)))))
(ert-deftest test-ox-latex/verse ()
"Test verse blocks."
(org-test-with-exported-text
'latex
"#+begin_verse
lorem ipsum dolor
lorem ipsum dolor
lorem ipsum dolor
lorem ipsum dolor
lorem ipsum dolor
lorem ipsum dolor
#+end_verse
"
(goto-char (point-min))
(should
(search-forward
"\\begin{verse}
lorem ipsum dolor\\\\\\empty
lorem ipsum dolor\\\\\\empty
\\vspace*{1em}
lorem ipsum dolor\\\\\\empty
lorem ipsum dolor\\\\\\empty
\\vspace*{1em}
lorem ipsum dolor\\\\\\empty
lorem ipsum dolor\\\\\\empty
\\end{verse}"))))
(provide 'test-ox-latex)
;;; test-ox-latex.el ends here