From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: [patch] ob-latex: htlatex and imagemagick Date: Sat, 21 Mar 2015 22:22:17 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZRmo-00045X-Mr for emacs-orgmode@gnu.org; Sat, 21 Mar 2015 18:22:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YZRml-0007sV-Fc for emacs-orgmode@gnu.org; Sat, 21 Mar 2015 18:22:30 -0400 Received: from plane.gmane.org ([80.91.229.3]:59261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZRml-0007sR-5C for emacs-orgmode@gnu.org; Sat, 21 Mar 2015 18:22:27 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YZRmj-00039n-L2 for emacs-orgmode@gnu.org; Sat, 21 Mar 2015 23:22:25 +0100 Received: from cpc33-cmbg15-2-0-cust4.5-4.cable.virginm.net ([81.102.136.5]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 21 Mar 2015 23:22:25 +0100 Received: from andreas.leha by cpc33-cmbg15-2-0-cust4.5-4.cable.virginm.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 21 Mar 2015 23:22:25 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi all, please find attached a small patch that fixes a problem discussed in [1]. In short, when executing a latex src block and htlatex is a valid option, it should be used even if imagemagick is part of the headers. Regards, Andreas [1] http://permalink.gmane.org/gmane.emacs.orgmode/96257 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ob-latex-htlatex-preferred-over-imagemagick.patch Content-Description: patch >From 2986826441c24e2f0d6cf5efe6bf8aca75c4bdbb Mon Sep 17 00:00:00 2001 From: Andreas Leha Date: Sat, 21 Mar 2015 22:11:37 +0000 Subject: [PATCH] ob-latex: htlatex preferred over imagemagick * ob-latex.el (org-babel-execute:latex): change the order of the handlers When `imagemagick' is given this entry acts as an else option. So, it should always come last. --- lisp/ob-latex.el | 80 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el index ba83bf9..2727a2a 100644 --- a/lisp/ob-latex.el +++ b/lisp/ob-latex.el @@ -99,46 +99,6 @@ This function is called by `org-babel-execute-src-block'." (when (file-exists-p out-file) (delete-file out-file)) (with-temp-file out-file (insert body))) - ((or (string-match "\\.pdf$" out-file) imagemagick) - (with-temp-file tex-file - (require 'ox-latex) - (insert - (org-latex-guess-inputenc - (org-splice-latex-header - org-format-latex-header - (delq - nil - (mapcar - (lambda (el) - (unless (and (listp el) (string= "hyperref" (cadr el))) - el)) - org-latex-default-packages-alist)) - org-latex-packages-alist - nil)) - (if fit "\n\\usepackage[active, tightpage]{preview}\n" "") - (if border (format "\\setlength{\\PreviewBorder}{%s}" border) "") - (if height (concat "\n" (format "\\pdfpageheight %s" height)) "") - (if width (concat "\n" (format "\\pdfpagewidth %s" width)) "") - (if headers - (concat "\n" - (if (listp headers) - (mapconcat #'identity headers "\n") - headers) "\n") - "") - (if fit - (concat "\n\\begin{document}\n\\begin{preview}\n" body - "\n\\end{preview}\n\\end{document}\n") - (concat "\n\\begin{document}\n" body "\n\\end{document}\n")))) - (when (file-exists-p out-file) (delete-file out-file)) - (let ((transient-pdf-file (org-babel-latex-tex-to-pdf tex-file))) - (cond - ((string-match "\\.pdf$" out-file) - (rename-file transient-pdf-file out-file)) - (imagemagick - (org-babel-latex-convert-pdf - transient-pdf-file out-file im-in-options im-out-options) - (when (file-exists-p transient-pdf-file) - (delete-file transient-pdf-file)))))) ((and (or (string-match "\\.svg$" out-file) (string-match "\\.html$" out-file)) (executable-find org-babel-latex-htlatex)) @@ -184,6 +144,46 @@ This function is called by `org-babel-execute-src-block'." ".html") out-file) (error "HTML file produced but SVG file requested"))))) + ((or (string-match "\\.pdf$" out-file) imagemagick) + (with-temp-file tex-file + (require 'ox-latex) + (insert + (org-latex-guess-inputenc + (org-splice-latex-header + org-format-latex-header + (delq + nil + (mapcar + (lambda (el) + (unless (and (listp el) (string= "hyperref" (cadr el))) + el)) + org-latex-default-packages-alist)) + org-latex-packages-alist + nil)) + (if fit "\n\\usepackage[active, tightpage]{preview}\n" "") + (if border (format "\\setlength{\\PreviewBorder}{%s}" border) "") + (if height (concat "\n" (format "\\pdfpageheight %s" height)) "") + (if width (concat "\n" (format "\\pdfpagewidth %s" width)) "") + (if headers + (concat "\n" + (if (listp headers) + (mapconcat #'identity headers "\n") + headers) "\n") + "") + (if fit + (concat "\n\\begin{document}\n\\begin{preview}\n" body + "\n\\end{preview}\n\\end{document}\n") + (concat "\n\\begin{document}\n" body "\n\\end{document}\n")))) + (when (file-exists-p out-file) (delete-file out-file)) + (let ((transient-pdf-file (org-babel-latex-tex-to-pdf tex-file))) + (cond + ((string-match "\\.pdf$" out-file) + (rename-file transient-pdf-file out-file)) + (imagemagick + (org-babel-latex-convert-pdf + transient-pdf-file out-file im-in-options im-out-options) + (when (file-exists-p transient-pdf-file) + (delete-file transient-pdf-file)))))) ((string-match "\\.\\([^\\.]+\\)$" out-file) (error "Can not create %s files, please specify a .png or .pdf file or try the :imagemagick header argument" (match-string 1 out-file)))) -- 2.1.1 --=-=-=--