org-latex-preview: Simplify color formatting

* lisp/org-latex-preview.el (org-latex-preview--format-color,
org-latex-preview--normalize-color): Use three decimal places, and
remove the now-obsolete `org-latex-preview--normalize-color'.

* lisp/org-compat.el (org-normalize-color): With the removal of the
`org-latex-preview--normalize-color' alias, mark `org-normalize-color'
as obsolete.
This commit is contained in:
TEC 2024-01-05 15:23:59 +08:00
parent b37062d4a8
commit 40d8b3acea
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
2 changed files with 10 additions and 9 deletions

View File

@ -704,8 +704,6 @@ This constant, for example, makes the below code not err:
'org-latex-color-format 'org-latex-preview--format-color "9.7") 'org-latex-color-format 'org-latex-preview--format-color "9.7")
(define-obsolete-function-alias (define-obsolete-function-alias
'org-latex-color 'org-latex-preview--attr-color "9.7") 'org-latex-color 'org-latex-preview--attr-color "9.7")
(define-obsolete-function-alias
'org-normalize-color 'org-latex-preview--normalize-color "9.7")
;; MathML related functions from org-latex-preview.el ;; MathML related functions from org-latex-preview.el
(define-obsolete-variable-alias (define-obsolete-variable-alias
'org-latex-to-mathml-jar-file 'org-mathml-converter-jar-file "9.7") 'org-latex-to-mathml-jar-file 'org-mathml-converter-jar-file "9.7")
@ -760,6 +758,12 @@ This constant, for example, makes the below code not err:
(make-obsolete (make-obsolete
'org-dvipng-color-format "to be removed" "9.7") 'org-dvipng-color-format "to be removed" "9.7")
;; FIXME: Unused; obsoleted; to be removed.
(defun org-normalize-color (value)
"Return string to be used as color value for an RGB component."
(format "%g" (/ value 65535.0)))
(make-obsolete 'org-normalize-color "to be removed" "9.7")
;; FIXME: Unused; obsoleted; to be removed. ;; FIXME: Unused; obsoleted; to be removed.
(defcustom org-preview-latex-image-directory "ltximg/" (defcustom org-preview-latex-image-directory "ltximg/"
"Path to store latex preview images. "Path to store latex preview images.

View File

@ -2397,14 +2397,11 @@ used it can be worth storing the results to avoid re-computing.")
"Convert COLOR-NAME to a RGB color value." "Convert COLOR-NAME to a RGB color value."
(or (alist-get color-name org-latex-preview--format-color-cache nil nil #'equal) (or (alist-get color-name org-latex-preview--format-color-cache nil nil #'equal)
(cdar (push (cons color-name (cdar (push (cons color-name
(apply #'format "%s,%s,%s" (apply #'format "%.3f,%.3f,%.3f"
(mapcar 'org-latex-preview--normalize-color (mapcar
(color-values color-name)))) (lambda (v) (/ v 65535.0))
(color-values color-name))))
org-latex-preview--format-color-cache)))) org-latex-preview--format-color-cache))))
(defun org-latex-preview--normalize-color (value)
"Return string to be used as color value for an RGB component."
(format "%g" (/ value 65535.0)))
(provide 'org-latex-preview) (provide 'org-latex-preview)
;;; org-latex-preview.el ends here ;;; org-latex-preview.el ends here