Function: tsx-ts--syntax-propertize-captures
tsx-ts--syntax-propertize-captures is a byte-compiled function defined
in typescript-ts-mode.el.gz.
Signature
(tsx-ts--syntax-propertize-captures CAPTURES)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/typescript-ts-mode.el.gz
(defun tsx-ts--syntax-propertize-captures (captures)
(pcase-dolist (`(,name . ,node) captures)
(let ((ns (treesit-node-start node))
(ne (treesit-node-end node)))
(pcase-exhaustive name
('regexp
(let ((syntax (string-to-syntax "\"/")))
(decf ns)
(incf ne)
(put-text-property ns (1+ ns) 'syntax-table syntax)
(put-text-property (1- ne) ne 'syntax-table syntax)))
('jsx
(if (member (treesit-node-type node)
'("jsx_opening_element"
"jsx_closing_element"
"jsx_self_closing_element"))
;; A JSX tag's only real delimiters are its own outermost
;; '<' and '>'. Mark just those two as a matching pair and
;; leave the interior alone: attribute values are '{...}'
;; expressions of ordinary code (possibly with nested JSX)
;; whose brackets must keep their normal syntax so they
;; nest, match and highlight correctly.
(progn
(put-text-property ns (1+ ns)
'syntax-table (string-to-syntax "(>"))
(put-text-property (1- ne) ne
'syntax-table (string-to-syntax ")<")))
;; jsx_text is raw text with no nesting to preserve, so
;; neutralize its balanced-pair characters to punctuation;
;; otherwise stray or unbalanced brackets in the text would
;; confuse syntax-ppss.
(save-excursion
(goto-char ns)
(while (re-search-forward (rx (or "{" "}" "[" "]"
"(" ")" "<" ">"))
ne t)
(put-text-property
(match-beginning 0) (match-end 0)
'syntax-table (string-to-syntax "."))))))))))