Function: htmlize-color-to-rgb
htmlize-color-to-rgb is a byte-compiled function defined in
htmlize.el.
Signature
(htmlize-color-to-rgb COLOR)
Source Code
;; Defined in ~/.emacs.d/elpa/htmlize-20250724.1703/htmlize.el
;; Convert COLOR to the #RRGGBB string. If COLOR is already in that
;; format, it's left unchanged.
(defun htmlize-color-to-rgb (color)
(let ((rgb-string nil))
(cond ((null color)
;; Ignore nil COLOR because it means that the face is not
;; specifying any color. Hence (htmlize-color-to-rgb nil)
;; returns nil.
)
((string-match "\\`#[0-9a-fA-F]\\{6\\}" color)
;; The color is already in #rrggbb format.
(setq rgb-string color))
((and htmlize-use-rgb-txt
htmlize-color-rgb-hash)
;; Use of rgb.txt is requested, and it's available on the
;; system. Use it.
(setq rgb-string (gethash (downcase color) htmlize-color-rgb-hash)))
(t
;; We're getting the RGB components from Emacs.
(let ((rgb (mapcar (lambda (arg)
(/ arg 256))
(color-values color))))
(when rgb
(setq rgb-string (apply #'format "#%02x%02x%02x" rgb))))))
;; If RGB-STRING is still nil, it means the color cannot be found,
;; for whatever reason. In that case just punt and return COLOR.
;; Most browsers support a decent set of color names anyway.
(or rgb-string color)))