{"_id":"parserlib","_rev":"143882","name":"parserlib","description":"CSS3 SAX-inspired parser","dist-tags":{"latest":"1.1.1"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"time":{"modified":"2021-06-03T11:28:35.000Z","created":"2012-02-10T21:03:20.892Z","1.1.1":"2016-12-06T08:34:57.297Z","1.1.0":"2016-12-06T08:30:32.948Z","1.0.0":"2016-07-15T09:49:54.784Z","0.2.5":"2014-05-07T19:51:02.261Z","0.2.4":"2014-01-07T15:33:53.024Z","0.2.3":"2013-06-19T18:19:19.741Z","0.2.2":"2013-01-17T18:27:31.119Z","0.2.1":"2012-12-04T19:58:58.645Z","0.2.0":"2012-11-13T21:18:47.983Z","0.1.8":"2012-07-23T16:57:56.063Z","0.1.6":"2012-03-02T22:45:10.759Z","0.1.5":"2012-02-10T21:03:20.892Z"},"users":{"fgribreau":true,"tivac":true,"nschonni":true,"erikvold":true,"arleytriana":true,"xueboren":true},"author":{"name":"Nicholas C. Zakas"},"repository":{"type":"git","url":"git+https://github.com/CSSLint/parser-lib.git"},"versions":{"1.1.1":{"name":"parserlib","version":"1.1.1","author":{"name":"Nicholas C. Zakas"},"contributors":[{"name":"Nick Schonning"}],"description":"CSS3 SAX-inspired parser","license":"MIT","homepage":"https://github.com/CSSLint/parser-lib","repository":{"type":"git","url":"git+https://github.com/CSSLint/parser-lib.git"},"bugs":{"url":"https://github.com/CSSLint/parser-lib/issues"},"keywords":["parser","css","css3","sax","style","stylesheet"],"main":"./src/index.js","scripts":{"coverage":"ytestrunner -c","lint":"jshint scripts src tests","pretest":"npm run lint","build":"node scripts/build.js","test-yuitest":"ytestrunner","test":"npm run lint && npm run test-yuitest","prepublish":"npm test"},"devDependencies":{"babybird":"0.0.1","browserify":"^13.0.0","concat-stream":"^1.5.1","factor-bundle":"^2.5.0","jshint":"^2.9.1","moment":"^2.11.2","shelljs":"^0.7.5","ytestrunner":"^0.3.3","yuitest":"^0.7.9"},"files":["dist","src"],"gitHead":"e709784d9f8c8f9e360bcddacc8c4b750376ce9f","_id":"parserlib@1.1.1","_shasum":"a64cfa724062434fdfc351c9a4ec2d92b94c06f4","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"dist":{"shasum":"a64cfa724062434fdfc351c9a4ec2d92b94c06f4","size":217393,"noattachment":false,"key":"/parserlib/-/parserlib-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-1.1.1.tgz"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/parserlib-1.1.1.tgz_1481013296664_0.7191815511323512"},"directories":{},"publish_time":1481013297297,"_cnpm_publish_time":1481013297297,"_hasShrinkwrap":false},"1.1.0":{"name":"parserlib","version":"1.1.0","author":{"name":"Nicholas C. Zakas"},"contributors":[{"name":"Nick Schonning"}],"description":"CSS3 SAX-inspired parser","license":"MIT","homepage":"https://github.com/CSSLint/parser-lib","repository":{"type":"git","url":"git+https://github.com/CSSLint/parser-lib.git"},"bugs":{"url":"https://github.com/CSSLint/parser-lib/issues"},"keywords":["parser","css","css3","sax","style","stylesheet"],"main":"./src/index.js","scripts":{"coverage":"ytestrunner -c","lint":"jshint scripts src tests","pretest":"npm run lint","build":"node scripts/build.js","test-yuitest":"ytestrunner","test":"npm run lint && npm run test-yuitest","prepublish":"npm test"},"devDependencies":{"babybird":"0.0.1","browserify":"^13.0.0","concat-stream":"^1.5.1","factor-bundle":"^2.5.0","jshint":"^2.9.1","moment":"^2.11.2","shelljs":"^0.7.5","ytestrunner":"^0.3.3","yuitest":"^0.7.9"},"files":["dist","src"],"gitHead":"413b0bedc8eed1641da356a17d0a0a02712c6f83","_id":"parserlib@1.1.0","_shasum":"210c2264da935bcc848d7fa2925ce3f2f9f51e74","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"dist":{"shasum":"210c2264da935bcc848d7fa2925ce3f2f9f51e74","size":214496,"noattachment":false,"key":"/parserlib/-/parserlib-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-1.1.0.tgz"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/parserlib-1.1.0.tgz_1481013030894_0.5879004206508398"},"directories":{},"publish_time":1481013032948,"_cnpm_publish_time":1481013032948,"_hasShrinkwrap":false},"1.0.0":{"name":"parserlib","version":"1.0.0","author":{"name":"Nicholas C. Zakas"},"contributors":[{"name":"Nick Schonning"}],"description":"CSS3 SAX-inspired parser","license":"MIT","homepage":"https://github.com/CSSLint/parser-lib","repository":{"type":"git","url":"git+https://github.com/CSSLint/parser-lib.git"},"bugs":{"url":"https://github.com/CSSLint/parser-lib/issues"},"keywords":["parser","css","css3","sax","style","stylesheet"],"main":"./src/index.js","scripts":{"coverage":"ytestrunner -c","lint":"jshint scripts src tests","pretest":"npm run lint","build":"node scripts/build.js","test-yuitest":"ytestrunner","test":"npm run lint && npm run test-yuitest","prepublish":"npm test"},"devDependencies":{"babybird":"0.0.1","browserify":"^13.0.0","concat-stream":"^1.5.1","factor-bundle":"^2.5.0","jshint":"^2.9.1","moment":"^2.11.2","shelljs":"^0.6.0","ytestrunner":"^0.3.3","yuitest":"^0.7.9"},"files":["dist","src"],"gitHead":"0f2e45dd09b4217aafe727e79fe77eac601c6aac","_id":"parserlib@1.0.0","_shasum":"88340e7e8d95bac9e09236742eef53bec1e4b30f","_from":".","_npmVersion":"2.15.8","_nodeVersion":"4.4.7","_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"dist":{"shasum":"88340e7e8d95bac9e09236742eef53bec1e4b30f","size":213511,"noattachment":false,"key":"/parserlib/-/parserlib-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-1.0.0.tgz"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/parserlib-1.0.0.tgz_1468576192194_0.15145790157839656"},"directories":{},"publish_time":1468576194784,"_cnpm_publish_time":1468576194784,"_hasShrinkwrap":false},"0.2.5":{"name":"parserlib","version":"0.2.5","author":{"name":"Nicholas C. Zakas"},"contributors":[{"name":"Nick Schonning"}],"description":"CSS3 SAX-inspired parser","license":"MIT","homepage":"https://github.com/CSSLint/parser-lib","repository":{"type":"git","url":"http://github.com/CSSLint/parser-lib.git"},"bugs":{"url":"https://github.com/CSSLint/parser-lib/issues"},"keywords":["parser","css","css3","sax","style","stylesheet"],"main":"./lib/node-parserlib.js","scripts":{"test":"ant -f ../../build.xml test","prepublish":"npm test"},"_id":"parserlib@0.2.5","dist":{"shasum":"85907dd8605aa06abb3dd295d50bb2b8fa4dd117","size":44889,"noattachment":false,"key":"/parserlib/-/parserlib-0.2.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-0.2.5.tgz"},"_from":"release/npm","_npmVersion":"1.4.3","_npmUser":{"name":"nschonni","email":"nschonni@gmail.com"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"directories":{},"publish_time":1399492262261,"_cnpm_publish_time":1399492262261,"_hasShrinkwrap":false},"0.2.4":{"name":"parserlib","version":"0.2.4","description":"CSS3 SAX-inspired parser","author":{"name":"Nicholas C. Zakas"},"keywords":["parser","css","css3","sax","style","stylesheet"],"contributors":[],"engines":{"node":">=0.2.0"},"directories":{"lib":"lib"},"main":"./lib/node-parserlib.js","licenses":[{"type":"MIT","url":"https://github.com/nzakas/parser-lib/blob/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/nzakas/parser-lib.git"},"scripts":{"test":"ant -f ../../build.xml test","prepublish":"npm test"},"readmeFilename":"README.md","bugs":{"url":"https://github.com/nzakas/parser-lib/issues"},"_id":"parserlib@0.2.4","dist":{"shasum":"40e9a91170548fa4c0b24b3e6272bf45a2135c54","size":44254,"noattachment":false,"key":"/parserlib/-/parserlib-0.2.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-0.2.4.tgz"},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"publish_time":1389108833024,"_cnpm_publish_time":1389108833024,"_hasShrinkwrap":false},"0.2.3":{"name":"parserlib","version":"0.2.3","description":"CSS3 SAX-inspired parser","author":{"name":"Nicholas C. Zakas"},"keywords":["parser","css","css3","sax","style","stylesheet"],"contributors":[],"engines":{"node":">=0.2.0"},"directories":{"lib":"lib"},"main":"./lib/node-parserlib.js","licenses":[{"type":"MIT","url":"https://github.com/nzakas/parser-lib/blob/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/nzakas/parser-lib.git"},"scripts":{"test":"ant -f ../../build.xml test","prepublish":"npm test"},"_id":"parserlib@0.2.3","dist":{"shasum":"53b3818a5117c4c289e6cc6fb208eac215476a1a","size":39492,"noattachment":false,"key":"/parserlib/-/parserlib-0.2.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-0.2.3.tgz"},"_npmVersion":"1.1.59","_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"publish_time":1371665959741,"_cnpm_publish_time":1371665959741,"_hasShrinkwrap":false},"0.2.2":{"name":"parserlib","version":"0.2.2","description":"CSSLint","author":{"name":"Nicholas C. Zakas"},"contributors":[],"engines":{"node":">=0.2.0"},"directories":{"lib":"lib"},"main":"./lib/node-parserlib.js","licenses":[{"type":"MIT","url":"https://github.com/nzakas/parser-lib/blob/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/nzakas/parser-lib.git"},"_id":"parserlib@0.2.2","dist":{"shasum":"49d300a1d8d0a2c7f36593d23b92260156291172","size":40001,"noattachment":false,"key":"/parserlib/-/parserlib-0.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-0.2.2.tgz"},"_npmVersion":"1.1.59","_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"publish_time":1358447251119,"_cnpm_publish_time":1358447251119,"_hasShrinkwrap":false},"0.2.1":{"name":"parserlib","version":"0.2.1","description":"CSSLint","author":{"name":"Nicholas C. Zakas"},"contributors":[],"engines":{"node":">=0.2.0"},"directories":{"lib":"lib"},"main":"./lib/node-parserlib.js","licenses":[{"type":"MIT","url":"https://github.com/nzakas/parser-lib/blob/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/nzakas/parser-lib.git"},"_id":"parserlib@0.2.1","dist":{"shasum":"084ece9e7ce368749f6dc3ea452f07c10d2e48ca","size":39941,"noattachment":false,"key":"/parserlib/-/parserlib-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-0.2.1.tgz"},"_npmVersion":"1.1.59","_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"publish_time":1354651138645,"_cnpm_publish_time":1354651138645,"_hasShrinkwrap":false},"0.2.0":{"name":"parserlib","version":"0.2.0","description":"CSSLint","author":{"name":"Nicholas C. Zakas"},"os":["darwin","linux"],"contributors":[],"engines":{"node":">=0.2.0"},"directories":{"lib":"lib"},"main":"./lib/node-parserlib.js","licenses":[{"type":"MIT","url":"https://github.com/nzakas/parser-lib/blob/master/LICENSE"}],"repository":{"type":"git","url":"http://github.com/nzakas/parser-lib.git"},"_id":"parserlib@0.2.0","dist":{"shasum":"8a720e60d557b110f1d37363ae632dde54c00a13","size":39189,"noattachment":false,"key":"/parserlib/-/parserlib-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-0.2.0.tgz"},"_npmVersion":"1.1.59","_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"publish_time":1352841527983,"_cnpm_publish_time":1352841527983,"_hasShrinkwrap":false},"0.1.8":{"name":"parserlib","version":"0.1.8","description":"CSSLint","author":{"name":"Nicholas C. Zakas"},"os":["darwin","linux"],"contributors":[],"engines":{"node":">=0.2.0"},"directories":{"lib":"lib"},"main":"./lib/node-parserlib.js","licenses":[{"type":"MIT","url":"https://github.com/nzakas/parser-lib/blob/master/LICENSE"}],"repository":{"type":"git","url":"git://github.com/nzakas/parser-lib.git"},"_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"_id":"parserlib@0.1.8","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.0-3","_nodeVersion":"v0.8.2","_defaultsLoaded":true,"dist":{"shasum":"43b2286f353c708fbeece05bd3848150952877b0","size":39258,"noattachment":false,"key":"/parserlib/-/parserlib-0.1.8.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-0.1.8.tgz"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"publish_time":1343062676063,"_cnpm_publish_time":1343062676063,"_hasShrinkwrap":false},"0.1.6":{"name":"parserlib","version":"0.1.6","description":"CSSLint","author":{"name":"Nicholas C. Zakas"},"os":["darwin","linux"],"contributors":[],"engines":{"node":">=0.2.0"},"directories":{"lib":"lib"},"main":"./lib/node-parserlib.js","licenses":[{"type":"MIT","url":"https://github.com/nzakas/parser-lib/blob/master/LICENSE"}],"repository":{"type":"git","url":"git://github.com/nzakas/parser-lib.git"},"_npmUser":{"name":"nzakas","email":"nzakas@yahoo-inc.com"},"_id":"parserlib@0.1.6","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.0-3","_nodeVersion":"v0.6.9","_defaultsLoaded":true,"dist":{"shasum":"a57b448aab82211e23bd117ce7792d54bd9c1e70","size":38975,"noattachment":false,"key":"/parserlib/-/parserlib-0.1.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-0.1.6.tgz"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"publish_time":1330728310759,"_cnpm_publish_time":1330728310759,"_hasShrinkwrap":false},"0.1.5":{"name":"parserlib","version":"0.1.5","description":"CSSLint","author":{"name":"Nicholas C. Zakas"},"os":["darwin","linux"],"contributors":[],"engines":{"node":">=0.2.0"},"directories":{"lib":"lib"},"main":"./lib/node-parserlib.js","licenses":[{"type":"MIT","url":"https://github.com/nzakas/parser-lib/blob/master/LICENSE"}],"repository":{"type":"git","url":"git://github.com/nzakas/parser-lib.git"},"_npmUser":{"name":"nzakas","email":"nzakas@yahoo-inc.com"},"_id":"parserlib@0.1.5","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.0-3","_nodeVersion":"v0.6.9","_defaultsLoaded":true,"dist":{"shasum":"dd21c5711769011ab7e05df2587cd7d0f4f917dd","size":38968,"noattachment":false,"key":"/parserlib/-/parserlib-0.1.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/parserlib/download/parserlib-0.1.5.tgz"},"maintainers":[{"name":"cscott","email":"cscott@cscott.net"},{"name":"nschonni","email":"nschonni@gmail.com"},{"name":"stubbornella","email":"nicole@stubbornella.org"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"publish_time":1328907800892,"_cnpm_publish_time":1328907800892,"_hasShrinkwrap":false}},"readme":"# CSS Parser\r\n\r\n[![build status](https://secure.travis-ci.org/CSSLint/parser-lib.svg?branch=master)](https://travis-ci.org/CSSLint/parser-lib)\r\n\r\n## Introduction\r\n\r\nThe ParserLib CSS parser is a CSS3 SAX-inspired parser written in JavaScript.\r\nIt handles standard CSS syntax as well as validation (checking of\r\nproperty names and values) although it is not guaranteed to thoroughly\r\nvalidate all possible CSS properties.\r\n\r\n## Adding to your project\r\n\r\nThe CSS parser is built for a number of different JavaScript\r\nenvironments.  The most recently released version of the parser\r\ncan be found in the `dist` directory when you check out the\r\nrepository; run `npm run build` to regenerate them from the\r\nlatest sources.\r\n\r\n### Node.js\r\n\r\nYou can use the CSS parser in a `Node.js` script via the standard\r\n`npm` package manager as the `parserlib` package (`npm install parserlib`):\r\n\r\n```js\r\nvar parserlib = require(\"parserlib\");\r\n\r\nvar parser = new parserlib.css.Parser();\r\n```\r\n\r\nAlternatively, you can copy a single file version of the parser from\r\n`dist/node-parserlib.js` to your own project, and use it as follows:\r\n\r\n```js\r\nvar parserlib = require(\"./node-parserlib\");\r\n```\r\n\r\n### Rhino\r\n\r\nTo use the CSS parser in a Rhino script, copy the file\r\n`dist/parserlib.js` to your project and then include it at the beginning:\r\n\r\n```js\r\nload(\"parserlib.js\");\r\n```\r\n\r\n### HTML page\r\n\r\nTo use the CSS parser on an HTML page, you can either include the entire\r\nlibrary on your page:\r\n\r\n```html\r\n<script src=\"parserlib.js\"></script>\r\n```\r\n\r\nOr include it as its component parts, the ParserLib core and the CSS parser:\r\n\r\n```html\r\n<script src=\"parserlib-core.js\"></script>\r\n<script src=\"parserlib-css.js\"></script>\r\n```\r\n\r\nNote that parsing large JavaScript files may cause the browser to\r\nbecome unresponsive.  All three of these files are located in the\r\n`dist` directory.\r\n\r\n## Basic usage\r\n\r\nYou can create a new instance of the parser by using the following code:\r\n\r\n```js\r\nvar parser = new parserlib.css.Parser();\r\n```\r\n\r\nThe constructor accepts an options object that specifies additional features\r\nthe parser should use. The available options are:\r\n\r\n* `starHack` - set to true to treat properties with a leading asterisk as if\r\n  the asterisk wasn't there. Default is `false`.\r\n* `underscoreHack` - set to true to treat properties with a leading underscore\r\n  as if the underscore wasn't there. Default is `false`.\r\n* `ieFilters` - set to true to accept IE < 8 style `filter` properties.\r\n  Default is `false`.\r\n* `strict` - set to true to disable error recovery and stop on the first\r\n  syntax error. Default is `false`.\r\n\r\nHere's an example with some options set:\r\n\r\n```js\r\nvar parser = new parserlib.css.Parser({ starHack: true, underscoreHack: true });\r\n```\r\n\r\nYou can then parse a string of CSS code by passing into the `parse()` method:\r\n\r\n```js\r\nparser.parse(someCSSText);\r\n```\r\n\r\nThe `parse()` method throws an error if a non-recoverable syntax error occurs,\r\notherwise it finishes silently.\r\nThis method does not return a value nor does it build up an abstract syntax\r\ntree (AST) for you, it simply parses the CSS text and fires events at important\r\nmoments along the parse.\r\n\r\nNote: The `parseStyleSheet()` method is provided for compatibility with\r\nSAC-based APIs but does the exact same thing as `parse()`.\r\n\r\n## Understanding syntax units\r\n\r\nThe CSS parser defines several types that inherit from `parserlib.util.SyntaxUnit`.\r\nThese types are designed to give you easy access to all relevant parts of the CSS syntax.\r\n\r\n### Media Queries\r\n\r\nThe `parserlib.css.MediaFeature` type represents a specific media feature in a\r\nmedia query, such as `(orientation: portrait)` or `(color)`. Essentially, this\r\ntype of object represents anything enclosed in parentheses in a media query.\r\nObject of this type have the following properties:\r\n\r\n* `name` - the name of the media feature such as \"orientation\"\r\n* `value` - the value of the media feature (may be `null`)\r\n\r\nThe `parserlib.css.MediaQuery` type represents all parts of a media query.\r\nEach instance has the following properties:\r\n\r\n* `modifier` - either \"not\" or \"only\"\r\n* `mediaType` - the actual media type such as \"print\"\r\n* `features` - an array of `parserlib.css.MediaFeature` objects\r\n\r\nFor example, consider the following media query:\r\n\r\n```css\r\nonly screen and (max-device-width: 768px) and (orientation: portrait)\r\n```\r\n\r\nA corresponding object would have the following values:\r\n\r\n* `modifier` = \"only\"\r\n* `mediaType` = \"screen\"\r\n* `features` = array of (`name`=\"max-device-width\", `value`=\"768px\") and (`name`=\"orientation\", `value`=\"portrait\")\r\n\r\n### Properties\r\n\r\nThe `parserlib.css.PropertyName` type represents a property name. Each instance has the following properties:\r\n\r\n* `hack` - if star or underscore hacks are allowed, either `*` or `_` if present (`null` if not present or hacks are not allowed)\r\n\r\nWhen star hacks are allowed, the `text` property becomes the actual property name,\r\nso `*width` has `hack` equal to `*` and `text` equal to \"width\". If no hacks are allowed,\r\nthen `*width` causes a syntax error while `_width` has `hack` equal to `null` and `text` equal to `_width`.\r\n\r\nThe `parserlib.css.PropertyValue` type represents a property value. Since property values in CSS are complex,\r\nthis type of object wraps the various parts into a single interface. Each instance has the following properties:\r\n\r\n* `parts` - array of `PropertyValuePart` objects\r\n\r\nThe `parts` array always has at least one item.\r\n\r\nThe `parserlib.css.PropertyValuePart` type represents an individual part of a\r\nproperty value. Each instance has the following properties:\r\n\r\n* `type` - the type of value part (\"unknown\", \"dimension\", \"percentage\", \"integer\", \"number\", \"color\", \"uri\",  \"string\", \"identifier\" or \"operator\")\r\n\r\nA part is considered any atomic piece of a property value not including white space. Consider the following:\r\n\r\n```css\r\nfont: 1em/1.5em \"Times New Roman\", Times, serif;\r\n```\r\n\r\nThe `PropertyName` is \"font\" and the `PropertyValue` represents everything after the colon.\r\nThe parts are \"1em\" (dimension), \"/\" (operator), \"1.5em\" (dimension), \"Times New Roman\" (string),\r\n\",\" (operator), \"Times\" (identifier), \",\" (operator), and \"serif\" (identifier).\r\n\r\n### Selectors\r\n\r\nThe `parserlib.css.Selector` type represents a single selector. Each instance\r\nhas a `parts` property, which is an array of `parserlib.css.SelectorPart` objects,\r\nwhich represent atomic parts of the selector, and `parserlib.css.Combinator`\r\nobjects, which represent combinators in the selector.\r\nConsider the following selector:\r\n\r\n```css\r\nli.selected > a:hover\r\n```\r\n\r\nThis selector has three parts: `li.selected`, `>`, and `a:hover`. The first\r\npart is a `SelectorPart`, the second is a `Combinator`, and the third is a\r\n`SelectorPart`. Each `SelectorPart` is made up of an optional element name\r\nfollowed by an ID, class, attribute condition, pseudo class, and/or pseudo element.\r\n\r\nEach instance of `parserlib.css.SelectorPart` has an `elementName` property, which represents\r\nthe element name as a `parserlib.css.SelectorSubPart` object or `null` if there isn't one,\r\nand a `modifiers` property, which is an array of `parserlib.css.SelectorSubPart` objects.\r\nEach `SelectorSubPart` object represents the smallest individual piece of a selector\r\nand has a `type` property indicating the type of subpart, \"elementName\", \"class\", \"attribute\",\r\n\"pseudo\", \"id\", \"not\". If the `type` is \"not\", then the `args` property contains an array\r\nof `SelectorPart` arguments that were passed to `not()`.\r\n\r\nEach instance of `parserlib.css.Combinator` has an additional `type` property that indicates\r\nthe type of combinator: \"descendant\", \"child\", \"sibling\", or \"adjacent-sibling\".\r\n\r\n## Using events\r\n\r\nThe CSS parser fires events as it parses text. The events correspond to important parts\r\nof the parsing algorithm and are designed to provide developers with all of the information\r\nnecessary to create lint checkers, ASTs, and other data structures.\r\n\r\nFor many events, the `event` object contains additional information. This additional\r\ninformation is most frequently in the form of a `parserlib.util.SyntaxUnit` object,\r\nwhich has three properties:\r\n\r\n1. `text` - the string value\r\n2. `line` - the line on which this token appeared\r\n3. `col` - the column within the line at which this token appeared\r\n\r\nThe `toString()` method for these objects is overridden to be the same value as `text`,\r\nso that you can treat the object as a string for comparison and concatenation purposes.\r\n\r\nYou should assign your event handlers before calling the `parse()` method.\r\n\r\n### `startstylesheet` and `endstylesheet` events\r\n\r\nThe `startstylesheet` event fires just before parsing of the CSS text begins\r\nand the `endstylesheet` event fires just after all of the CSS text has been parsed.\r\nThere is no additional information provided for these events. Example:\r\n\r\n```js\r\nparser.addListener(\"startstylesheet\", function() {\r\n    console.log(\"Starting to parse stylesheet\");\r\n});\r\n\r\nparser.addListener(\"endstylesheet\", function() {\r\n    console.log(\"Finished parsing stylesheet\");\r\n});\r\n```\r\n\r\n### `charset` event\r\n\r\nThe `charset` event fires when the `@charset` directive is found in a stylesheet.\r\nSince `@charset` is required to appear first in a stylesheet, any other occurances\r\ncause a syntax error. The `charset` event provides an `event` object with a property\r\ncalled `charset`, which contains the name of the character set for the stylesheet. Example:\r\n\r\n```js\r\nparser.addListener(\"charset\", function(event) {\r\n    console.log(\"Character set is \" + event.charset);\r\n});\r\n```\r\n\r\n### `namespace` event\r\n\r\nThe `namespace` event fires when the `@namespace` directive is found in a stylesheet.\r\nThe `namespace` event provides an `event` object with two properties: `prefix`,\r\nwhich is the namespace prefix, and `uri`, which is the namespace URI. Example:\r\n\r\n```js\r\nparser.addListener(\"namespace\", function(event) {\r\n    console.log(\"Namespace with prefix=\" + event.prefix + \" and URI=\" + event.uri);\r\n});\r\n```\r\n\r\n### `import` event\r\n\r\nThe `import` event fires when the `@import` directive is found in a stylesheet.\r\nThe `import` event provides an `event` object with two properties: `uri`,\r\nwhich is the URI to import, and `media`, which is an array of media queries\r\nfor which this URI applies. The `media` array contains zero or more\r\n`parserlib.css.MediaQuery` objects. Example:\r\n\r\n```js\r\nparser.addListener(\"import\", function(event) {\r\n    console.log(\"Importing \" + event.uri + \" for media types [\" + event.media + \"]\");\r\n});\r\n```\r\n\r\n### `startfontface` and `endfontface` events\r\n\r\nThe `startfontface` event fires when `@font-face` is encountered and the `endfontface` event\r\nfires just after the closing right brace (`}`) is encountered after `@font-face`.\r\nThere is no additional information available on the `event` object. Example:\r\n\r\n```js\r\nparser.addListener(\"startfontface\", function(event) {\r\n    console.log(\"Starting font face\");\r\n});\r\n\r\nparser.addListener(\"endfontface\", function(event) {\r\n    console.log(\"Ending font face\");\r\n});\r\n```\r\n\r\n### `startpage` and `endpage` events\r\n\r\nThe `startpage` event fires when `@page` is encountered and the `endpage` event\r\nfires just after the closing right brace (`}`) is encountered after `@page`.\r\nThe `event` object has two properties: `id`, which is the page ID, and `pseudo`,\r\nwhich is the page pseudo class. Example:\r\n\r\n```js\r\nparser.addListener(\"startpage\", function(event) {\r\n    console.log(\"Starting page with ID=\" + event.id + \" and pseudo=\" + event.pseudo);\r\n});\r\n\r\nparser.addListener(\"endpage\", function(event) {\r\n    console.log(\"Ending page with ID=\" + event.id + \" and pseudo=\" + event.pseudo);\r\n});\r\n```\r\n\r\n### `startpagemargin` and `endpagemargin` events\r\n\r\nThe `startpagemargin` event fires when a page margin directive (such as `@top-left`)\r\nis encountered and the `endfontface` event fires just after the closing right brace (`}`)\r\nis encountered after the page margin. The `event` object has a `margin` property,\r\nwhich contains the actual page margin encountered. Example:\r\n\r\n```js\r\nparser.addListener(\"startpagemargin\", function(event) {\r\n    console.log(\"Starting page margin \" + event.margin);\r\n});\r\n\r\nparser.addListener(\"endpagemargin\", function(event) {\r\n    console.log(\"Ending page margin \" + event.margin);\r\n});\r\n```\r\n\r\n### `startmedia` and `endmedia` events\r\n\r\nThe `startmedia` event fires when `@media` is encountered and the `endmedia`\r\nevent fires just after the closing right brace (`}`) is encountered after\r\n`@media`. The `event` object has one property, `media`, which is an array of\r\n`parserlib.css.MediaQuery` objects. Example:\r\n\r\n```js\r\nparser.addListener(\"startpagemargin\", function(event) {\r\n    console.log(\"Starting page margin \" + event.margin);\r\n});\r\n\r\nparser.addListener(\"endpagemargin\", function(event) {\r\n    console.log(\"Ending page margin \" + event.margin);\r\n});\r\n```\r\n\r\n### `startkeyframes` and `endkeyframes` events\r\n\r\nThe `startkeyframes` event fires when `@keyframes` (or any vendor prefixed version)\r\nis encountered and the `endkeyframes` event fires just after the closing right brace (`}`)\r\nis encountered after `@keyframes`. The `event` object has one property, `name`,\r\nwhich is the name of the animation. Example:\r\n\r\n```js\r\nparser.addListener(\"startkeyframes\", function(event) {\r\n    console.log(\"Starting animation definition \" + event.name);\r\n});\r\n\r\nparser.addListener(\"endkeyframes\", function(event) {\r\n    console.log(\"Ending animation definition \" + event.name);\r\n});\r\n```\r\n\r\n### `startrule` and `endrule` events\r\n\r\nThe `startrule` event fires just after all selectors on a rule have been parsed\r\nand the `endrule` event fires just after the closing right brace (`}`)\r\nis encountered for the rule. The `event` object has one additional property, `selectors`,\r\nwhich is an array of `parserlib.css.Selector` objects. Example:\r\n\r\n```js\r\nparser.addListener(\"startrule\", function(event) {\r\n    console.log(\"Starting rule with \" + event.selectors.length + \" selector(s)\");\r\n\r\n    for (var i = 0, len = event.selectors.length; i < len; i++) {\r\n        var selector = event.selectors[i];\r\n\r\n        console.log(\"  Selector #1 (\" + selector.line + \",\" + selector.col + \")\");\r\n\r\n        for (var j = 0, count=selector.parts.length; j < count; j++) {\r\n            console.log(\"    Unit #\" + (j + 1));\r\n\r\n            if (selector.parts[j] instanceof parserlib.css.SelectorPart) {\r\n                console.log(\"      Element name: \" + selector.parts[j].elementName);\r\n\r\n                for (var k = 0; k < selector.parts[j].modifiers.length; k++) {\r\n                    console.log(\"        Modifier: \" + selector.parts[j].modifiers[k]);\r\n                }\r\n            } else {\r\n                console.log(\"      Combinator: \" + selector.parts[j]);\r\n            }\r\n        }\r\n    }\r\n});\r\n\r\nparser.addListener(\"endrule\", function(event) {\r\n    console.log(\"Ending rule with selectors [\" + event.selectors + \"]\");\r\n});\r\n```\r\n\r\n### `property` event\r\n\r\nThe `property` event fires whenever a CSS property (`name:value`) is encountered,\r\nwhich may be inside of a rule, a media block, a page block, etc. The `event` object\r\nhas four additional properties: `property`, which is the name of the property as a\r\n`parserlib.css.PropertyName` object, `value`, which is an instance of\r\n`parserlib.css.PropertyValue` (both types inherit from `parserlib.util.SyntaxUnit`),\r\n`important`, which is a Boolean value indicating if the property is flagged\r\nwith `!important`, and `invalid` which is a Boolean value indicating\r\nwhether the property value failed validation. Example:\r\n\r\n```js\r\nparser.addListener(\"property\", function(event) {\r\n    console.log(\"Property '\" + event.property + \"' has a value of '\" + event.value + \"' and \" + (event.important ? \"is\" : \"isn't\") + \" important. (\" + event.property.line + \",\" + event.property.col + \")\");\r\n});\r\n```\r\n\r\n### `error` event\r\n\r\nThe `error` event fires whenever a recoverable error occurs during parsing.\r\nWhen in strict mode, this event does not fire. The `event` object contains three\r\nadditional properties: `message`, which is the error message, `line`, which is the line\r\non which the error occurred, and `col`, which is the column on that line in which\r\nthe error occurred. Example:\r\n\r\n```js\r\nparser.addListener(\"error\", function(event) {\r\n    console.log(\"Parse error: \" + event.message + \" (\" + event.line + \",\" + event.col + \")\", \"error\");\r\n});\r\n```\r\n\r\n## Error recovery\r\n\r\nThe CSS parser's goal is to be on-par with error recovery of CSS parsers in browsers.\r\nTo that end, the following error recovery mechanisms are in place:\r\n\r\n* **Properties** - a syntactically incorrect property definition will be\r\n  skipped over completely. For instance, the second property below is dropped:\r\n\r\n```css\r\na:hover {\r\n    color: red;\r\n    font:: Helvetica;   /* dropped! */\r\n    text-decoration: underline;\r\n}\r\n```\r\n\r\n* **Selectors** - if there's a syntax error in *any* selector, the entire rule\r\n  is skipped over. For instance, the following rule is completely skipped:\r\n\r\n```css\r\na:hover, foo ... bar {\r\n    color: red;\r\n    font: Helvetica;\r\n    text-decoration: underline;\r\n}\r\n```\r\n\r\n* **@ Rules** - there are certain @ rules that are only valid in certain\r\n  contexts. The parser will skip over `@charset`, `@namespace`, and `@import`\r\n  if they're found anywhere other than the beginning of the input.\r\n\r\n* **Unknown @ Rules** - any @ rules that isn't recognized is automatically\r\n  skipped, meaning the entire block after it is not parsed.\r\n\r\n## Running Tests\r\n\r\nYou can run the tests via `npm test` from the repository's root. You\r\nmay need to run `npm install` first to install the necessary dependencies.\r\n","_attachments":{},"homepage":"https://github.com/CSSLint/parser-lib","bugs":{"url":"https://github.com/CSSLint/parser-lib/issues"},"license":"MIT"}