Function: web-mode-fontify-part
web-mode-fontify-part is a natively compiled function defined in
web-mode.el.
Signature
(web-mode-fontify-part REG-BEG REG-END &optional DEPTH)
Source Code
;; Defined in /nix/store/2qgnz1rp30nzfz6w0apx4kdm14if1bbs-emacs-packages-deps/share/emacs/site-lisp/elpa/web-mode-20260831.219/web-mode.el
(defun web-mode-fontify-part (reg-beg reg-end &optional depth)
(save-excursion
(let (continue token-type face pos beg end string-face comment-face content-type)
;;(message "fontify-part: reg-beg(%S) reg-end(%S)" reg-beg reg-end)
(if (member web-mode-content-type web-mode-part-content-types)
(setq content-type web-mode-content-type)
(setq content-type (symbol-name (get-text-property reg-beg 'part-side))))
;;(message "content-type=%S" content-type)
(unless depth
(when (string= content-type "jsx") (setq depth 0))
)
(setq string-face 'web-mode-part-string-face
comment-face 'web-mode-part-comment-face)
(cond
((member content-type '("javascript" "jsx"))
(setq string-face 'web-mode-javascript-string-face
comment-face 'web-mode-javascript-comment-face)
(web-mode-fontify-region reg-beg reg-end web-mode-javascript-font-lock-keywords))
((string= content-type "json")
(setq string-face 'web-mode-json-string-face
comment-face 'web-mode-json-comment-face)
(web-mode-fontify-region reg-beg reg-end web-mode-javascript-font-lock-keywords))
((string= content-type "css")
(setq string-face 'web-mode-css-string-face
comment-face 'web-mode-css-comment-face)
(web-mode-fontify-css-rules reg-beg reg-end))
((string= content-type "sql")
(web-mode-fontify-region reg-beg reg-end web-mode-sql-font-lock-keywords))
((string= content-type "stylus")
(web-mode-fontify-region reg-beg reg-end web-mode-stylus-font-lock-keywords))
((string= content-type "sass")
(web-mode-fontify-region reg-beg reg-end web-mode-sass-font-lock-keywords))
((string= content-type "pug")
(web-mode-fontify-region reg-beg reg-end web-mode-pug-font-lock-keywords))
((string= content-type "markdown")
(web-mode-fontify-region reg-beg reg-end web-mode-markdown-font-lock-keywords))
((string= content-type "ruby")
(web-mode-fontify-region reg-beg reg-end web-mode-erb-font-lock-keywords))
((string= content-type "typescript")
(web-mode-fontify-region reg-beg reg-end web-mode-javascript-font-lock-keywords))
) ;cond
(goto-char reg-beg)
;;(when (string= content-type "jsx") (web-mode-fontify-tags reg-beg reg-end))
;;(setq continue (and pos (< pos reg-end)))
(setq continue t
pos reg-beg)
(while continue
(if (get-text-property pos 'part-token)
(setq beg pos)
(setq beg (next-single-property-change pos 'part-token)))
(cond
((or (null beg) (>= beg reg-end))
(setq continue nil
end nil))
((and (eq depth 0) (get-text-property beg 'jsx-depth))
(setq pos (or (next-single-property-change beg 'jsx-depth) (point-max))))
(t
;;(message "%c" (char-after beg))
(setq token-type (get-text-property beg 'part-token))
(setq face (cond
((eq token-type 'string) string-face)
((eq token-type 'comment) comment-face)
((eq token-type 'context) 'web-mode-json-context-face)
((eq token-type 'key) 'web-mode-json-key-face)
(t nil)))
(setq end (or (next-single-property-change beg 'part-token) (point-max))
pos end)
(cond
((or (null end) (> end reg-end))
(setq continue nil
end nil))
(t
(when face
(remove-list-of-text-properties beg end '(face))
(put-text-property beg end 'font-lock-face face))
(cond
((< (- end beg) 6)
)
((eq token-type 'string)
(cond
((and (eq (char-after beg) ?\`)
web-mode-enable-literal-interpolation
(member content-type '("javascript" "jsx" "typescript")))
(web-mode-interpolate-javascript-literal beg end)
)
((and (eq (char-after beg) ?\")
web-mode-enable-string-interpolation
(member content-type '("javascript" "jsx" "typescript")))
(web-mode-interpolate-javascript-string beg end))
) ;cond
) ;case string
((eq token-type 'comment)
(when web-mode-enable-comment-interpolation
(web-mode-interpolate-comment beg end t))
(when web-mode-enable-comment-annotation
(web-mode-annotate-comment beg end))
)
) ;cond
) ;t
) ;cond
) ;t
) ;cond
) ;while
(when (and (string= web-mode-content-type "html") web-mode-enable-part-face)
(font-lock-append-text-property reg-beg reg-end 'face
(cond
((string= content-type "javascript")
'web-mode-script-face)
((string= content-type "css")
'web-mode-style-face)
(t
'web-mode-part-face)))
)
(when (and web-mode-enable-css-colorization (string= content-type "stylus"))
(goto-char reg-beg)
(while (and (re-search-forward "#[0-9a-fA-F]\\{6\\}\\|#[0-9a-fA-F]\\{3\\}\\|rgba?([ ]*\\([[:digit:]]\\{1,3\\}\\)[ ]*,[ ]*\\([[:digit:]]\\{1,3\\}\\)[ ]*,[ ]*\\([[:digit:]]\\{1,3\\}\\)\\(.*?\\))" end t)
(<= (point) reg-end))
(web-mode-colorize (match-beginning 0) (match-end 0))
)
)
(when (and (eq depth 0) (string= content-type "jsx"))
(let (pair elt-beg elt-end exp-beg exp-end exp-depth)
(goto-char reg-beg)
(while (setq pair (web-mode-jsx-element-next reg-end))
;;(message "elt-pair=%S" pair)
(setq elt-beg (car pair)
elt-end (cdr pair))
(remove-list-of-text-properties elt-beg (1+ elt-end) '(face))
(web-mode-fontify-tags elt-beg elt-end 1)
(goto-char elt-beg)
(while (setq pair (web-mode-jsx-expression-next elt-end))
;;(message "exp-pair=%S elt-end=%S" pair elt-end)
(setq exp-beg (car pair)
exp-end (cdr pair))
(when (eq (char-after exp-beg) ?\{)
;;(message "%S : %c %c" exp-beg (char-after (+ exp-beg 1)) (char-after (+ exp-beg 2)))
(cond
;;((and (eq (char-after (+ exp-beg 1)) ?\/) (eq (char-after (+ exp-beg 2)) ?\*))
;; (put-text-property exp-beg (1+ exp-end) 'font-lock-face 'web-mode-part-comment-face)
;; )
(t
(setq exp-depth (get-text-property exp-beg 'jsx-depth))
(remove-list-of-text-properties exp-beg exp-end '(font-lock-face))
(put-text-property exp-beg (1+ exp-beg) 'font-lock-face 'web-mode-block-delimiter-face)
(when (and (eq (get-text-property exp-beg 'tag-attr-beg) 4) (web-mode-looking-at-p "\.\.\." (1+ exp-beg)))
(put-text-property exp-beg (+ exp-beg 4) 'font-lock-face 'web-mode-block-delimiter-face))
(put-text-property exp-end (1+ exp-end) 'font-lock-face 'web-mode-block-delimiter-face)
(web-mode-fontify-tags (1+ exp-beg) exp-end (1+ exp-depth))
(web-mode-fontify-part (1+ exp-beg) exp-end exp-depth)
(web-mode-fontify-region (1+ exp-beg) exp-end web-mode-javascript-font-lock-keywords)
) ;t
) ;cond
) ;when
(goto-char (1+ exp-beg))
) ;while exp
(when (and elt-beg web-mode-jsx-depth-faces)
(let (depth-beg depth-end jsx-face)
(goto-char elt-beg)
(while (setq pair (web-mode-jsx-depth-next reg-end))
;;(message "depth-pair=%S" pair)
(setq depth-beg (car pair)
depth-end (cdr pair)
depth (get-text-property depth-beg 'jsx-depth)
jsx-face (elt web-mode-jsx-depth-faces (1- depth)))
;;(message "%S" jsx-face)
(font-lock-prepend-text-property depth-beg (1+ depth-end) 'face jsx-face)
(goto-char (+ depth-beg 2))
)
) ;let
)
(goto-char (1+ elt-end))
) ;while elt
) ;let
) ;when
) ;let
) ;save-excursion
)