Function: htmlize-face-css-name

htmlize-face-css-name is a byte-compiled function defined in htmlize.el.

Signature

(htmlize-face-css-name FACE)

Source Code

;; Defined in ~/.emacs.d/elpa/htmlize-20250724.1703/htmlize.el
(defun htmlize-face-css-name (face)
  ;; Generate the css-name property for the given face.  Emacs places
  ;; no restrictions on the names of symbols that represent faces --
  ;; any characters may be in the name, even control chars.  We try
  ;; hard to beat the face name into shape, both esthetically and
  ;; according to CSS1 specs.
  (let ((name (downcase (symbol-name face))))
    (when (string-match "\\`font-lock-" name)
      ;; font-lock-FOO-face -> FOO.
      (setq name (replace-match "" t t name)))
    (when (string-match "-face\\'" name)
      ;; Drop the redundant "-face" suffix.
      (setq name (replace-match "" t t name)))
    (while (string-match "[^-a-zA-Z0-9]" name)
      ;; Drop the non-alphanumerics.
      (setq name (replace-match "X" t t name)))
    (when (string-match "\\`[-0-9]" name)
      ;; CSS identifiers may not start with a digit.
      (setq name (concat "X" name)))
    ;; After these transformations, the face could come out empty.
    (when (equal name "")
      (setq name "face"))
    ;; Apply the prefix.
    (concat htmlize-css-name-prefix name)))