summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-01-18 23:30:01 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-01-18 23:30:01 +0100
commit35e90ced2448a9451ad2a753166398bf5177a96c (patch)
tree0c4a08230bcc904ad2d68acef510ed6539932fc4
parent1fbc7a424f703f86235c4c5b30caab6604b8feb7 (diff)
downloadorg-mode-35e90ced2448a9451ad2a753166398bf5177a96c.tar.gz
ox-latex: Fix insertion of line breaks at invalid locations
* lisp/ox-latex.el (org-latex-clean-invalid-line-breaks): New function. Reported-by: Takeshi Teshima <takeshi.diadochos@gmail.com> <http://permalink.gmane.org/gmane.emacs.orgmode/111313>
-rw-r--r--lisp/ox-latex.el33
1 files changed, 22 insertions, 11 deletions
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 1ef070d..a4d528f 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -100,8 +100,10 @@
(if a (org-latex-export-to-pdf t s v b)
(org-open-file (org-latex-export-to-pdf nil s v b)))))))
:filters-alist '((:filter-options . org-latex-math-block-options-filter)
+ (:filter-paragraph . org-latex-clean-invalid-line-breaks)
(:filter-parse-tree org-latex-math-block-tree-filter
- org-latex-matrices-tree-filter))
+ org-latex-matrices-tree-filter)
+ (:filter-verse-block . org-latex-clean-invalid-line-breaks))
:options-alist
'((:latex-class "LATEX_CLASS" nil org-latex-default-class t)
(:latex-class-options "LATEX_CLASS_OPTIONS" nil nil t)
@@ -1622,6 +1624,25 @@ INFO is a plist used as a communication channel."
(format org-latex-compiler-file-string compiler))))
+;;; Filters
+
+(defun org-latex-matrices-tree-filter (tree _backend info)
+ (org-latex--wrap-latex-matrices tree info))
+
+(defun org-latex-math-block-tree-filter (tree _backend info)
+ (org-latex--wrap-latex-math-block tree info))
+
+(defun org-latex-math-block-options-filter (info _backend)
+ (dolist (prop '(:author :date :title) info)
+ (plist-put info prop
+ (org-latex--wrap-latex-math-block (plist-get info prop) info))))
+
+(defun org-latex-clean-invalid-line-breaks (data _backend _info)
+ (replace-regexp-in-string
+ "\\(\\end{[A-Za-z0-9*]+}\\|^\\)[ \t]*\\\\\\\\[ \t]*$" "\\1"
+ data))
+
+
;;; Template
(defun org-latex-template (contents info)
@@ -2683,8 +2704,6 @@ channel."
(t "\\[\n%s\\]"))
contents))
-(defun org-latex-matrices-tree-filter (tree _backend info)
- (org-latex--wrap-latex-matrices tree info))
;;;; Pseudo Object: LaTeX Math Block
@@ -2742,14 +2761,6 @@ containing export options. Modify DATA by side-effect and return it."
;; Return updated DATA.
data))
-(defun org-latex-math-block-tree-filter (tree _backend info)
- (org-latex--wrap-latex-math-block tree info))
-
-(defun org-latex-math-block-options-filter (info _backend)
- (dolist (prop '(:author :date :title) info)
- (plist-put info prop
- (org-latex--wrap-latex-math-block (plist-get info prop) info))))
-
(defun org-latex-math-block (_math-block contents _info)
"Transcode a MATH-BLOCK object from Org to LaTeX.
CONTENTS is a string. INFO is a plist used as a communication