{"_id":"cssesc","_rev":"77883","name":"cssesc","description":"A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"mathias","email":""}],"time":{"modified":"2021-06-03T10:25:00.000Z","created":"2013-08-09T13:30:13.761Z","3.0.0":"2019-02-04T16:34:20.250Z","2.0.0":"2018-04-25T08:23:57.308Z","1.0.1":"2018-03-25T12:41:20.795Z","1.0.0":"2016-09-28T21:39:50.026Z","0.1.0":"2013-08-09T13:30:13.761Z"},"users":{"yinyongcom666":true,"maddas":true},"author":{"name":"Mathias Bynens","url":"https://mathiasbynens.be/"},"repository":{"type":"git","url":"git+https://github.com/mathiasbynens/cssesc.git"},"versions":{"3.0.0":{"name":"cssesc","version":"3.0.0","description":"A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.","homepage":"https://mths.be/cssesc","engines":{"node":">=4"},"main":"cssesc.js","bin":{"cssesc":"bin/cssesc"},"man":["man/cssesc.1"],"keywords":["css","escape","identifier","string","tool"],"license":"MIT","author":{"name":"Mathias Bynens","url":"https://mathiasbynens.be/"},"repository":{"type":"git","url":"git+https://github.com/mathiasbynens/cssesc.git"},"bugs":{"url":"https://github.com/mathiasbynens/cssesc/issues"},"scripts":{"build":"grunt template && babel cssesc.js -o cssesc.js","test":"mocha tests","cover":"istanbul cover --report html node_modules/.bin/_mocha tests -- -u exports -R spec"},"devDependencies":{"babel-cli":"^6.26.0","babel-preset-env":"^1.6.1","codecov":"^1.0.1","grunt":"^1.0.1","grunt-template":"^1.0.0","istanbul":"^0.4.4","mocha":"^2.5.3","regenerate":"^1.2.1","requirejs":"^2.1.16"},"gitHead":"cb894eb42f27c8d3cd793f16afe35b3ab38000a1","_id":"cssesc@3.0.0","_nodeVersion":"10.4.0","_npmVersion":"6.7.0","dist":{"shasum":"37741919903b868565e1c09ea747445cd18983ee","size":6495,"noattachment":false,"key":"/cssesc/-/cssesc-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cssesc/download/cssesc-3.0.0.tgz"},"maintainers":[{"name":"mathias","email":""}],"_npmUser":{"name":"mathias","email":"mathias@qiwi.be"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cssesc_3.0.0_1549298060123_0.3791149152663338"},"_hasShrinkwrap":false,"publish_time":1549298060250,"_cnpm_publish_time":1549298060250},"2.0.0":{"name":"cssesc","version":"2.0.0","description":"A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.","homepage":"https://mths.be/cssesc","engines":{"node":">=4"},"main":"cssesc.js","bin":{"cssesc":"bin/cssesc"},"man":["man/cssesc.1"],"keywords":["css","escape","identifier","string","tool"],"license":"MIT","author":{"name":"Mathias Bynens","url":"https://mathiasbynens.be/"},"repository":{"type":"git","url":"git+https://github.com/mathiasbynens/cssesc.git"},"bugs":{"url":"https://github.com/mathiasbynens/cssesc/issues"},"files":["LICENSE-MIT.txt","cssesc.js","bin/","man/"],"scripts":{"build":"grunt template && babel cssesc.js -o cssesc.js","test":"mocha tests","cover":"istanbul cover --report html node_modules/.bin/_mocha tests -- -u exports -R spec"},"devDependencies":{"babel-cli":"^6.26.0","babel-preset-env":"^1.6.1","codecov":"^1.0.1","grunt":"^1.0.1","grunt-template":"^1.0.0","istanbul":"^0.4.4","mocha":"^2.5.3","regenerate":"^1.2.1","requirejs":"^2.1.16"},"gitHead":"12a4aeca706d4fc589fd645fa9b27f83414a46df","_id":"cssesc@2.0.0","_npmVersion":"5.8.0","_nodeVersion":"8.10.0","_npmUser":{"name":"mathias","email":"mathias@qiwi.be"},"dist":{"shasum":"3b13bd1bb1cb36e1bcb5a4dcd27f54c5dcb35703","size":6615,"noattachment":false,"key":"/cssesc/-/cssesc-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cssesc/download/cssesc-2.0.0.tgz"},"maintainers":[{"name":"mathias","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cssesc_2.0.0_1524644637233_0.5067917713067536"},"_hasShrinkwrap":false,"publish_time":1524644637308,"_cnpm_publish_time":1524644637308},"1.0.1":{"name":"cssesc","version":"1.0.1","description":"A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.","homepage":"https://mths.be/cssesc","engines":{"node":">=4"},"main":"cssesc.js","bin":{"cssesc":"bin/cssesc"},"man":["man/cssesc.1"],"keywords":["css","escape","identifier","string","tool"],"license":"MIT","author":{"name":"Mathias Bynens","url":"https://mathiasbynens.be/"},"repository":{"type":"git","url":"git+https://github.com/mathiasbynens/cssesc.git"},"bugs":{"url":"https://github.com/mathiasbynens/cssesc/issues"},"files":["LICENSE-MIT.txt","cssesc.js","bin/","man/"],"scripts":{"build":"grunt template","test":"mocha tests","cover":"istanbul cover --report html node_modules/.bin/_mocha tests -- -u exports -R spec"},"devDependencies":{"codecov":"^1.0.1","grunt":"^1.0.1","grunt-template":"^1.0.0","istanbul":"^0.4.4","mocha":"^2.5.3","regenerate":"^1.2.1","requirejs":"^2.1.16"},"gitHead":"c124697ebb086fb3a20519a3d95141e62298f727","_id":"cssesc@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"mathias","email":"mathias@qiwi.be"},"dist":{"shasum":"ef7bd8d0229ed6a3a7051ff7771265fe7330e0a8","size":6570,"noattachment":false,"key":"/cssesc/-/cssesc-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/cssesc/download/cssesc-1.0.1.tgz"},"maintainers":[{"name":"mathias","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cssesc_1.0.1_1521981680742_0.9027062666161223"},"_hasShrinkwrap":false,"publish_time":1521981680795,"_cnpm_publish_time":1521981680795},"1.0.0":{"name":"cssesc","version":"1.0.0","description":"A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.","homepage":"https://mths.be/cssesc","engines":{"node":">=4"},"main":"cssesc.js","bin":{"cssesc":"bin/cssesc"},"man":["man/cssesc.1"],"keywords":["css","escape","identifier","string","tool"],"license":"MIT","author":{"name":"Mathias Bynens","url":"https://mathiasbynens.be/"},"repository":{"type":"git","url":"git+https://github.com/mathiasbynens/cssesc.git"},"bugs":{"url":"https://github.com/mathiasbynens/cssesc/issues"},"files":["LICENSE-MIT.txt","cssesc.js","bin/","man/"],"scripts":{"build":"grunt template","test":"mocha tests","cover":"istanbul cover --report html node_modules/.bin/_mocha tests -- -u exports -R spec"},"devDependencies":{"codecov":"^1.0.1","grunt":"^1.0.1","grunt-template":"^1.0.0","istanbul":"^0.4.4","mocha":"^2.5.3","regenerate":"^1.2.1","requirejs":"^2.1.16"},"gitHead":"3c3cbe285bbea1961e33d739ccc17ec4dcd66479","_id":"cssesc@1.0.0","_shasum":"5a6c0f71c93e99c4bda3dbd0f088e59f18676e56","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.4.0","_npmUser":{"name":"mathias","email":"mathias@qiwi.be"},"maintainers":[{"name":"mathias","email":""}],"dist":{"shasum":"5a6c0f71c93e99c4bda3dbd0f088e59f18676e56","size":6571,"noattachment":false,"key":"/cssesc/-/cssesc-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cssesc/download/cssesc-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/cssesc-1.0.0.tgz_1475098788193_0.1862117713317275"},"directories":{},"publish_time":1475098790026,"_cnpm_publish_time":1475098790026,"_hasShrinkwrap":false},"0.1.0":{"name":"cssesc","version":"0.1.0","description":"A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.","homepage":"http://mths.be/cssesc","main":"cssesc.js","bin":{"cssesc":"bin/cssesc"},"man":["man/cssesc.1"],"keywords":["css","escape","identifier","string","tool"],"licenses":[{"type":"MIT","url":"http://mths.be/mit"}],"author":{"name":"Mathias Bynens","url":"http://mathiasbynens.be/"},"repository":{"type":"git","url":"https://github.com/mathiasbynens/cssesc.git"},"bugs":{"url":"https://github.com/mathiasbynens/cssesc/issues"},"files":["LICENSE-MIT.txt","cssesc.js","bin/","man/"],"directories":{"test":"tests"},"scripts":{"test":"node tests/tests.js"},"dependencies":{},"devDependencies":{"grunt":"~0.4.1","grunt-shell":"~0.3.1","grunt-template":"~0.2.0","istanbul":"~0.1.42","qunit-clib":"~1.3.0","qunitjs":"~1.11.0","regenerate":"~0.5.2","requirejs":"~2.1.8"},"readmeFilename":"README.md","_id":"cssesc@0.1.0","dist":{"shasum":"c814903e45623371a0477b40109aaafbeeaddbb4","size":6960,"noattachment":false,"key":"/cssesc/-/cssesc-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cssesc/download/cssesc-0.1.0.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"mathias","email":"mathias@qiwi.be"},"maintainers":[{"name":"mathias","email":""}],"publish_time":1376055013761,"_cnpm_publish_time":1376055013761,"_hasShrinkwrap":false}},"readme":"# cssesc [![Build status](https://travis-ci.org/mathiasbynens/cssesc.svg?branch=master)](https://travis-ci.org/mathiasbynens/cssesc) [![Code coverage status](https://img.shields.io/codecov/c/github/mathiasbynens/cssesc.svg)](https://codecov.io/gh/mathiasbynens/cssesc)\n\nA JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.\n\nThis is a JavaScript library for [escaping text for use in CSS strings or identifiers](https://mathiasbynens.be/notes/css-escapes) while generating the shortest possible valid ASCII-only output. [Here’s an online demo.](https://mothereff.in/css-escapes)\n\n[A polyfill for the CSSOM `CSS.escape()` method is available in a separate repository.](https://mths.be/cssescape) (In comparison, _cssesc_ is much more powerful.)\n\nFeel free to fork if you see possible improvements!\n\n## Installation\n\nVia [npm](https://www.npmjs.com/):\n\n```bash\nnpm install cssesc\n```\n\nIn a browser:\n\n```html\n<script src=\"cssesc.js\"></script>\n```\n\nIn [Node.js](https://nodejs.org/):\n\n```js\nconst cssesc = require('cssesc');\n```\n\nIn Ruby using [the `ruby-cssesc` wrapper gem](https://github.com/borodean/ruby-cssesc):\n\n```bash\ngem install ruby-cssesc\n```\n\n```ruby\nrequire 'ruby-cssesc'\nCSSEsc.escape('I ♥ Ruby', is_identifier: true)\n```\n\nIn Sass using [`sassy-escape`](https://github.com/borodean/sassy-escape):\n\n```bash\ngem install sassy-escape\n```\n\n```scss\nbody {\n  content: escape('I ♥ Sass', $is-identifier: true);\n}\n```\n\n## API\n\n### `cssesc(value, options)`\n\nThis function takes a value and returns an escaped version of the value where any characters that are not printable ASCII symbols are escaped using the shortest possible (but valid) [escape sequences for use in CSS strings or identifiers](https://mathiasbynens.be/notes/css-escapes).\n\n```js\ncssesc('Ich ♥ Bücher');\n// → 'Ich \\\\2665  B\\\\FC cher'\n\ncssesc('foo ???? bar');\n// → 'foo \\\\1D306  bar'\n```\n\nBy default, `cssesc` returns a string that can be used as part of a CSS string. If the target is a CSS identifier rather than a CSS string, use the `isIdentifier: true` setting (see below).\n\nThe optional `options` argument accepts an object with the following options:\n\n#### `isIdentifier`\n\nThe default value for the `isIdentifier` option is `false`. This means that the input text will be escaped for use in a CSS string literal. If you want to use the result as a CSS identifier instead (in a selector, for example), set this option to `true`.\n\n```js\ncssesc('123a2b');\n// → '123a2b'\n\ncssesc('123a2b', {\n  'isIdentifier': true\n});\n// → '\\\\31 23a2b'\n```\n\n#### `quotes`\n\nThe default value for the `quotes` option is `'single'`. This means that any occurences of `'` in the input text will be escaped as `\\'`, so that the output can be used in a CSS string literal wrapped in single quotes.\n\n```js\ncssesc('Lorem ipsum \"dolor\" sit \\'amet\\' etc.');\n// → 'Lorem ipsum \"dolor\" sit \\\\\\'amet\\\\\\' etc.'\n// → \"Lorem ipsum \\\"dolor\\\" sit \\\\'amet\\\\' etc.\"\n\ncssesc('Lorem ipsum \"dolor\" sit \\'amet\\' etc.', {\n  'quotes': 'single'\n});\n// → 'Lorem ipsum \"dolor\" sit \\\\\\'amet\\\\\\' etc.'\n// → \"Lorem ipsum \\\"dolor\\\" sit \\\\'amet\\\\' etc.\"\n```\n\nIf you want to use the output as part of a CSS string literal wrapped in double quotes, set the `quotes` option to `'double'`.\n\n```js\ncssesc('Lorem ipsum \"dolor\" sit \\'amet\\' etc.', {\n  'quotes': 'double'\n});\n// → 'Lorem ipsum \\\\\"dolor\\\\\" sit \\'amet\\' etc.'\n// → \"Lorem ipsum \\\\\\\"dolor\\\\\\\" sit 'amet' etc.\"\n```\n\n#### `wrap`\n\nThe `wrap` option takes a boolean value (`true` or `false`), and defaults to `false` (disabled). When enabled, the output will be a valid CSS string literal wrapped in quotes. The type of quotes can be specified through the `quotes` setting.\n\n```js\ncssesc('Lorem ipsum \"dolor\" sit \\'amet\\' etc.', {\n  'quotes': 'single',\n  'wrap': true\n});\n// → '\\'Lorem ipsum \"dolor\" sit \\\\\\'amet\\\\\\' etc.\\''\n// → \"\\'Lorem ipsum \\\"dolor\\\" sit \\\\\\'amet\\\\\\' etc.\\'\"\n\ncssesc('Lorem ipsum \"dolor\" sit \\'amet\\' etc.', {\n  'quotes': 'double',\n  'wrap': true\n});\n// → '\"Lorem ipsum \\\\\"dolor\\\\\" sit \\'amet\\' etc.\"'\n// → \"\\\"Lorem ipsum \\\\\\\"dolor\\\\\\\" sit \\'amet\\' etc.\\\"\"\n```\n\n#### `escapeEverything`\n\nThe `escapeEverything` option takes a boolean value (`true` or `false`), and defaults to `false` (disabled). When enabled, all the symbols in the output will be escaped, even printable ASCII symbols.\n\n```js\ncssesc('lolwat\"foo\\'bar', {\n  'escapeEverything': true\n});\n// → '\\\\6C\\\\6F\\\\6C\\\\77\\\\61\\\\74\\\\\"\\\\66\\\\6F\\\\6F\\\\\\'\\\\62\\\\61\\\\72'\n// → \"\\\\6C\\\\6F\\\\6C\\\\77\\\\61\\\\74\\\\\\\"\\\\66\\\\6F\\\\6F\\\\'\\\\62\\\\61\\\\72\"\n```\n\n#### Overriding the default options globally\n\nThe global default settings can be overridden by modifying the `css.options` object. This saves you from passing in an `options` object for every call to `encode` if you want to use the non-default setting.\n\n```js\n// Read the global default setting for `escapeEverything`:\ncssesc.options.escapeEverything;\n// → `false` by default\n\n// Override the global default setting for `escapeEverything`:\ncssesc.options.escapeEverything = true;\n\n// Using the global default setting for `escapeEverything`, which is now `true`:\ncssesc('foo © bar ≠ baz ???? qux');\n// → '\\\\66\\\\6F\\\\6F\\\\ \\\\A9\\\\ \\\\62\\\\61\\\\72\\\\ \\\\2260\\\\ \\\\62\\\\61\\\\7A\\\\ \\\\1D306\\\\ \\\\71\\\\75\\\\78'\n```\n\n### `cssesc.version`\n\nA string representing the semantic version number.\n\n### Using the `cssesc` binary\n\nTo use the `cssesc` binary in your shell, simply install cssesc globally using npm:\n\n```bash\nnpm install -g cssesc\n```\n\nAfter that you will be able to escape text for use in CSS strings or identifiers from the command line:\n\n```bash\n$ cssesc 'föo ♥ bår ???? baz'\nf\\F6o \\2665  b\\E5r \\1D306  baz\n```\n\nIf the output needs to be a CSS identifier rather than part of a string literal, use the `-i`/`--identifier` option:\n\n```bash\n$ cssesc --identifier 'föo ♥ bår ???? baz'\nf\\F6o\\ \\2665\\ b\\E5r\\ \\1D306\\ baz\n```\n\nSee `cssesc --help` for the full list of options.\n\n## Support\n\nThis library supports the Node.js and browser versions mentioned in [`.babelrc`](https://github.com/mathiasbynens/cssesc/blob/master/.babelrc). For a version that supports a wider variety of legacy browsers and environments out-of-the-box, [see v0.1.0](https://github.com/mathiasbynens/cssesc/releases/tag/v0.1.0).\n\n## Author\n\n| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias \"Follow @mathias on Twitter\") |\n|---|\n| [Mathias Bynens](https://mathiasbynens.be/) |\n\n## License\n\nThis library is available under the [MIT](https://mths.be/mit) license.\n","_attachments":{},"homepage":"https://mths.be/cssesc","bugs":{"url":"https://github.com/mathiasbynens/cssesc/issues"},"license":"MIT"}