org.el (org-create-formula-image): Fix ignored background color

* lisp/org.el (org-preview-latex-process-alist): add a
`:transparent-image-converter' property for `dvipng'.
(org-create-formula-image): If available, use
`:transparent-image-converter' when no background color is set.
This commit is contained in:
Sébastien Miquel 2021-05-23 22:07:25 +02:00 committed by Bastien
parent 55cf527375
commit 10139c86bc
1 changed files with 11 additions and 3 deletions

View File

@ -3324,7 +3324,9 @@ All available processes and theirs documents can be found in
:image-output-type "png" :image-output-type "png"
:image-size-adjust (1.0 . 1.0) :image-size-adjust (1.0 . 1.0)
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f") :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
:image-converter ("dvipng -D %D -T tight -bg Transparent -o %O %f")) :image-converter ("dvipng -D %D -T tight -o %O %f")
:transparent-image-converter
("dvipng -D %D -T tight -bg Transparent -o %O %f"))
(dvisvgm (dvisvgm
:programs ("latex" "dvisvgm") :programs ("latex" "dvisvgm")
:description "dvi > svg" :description "dvi > svg"
@ -3379,6 +3381,9 @@ PROPERTIES accepts the following attributes:
given to the shell and supports any of the following given to the shell and supports any of the following
place-holders defined below. place-holders defined below.
If set, :transparent-image-converter is used instead of :image-converter to
convert an image when the background color is nil or \"Transparent\".
Place-holders used by `:image-converter' and `:latex-compiler': Place-holders used by `:image-converter' and `:latex-compiler':
%f input file name %f input file name
@ -16303,7 +16308,6 @@ a HTML file."
org-format-latex-header org-format-latex-header
'snippet))) 'snippet)))
(latex-compiler (plist-get processing-info :latex-compiler)) (latex-compiler (plist-get processing-info :latex-compiler))
(image-converter (plist-get processing-info :image-converter))
(tmpdir temporary-file-directory) (tmpdir temporary-file-directory)
(texfilebase (make-temp-name (texfilebase (make-temp-name
(expand-file-name "orgtex" tmpdir))) (expand-file-name "orgtex" tmpdir)))
@ -16317,7 +16321,11 @@ a HTML file."
"Black")) "Black"))
(bg (or (plist-get options (if buffer :background :html-background)) (bg (or (plist-get options (if buffer :background :html-background))
"Transparent")) "Transparent"))
(log-buf (get-buffer-create "*Org Preview LaTeX Output*")) (image-converter
(or (and (string= bg "Transparent")
(plist-get processing-info :transparent-image-converter))
(plist-get processing-info :image-converter)))
(log-buf (get-buffer-create "*Org Preview LaTeX Output*"))
(resize-mini-windows nil)) ;Fix Emacs flicker when creating image. (resize-mini-windows nil)) ;Fix Emacs flicker when creating image.
(dolist (program programs) (dolist (program programs)
(org-check-external-command program error-message)) (org-check-external-command program error-message))