Function: mhtml-ts-mode--colorize-css-value
mhtml-ts-mode--colorize-css-value is a byte-compiled function defined
in mhtml-ts-mode.el.gz.
Signature
(mhtml-ts-mode--colorize-css-value NODE OVERRIDE START END &rest _)
Documentation
Colorize CSS property value like css--fontify-region.
For NODE, OVERRIDE, START, and END, see treesit-font-lock-rules.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/mhtml-ts-mode.el.gz
;; Custom font-lock function that's used to apply color to css color
;; The signature of the function should be conforming to signature
;; QUERY-SPEC required by `treesit-font-lock-rules'.
(defun mhtml-ts-mode--colorize-css-value (node override start end &rest _)
"Colorize CSS property value like `css--fontify-region'.
For NODE, OVERRIDE, START, and END, see `treesit-font-lock-rules'."
(let ((node-start (treesit-node-start node))
(node-end (treesit-node-end node)))
(treesit-fontify-with-override
node-start node-end
'font-lock-variable-name-face
override start end)
;; apply color if required
(when-let* ((ok (and mhtml-ts-mode-css-fontify-colors
(member (treesit-node-type node) '("plain_value" "color_value"))))
(color (css--compute-color start (treesit-node-text node t))))
(with-silent-modifications
(add-text-properties
node-start node-end
(list 'face (list :background color
:foreground (readable-foreground-color
color)
:box '(:line-width -1))))))))