Function: htmlize-make-face-map

htmlize-make-face-map is a byte-compiled function defined in htmlize.el.

Signature

(htmlize-make-face-map FACES)

Source Code

;; Defined in ~/.emacs.d/elpa/htmlize-20250724.1703/htmlize.el
(defun htmlize-make-face-map (faces)
  ;; Return a hash table mapping Emacs faces to htmlize's fstructs.
  ;; The keys are either face symbols or attrlists, so the test
  ;; function must be `equal'.
  (let ((face-map (make-hash-table :test 'equal))
        css-names)
    (dolist (face faces)
      (unless (gethash face face-map)
        ;; Haven't seen FACE yet; convert it to an fstruct and cache
        ;; it.
        (let ((fstruct (htmlize-face-to-fstruct face)))
          (setf (gethash face face-map) fstruct)
          (let* ((css-name (htmlize-fstruct-css-name fstruct))
                 (new-name css-name)
                 (i 0))
            ;; Uniquify the face's css-name by using NAME-1, NAME-2,
            ;; etc.
            (while (member new-name css-names)
              (setq new-name (format "%s-%s" css-name (cl-incf i))))
            (unless (equal new-name css-name)
              (setf (htmlize-fstruct-css-name fstruct) new-name))
            (push new-name css-names)))))
    face-map))