Преглед изворни кода

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>
Nicolas Goaziou пре 8 година
родитељ
комит
35e90ced24
1 измењених фајлова са 22 додато и 11 уклоњено
  1. 22 11
      lisp/ox-latex.el

+ 22 - 11
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)
@@ -1621,6 +1623,25 @@ INFO is a plist used as a communication channel."
 	    (member (or compiler "") org-latex-compilers)
 	    (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
 
@@ -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