From 8ccc93eae16321004f55d0a485875d4038777d7e Mon Sep 17 00:00:00 2001 From: TEC Date: Wed, 1 Mar 2023 00:42:31 +0800 Subject: [PATCH] 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. --- lisp/org-latex-preview.el | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lisp/org-latex-preview.el b/lisp/org-latex-preview.el index 21cc46c02..629d11bac 100644 --- a/lisp/org-latex-preview.el +++ b/lisp/org-latex-preview.el @@ -371,6 +371,13 @@ indeed LaTeX fragments/environments.") '(org-indent) "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) "Build an overlay between BEG and END." (let (ov) @@ -1072,7 +1079,10 @@ is either the substring between BEG and END or (when provided) VALUE." :number number :continue-color (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))) (org-latex-preview--update-overlay (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 ;; the display of errors. (delete-file path) - (when (re-search-forward "