From 7f2cbee0e45ba6a57c913ed49690262401e67f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= Date: Thu, 15 Aug 2019 10:28:27 -0400 Subject: [PATCH] ob-latex: Use org-create-formula-image when generating SVG * lisp/ob-latex.el (org-babel-execute:latex): Remove convoluted and buggy htlatex based SVG generation, and use `org-create-formula-image` --- lisp/ob-latex.el | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el index adf83d460..02ddfa2a8 100644 --- a/lisp/ob-latex.el +++ b/lisp/ob-latex.el @@ -114,14 +114,13 @@ 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))) - ((and (or (string= "svg" extension) - (string= "html" extension)) + ;; TODO: this is a very different way of generating the + ;; frame latex document than in the pdf case. Ideally, both + ;; would be unified. This would prevent bugs creeping in + ;; such as the one fixed on Aug 16 2014 whereby :headers was + ;; not included in the SVG/HTML case. + ((and (string= "html" extension) (executable-find org-babel-latex-htlatex)) - ;; TODO: this is a very different way of generating the - ;; frame latex document than in the pdf case. Ideally, both - ;; would be unified. This would prevent bugs creeping in - ;; such as the one fixed on Aug 16 2014 whereby :headers was - ;; not included in the SVG/HTML case. (with-temp-file tex-file (insert (concat "\\documentclass[preview]{standalone} @@ -143,23 +142,14 @@ This function is called by `org-babel-execute-src-block'." (when (file-exists-p out-file) (delete-file out-file)) (let ((default-directory (file-name-directory tex-file))) (shell-command (format "%s %s" org-babel-latex-htlatex tex-file))) - (cond - ((file-exists-p (concat (file-name-sans-extension tex-file) "-1.svg")) - (if (string-suffix-p ".svg" out-file) - (progn - (shell-command "pwd") - (shell-command (format "mv %s %s" - (concat (file-name-sans-extension tex-file) "-1.svg") - out-file))) - (error "SVG file produced but HTML file requested"))) - ((file-exists-p (concat (file-name-sans-extension tex-file) ".html")) - (if (string-suffix-p ".html" out-file) - (shell-command "mv %s %s" - (concat (file-name-sans-extension tex-file) - ".html") - out-file) - (error "HTML file produced but SVG file requested"))))) + (when (file-exists-p (concat (file-name-sans-extension tex-file) ".html")) + (shell-command "mv %s %s" + (concat (file-name-sans-extension tex-file) + ".html") + out-file))) + ((string= "svg" extension) + (org-create-formula-image + body out-file org-format-latex-options nil 'dvisvgm)) ((or (string= "pdf" extension) imagemagick) (with-temp-file tex-file (require 'ox-latex) -- 2.22.0