Function: web-mode-element-contract
web-mode-element-contract is an interactive and natively compiled
function defined in web-mode.el.
Signature
(web-mode-element-contract)
Documentation
Flatten elements.
Key Bindings
web-mode-map C-c C-e -
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-element-contract ()
"Flatten elements."
(interactive)
(let (beg end (continue t) replacement boundaries)
(cond
((or (not (get-text-property (point) 'tag-type))
(not (member (get-text-property (point) 'tag-type) '(start end))))
(web-mode-element-parent))
((eq (get-text-property (point) 'tag-type) 'end)
(web-mode-tag-match))
) ;cond
(setq boundaries (web-mode-element-boundaries (point)))
(setq beg (car (car boundaries))
end (cdr (cdr boundaries)))
(goto-char beg)
;;(message "beg(%S) end(%S)" beg end)
(while continue
(if (or (not (re-search-forward ">[ \t\r\n]+\\|[ \t\r\n]+<"))
(>= (point) end))
(setq continue nil)
(setq end (+ (- end (length (match-string-no-properties 0))) 1))
(setq replacement (if (eq (char-before) ?\<) "<" ">"))
(replace-match replacement nil nil)
;;(message "end(%S)" end))
)
) ;while
(goto-char beg)
))