Function: web-mode-block-scan
web-mode-block-scan is a natively compiled function defined in
web-mode.el.
Signature
(web-mode-block-scan BLOCK-BEG BLOCK-END)
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-block-scan (block-beg block-end)
(let (sub1 sub2 sub3 regexp token-type)
;;(message "block-beg=%S block-end=%S" block-beg block-end)
;;(remove-text-properties block-beg block-end web-mode-scan-properties)
(goto-char block-beg)
(cond
((>= (point-max) (+ block-beg 3))
(setq sub3 (buffer-substring-no-properties block-beg (+ block-beg 3))
sub2 (buffer-substring-no-properties block-beg (+ block-beg 2))
sub1 (buffer-substring-no-properties block-beg (+ block-beg 1)))
)
((>= (point-max) (+ block-beg 2))
(setq sub3 (buffer-substring-no-properties block-beg (+ block-beg 2))
sub2 (buffer-substring-no-properties block-beg (+ block-beg 2))
sub1 (buffer-substring-no-properties block-beg (+ block-beg 1)))
)
(t
(setq sub1 (buffer-substring-no-properties block-beg (+ block-beg 1)))
(setq sub2 sub1
sub3 sub1)
)
)
(cond
((member web-mode-engine '("php" "lsp" "python" "web2py" "mason"))
(setq regexp web-mode-engine-token-regexp))
((string= web-mode-engine "mako")
(cond
((string= sub2 "##")
(setq token-type 'comment)
)
(t
(setq regexp web-mode-engine-token-regexp))
)
) ;mako
((string= web-mode-engine "django")
(cond
((member sub2 '("{{" "{%"))
(setq regexp "\"\\|'"))
((string= sub2 "{#")
(setq token-type 'comment))
)
) ;django
((string= web-mode-engine "ctemplate")
(cond
((string= sub3 "{{!")
(setq token-type 'comment))
((member sub2 '("{{"))
)
)
) ;ctemplate
((string= web-mode-engine "antlers")
(cond
((string= sub3 "{{#")
(setq token-type 'comment))
((member sub2 '("{{"))
)
)
) ;antlers
((string= web-mode-engine "astro")
(setq regexp "\"\\|'")
) ;astro
((string= web-mode-engine "go")
(cond
((string= sub3 "{{/")
(setq token-type 'comment))
((string= sub2 "{{")
(setq regexp "\"\\|'"))
)
) ;go
((string= web-mode-engine "hero")
(cond
((string= sub3 "<%#")
(setq token-type 'comment))
(t
(setq regexp "\"\\|'"))
)
) ;hero
((string= web-mode-engine "razor")
(cond
((string= sub2 "@*")
(setq token-type 'comment))
(t
(setq regexp "//\\|@\\*\\|\"\\|'"))
)
) ;razor
((string= web-mode-engine "blade")
(cond
((string= sub3 "{{-")
(setq token-type 'comment))
(t
(setq regexp "\"\\|'"))
)
) ;blade
((string= web-mode-engine "cl-emb")
(cond
((string= sub3 "<%#")
(setq token-type 'comment))
(t
(setq regexp "\"\\|'"))
)
) ;cl-emb
((string= web-mode-engine "artanis")
(cond
((string= sub3 "<%;")
(setq token-type 'comment))
((string= sub3 "<%#|")
(setq token-type 'comment))
(t
(setq regexp "\""))
)
) ;artanis
((string= web-mode-engine "elixir")
(cond
((string= sub3 "<%#")
(setq token-type 'comment))
(t
(setq regexp "\"\\|'"))
)
) ;elixir
((string= web-mode-engine "mojolicious")
(cond
((or (string= sub2 "%#") (string= sub3 "<%#"))
(setq token-type 'comment))
(t
(setq regexp "\"\\|'"))
)
) ;mojolicious
((string= web-mode-engine "velocity")
(cond
((member sub2 '("##" "#*"))
(setq token-type 'comment))
((member sub1 '("$" "#"))
(setq regexp "\"\\|'"))
)
) ;velocity
((string= web-mode-engine "jsp")
(cond
((string= sub3 "<%-")
(setq token-type 'comment))
((string= sub3 "<%@")
(setq regexp "/\\*"))
((member sub2 '("${" "#{"))
(setq regexp "\"\\|'"))
((string= sub2 "<%")
(setq regexp "//\\|/\\*\\|\"\\|'"))
)
) ;jsp
((string= web-mode-engine "clip")
(setq regexp nil)
) ;clip
((string= web-mode-engine "perl")
(setq regexp nil)
) ;perl
((and (string= web-mode-engine "asp")
(string= sub2 "<%"))
(setq regexp "//\\|/\\*\\|\"\\|'")
) ;asp
((string= web-mode-engine "aspx")
(cond
((string= sub3 "<%-")
(setq token-type 'comment))
((string= sub3 "<%@")
(setq regexp "/\\*"))
((string= sub3 "<%$")
(setq regexp "\"\\|'"))
(t
(setq regexp "//\\|/\\*\\|\"\\|'"))
)
) ;aspx
((string= web-mode-engine "freemarker")
(cond
((member sub3 '("<#-" "[#-"))
(setq token-type 'comment))
((member sub2 '("${" "#{"))
(setq regexp "\"\\|'"))
((or (member sub2 '("<@" "[@" "<#" "[#"))
(member sub3 '("</@" "[/@" "</#" "[/#")))
(setq regexp "\"\\|'"))
)
) ;freemarker
((member web-mode-engine '("ejs" "erb"))
(cond
((string= sub3 "<%#")
(setq token-type 'comment))
(t
(setq regexp web-mode-engine-token-regexp))
)
) ;erb
((string= web-mode-engine "template-toolkit")
(cond
((member sub3 '("[%#" "%%#"))
(setq token-type 'comment))
(t
(setq regexp "#\\|\"\\|'"))
)
) ;template-toolkit
((string= web-mode-engine "underscore")
(setq regexp "/\\*\\|\"\\|'")
) ;underscore
((string= web-mode-engine "angular")
(setq regexp "#\\|\"\\|'")) ;angular
((string= web-mode-engine "vue")
) ;vue
((string= web-mode-engine "smarty")
(cond
((string= sub2 "{*")
(setq token-type 'comment))
(t
(setq regexp "\"\\|'")))
) ;smarty
((string= web-mode-engine "xoops")
(cond
((string= sub3 "<{*")
(setq token-type 'comment))
(t
(setq regexp "\"\\|'")))
) ;xoops
((string= web-mode-engine "spip")
(if (string= (buffer-substring-no-properties
block-beg (+ block-beg 7))
"[(#REM)")
(setq token-type 'comment
regexp "\\]")))
((string= web-mode-engine "dust")
(cond
((string= sub2 "{!")
(setq token-type 'comment))
(t
(setq regexp "\"\\|'"))
)
) ;dust
((string= web-mode-engine "expressionengine")
(cond
((string= sub2 "{!")
(setq token-type 'comment))
(t
(setq regexp "\"\\|'")))
) ;expressionengine
((string= web-mode-engine "closure")
(cond
((member sub2 '("/*" "//"))
(setq token-type 'comment))
(t
(setq regexp "\"\\|'"))
)
) ;closure
((string= web-mode-engine "svelte")
) ;svelte
) ;cond
(cond
(token-type
(put-text-property block-beg block-end 'block-token token-type))
((and regexp
(> (- block-end block-beg) 6))
(web-mode-block-tokenize
(web-mode-block-code-beginning-position block-beg)
(web-mode-block-code-end-position block-beg)
regexp)
)
) ;cond
))