Function: htmlize-attrlist-to-fstruct

htmlize-attrlist-to-fstruct is a byte-compiled function defined in htmlize.el.

Signature

(htmlize-attrlist-to-fstruct ATTRLIST &optional NAME)

Source Code

;; Defined in ~/.emacs.d/elpa/htmlize-20250724.1703/htmlize.el
;; GNU Emacs 20+ supports attribute lists in `face' properties.  For
;; example, you can use `(:foreground "red" :weight bold)' as an
;; overlay's "face", or you can even use a list of such lists, etc.
;; We call those "attrlists".
;;
;; htmlize supports attrlist by converting them to fstructs, the same
;; as with regular faces.

(defun htmlize-attrlist-to-fstruct (attrlist &optional name)
  ;; Like htmlize-face-to-fstruct, but accepts an ATTRLIST as input.
  (let ((fstruct (make-htmlize-fstruct)))
    (cond ((eq (car attrlist) 'foreground-color)
           ;; ATTRLIST is (foreground-color . COLOR)
           (setf (htmlize-fstruct-foreground fstruct)
                 (htmlize-color-to-rgb (cdr attrlist))))
          ((eq (car attrlist) 'background-color)
           ;; ATTRLIST is (background-color . COLOR)
           (setf (htmlize-fstruct-background fstruct)
                 (htmlize-color-to-rgb (cdr attrlist))))
          (t
           ;; ATTRLIST is a plist.
           (while attrlist
             (let ((attr (pop attrlist))
                   (value (pop attrlist)))
               (when (and value (not (eq value 'unspecified)))
                 (htmlize-face-set-from-keyword-attr fstruct attr value))))))
    (setf (htmlize-fstruct-css-name fstruct) (or name "custom"))
    fstruct))