blob: 058e4eda4812f4cb48067fd8f8772e0bbbdd2f2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
# About Zencoding
[Description
here](http://www.456bereastreet.com/archive/200909/write_html_and_css_quicker_with_with_zen_coding/)
and [here](http://mondaybynoon.com/2009/08/17/the-art-of-zen-coding-bringing-snippets-to-a-new-level/).
I’ll quote the blog:
> zen-coding includes an entirely new angle to writing markup, and it
> facilitates the feature by letting you write HTML based on CSS
> selectors. It’s so simple it’s confusing at first. I think it’s best
> explained by doing a quick before and after. If you were to type:
div#name.one.two
> and follow that with the zen-coding plugin keystroke (CMD+E in
TextMate), the plugin will reformat the line as:
<div id="name" class="one two"></div>
See the [EmacsWiki for more background on this mode.](http://www.emacswiki.org/emacs/ZenCoding)
# Screenshots and videos
* 
* [YouTube video](http://www.youtube.com/watch?v=u2r8JfJJgy8)
# Installation
Just make sure zencoding-mode.el is in your `load-path`, if you
extracted zencoding-mode to a directory:
(add-to-list "~/emacs.d/zencoding-mode")
And then just require as normal:
(require 'zencoding-mode)
# Usage
Enable it by running `M-x zencoding-mode`. You probably want to add it
to auto-load on your sgml modes:
(add-hook 'sgml-mode-hook 'zencoding-mode) ;; Auto-start on any markup modes
Good to go: place point in a zencoding snippet and press C-j to expand it (or
alternatively, alias your preferred keystroke to M-x zencoding-expand-line) and
you'll transform your snippet into the appropriate tag structure.
# Examples
## Basic tags
a <a></a>
a.x <a class="x"></a>
a#q.x <a id="q" class="x"></a>
a#q.x.y.z <a id="q" class="x y z"></a>
#q <div id="q">
</div>
.x <div class="x">
</div>
#q.x <div id="q" class="x">
</div>
#q.x.y.z <div id="q" class="x y z">
</div>
## Empty tags
a/ <a/>
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 <input type="text"/>
img <img/>
img>metadata/*2 <img>
<metadata/>
<metadata/>
</img>
## Siblings
a+b <a></a>
<b></b>
a+b+c <a></a>
<b></b>
<c></c>
a.x+b <a class="x"></a>
<b></b>
a#q.x+b <a id="q" class="x"></a>
<b></b>
a#q.x.y.z+b <a id="q" class="x y z"></a>
<b></b>
a#q.x.y.z+b#p.l.m.n <a id="q" class="x y z"></a>
<b id="p" class="l m n"></b>
## Tag expansion
table+ <table>
<tr>
<td>
</td>
</tr>
</table>
dl+ <dl>
<dt></dt>
<dd></dd>
</dl>
ul+ <ul>
<li></li>
</ul>
ul++ol+ <ul>
<li></li>
</ul>
<ol>
<li></li>
</ol>
ul#q.x.y m=l+ <ul id="q" class="x y" m="l">
<li></li>
</ul>
## Parent > child
a>b <a><b></b></a>
a>b>c <a><b><c></c></b></a>
a.x>b <a class="x"><b></b></a>
a#q.x>b <a id="q" class="x"><b></b></a>
a#q.x.y.z>b <a id="q" class="x y z"><b></b></a>
a#q.x.y.z>b#p.l.m.n <a id="q" class="x y z"><b id="p" class="l m n"></b></a>
#q>.x <div id="q">
<div class="x">
</div>
</div>
a>b+c <a>
<b></b>
<c></c>
</a>
a>b+c>d <a>
<b></b>
<c><d></d></c>
</a>
## Multiplication
a*1 <a></a>
a*2 <a></a>
<a></a>
a/*2 <a/>
<a/>
a*2+b*2 <a></a>
<a></a>
<b></b>
<b></b>
a*2>b*2 <a>
<b></b>
<b></b>
</a>
<a>
<b></b>
<b></b>
</a>
a>b*2 <a>
<b></b>
<b></b>
</a>
a#q.x>b#q.x*2 <a id="q" class="x">
<b id="q" class="x"></b>
<b id="q" class="x"></b>
</a>
a#q.x>b/#q.x*2 <a id="q" class="x">
<b id="q" class="x"/>
<b id="q" class="x"/>
</a>
## Properties
a x <a x=""></a>
a x= <a x=""></a>
a x="" <a x=""></a>
a x=y <a x="y"></a>
a x="y" <a x="y"></a>
a x="()" <a x="()"></a>
a x m <a x="" m=""></a>
a x= m="" <a x="" m=""></a>
a x=y m=l <a x="y" m="l"></a>
a/ x=y m=l <a x="y" m="l"/>
a#foo x=y m=l <a id="foo" x="y" m="l"></a>
a.foo x=y m=l <a class="foo" x="y" m="l"></a>
a#foo.bar.mu x=y m=l <a id="foo" class="bar mu" x="y" m="l"></a>
a/#foo.bar.mu x=y m=l <a id="foo" class="bar mu" x="y" m="l"/>
a x=y+b <a x="y"></a>
<b></b>
a x=y+b x=y <a x="y"></a>
<b x="y"></b>
a x=y>b <a x="y"><b></b></a>
a x=y>b x=y <a x="y"><b x="y"></b></a>
a x=y>b x=y+c x=y <a x="y">
<b x="y"></b>
<c x="y"></c>
</a>
## Parentheses
(a) <a></a>
(a)+(b) <a></a>
<b></b>
a>(b) <a><b></b></a>
(a>b)>c <a><b></b></a>
(a>b)+c <a><b></b></a>
<c></c>
z+(a>b)+c+k <z></z>
<a><b></b></a>
<c></c>
<k></k>
(a)*2 <a></a>
<a></a>
((a)*2) <a></a>
<a></a>
((a))*2 <a></a>
<a></a>
(a>b)*2 <a><b></b></a>
<a><b></b></a>
(a+b)*2 <a></a>
<b></b>
<a></a>
<b></b>
## Text inner tag.
a{Click me} <a>Click me</a>
a>{Click me}*2 <a>
Click me
Click me
</a>
a{click}+b{here} <a>click</a>
<b>here</b>
a>{click}+b{here} <a>
click
<b>here</b>
</a>
p>{Click }+a{here}+{ to continue}
<p>
Click
<a>here</a>
to continue
</p>
p{Click }+a{here}+{ to continue}
<p>
Click
</p>
<a>here</a>
to continue
## Filter: HTML with comments
a.b|c <!-- .b -->
<a class="b"></a>
<!-- /.b -->
#a>.b|c <!-- #a -->
<div id="a">
<!-- .b -->
<div class="b">
</div>
<!-- /.b -->
</div>
<!-- /#a -->
## 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>a href=#+br|haml %p
%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)+p>b|hic [:div#q
[:a [:b]]
[:a [:b]]
[:p
[:b]]]
## Filter: escape
script src="|e <script src="&quot;">
</script>
|