Function: js-jsx--syntax-propertize-tag-text
js-jsx--syntax-propertize-tag-text is a byte-compiled function defined
in js.el.gz.
Signature
(js-jsx--syntax-propertize-tag-text END)
Documentation
Determine if JSXText is before END and propertize it.
Text within an open/close tag pair may be JSXText. Temporarily interrupt JSXText by JSXExpressionContainers, and terminate JSXText when another JSXBoundaryElement is encountered. Despite terminations, all JSXText will be identified once all the JSXBoundaryElements within an outermost JSXElement’s tree have been propertized.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
;; In order to respect the end boundary `syntax-propertize-function'
;; sets, care is taken in the following functions to abort parsing
;; whenever that boundary is reached.
(defun js-jsx--syntax-propertize-tag-text (end)
"Determine if JSXText is before END and propertize it.
Text within an open/close tag pair may be JSXText. Temporarily
interrupt JSXText by JSXExpressionContainers, and terminate
JSXText when another JSXBoundaryElement is encountered. Despite
terminations, all JSXText will be identified once all the
JSXBoundaryElements within an outermost JSXElement’s tree have
been propertized."
(let ((text-beg (point))
forward-sexp-function) ; Use Lisp version.
(catch 'stop
(while (re-search-forward "[{<]" end t)
(js-jsx--text-range text-beg (1- (point)))
(cond
((= (char-before) ?{)
(let (expr-beg expr-end)
(condition-case nil
(save-excursion
(backward-char)
(setq expr-beg (point))
(forward-sexp)
(setq expr-end (point)))
(scan-error nil))
;; Recursively propertize the JSXExpressionContainer’s
;; (possibly-incomplete) expression.
(js-syntax-propertize (1+ expr-beg) (if expr-end (min (1- expr-end) end) end))
;; Ensure future propertization beginning from within the
;; (possibly-incomplete) expression can determine JSXText
;; context from earlier lines.
(put-text-property expr-beg (1+ expr-beg) 'js-jsx-expr (or expr-end end)) ; font-lock
(put-text-property expr-beg (if expr-end (min expr-end end) end) 'syntax-multiline t) ; syntax-propertize
;; Exit the JSXExpressionContainer if that’s possible,
;; else move to the end of the propertized area.
(goto-char (if expr-end (min expr-end end) end))))
((= (char-before) ?<)
(backward-char) ; Ensure the next tag can be propertized.
(throw 'stop nil)))
(setq text-beg (point))))))