From 9d93c9d526f0c5088b4767a628d006d12f01555f Mon Sep 17 00:00:00 2001 From: smihica Date: Fri, 15 Feb 2013 00:50:30 +0900 Subject: Added Climb-up:^ syntax support. (http://docs.emmet.io/abbreviations/syntax/#climb-up-) --- zencoding-mode.el | 64 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 7 deletions(-) (limited to 'zencoding-mode.el') diff --git a/zencoding-mode.el b/zencoding-mode.el index 218d738..561d597 100644 --- a/zencoding-mode.el +++ b/zencoding-mode.el @@ -292,18 +292,23 @@ (defun zencoding-parent-child (input) "Parse an tag>e expression, where `n' is an tag and `e' is any expression." + (defun listing (parents child input) + `((list ,(mapcar (lambda (parent) + `(parent-child ,parent ,child)) + parents)) . ,input)) (zencoding-run zencoding-multiplier (let* ((items (cadr expr)) (rest (zencoding-child-sans expr input))) (if (not (eq (car rest) 'error)) (let ((child (car rest)) (input (cdr rest))) - (cons (cons 'list - (cons (mapcar (lambda (parent) - `(parent-child ,parent ,child)) - items) - nil)) - input)) + + (zencoding-aif (zencoding-regex "^" input '(0 1)) + (let ((input (elt it 1))) + (zencoding-run zencoding-subexpr + `((sibling ,(car (listing items child "")) ,expr) . ,input) + (listing items child input))) + (listing items child input))) '(error "expected child"))) (zencoding-run zencoding-tag (zencoding-child expr input) @@ -319,7 +324,12 @@ (zencoding-parse ">" 1 ">" (zencoding-run zencoding-subexpr (let ((child expr)) - `((parent-child ,parent ,child) . ,input)) + (zencoding-aif (zencoding-regex "^" input '(0 1)) + (let ((input (elt it 1))) + (zencoding-run zencoding-subexpr + `((sibling (parent-child ,parent ,child) ,expr) . ,input) + `((parent-child ,parent ,child) . ,input))) + `((parent-child ,parent ,child) . ,input))) '(error "expected child")))) (defun zencoding-sibling (input) @@ -820,6 +830,46 @@ "

" "here" " to continue") + ;; ClimbUp + ("a>b>c^d" "" + " " + " " + "") + ("a>b>c^^d" "" + "") + ("a*2>b*2>c^d" "" + " " + " " + " " + "" + "" + " " + " " + " " + "") + ("div+a>p>span{foo}+em>b^^^p" + "
" + "
" + "" + "

" + " foo" + " " + "

" + "
" + "

" + "

") + ("div+div>p>span+em^blockquote{foo}" + "
" + "
" + "
" + "

" + " " + " " + "

" + "
" + " foo" + "
" + "
") ;; Filter: comment ("a.b|c" "" "" -- cgit v1.2.3