forked from mirrors/org-mode
org-latex-preview: Use stand-in color for SVG fg
* lisp/org-latex-preview.el (org-latex-preview--svg-make-fg-currentColor, org-latex-preview-place): Instead of guessing the SVG foreground to be the first color seen, set a static stand-in color that is unlikely to occur organically.
This commit is contained in:
parent
13888aeeb3
commit
8ccc93eae1
|
@ -371,6 +371,13 @@ indeed LaTeX fragments/environments.")
|
||||||
'(org-indent)
|
'(org-indent)
|
||||||
"Faces that should not affect the color of preview overlays.")
|
"Faces that should not affect the color of preview overlays.")
|
||||||
|
|
||||||
|
(defconst org-latex-preview--svg-fg-standin "#000001"
|
||||||
|
"Hex color that is used as a stand-in for the current color.
|
||||||
|
The entire purpose of this is to be replaced by \"currentColor\"
|
||||||
|
in `org-latex-preview--svg-make-fg-currentColor', and so it
|
||||||
|
should be a color that is extremely likely not otherwise found in
|
||||||
|
the image.")
|
||||||
|
|
||||||
(defun org-latex-preview--ensure-overlay (beg end)
|
(defun org-latex-preview--ensure-overlay (beg end)
|
||||||
"Build an overlay between BEG and END."
|
"Build an overlay between BEG and END."
|
||||||
(let (ov)
|
(let (ov)
|
||||||
|
@ -1072,7 +1079,10 @@ is either the substring between BEG and END or (when provided) VALUE."
|
||||||
:number number
|
:number number
|
||||||
:continue-color
|
:continue-color
|
||||||
(and (equal prev-bg bg)
|
(and (equal prev-bg bg)
|
||||||
(equal prev-fg fg))))))
|
(equal prev-fg fg)))
|
||||||
|
(and (eq processing-type 'dvisvgm)
|
||||||
|
(list :foreground
|
||||||
|
org-latex-preview--svg-fg-standin)))))
|
||||||
(if-let ((path-info (org-latex-preview--get-cached hash)))
|
(if-let ((path-info (org-latex-preview--get-cached hash)))
|
||||||
(org-latex-preview--update-overlay
|
(org-latex-preview--update-overlay
|
||||||
(org-latex-preview--ensure-overlay beg end)
|
(org-latex-preview--ensure-overlay beg end)
|
||||||
|
@ -1896,12 +1906,9 @@ tests with the output of dvisvgm."
|
||||||
;; This also works better with other parts of the system, such as
|
;; This also works better with other parts of the system, such as
|
||||||
;; the display of errors.
|
;; the display of errors.
|
||||||
(delete-file path)
|
(delete-file path)
|
||||||
(when (re-search-forward "<g fill='\\(#[0-9a-f]\\{6\\}\\)'" nil t)
|
(while (search-forward org-latex-preview--svg-fg-standin nil t)
|
||||||
(let* ((same-color (format "\\(?:fill\\|stroke\\)='\\(%s\\)'" (match-string 1))))
|
(replace-match "currentColor" t t))
|
||||||
(replace-match "currentColor" t t nil 1)
|
(write-region nil nil path nil 0))))))
|
||||||
(while (re-search-forward same-color nil t)
|
|
||||||
(replace-match "currentColor" t t nil 1)))
|
|
||||||
(write-region nil nil path nil 0)))))))
|
|
||||||
|
|
||||||
(defun org-latex-preview--dvipng-filter (_proc _string extended-info)
|
(defun org-latex-preview--dvipng-filter (_proc _string extended-info)
|
||||||
"Look for newly created images in the dvipng stdout buffer.
|
"Look for newly created images in the dvipng stdout buffer.
|
||||||
|
|
Loading…
Reference in New Issue