From 7ff95cafdcf85b5048e5ec51f5fd51a176e3d97e Mon Sep 17 00:00:00 2001 From: smihica Date: Tue, 12 Mar 2013 10:50:02 +0900 Subject: Created emmet branch. --- zencoding-mode.el | 349 ++---------------------------------------------------- 1 file changed, 7 insertions(+), 342 deletions(-) (limited to 'zencoding-mode.el') diff --git a/zencoding-mode.el b/zencoding-mode.el index 824b15c..370d570 100644 --- a/zencoding-mode.el +++ b/zencoding-mode.el @@ -1,3 +1,4 @@ + ;;; zencoding-mode.el --- Unfold CSS-selector-like expressions to markup ;; Copyright (C) 2009, Chris Done @@ -41,6 +42,8 @@ ;; (add-to-list 'load-path "~/Emacs/zencoding/") ;; (require 'zencoding-mode) ;; (add-hook 'sgml-mode-hook 'zencoding-mode) ;; Auto-start on any markup modes +;; (add-hook 'html-mode-hook 'zencoding-mode) +;; (add-hook 'css-mode-hook 'zencoding-mode) ;; ;; Enable the minor mode with M-x zencoding-mode. ;; @@ -114,9 +117,8 @@ (mapcar (lambda (ref) (match-string ref string)) (if (sequencep refs) refs (list refs))) nil)) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Zen coding parsers +;; XML abbrev (defun zencoding-expr (input) "Parse a zen coding expression with optional filters." @@ -709,346 +711,9 @@ (replace-regexp-in-string "\n" "\n " (concat "\n" text)) nil)) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Test-cases - -(defun zencoding-test-cases () - (let ((tests '(;; Tags - ("a" "") - ("a.x" "") - ("a#q.x" "") - ("a#q.x.y.z" "") - ("#q" "
" - "
") - (".x" "
" - "
") - ("#q.x" "
" - "
") - ("#q.x.y.z" "
" - "
") - ;; Empty tags - ("a/" "") - ("a/.x" "") - ("a/#q.x" "") - ("a/#q.x.y.z" "") - ;; Self-closing tags - ("input type=text" "") - ("img" "") - ("img>metadata/*2" "" - " " - " " - "") - ;; Siblings - ("a+b" "" - "") - ("a+b+c" "" - "" - "") - ("a.x+b" "" - "") - ("a#q.x+b" "" - "") - ("a#q.x.y.z+b" "" - "") - ("a#q.x.y.z+b#p.l.m.n" "" - "") - ;; Tag expansion - ("table+" "" - " " - " " - " " - "
" - "
") - ("dl+" "
" - "
" - "
" - "
") - ("ul+" "") - ("ul++ol+" "" - "
    " - "
  1. " - "
") - ("ul#q.x.y m=l+" "") - ;; Parent > child - ("a>b" "") - ("a>b>c" "") - ("a.x>b" "") - ("a#q.x>b" "") - ("a#q.x.y.z>b" "") - ("a#q.x.y.z>b#p.l.m.n" "") - ("#q>.x" "
" - "
" - "
" - "
") - ("a>b+c" "" - " " - " " - "") - ("a>b+c>d" "" - " " - " " - "") - ;; Multiplication - ("a*1" "") - ("a*2" "" - "") - ("a/*2" "" - "") - ("a*2+b*2" "" - "" - "" - "") - ("a*2>b*2" "" - " " - " " - "" - "" - " " - " " - "") - ("a>b*2" "" - " " - " " - "") - ("a#q.x>b#q.x*2" "" - " " - " " - "") - ("a#q.x>b/#q.x*2" "" - " " - " " - "") - ;; Numbering - ("a.$x*3" "" - "" - "") - ("ul>li.item$*3" "
    " - "
  • " - "
  • " - "
  • " - "
") - ("ul>li.item$$$*3" "
    " - "
  • " - "
  • " - "
  • " - "
") - ("ul>li.item$@-*2" "
    " - "
  • " - "
  • " - "
") - ("ul>li.item$@-1000*2" "
    " - "
  • " - "
  • " - "
") - ("a.$*2>b.$$@-*3" "" - " " - " " - " " - "" - "" - " " - " " - " " - "") - ("(div>(a#id$$*2)+b.c$@-3+c#d$)*2" - "
" - " " - " " - " " - " " - "
" - "
" - " " - " " - " " - " " - "
") - ("a:b$$$-c$$@-:d$@-3-e$$@100/#b.c$*3" - "" - "" - "") - ("ul>li.item${name: item$ price: $\\$}*3" - "
    " - "
  • name: item1 price: 1$
  • " - "
  • name: item2 price: 2$
  • " - "
  • name: item3 price: 3$
  • " - "
") - ;; Properties - ("a x" "") - ("a x=" "") - ("a x=\"\"" "") - ("a x=y" "") - ("a x=\"y\"" "") - ("a x=\"()\"" "") - ("a x m" "") - ("a x= m=\"\"" "") - ("a x=y m=l" "") - ("a/ x=y m=l" "") - ("a#foo x=y m=l" "") - ("a.foo x=y m=l" "") - ("a#foo.bar.mu x=y m=l" "") - ("a/#foo.bar.mu x=y m=l" "") - ("a x=y+b" "" - "") - ("a x=y+b x=y" "" - "") - ("a x=y>b" "") - ("a x=y>b x=y" "") - ("a x=y>b x=y+c x=y" "" - " " - " " - "") - ;; Parentheses - ("(a)" "") - ("(a)+(b)" "" - "") - ("a>(b)" "") - ("(a>b)>c" "") - ("(a>b)+c" "" - "") - ("z+(a>b)+c+k" "" - "" - "" - "") - ("(a)*2" "" - "") - ("((a)*2)" "" - "") - ("((a))*2" "" - "") - ("(a>b)*2" "" - "") - ("(a+b)*2" "" - "" - "" - "") - ;; Text - ("a{Click me}" "Click me") - ("a>{Click me}*3" "" - " Click me" - " Click me" - " Click me" - "") - ("a{click}+b{here}" "click" - "here") - ("a>{click}+b{here}" "" - " click" - " here" - "") - ("p>{Click }+a{here}+{ to continue}" - "

" - " Click " - " here" - " to continue" - "

") - ("p{Click }+a{here}+{ to continue}" - "

" - " Click " - "

" - "here" - " to continue") - ;; Climb-up - ("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" "" - "" - "") - ("#a>.b|c" "" - "
" - " " - "
" - "
" - " " - "
" - "") - ;; Filter: HAML - ("a|haml" "%a") - ("a#q.x.y.z|haml" "%a#q.x.y.z") - ("a#q.x x=y m=l|haml" "%a#q.x{:x => \"y\", :m => \"l\"}") - ("div|haml" "%div") - ("div.footer|haml" ".footer") - (".footer|haml" ".footer") - ("p>{This is haml}*2+a href=#+br|haml" - "%p" - " This is haml" - " This is haml" - " %a{:href => \"#\"}" - " %br") - - ;; Filter: Hiccup - ("a|hic" "[:a]") - ("a#q.x.y.z|hic" "[:a#q.x.y.z]") - ("a#q.x x=y m=l|hic" "[:a#q.x {:x \"y\", :m \"l\"}]") - (".footer|hic" "[:div.footer]") - ("p>a href=#+br|hic" "[:p" - " [:a {:href \"#\"}]" - " [:br]]") - ("#q>(a*2>b{x})+p>{m}+b|hic" - "[:div#q" - " [:a [:b \"x\"]]" - " [:a [:b \"x\"]]" - " [:p" - " \"m\"" - " [:b]]]") - ;; Filter: escape - ("script src="|e" "<script src=\"&quot;\">" - "</script>") - ))) - (mapc (lambda (input) - (let ((expected (mapconcat 'identity (cdr input) "\n")) - (actual (zencoding-transform (car (zencoding-expr (car input)))))) - (if (not (equal expected actual)) - (error (concat "Assertion " (car input) " failed:" - expected - " == " - actual))))) - tests) - (concat (number-to-string (length tests)) " tests performed. All OK."))) - +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; CSS abbrev: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Zencoding minor mode -- cgit v1.2.3