From 500675ec730dc6dc911cf1c716002ff888ab0eb9 Mon Sep 17 00:00:00 2001 From: Ron Panduwana Date: Tue, 8 Feb 2011 09:34:00 +0700 Subject: Automatically close child-less self-closing tags (eg. br img input) --- zencoding-mode.el | 13 +++++++++++-- 1 file 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/#q.x" "") ("a/#q.x.y.z" "") + ;; Self-closing tags + ("input type=text" "\n") + ("img" "\n") + ("img>metadata/*2" "\n\n\n\n") ;; Siblings ("a+b" "") ("a+b+c" "") -- cgit v1.2.3