{"_id":"vscode-expand-abbreviation","_rev":"264872","name":"vscode-expand-abbreviation","description":"A fork of @emmetio/expand-abbreviation module","dist-tags":{"latest":"0.5.8"},"maintainers":[{"name":"ramya-rao-a","email":"ramya.rao.a@outlook.com"}],"time":{"modified":"2023-03-27T18:55:47.000Z","created":"2017-07-31T20:25:46.013Z","0.5.8":"2017-07-31T20:25:46.013Z"},"users":{},"author":{"name":"Sergey Chikuyonok","email":"serge.che@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/emmetio/expand-abbreviation.git"},"versions":{"0.5.8":{"name":"vscode-expand-abbreviation","version":"0.5.8","description":"A fork of @emmetio/expand-abbreviation module","main":"dist/expand.cjs.js","module":"dist/expand.es.js","dependencies":{"emmet-abbreviation-helper":"0.6.1","@emmetio/css-abbreviation":"^0.3.1","@emmetio/css-snippets-resolver":"^0.2.5","@emmetio/html-snippets-resolver":"^0.1.4","@emmetio/html-transform":"^0.3.2","@emmetio/lorem":"^1.0.1","@emmetio/markup-formatters":"^0.3.3","@emmetio/output-profile":"^0.1.5","@emmetio/snippets":"^0.2.4","@emmetio/snippets-registry":"^0.3.1","@emmetio/stylesheet-formatters":"^0.1.2","@emmetio/variable-resolver":"^0.2.1"},"devDependencies":{"babel-plugin-transform-es2015-modules-commonjs":"^6.22.0","babel-register":"^6.22.0","mocha":"^3.4.1","rollup":"^0.41.4","rollup-plugin-node-resolve":"^2.0.0"},"scripts":{"test":"mocha","build":"rollup -c && npm run build:full","build:full":"rollup -c --environment BUILD_FULL","prepublish":"npm run test && npm run build"},"repository":{"type":"git","url":"git+https://github.com/emmetio/expand-abbreviation.git"},"keywords":["emmet","abbreviation","expand"],"author":{"name":"Sergey Chikuyonok","email":"serge.che@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/emmetio/expand-abbreviation/issues"},"homepage":"https://github.com/emmetio/expand-abbreviation#readme","gitHead":"5ac8b8656c305f608714e9ef4b404e89f78d7323","_id":"vscode-expand-abbreviation@0.5.8","_shasum":"0f389df6911ef628c195050ef1684c8e5804e346","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.4","_npmUser":{"name":"ramya-rao-a","email":"ramya.rao.a@outlook.com"},"dist":{"shasum":"0f389df6911ef628c195050ef1684c8e5804e346","size":49891,"noattachment":false,"key":"/vscode-expand-abbreviation/-/vscode-expand-abbreviation-0.5.8.tgz","tarball":"http://name.csiicloud.com:7001/vscode-expand-abbreviation/download/vscode-expand-abbreviation-0.5.8.tgz"},"maintainers":[{"name":"ramya-rao-a","email":"ramya.rao.a@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vscode-expand-abbreviation-0.5.8.tgz_1501532744861_0.6410048906691372"},"directories":{},"publish_time":1501532746013,"_hasShrinkwrap":false,"_cnpm_publish_time":1501532746013,"_cnpmcore_publish_time":"2021-12-16T16:04:30.955Z"}},"readme":"# [Emmet](http://emmet.io) abbreviation expander\r\n\r\nReference implementation of Emmet’s “Expand Abbreviation” action.\r\n\r\n```js\r\nimport { expand } from '@emmetio/expand-abbreviation';\r\n\r\nconsole.log(expand('ul.nav>.nav-item{Item $}*2'));\r\n// outputs:\r\n// <ul class=\"nav\">\r\n//   <li class=\"nav-item\">Item 1</li>\r\n//   <li class=\"nav-item\">Item 2</li>\r\n// </ul>\r\n\r\n// use XHTML-style output\r\nconsole.log(expand('img[src=image.png]', {\r\n    profile: {\r\n        selfClosingStyle: 'xhtml'\r\n    }\r\n}));\r\n// outputs: <img src=\"image.png\" alt=\"\" />\r\n\r\n// Output in Slim syntax\r\nconsole.log(expand('ul.nav>.nav-item{Item $}*2', {syntax: 'slim'}));\r\n// outputs:\r\n// ul.nav\r\n//   li.nav-item Item 1\r\n//   li.nav-item Item 2\r\n```\r\n\r\n## API\r\n\r\nThis module exports two functions: `parse(abbr, options)` and `expand(abbr, options)`.\r\n\r\nThe `parse(abbr, options)` function [parses abbreviation into tree](https://github.com/emmetio/abbreviation), applies various transformations required for proper output and returns parsed tree. The `expand(abbr, options)` does the same but returns formatted string. In most cases you should use `expand(abbr, options)` only but if you want to update parsed abbreviation somehow, you can `parse()` abbreviation first, update parsed tree and then `expand()` it:\r\n\r\n```js\r\nimport { parse, expand } from '@emmetio/expand-abbreviation';\r\n\r\n// 1. Parse string abbreviation into tree\r\nconst tree = parse('ul>.item*3');\r\n\r\n// 2. Walk on each tree node, update them somehow\r\ntree.walk(node => { ... });\r\n\r\n// 3. Output result\r\nconsole.log(expand(tree));\r\n```\r\n\r\n### Options\r\n\r\nBoth `parse()` and `expand()` methods accept the following options:\r\n\r\n* `syntax` (string): abbreviation output syntax. Currently supported syntaxes are: `html`, `slim`, `pug`, `haml`.\r\n* `field(index, placeholder)` (function): field/tabstop generator for host editor. Most editors support TextMate-style fields: `${0}` or `${1:placeholder}`. For TextMate-style fields this function will look like this:\r\n\r\n```js\r\nconst field = (index, placeholder) => `\\${${index}${placeholder ? ':' + placeholder : ''}}`;\r\n```\r\n\r\n> Emmet natively supports TextMate fields and provides [module for parsing them](https://github.com/emmetio/field-parser).\r\n\r\n* `text` (string or array of strings): insert given text string(s) into expanded abbreviation. If array of strings is given, the implicitly repeated element (e.g. `li*`) will be repeated by the amount of items in array.\r\n* `profile` (object or [`Profile`](https://github.com/emmetio/output-profile)): either predefined [output profile](https://github.com/emmetio/output-profile) or options for output profile. Used for by [markup formatters](https://github.com/emmetio/markup-formatters) to shape-up final output.\r\n* `variables` (object): custom variables for [variable resolver](https://github.com/emmetio/variable-resolver).\r\n* `snippets` (object, array of objects or [`SnippetsRegistry`](https://github.com/emmetio/snippets-registry)): custom predefined snippets for abbreviation. The expanded abbreviation will try to match given snippets that may contain custom elements, predefined attributes etc. May also contain array of items: either snippets (object) or references to [default syntax snippets](https://github.com/emmetio/snippets) (string; the key in default snippets hash).\r\n* `addons` (object): hash of [additional transformations](https://github.com/emmetio/html-transform/tree/master/lib/addons) that should be applied to expanded abbreviation, like BEM or JSX. Since these transformations introduce side-effect, they are disabled by default and should be enabled by providing a transform name as key and transform options as value:\r\n\r\n```js\r\n{\r\n    bem: {element: '--'}, // enable transform & override options\r\n    jsx: true // no options, just enable transform\r\n}\r\n```\r\n\r\n* `format` (object): additional options for output formatter. Currently, [HTML element commenting](https://github.com/emmetio/markup-formatters/blob/master/format/html.js#L33) is the only supported format option.\r\n\r\nSee [`test`](/test) folder for usage examples.\r\n\r\n## Design goals\r\n\r\nThis module is just an umbrella projects that combines various stand-alone submodules into a unified process for parsing and outputting Emmet abbreviations. Thus, you can create your own “Expand Abbreviation” implementation that can re-use these submodules with additional tweaks and transforms that matches your requirements.\r\n\r\nThe standard abbreviation expanding workflow:\r\n\r\n1. [Parse Emmet abbreviation](https://github.com/emmetio/abbreviation) into DOM-like tree.\r\n1. [Prepare parsed tree for markup output](https://github.com/emmetio/html-transform). This step includes implicit name resolving (`.item` → `div.item`), item numbering (`.item$*2` → `.item1+.item2`) and so on.\r\n1. Match tree nodes with [predefined snippets](https://github.com/emmetio/snippets). Snippets are basically another Emmet abbreviations that define element shape (name, attributes, self-closing etc.).\r\n1. [Resolve variables](https://github.com/emmetio/variable-resolver) in parsed tree.\r\n1. Convert parsed abbreviation to formatted string using [markup formatters](https://github.com/emmetio/markup-formatters).\r\n\r\n## Build targets\r\n\r\n`@emmetio/expand-abbreviation` NPM module is available in two flavors: CommonJS and ES6 modules. There’s also a complete, zero-dependency UMD module suitable for browsers (see `dist/expand-full.js`).\r\n","_attachments":{},"homepage":"https://github.com/emmetio/expand-abbreviation#readme","bugs":{"url":"https://github.com/emmetio/expand-abbreviation/issues"},"license":"MIT"}