diff options
author | Ron Panduwana <panduwana@gmail.com> | 2011-02-08 09:34:00 +0700 |
---|---|---|
committer | Ron Panduwana <panduwana@gmail.com> | 2011-02-08 09:34:00 +0700 |
commit | 500675ec730dc6dc911cf1c716002ff888ab0eb9 (patch) | |
tree | a7e61f30deb02226ab97be0ba5cbe99edaa80fad | |
parent | f345e95a7a842d339507e515843c466d3073b421 (diff) | |
download | emmet-mode-500675ec730dc6dc911cf1c716002ff888ab0eb9.tar.lz emmet-mode-500675ec730dc6dc911cf1c716002ff888ab0eb9.tar.xz emmet-mode-500675ec730dc6dc911cf1c716002ff888ab0eb9.zip |
Automatically close child-less self-closing tags (eg. br img input)
-rw-r--r-- | zencoding-mode.el | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/zencoding-mode.el b/zencoding-mode.el index eb909fd..acc1fa9 100644 --- a/zencoding-mode.el +++ b/zencoding-mode.el @@ -322,6 +322,11 @@ (defvar zencoding-block-tags '("p")) +(defvar zencoding-closed-tags + '("br" + "img" + "input")) + ;; li ;; a ;; em @@ -333,7 +338,7 @@ (defun zencoding-make-tag (tag &optional content) (let* ((name (caar tag)) - (has-body? (cdar tag)) + (has-body? (and (cdar tag) (not (member name zencoding-closed-tags)))) (lf (if (or (member name zencoding-block-tags) @@ -348,7 +353,7 @@ "=\"" (cadr prop) "\"")) (cadr tag))))) (concat lf "<" name props - (if has-body? + (if (or content has-body?) (concat ">" (if content content (if zencoding-leaf-function @@ -391,6 +396,10 @@ ("a/.x" "<a class=\"x\"/>") ("a/#q.x" "<a id=\"q\" class=\"x\"/>") ("a/#q.x.y.z" "<a id=\"q\" class=\"x y z\"/>") + ;; Self-closing tags + ("input type=text" "\n<input type=\"text\"/>") + ("img" "\n<img/>") + ("img>metadata/*2" "\n<img>\n<metadata/>\n<metadata/>\n</img>") ;; Siblings ("a+b" "<a></a><b></b>") ("a+b+c" "<a></a><b></b><c></c>") |