├── README.md ├── relativize.py └── src ├── documents ├── abbreviations │ ├── implicit-names │ │ └── index.html.md │ ├── index.html.md │ ├── lorem-ipsum │ │ └── index.html.md │ ├── syntax │ │ └── index.html.md │ └── types │ │ └── index.html.md ├── actions │ ├── base64 │ │ └── index.html.md │ ├── evaluate-math │ │ └── index.html.md │ ├── expand-abbreviation │ │ └── index.html.md │ ├── go-to-edit-point │ │ └── index.html.md │ ├── go-to-pair │ │ └── index.html.md │ ├── inc-dec-number │ │ └── index.html.md │ ├── index.html.md │ ├── match-pair │ │ └── index.html.md │ ├── merge-lines │ │ └── index.html.md │ ├── reflect-css-value │ │ └── index.html.md │ ├── remove-tag │ │ └── index.html.md │ ├── select-item │ │ └── index.html.md │ ├── split-join-tag │ │ └── index.html.md │ ├── toggle-comment │ │ └── index.html.md │ ├── update-image-size │ │ └── index.html.md │ └── wrap-with-abbreviation │ │ └── index.html.md ├── cheat-sheet │ └── index.html ├── css-abbreviations │ ├── fuzzy-search │ │ └── index.html.md │ ├── gradients │ │ └── index.html.md │ ├── index.html.md │ └── vendor-prefixes │ │ └── index.html.md ├── customization │ ├── index.html.md │ ├── preferences │ │ └── index.html.md │ ├── snippets │ │ └── index.html.md │ └── syntax-profiles │ │ └── index.html.md ├── filters │ ├── bem │ │ └── index.html.md │ └── index.html.md └── index.html.md ├── files └── css │ └── assets │ └── _layout.css └── layouts ├── default.html.eco └── page.html.eco /README.md: -------------------------------------------------------------------------------- 1 | # Emmet 文档 2 | 3 | Emmet 文档中文翻译。 4 | 5 | 官方文档:[网站](http://docs.emmet.io/) [源码](https://github.com/emmetio/emmet-docs/) 6 | 7 | - 对样式做了些调整。 8 | - 页面生成后运行 relativize.py,将所有 index.html 里的绝对路径转为相对路径。可能存在问题。 9 | 10 | ## 版权 11 | 12 | 翻译版权 CC BY 3.0 CN -------------------------------------------------------------------------------- /relativize.py: -------------------------------------------------------------------------------- 1 | #!/bin/python 2 | # -*- coding: utf-8 -*- 3 | # Ivan Yan 4 | # 2013-10-11 5 | # Relativize absolute paths in emmet-docs 6 | 7 | from __future__ import unicode_literals 8 | 9 | import os 10 | import re 11 | 12 | def relativize(filename, rel): 13 | old = open(filename).read().decode('utf-8') 14 | # href="/..." src="/..." 15 | def repl(matchobj): 16 | return matchobj.group(1) + '="' + rel + '/' 17 | new = re.sub(r'(href|src)="/(?!/)', repl, old) 18 | if new != old: 19 | open(filename, 'wb').write(new.encode('utf-8')) 20 | 21 | def main(dirname): 22 | rootpath = os.path.abspath(dirname) 23 | for root, dirs, files in os.walk(rootpath): 24 | for dirname in dirs: 25 | curdir = os.path.abspath(os.path.join(root, dirname)) 26 | index = os.path.join(curdir, 'index.html') 27 | if dirname != 'codemirror-movie' and os.path.exists(index): 28 | print(curdir) 29 | rel = os.path.relpath(rootpath, curdir).replace('\\', '/') 30 | # print(rel) 31 | relativize(index, rel) 32 | 33 | if __name__ == '__main__': 34 | relativize('out/index.html', '.') 35 | main('out') -------------------------------------------------------------------------------- /src/documents/abbreviations/implicit-names/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 隐式标签名 4 | menuOrder: 3 5 | --- 6 | Even with such a powerful abbreviation engine, which can expand large HTML structures from short abbreviation, writing tag names may be very tedious. 7 | 8 | 尽管可以利用强大的缩写引擎从简短的缩写展开大段的 HTML,但是书写标签仍然可能让人烦。 9 | 10 | In many cases you can skip typing tag names and Emmet will substitute it for you. For example, instead of `div.content` you can simply write `.content` and expand it into `
`. 11 | 12 | 在许多情况下可以省略标签名,Emmet 会妥善处理。比如不写 `div.content` 而写 `.content`,可以展开为 `
`。 13 | 14 | ## How it works 工作原理 15 | 16 | When you expand abbreviation, Emmet tries to grab parent context, e.g. the HTML element, inside which you’re expanding the abbreviation. If the context was grabbed successfully, Emmet uses its name to resolve implicit names: 17 | 18 | 当展开缩写时,Emmet 尝试获取缩写所处位置的父元素上下文,比如 HTML 元素。如果获取成功,Emmet 使用它的名字来解析隐式标签名: 19 | 20 | 49 | 50 | As you can see from the example above, Emmet looks at the parent tag name every time you’re expanding the abbreviation with an implicit name. Here’s how it resolves the names for some parent elements: 51 | 52 | 如你所见,当展开隐式标签名时 Emmet 查找父元素标签名。下面是 Emmet 解析机制: 53 | 54 | * `li` for `ul` and `ol` 55 | * `tr` for `table`, `tbody`, `thead` and `tfoot` 56 | * `td` for `tr` 57 | * `option` for `select` and `optgroup` 58 | 59 | Take a look at some abbreviations equivalents with implicit and explicit tag names: 60 | 61 | 下面缩写隐式与显式标签名输出一致: 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |
`.wrap>.content``div.wrap>div.content`
`em>.info``em>span.info`
`ul>.item*3``ul>li.item*3`
`table>#row$*4>[colspan=2]``table>tr#row$*4>td[colspan=2]`
81 | 82 | -------------------------------------------------------------------------------- /src/documents/abbreviations/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 缩写 4 | menuOrder: 1 5 | --- 6 | Abbreviations are the heart of the Emmet toolkit: these special expressions are parsed in runtime and transformed into structured code block, HTML for example. The abbreviation’s syntax looks like CSS selectors with a few extensions specific to code generation. So every web-developer already knows how to use it. 7 | 8 | 缩写是 Emmet 的核心:这些特殊的表达式被实时的解析转化为代码块。缩写的语法类似于 CSS 选择器,每个网页开发者都知道怎么用。 9 | 10 | Here’s an example: this abbreviation 11 | 12 | 例如这个缩写: 13 | 14 | #page>div.logo+ul#navigation>li*5>a{Item $} 15 | 16 | ...can be transformed into 17 | 18 |
19 | 20 | 27 |
28 | 29 | ...with just a single key stroke. In many editors (such as Eclipse, Sublime Text 2, Espresso etc.) plugins will also generate proper _tabstop marks_ so you can quickly traverse between important places of generated code with the Tab key. 30 | 31 | 许多编辑器(比如 Eclipse, Sublime Text 2, Espresso 等) 的插件也生成插入占位,使用 Tab 键可以快捷在这些重要的地方跳转。 32 | 33 | Abbreviations are optimised for, but not limited to, HTML and XML generation, and make writing tedious markup code a breeze. You can start learning [syntax](/abbreviations/syntax/) to unleash the full power of Emmet abbreviations. 34 | 35 | 缩写最适合于生成 HTML/XML,但是不限于此。下面开始学习[语法](/abbreviations/syntax/)来了解 Emmet 缩写的强大。 -------------------------------------------------------------------------------- /src/documents/abbreviations/lorem-ipsum/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: “Lorem Ipsum” 生成器 4 | menuOrder: 4 5 | --- 6 | [“Lorem ipsum”](http://www.lipsum.com) dummy text is used by many web-developers to test how their HTML templates will look with real data. Often, developers use third-party services to generate “Lorem ipsum” text, but now you can do that right in your editor. Just expand `lorem` or `lipsum` abbreviations to get the following snippet: 7 | 8 | [“Lorem ipsum”](http://www.lipsum.com) 假文,许多开发者用它来测试 HTML 模板填充数据后的样子。开发者常常用第三方服务来生成假文,不过现在在编辑器里就能做到,只用展开 `lorem` 或 `lipsum` : 9 | 10 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eligendi non quis exercitationem culpa nesciunt nihil aut nostrum explicabo reprehenderit optio amet ab temporibus asperiores quasi cupiditate. Voluptatum ducimus voluptates voluptas? 11 | 12 | `lorem` is not just a normal snippet—it’s actually a _generator_. Every time you expand it, it will generate a 30-words dummy text, splitted into a few sentences. 13 | 14 | `lorem` 不是普通的代码片断——它是一个 **生成器**。每次展开将生成 30 字数的假文,分为几个句子。 15 | 16 | You can specify how many words should be generated right in the abbreviation. For example, `lorem100` will generate a 100-words dummy text. 17 | 18 | 可以指定字数。比如 `lorem100` 将生成 100 字数的假文。 19 | 20 | ## Repeated “Lorem ipsum”重复假文 21 | 22 | You can use `lorem` generator inside repeated elements to create tags filled with completely random sentences. For example, `p*4>lorem` abbreviation would generate something like this: 23 | 24 | 在重复元素内使用 `lorem` 填充随机文本。比如 `p*4>lorem`: 25 | 26 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui dicta minus molestiae vel beatae natus eveniet ratione temporibus aperiam harum alias officiis assumenda officia quibusdam deleniti eos cupiditate dolore doloribus!

27 |

Ad dolore dignissimos asperiores dicta facere optio quod commodi nam tempore recusandae. Rerum sed nulla eum vero expedita ex delectus voluptates rem at neque quos facere sequi unde optio aliquam!

28 |

Tenetur quod quidem in voluptatem corporis dolorum dicta sit pariatur porro quaerat autem ipsam odit quam beatae tempora quibusdam illum! Modi velit odio nam nulla unde amet odit pariatur at!

29 |

Consequatur rerum amet fuga expedita sunt et tempora saepe? Iusto nihil explicabo perferendis quos provident delectus ducimus necessitatibus reiciendis optio tempora unde earum doloremque commodi laudantium ad nulla vel odio?

30 | 31 | Also, `lorem` generator utilizes the [implicit tag name resolver](/abbreviations/implicit-names/) when `lorem` element is self-repeated so you can shorten your abbreviations: 32 | 33 | `lorem` 也能 [解析隐式标签名](/abbreviations/implicit-names/)。当只重复 `lorem` 时可以简化缩写: 34 | 35 | `ul.generic-list>lorem10.item*4` 36 | 37 | ...will produce 38 | 39 | 45 | 46 | -------------------------------------------------------------------------------- /src/documents/abbreviations/syntax/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 缩写语法 4 | menuTitle: 语法 5 | menuOrder: 1 6 | --- 7 | Emmet uses syntax similar to CSS selectors for describing elements’ positions inside generated tree and elements’ attributes. 8 | 9 | Emmet 使用类似于 CSS 选择器的语法来描述元素的结构与属性。 10 | 11 | ## Elements 元素 12 | 13 | You can use elements’ names like `div` or `p` to _generate_ HTML tags. Emmet doesn’t have a predefined set of available tag names, you can write any word and transform it into a tag: `div` → `
`, `foo` → `` and so on. 14 | 15 | 使用元素的名字,比如 `div`、 `p` 来生成 HTML 标签。 Emmet 没有预定义标签集合,所以可以用任意单词来生成对应的标签:`div` → `
`, `foo` → `` 16 | 17 | ## Nesting operators 嵌套操作符 18 | 19 | Nesting operators are used to position abbreviation elements inside generated tree: whether it should be placed inside or near the context element. 20 | 21 | ### Child: `>` 子元素 22 | 23 | You can use `>` operator to nest elements inside each other: 24 | 25 | div>ul>li 26 | 27 | ...will produce 28 | 29 |
30 | 33 |
34 | 35 | ### Sibling: `+` 兄弟元素 36 | 37 | Use `+` operator to place elements near each other, on the same level: 38 | 39 | div+p+bq 40 | 41 | ...will output 42 | 43 |
44 |

45 |
46 | 47 | ### Climb-up: `^` 返回上层 48 | 49 | With `>` operator you’re descending down the generated tree and positions of all sibling elements will be resolved against the most deepest element: 50 | 51 | `>` 操作符加深结构层次: 52 | 53 | div+div>p>span+em 54 | 55 | ...will be expanded to 56 | 57 |
58 |
59 |

60 |
61 | 62 | With `^` operator, you can climb one level up the tree and change context where following elements should appear: 63 | 64 | `>` 操作符返回上一层: 65 | 66 | div+div>p>span+em^bq 67 | 68 | ...outputs to 69 | 70 |
71 |
72 |

73 |
74 |
75 | 76 | You can use as many `^` operators as you like, each operator will move one level up: 77 | 78 | 多个`^`连写将向上一层层返回: 79 | 80 | div+div>p>span+em^^^bq 81 | 82 | ...will output to 83 | 84 |
85 |
86 |

87 |
88 |
89 | 90 | ### Multiplication: `*` 乘法 91 | 92 | With `*` operator you can define how many times element should be outputted: 93 | 94 | ul>li*5 95 | 96 | ...outputs to 97 | 98 | 105 | 106 | ### Grouping: `()` 分组 107 | 108 | Parenthesises are used by Emmets’ power users for grouping subtrees in complex abbreviations: 109 | 110 | div>(header>ul>li*2>a)+footer>p 111 | 112 | ...expands to 113 | 114 |
115 |
116 | 120 |
121 | 124 |
125 | 126 | If you’re working with browser’s DOM, you may think of groups as Document Fragments: each group contains abbreviation subtree and all the following elements are inserted at the same level as the first element of group. 127 | 128 | 可以将分组当作 Document Fragments,后续元素将与分组第一个元素同级。 129 | 130 | You can nest groups inside each other and combine them with multiplication `*` operator: 131 | 132 | 分组嵌套,并且使用 `*` 操作法: 133 | 134 | (div>dl>(dt+dd)*3)+footer>p 135 | 136 | ...produces 137 | 138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 | 151 | 152 | With groups, you can literally write full page mark-up with a single abbreviation, but please don’t do that. 153 | 154 | 使用分组后,可以用一个缩写来生成整个页面,不过不要这么做。 155 | 156 | ## Attribute operators 属性操作符 157 | 158 | Attribute operators are used to modify attributes of outputted elements. For example, in HTML and XML you can quickly add `class` attribute to generated element. 159 | 160 | ### ID and CLASS 161 | 162 | In CSS, you use `elem#id` and `elem.class` notation to reach the elements with specified `id` or `class` attributes. In Emmet, you can use the very same syntax to _add_ these attributes to specified element: 163 | 164 | Emmet 使用类似于 CSS 选择器的语法给元素添加属性: 165 | 166 | div#header+div.page+div#footer.class1.class2.class3 167 | 168 | ...will output 169 | 170 | 171 |
172 | 173 | 174 | ### Custom attributes 自定义属性 175 | 176 | You can use `[attr]` notation (as in CSS) to add custom attributes to your element: 177 | 178 | td[title="Hello world!" colspan=3] 179 | 180 | ...outputs 181 | 182 | 183 | 184 | * You can place as many attributes as you like inside square brackets. 185 | * 方括号内属性数量不限。 186 | * You don’t have to specify attribute values: `td[colspan title]` will produce `` with tabstops inside each empty attribute (if your editor supports them). 187 | * 没有指定值的属性将生成插入占位(需要编辑器支持)。 188 | * You can use single or double quotes for quoting attribute values. 189 | * 属性值使用单引号或双引号。 190 | * You don’t need to quote values if they don’t contain spaces: `td[title=hello colspan=3]` will work. 191 | * 属性值如果不包含空格可以省略引号。 192 | 193 | ### Item numbering: `$` 编号 194 | 195 | With multiplication `*` operator you can repeat elements, but with `$` you can _number_ them. Place `$` operator inside element’s name, attribute’s name or attribute’s value to output current number of repeated element: 196 | 197 | `*` 操作符可以生成重复元素,而 `$` 可以对元素编号。将 `$` 放在元素名、属性名或属性值中: 198 | 199 | ul>li.item$*5 200 | 201 | ...outputs to 202 | 203 | 210 | 211 | You can use multiple `$` in a row to pad number with zeroes: 212 | 213 | 多个连写的 `$` 可以生成带有前导零的编号: 214 | 215 | ul>li.item$$$*5 216 | 217 | ...outputs to 218 | 219 | 226 | 227 | #### Changing numbering base and direction 228 | 229 | With `@` modifier, you can change numbering direction (ascending or descending) and base (e.g. start value). 230 | 231 | 使用 `@` 修饰符,可以改变编号的方向(升序或降序)及起点。 232 | 233 | For example, to change direction, add `@-` after `$`: 234 | 235 | 例如改变方向,将 `@-` 放在 `$` 后: 236 | 237 | ul>li.item$@-*5 238 | 239 | …outputs to 240 | 241 | 248 | 249 | To change counter base value, add `@N` modifier to `$`: 250 | 251 | 改变起点,将 `@N` 放在 `$` 后: 252 | 253 | ul>li.item$@3*5 254 | 255 | …transforms to 256 | 257 | 264 | 265 | You can use these modifiers together: 266 | 267 | 混合使用这几种修饰符: 268 | 269 | ul>li.item$@-3*5 270 | 271 | …is transformed to 272 | 273 | 280 | 281 | ## Text: `{}` 文本 282 | 283 | You can use curly braces to add text to element: 284 | 285 | 使用大括号为元素添加文本(译注:类似于模板的插入符) 286 | 287 | a{Click me} 288 | 289 | ...will produce 290 | 291 | Click me 292 | 293 | Note that `{text}` is used and parsed as a separate element (like, `div`, `p` etc.) but has a special meaning when written right after element. For example, `a{click}` and `a>{click}` will produce the same output, but `a{click}+b{here}` and `a>{click}+b{here}` won’t: 294 | 295 | 注意 `{text}` 类似于独立元素(比如`div`, `p`),不过当它紧跟在元素后面时有特别的意义。比如 `a{click}` 与 `a>{click}` 结果一样,而 `a{click}+b{here}` 与 `a>{click}+b{here}` 结果不一样: 296 | 297 | 298 | clickhere 299 | 300 | 301 | clickhere 302 | 303 | In second example the `` element is placed _inside_ `` element. And that’s the difference: when `{text}` is written right after element, it doesn’t change parent context. Here’s more complex example showing why it is important: 304 | 305 | 第二个例子里 `` 位于 `` 内。这便是不同点: 当 `{text}` 紧跟在元素后面时,它没有改变父元素的上下文。下面用一个复杂例子来说明: 306 | 307 | p>{Click }+a{here}+{ to continue} 308 | 309 | ...produces 310 | 311 |

Click here to continue

312 | 313 | In this example, to write `Click here to continue` inside `

` element we have explicitly move down the tree with `>` operator after `p`, but in case of `a` element we don’t have to, since we need `` element with `here` word only, without changing parent context. 314 | 315 | 在这个例子中,为了让 `

` 包含 `Click here to continue`,`p` 后面使用了 `>` 以进入子级结构,而 `a` 只需要包含文本 `here`,不用改变父元素上下文,所以不需要这样做。 316 | 317 | For comparison, here’s the same abbreviation written without child `>` operator: 318 | 319 | 下面不用 `>` 做下对比: 320 | 321 | p{Click }+a{here}+{ to continue} 322 | 323 | ...produces 324 | 325 |

Click

326 | here to continue 327 | 328 | ## Notes on abbreviation formatting 格式化缩写注意事项 329 | 330 | When you get familiar with Emmet’s abbreviations syntax, you may want to use some formatting to make your abbreviations more readable. For example, use spaces between elements and operators, like this: 331 | 332 | 当熟悉 Emmet 的缩写语法后,你可能为了可读性而去格式化缩写。比如在元素与操作符之间插入空格: 333 | 334 | (header > ul.nav > li*5) + footer 335 | 336 | But it won’t work, because space is a _stop symbol_ where Emmet stops abbreviation parsing. 337 | 338 | 但是这时 Emmet 失效,因为 Emmet 遇到空格后停止解析缩写。 339 | 340 | Many users mistakenly think that each abbreviation should be written in a new line, but they are wrong: you can type and expand abbreviation *anywhere in the text*: 341 | 342 | 许多用户错误地认为缩写应该新起一行,但是这是错的:可以在文本的任意位置书写并展开缩写。 343 | 344 | 366 | 367 | This is why Emmet needs some indicators (like spaces) where it should stop parsing to not expand anything that you don’t need. If you’re still thinking that such formatting is required for complex abbreviations to make them more readable: 368 | 369 | 这便是为什么 Emmet 需要指示符(比如空格)来停止解析缩写。如果你仍然认为对于复杂的缩写,为了可读性必须格式化: 370 | 371 | * Abbreviations are not a template language, they don’t have to be “readable”, they have to be “quickly expandable and removable”. 372 | * 缩写不是模板语言,不需要可读性,即写即用。 373 | * You don’t really need to write complex abbreviations. Stop thinking that “typing” is the slowest process in web-development. You’ll quickly find out that constructing a single complex abbreviation is much slower and error-prone than constructing and typing a few short ones. 374 | * 你真的没必要书写复杂的缩写。停止这样的认识:书写是网页开发中最慢的过程。你将很快发现书写一个复杂的缩写比起使用多个简短缩写,要慢得多并且容易出错。 -------------------------------------------------------------------------------- /src/documents/abbreviations/types/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 元素类型 4 | menuOrder: 2 5 | --- 6 | in HTML and XML documents, when you expand abbreviations, all abbreviation parts are transformed on-the-fly into HTML/XML tags. But certain elements like `a` or `img` are transformed into elements with predefined attributes: `` and ``. How does Emmet know when to add those attributes? 7 | 8 | 当编辑 HTML/XML 文档时,缩写展开为 HTML/XML 标签。不过一些元素,比如 `a` 或 `img`, 缩写展开后带有属性:`` 或 ``。Emmet 怎么知道何时添加这些属性? 9 | 10 | All Emmet elements definitions are stored in [snippets.json](https://github.com/emmetio/emmet/blob/master/snippets.json) file in the following format: 11 | 12 | Emmet 所有元素的定义放在 [snippets.json](https://github.com/emmetio/emmet/blob/master/snippets.json) 文件里,格式如下: 13 | 14 | { 15 | "html": { 16 | "abbreviations": { 17 | "a": "", 18 | "link": "" 19 | ... 20 | }, 21 | "snippets": { 22 | "cc:ie6": "" 23 | ... 24 | } 25 | }, 26 | 27 | "css": { 28 | ... 29 | } 30 | } 31 | 32 | As you can see, at first level there are syntax names for which elements are defined. Inside the syntax section there are elements definitions split across two sections: _snippets_ and _abbreviations_. 33 | 34 | 如你所见,第一级是元素所属语法名,其中元素定义分成两部分: 代码片断与缩写。 35 | 36 | ## Snippets 代码片断 37 | 38 | Snippets are just blocks of plain code, just like in all programmers’ editors. You can type anything there and it will be outputted “as-is”, without any transformation. 39 | 40 | 代码片断,同其它程序编辑器一样,是文本代码块,所见即所得,没有转化操作。 41 | 42 | ## Abbreviations 缩写 43 | 44 | Abbreviations are actually building blocks with some data hints. Since Emmet is mostly used for writing HTML/XML tags, _abbreviation definition uses XML format to describe element_. 45 | 46 | 缩写是带有数据提示的代码块。既然 Emmet 主要用于编辑 HTML/XML, 于是缩写的定义使用 XML 格式来描述元素。 47 | 48 | Emmet parses abbreviation definition and retrieves the following data: 49 | 50 | Emmet 解析缩写的定义并获取下面数据: 51 | 52 | * element name 元素名字; 53 | * default attributes 默认属性; 54 | * attributes’ order 属性顺序; 55 | * attributes’ default values 属性默认值; 56 | * should element contain closing tag 元素是否包含关闭标签. 57 | 58 | Let’s take a closer look on HTML abbreviations’ definitions above. The `link` element is defined as `` (double quotes should be escaped in JSON; or use single quotes instead). This definition says that tag, generated for `link` abbreviation, should be named _link_ and should contain two attributes: _rel_ with default value “ and _href_ with empty value (exactly in this order), and generated element should not contain closing tag. 59 | 60 | 拿上面的例子来说明。`link` 元素定义为 `` (JSON 中需要转义双引号,或者用单引号)。这个定义的意思是,缩写 `link` 展开后元素带有两个属性: _rel_ 默认值stylesheet”;_href_ 空值,它们的顺序依照定义,元素不包含关闭标签。 61 | 62 | When the `link` abbreviation is expanded, you’ll receive the following output for HTML syntax: 63 | 64 | 展开结果: 65 | 66 | 67 | 68 | You can override default attribute values and add new ones as well: 69 | 70 | 可以覆盖默认值或添加一个新属性: 71 | 72 | link[rel=prefetch title="Hello world"] 73 | 74 | ...expands to: 75 | 76 | 77 | 78 | You can add child elements as well, which forces Emmet to output closing tag: 79 | 80 | 也可以添加子元素,这将强制 Emmet 输出关闭标签: 81 | 82 | link>xsl:apply-templates 83 | 84 | ...will output: 85 | 86 | 87 | 88 | 89 | 90 | ## Aliases 别名 91 | 92 | In the abbreviations section of `snippets.json` you can also define _aliases_: a short-hands for commonly used abbreviations. Aliases can be used to define: 93 | 94 | 在 `snippets.json` 文件的缩写部分,可以定义别名,作用是: 95 | 96 | * short names for long tag names 给长标签名起一个短名字; 97 | * referencing commonly used abbreviations 引用常用的缩写. 98 | 99 | In `snippets.json` file, you can find the following definitions: 100 | 101 | 在`snippets.json` 文件里可以看到: 102 | 103 | ... 104 | "html": { 105 | "abbreviations": { 106 | "bq": "blockquote", 107 | "ol+": "ol>li" 108 | } 109 | } 110 | 111 | In the example above, when you expand `bq` abbreviation, Emmet will look for `blockquote` abbreviation’s definition. If it doesn’t exist, it will simply output `
` element. The `ol+` abbreviation actually outputs the same result as `ol>li` does. 112 | 113 | 在这个例子中,当展开缩写 `bq` 时,Emmet 查找 `blockquote` 的定义。如果定义不存在,则只输出 `
`。`ol+` 输出结果同 `ol>li`。 114 | 115 | The `ol+` definition may look ambiguous since it contains `+` at the end which is also a sibling operator. Emmet correctly expands such abbreviations and the plus sign is left here for historical reasons. Just remember that you don’t need to use plus sign to create abbreviation alias. 116 | 117 | `ol+` 看着有点懵,因为 `+` 也是兄弟操作符。Emmet 能正确的展开这样的缩写,这里的加号是历史缘故。记住,不需要用加号来定义缩写别名。 118 | -------------------------------------------------------------------------------- /src/documents/actions/base64/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "编码/解码图像为 data:URL" 4 | menuOrder: 14 5 | --- 6 | HTML and CSS allows you to embed external resources right into base using [data:URL](http://en.wikipedia.org/wiki/Data_URI_scheme) scheme. Usually, image conversion to base64 is done with external on-line services or third-party assets builder. 7 | 8 | HTML 与 CSS 可以用 [data:URL](http://en.wikipedia.org/wiki/Data_URI_scheme) 插入外部资源。通常用在线服务或第三方软件将图像转换为 base64。 9 | 10 | But these tools have downsides: you have to spend extra time on on-line tools or loose control on images that should or should not be converted to base64. 11 | 12 | 但是这些工具有缺点:在线工具要花费额外的时间,或者不能控制图片是否应该转换为 base64。 13 | 14 | With Emmet, you can convert image to data:URL right in your editor, as well as convert it _back to external file_. 15 | 16 | 使用 Emmet 在编辑器里就可以将图像转换为 base64,或者相反操作。 17 | 18 | -------------------------------------------------------------------------------- /src/documents/actions/evaluate-math/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 计算数学表达式 4 | menuOrder: 11 5 | --- 6 | Evaluates simple math expression like `2*4` or `10/2` and outputs its result. You can use `\` operator which is equivalent to `round(a/b)`. 7 | 8 | 计算简单的数学表达式,比如`2*4` 或 `10/2`,并输出结果。`\` 操作符结果同 `round(a/b)`。 9 | 10 | Very useful in CSS where numeric values should be modified frequently. 11 | 12 | 当数字值频繁改变时这个比较很有用。 13 | 14 | -------------------------------------------------------------------------------- /src/documents/actions/expand-abbreviation/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 展开缩写 4 | menuOrder: 1 5 | --- 6 | Expands [CSS-like abbreviations](/abbreviations/) into HTML/XML/CSS code, depending on current document’s syntax. Also performs other context actions, for example, transforms [CSS Gradient](/css-abbreviations/gradients/). 7 | 8 | 依据当前文档的语法,将类似于 CSS 的[缩写](/abbreviations/)展开为 HTML/XML/CSS 代码。也能做其它的操作,例如转换 [CSS 渐变](/css-abbreviations/gradients/)。 9 | 10 | 26 | 27 | Generated output contains a number of _tabstops_ and if your editor supports them (Eclipse, Sublime Text 2, Espresso etc) you can quickly traverse between them with Tab key. 28 | 29 | 如果你的编辑器(Eclipse, Sublime Text 2, Espresso 等)支持插入占位,生成的代码包括多个插入占位,这样可以用 Tab 键在它们之间快速移动。 30 | 31 | In some editors (Eclipse, Sublime Text 2, CodeMirror) “Expand Abbreviation” can be invoked with Tab key. 32 | 33 | 一些编辑器(Eclipse, Sublime Text 2, CodeMirror),可以用 Tab 键触发 “展开缩写”功能。 -------------------------------------------------------------------------------- /src/documents/actions/go-to-edit-point/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 跳转到编辑点 4 | menuOrder: 4 5 | --- 6 | This action works for HTML code blocks and allows you to quickly traverse between important code points: 7 | 8 | 这个功能适用于 HTML 代码块,可以在要点之间跳转: 9 | 10 | * between tags 标签之间 11 | * empty attributes 空标签 12 | * newlines with indentation 缩进的新行 13 | 14 | 36 | -------------------------------------------------------------------------------- /src/documents/actions/go-to-pair/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 跳转到配对标签 4 | menuOrder: 2.5 5 | --- 6 | In HTML, allows you to quickly traverse between opening and closing tag: 7 | 8 | 在HTML标签的开始与关闭标记间跳转。 9 | 10 | 22 | 23 | ---------------- 24 | 25 | “Go to Matching Pair” action uses “[HTML Matcher](/actions/match-pair/)” internally so it may work in non-HTML syntaxes too. 26 | 27 | 这个功能在内部调用 [匹配标签](/actions/match-pair/) 功能,所以非 HTML 语法也可以用。 28 | -------------------------------------------------------------------------------- /src/documents/actions/inc-dec-number/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 增减数字 4 | menuOrder: 12 5 | --- 6 | This action, as name says, increments or decrements number under caret with different steps: 0.1, 1 or 10. 7 | 8 | 这个功能,如名字所示,以不同的步值增减插入符所在位置的数字。 9 | 10 | -------------------------------------------------------------------------------- /src/documents/actions/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 功能 4 | menuOrder: 3 5 | --- 6 | Emmet allows you to write large HTML code blocks at speed of light using well-known CSS selectors. But it’s not the only thing that every web-developer needs: occasionally you have to _edit_ your HTML and CSS code to fix bugs and add new features. 7 | 8 | Emmet 能让开发者以光速 :-) 书写大段的 HTML。但是这不是开发者唯一想要的:有时需要编辑 HTML 与 CSS 代码,以修订 bug 和添加新功能。 9 | 10 | Emmet offers very unique tools that can greatly improve your editing experience: 11 | 12 | Emmet 提供独有的工具,可以极大的提高你的编辑体验: 13 | 14 |
15 |
[Expand Abbreviation 展开缩写](./expand-abbreviation/)
16 |
Yep, this is _the_ action that expands CSS-like abbreviations into HTML code.
17 |
将类似于 CSS 的缩写展开为 HTML 代码。
18 | 19 |
[Match Tag Pair 匹配标签](./match-pair/)
20 |
Selects content, and/or opening and closing HTML tag name from current caret position (a.k.a “balancing”). Super-awesome implementation that _works even in non-HTML syntaxes_! Implicitly used by many Emmet actions.
21 |
从插入符所在的位置选择标签内外内容。更厉害的是在非 HTML 语法下也能使用。Emmet 多数功能隐式的用到此功能。
22 | 23 |
[Go to Matching Pair 跳转到配对标签](./go-to-pair/)
24 |
Quickly traverses between opening and closing HTML tag.
25 |
在 HTML 标签的开始与关闭标记间跳转。
26 | 27 |
[Wrap with Abbreviation 包裹缩写](./wrap-with-abbreviation/)
28 |
Same as “Expand Abbreviation” action but intelligently wraps selected content.
29 |
同“展开缩写”功能,不过可以智能的包裹选中的内容。
30 | 31 |
[Go to Edit Point 跳转编辑点](./go-to-edit-point/)
32 |
Quickly traverse between important HTML code points.
33 |
在重要的 HTML 编辑点间移动
34 | 35 |
[Select Item 选择](./select-item/)
36 |
Quickly select important HTML and CSS code parts.
37 |
快速选择 HTML 与 CSS 代码片断。
38 | 39 |
[Toggle Comment 切换注释](./toggle-comment/)
40 |
Toggles comment. Unlike basic editor’s implementations, matches HTML tag, CSS property or rule when there’s no selection.
41 |
不同于编辑器的实现,如果没有选择,则对匹配的 HTML 标签, CSS 属性或规则切换注释。
42 | 43 |
[Split/Join Tag 分割合并标签](./split-join-tag/)
44 |
Splits (`` → ``) or joins (`` → ``) HTML/XML tag under current caret position.
45 |
将插入符所在的 HTML/XML 标签分割 (`` → ``) 或合并 (`` → ``)。
46 | 47 |
[Remove Tag 删除标签](./remove-tag/)
48 |
Gracefully removes HTML/XML tag under current caret position.
49 |
删除插入符所在的 HTML/XML 标签。
50 | 51 |
[Merge Lines 合并行](./merge-lines/)
52 |
Merges selected lines into single one. With no selection, automatically matches nearest HTML tag.
53 |
将选中的多行合并为单行。如果没有选择,则自动将最近的 HTML 标签合并。
54 | 55 |
[Update Image Size 更新图片尺寸](./update-image-size/)
56 |
Updates matched HTML tag or CSS rule with image size, located under caret.
57 |
更新插入符所在的图片(img 标签或 background 等 CSS 属性)的尺寸。
58 | 59 |
[Evaluate Math Expression 计算数学表达式](./evaluate-math/)
60 |
Evaluates simple math expression
61 |
计算简单的数学表达式。
62 | 63 |
[Increment/Decrement Number 增减数字](./inc-dec-number/)
64 |
Increments or decrements number under current caret position with given step.
65 |
以给定步值增减插入符所在的数字。
66 | 67 |
[Reflect CSS Value 重构 CSS 值](./reflect-css-value/)
68 |
Automatically copies CSS value under current caret position to all vendor-prefixed variants.
69 |
自动将插入符所在的 CSS 属性值复制给所有带有厂商前缀的属性。
70 | 71 |
[Encode/Decode Image to data:URL 编码/解码图像为 data:URL](./base64/)
72 |
Encodes image under caret to data:URL format and vice versa.
73 |
将插入符所在的图片编码为 data:URL, 或逆操作。
74 | 75 |
76 | 77 | **译注:** 查看在 Sublime Text 下各功能的[快捷键](https://github.com/sergeche/emmet-sublime#available-actions)。 78 | -------------------------------------------------------------------------------- /src/documents/actions/match-pair/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 匹配标签 4 | menuOrder: 2 5 | --- 6 | A well-known tag balancing: searches for tag or tag's content bounds from current caret position and selects it. It will expand (outward balancing) or shrink (inward balancing) selection when called multiple times. Not every editor supports both inward and outward balancing due of some implementation issues, most editors have outward balancing only. 7 | 8 | 从插入符所在位置开始查找标签及标签内容,并选中它。当多次调用时将向外扩展或向内收缩选择。由于实现上的问题,不是所有的编辑器同时支持这两种操作,多数编辑器只支持向外扩展选择。 9 | 10 | 28 | 29 | Emmet’s tag balancing is quite unique. Unlike other implementation, this one will search tag bounds from caret’s position, not the start of the document. It means you can use tag balancer even in non-HTML documents. 30 | 31 | Emmet 的匹配标签功能很独特。不像其它实现,Emmet 从插入符所在位置而不是从文档的开头开始搜索标签,这意味着可以在非 HTML 文档使用这个功能。 32 | 33 | 56 | 57 | Note that tag matching may not work outside HTML if tag definition is assembled by concatenating strings, like this: `var cell = ''`; 58 | 59 | 注意如果标签是由拼接的字符定义,像这样:`var cell = ''`,不能匹配标签。 -------------------------------------------------------------------------------- /src/documents/actions/merge-lines/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 合并行 4 | menuOrder: 9 5 | --- 6 | Many editors have similar action: it merges selected lines into a single one. But when there’s no selection, Emmet will match context HTML tag. 7 | 8 | 许多编辑器有类似功能:将选中的多行合并为单行。不过如果没有选择,Emmet 将匹配所在 HTML 标签。 9 | 10 | 20 | -------------------------------------------------------------------------------- /src/documents/actions/reflect-css-value/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 重构 CSS 值 4 | menuOrder: 13 5 | --- 6 | A very useful action for CSS developers: it takes value of CSS property under caret and copies it into vendor-prefixed variations with additional transformations, if required. 7 | 8 | 对 CSS 开发很实用的功能: 将插入符所在的 CSS 属性值复制给带厂商前缀的属性中。 9 | 10 | -------------------------------------------------------------------------------- /src/documents/actions/remove-tag/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 删除标签 4 | menuOrder: 8 5 | --- 6 | Quickly removes tag, found by “[Match Tag Pair](/actions/match-pair/)” from current caret position, and adjusts indentation. 7 | 8 | 快速删除标签,并调整缩进。这里的标签是在插入符所在位置由 [匹配标签](/actions/match-pair/) 功能查找的标签。 9 | 10 | 25 | 26 | ---------------- 27 | 28 | “Remove Tag” action uses “[HTML Matcher](/actions/match-pair/)” internally so it may work in non-HTML syntaxes too. 29 | 30 | 这个功能在内部调用 [匹配标签](/actions/match-pair/) 功能,所以非 HTML 语法也可以用。 -------------------------------------------------------------------------------- /src/documents/actions/select-item/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 选择 4 | menuOrder: 5 5 | --- 6 | Action is similar to [“Go to Edit Point”](/actions/go-to-edit-point/), but selects important code parts. 7 | 8 | 这个功能类似于[编辑点间移动](/actions/go-to-edit-point/)功能,但是选择重要的代码部分。 9 | 10 | In HTML, these are tag name, full attribute and attribute value. For class attribute it also selects distinct classes. 11 | 12 | 对于 HTML,选择标签名,完整的属性与属性值。对于 class 属性也选择不同的 class。 13 | 14 | 32 | 33 | In CSS, it matches selector, full property and property value. For complex values and functions like `1px solid red` or `url(image.jpg)` also selects part of it. 34 | 35 | 对于 CSS,选择选择器,完整的属性与属性值。对于复杂的值比如 `1px solid red` 或 `url(image.jpg)` 也选择子部分。 36 | 37 | -------------------------------------------------------------------------------- /src/documents/actions/split-join-tag/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 分割合并标签 4 | menuOrder: 7 5 | --- 6 | This action splits and joins tag definition, e.g. converts from `` to `` and vice versa. Very useful for XML/XSL developers. 7 | 8 | 这个功能分割合并标签,例如将`` 转换为 `` ,或逆操作。对于 XML/XSL 开发很有用。 9 | 10 | 21 | 22 | ---------------- 23 | 24 | “Split/Join Tag” action uses “[HTML Matcher](/actions/match-pair/)” internally so it may work in non-HTML syntaxes too. 25 | 26 | 这个功能在内部调用 [匹配标签](/actions/match-pair/) 功能,所以非 HTML 语法也可以用。 27 | -------------------------------------------------------------------------------- /src/documents/actions/toggle-comment/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 切换注释 4 | menuOrder: 6 5 | --- 6 | This action, as name says, toggle comment on selection. Almost all programmer’s text editors have such action, but this one works differently. When there’s no selection, editor’s action toggles comment on current line while Emmet’s one do this on _current context_. For HTML it’s a full tag, for CSS it’s a rule or full property. 7 | 8 | 这个功能,如名字所示,注释或取消注释选中内容。几乎所有的程序员编辑器都有这样的功能,但是这个不同。当没有选择时,编辑器切换当前行的注释,而 Emmet 切换当前上下文的注释。对于 HTML 是整个标签内容,对于 CSS 是一条规则或整个属性。 9 | 10 | 30 | -------------------------------------------------------------------------------- /src/documents/actions/update-image-size/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 更新图片尺寸 4 | menuOrder: 10 5 | --- 6 | Many web-developers forget to write _width_ and _height_ attributes for `` tags which leads to poor UX. This action helps you to automate this process: simply place caret inside `` tag and run this action to add/update width and height attributes. 7 | 8 | 许多开发者忘记给 `` 标签添加 _width_ 与 _height_ 属性,这样对用户体验不好。这个功能自动帮你搞定:将插入符放在 `` 标签内,然后调用此功能,就可以添加或更新 width 与 height 属性。 9 | 10 | In CSS, place caret inside property value with `url()` function to add/update width and height properties for current rule. 11 | 12 | 对于 CSS,将插入符放在属性值 `url()` 内,然后调用此功能,就可以添加或更新 width 与 height 属性。 13 | 14 | 32 | 33 | Note that this action also works for absolute URLs: it will start searching for requested file from host file’s folder and then will traverse up the tree. 34 | 35 | 注意此功能对绝对 URL 路径也适用:从宿主文件所在目录开始查找文件,然后沿着目录结构向上查找。 -------------------------------------------------------------------------------- /src/documents/actions/wrap-with-abbreviation/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: 包裹缩写 4 | menuOrder: 3 5 | --- 6 | A very powerful tool of the Emmet toolkit. It takes an [abbreviation](/abbreviations/), expands it and places currently selected content in the last element of generated snippet. If there’s no selection, action will silently call [“Match Tag Pair”](/actions/match-pair/) to wrap context element. 7 | 8 | 这是 Emmet 的一个强大工具,展开[缩写](/abbreviations/),并将选中的内容放在最后生成的元素内。如果没有选择,则调用[匹配标签](/actions/match-pair/)功能,包裹匹配的元素。 9 | 10 | 19 | 20 | ## Wrapping individual lines 分行包裹 21 | 22 | Very commonly, web-developers will need to wrap text in HTML tags. For example, you may receive a text document from your client and need to wrap each paragraph with `

` tag or list of menu items with `