1. The function `org-html-format-latex' requires the `:output-file' property in order to pick a cache dir.
2. The `:output-file' property is only declared in `org-export-to-file'. 3. I know of at least one package that uses `org-export-to-buffer' to export org-to-HTML with latex snippets. 4. The result is the error `wrong-type-argument stringp nil'. My simple solution is using a temp dir, *see attached patch*. Alternatively, one could declare an `:output-file' in `org-export-to-buffer' as well, for example a temp dir. This will handle more backends, not just HTML; however only html/latex and texinfo currently use this property. Best, *Daniel Fleischer*
diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 654e510e4..70ca406ab 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -3109,7 +3109,9 @@ (defun org-html-format-latex (latex-frag processing-type info) (concat (file-name-as-directory org-preview-latex-image-directory) (file-name-sans-extension (file-name-nondirectory bfn))) - cache-dir (file-name-directory (plist-get info :output-file))) + ;; Use either the output file dir or a temp dir + cache-dir (file-name-directory (or (plist-get info :output-file) + (temporary-file-directory)))) ;; Re-create LaTeX environment from original buffer in ;; temporary buffer so that dvipng/imagemagick can properly ;; turn the fragment into an image.
