mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-05 21:42:54 +00:00
ox-latex: Make sure that [text] is not misinterpreted as LaTeX argument
* lisp/ox-latex.el (org-latex-plain-text): Protect plain text starting from [. It might be misinterpreted as optional command argument if previous exported fragment ends with a command accepting such. * testing/lisp/test-ox-latex.el (text-ox-latex/protect-square-brackets): Add new test. Link: https://orgmode.org/list/87o7dju9vn.fsf@posteo.net
This commit is contained in:
parent
15e51d7083
commit
bd305ecdf6
|
@ -3095,6 +3095,15 @@ contextual information."
|
|||
"\\(?:[ \t]*\\\\\\\\\\)?[ \t]*\n"
|
||||
(concat org-latex-line-break-safe "\n")
|
||||
output nil t)))
|
||||
;; Protect [foo] at the beginning of lines / beginning of the
|
||||
;; plain-text object. This prevents LaTeX from unexpectedly
|
||||
;; interpreting @@latex:\pagebreak@@ [foo] as a command with
|
||||
;; optional argument.
|
||||
(setq output (replace-regexp-in-string
|
||||
(rx bol (0+ space) (group "["))
|
||||
"{[}"
|
||||
output
|
||||
nil nil 1))
|
||||
;; Return value.
|
||||
output))
|
||||
|
||||
|
|
|
@ -29,6 +29,29 @@
|
|||
|
||||
|
||||
|
||||
(ert-deftest text-ox-latex/protect-square-brackets ()
|
||||
"Test [foo] being interpreted as plain text even after LaTeX commands."
|
||||
(org-test-with-exported-text
|
||||
'latex
|
||||
"* This is test
|
||||
lorem @@latex:\\pagebreak@@ [ipsum]
|
||||
|
||||
#+begin_figure
|
||||
[lorem] figure
|
||||
#+end_figure
|
||||
|
||||
| [foo] | 2 |
|
||||
| [bar] | 3 |
|
||||
|
||||
- [bax]
|
||||
- [aur]
|
||||
"
|
||||
(goto-char (point-min))
|
||||
(should (search-forward "lorem \\pagebreak {[}ipsum]"))
|
||||
(should (search-forward "{[}lorem] figure"))
|
||||
(should (search-forward "{[}foo]"))
|
||||
(should (search-forward "\\item {[}bax]"))))
|
||||
|
||||
(ert-deftest test-ox-latex/verse ()
|
||||
"Test verse blocks."
|
||||
(org-test-with-exported-text
|
||||
|
|
Loading…
Reference in a new issue