{"_id":"@enhance/css-parser","name":"@enhance/css-parser","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@enhance/css-parser","version":"1.0.0","description":"CSS parser & stringifier","main":"index","dependencies":{"inherits":"^2.0.4","source-map":"^0.6.1","source-map-resolve":"^0.6.0"},"devDependencies":{"mocha":"^8.0.1","should":"^13.2.3","matcha":"^0.7.0","bytes":"^3.1.0"},"scripts":{"benchmark":"matcha","test":"mocha --require should --reporter spec test/*.js"},"author":{"name":"Kristofer 'kj' Joseph","email":"kj@begin.com"},"contributors":[{"name":"TJ Holowaychuk","email":"tj@vision-media.ca"}],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/enhance-dev/css-parser.git"},"keywords":["css","parser","stringifier","stylesheet"],"gitHead":"af3f37f6bf5c1e1811376e2fb00b2b913d4342e6","bugs":{"url":"https://github.com/enhance-dev/css-parser/issues"},"homepage":"https://github.com/enhance-dev/css-parser#readme","_id":"@enhance/css-parser@1.0.0","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-DG18Jwxvf0WvUtA8VEA+axaIq0aoJzGTd25kdeLDPQcNnq3bWG+TUMPi8oa4btVXwHVyCR7Xsy0jW80m1ZwPow==","shasum":"87c8e863d52d3263e7e336aaa6162f91c42650fd","tarball":"https://registry.npmjs.org/@enhance/css-parser/-/css-parser-1.0.0.tgz","fileCount":10,"unpackedSize":36890,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFsBbrifxiQ4FMkuN1mtMPDfnSHPG5XJAA6/lGbO24FvAiAyIaVtDKJrTNzU3HfaFJvustmOPv48kJfgIyB2NDyUFA=="}]},"_npmUser":{"name":"dam","email":"kristoferjoseph@gmail.com"},"directories":{},"maintainers":[{"name":"colepeters","email":"cole@colepeters.com"},{"name":"ryanbethel","email":"ryan.bethel@gmail.com"},{"name":"brianleroux","email":"b@brian.io"},{"name":"tbeseda","email":"tbeseda@gmail.com"},{"name":"macdonst","email":"simon.macdonald@gmail.com"},{"name":"ryanblock","email":"rblock+npm@gmail.com"},{"name":"dam","email":"kristoferjoseph@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/css-parser_1.0.0_1685142814550_0.23128677082574867"},"_hasShrinkwrap":false}},"time":{"created":"2023-05-26T23:13:34.489Z","1.0.0":"2023-05-26T23:13:34.782Z","modified":"2023-05-26T23:13:35.053Z"},"maintainers":[{"name":"colepeters","email":"cole@colepeters.com"},{"name":"ryanbethel","email":"ryan.bethel@gmail.com"},{"name":"brianleroux","email":"b@brian.io"},{"name":"tbeseda","email":"tbeseda@gmail.com"},{"name":"macdonst","email":"simon.macdonald@gmail.com"},{"name":"ryanblock","email":"rblock+npm@gmail.com"},{"name":"dam","email":"kristoferjoseph@gmail.com"}],"description":"CSS parser & stringifier","homepage":"https://github.com/enhance-dev/css-parser#readme","keywords":["css","parser","stringifier","stylesheet"],"repository":{"type":"git","url":"git+https://github.com/enhance-dev/css-parser.git"},"contributors":[{"name":"TJ Holowaychuk","email":"tj@vision-media.ca"}],"author":{"name":"Kristofer 'kj' Joseph","email":"kj@begin.com"},"bugs":{"url":"https://github.com/enhance-dev/css-parser/issues"},"license":"MIT","readme":"CSS parser & stringifier.\n\n## Installation\n\n`npm install @enhance/css-parser`\n\n## Usage\n\n```js\nvar css = require('css');\nvar obj = css.parse('body { font-size: 12px; }', options);\ncss.stringify(obj, options);\n```\n\n## API\n\n### css.parse(code, [options])\n\nAccepts a CSS string and returns an AST `object`.\n\n`options`:\n\n- silent: silently fail on parse errors.\n- source: the path to the file containing `css`. Makes errors and source\n  maps more helpful, by letting them know where code comes from.\n\n### css.stringify(object, [options])\n\nAccepts an AST `object` (as `css.parse` produces) and returns a CSS string.\n\n`options`:\n\n- indent: the string used to indent the output. Defaults to two spaces.\n- compress: omit comments and extraneous whitespace.\n- sourcemap: return a sourcemap along with the CSS output. Using the `source`\n  option of `css.parse` is strongly recommended when creating a source map.\n  Specify `sourcemap: 'generator'` to return the SourceMapGenerator object\n  instead of serializing the source map.\n- inputSourcemaps: (enabled by default, specify `false` to disable) reads any\n  source maps referenced by the input files when generating the output source\n  map. When enabled, file system access may be required for reading the\n  referenced source maps.\n\n### Example\n\n```js\nvar ast = css.parse('body { font-size: 12px; }', { source: 'source.css' });\n\nvar css = css.stringify(ast);\n\nvar result = css.stringify(ast, { sourcemap: true });\nresult.code // string with CSS\nresult.map // source map object\n```\n\n### Errors\n\nErrors thrown during parsing have the following properties:\n\n- message: `String`. The full error message with the source position.\n- reason: `String`. The error message without position.\n- filename: `String` or `undefined`. The value of `options.source` if\n  passed to `css.parse`. Otherwise `undefined`.\n- line: `Integer`.\n- column: `Integer`.\n- source: `String`. The portion of code that couldn't be parsed.\n\nWhen parsing with the `silent` option, errors are listed in the\n`parsingErrors` property of the [`stylesheet`](#stylesheet) node instead\nof being thrown.\n\nIf you create any errors in plugins such as in\n[rework](https://github.com/reworkcss/rework), you __must__ set the same\nproperties for consistency.\n\n## AST\n\nInteractively explore the AST with <http://iamdustan.com/reworkcss_ast_explorer/>.\n\n### Common properties\n\nAll nodes have the following properties.\n\n#### position\n\nInformation about the position in the source string that corresponds to\nthe node.\n\n`Object`:\n\n- start: `Object`:\n  - line: `Number`.\n  - column: `Number`.\n- end: `Object`:\n  - line: `Number`.\n  - column: `Number`.\n- source: `String` or `undefined`. The value of `options.source` if passed to\n  `css.parse`. Otherwise `undefined`.\n- content: `String`. The full source string passed to `css.parse`.\n\nThe line and column numbers are 1-based: The first line is 1 and the first\ncolumn of a line is 1 (not 0).\n\nThe `position` property lets you know from which source file the node comes\nfrom (if available), what that file contains, and what part of that file was\nparsed into the node.\n\n#### type\n\n`String`. The possible values are the ones listed in the Types section below.\n\n#### parent\n\nA reference to the parent node, or `null` if the node has no parent.\n\n### Types\n\nThe available values of `node.type` are listed below, as well as the available\nproperties of each node (other than the common properties listed above.)\n\n#### stylesheet\n\nThe root node returned by `css.parse`.\n\n- stylesheet: `Object`:\n  - rules: `Array` of nodes with the types `rule`, `comment` and any of the\n    at-rule types.\n  - parsingErrors: `Array` of `Error`s. Errors collected during parsing when\n    option `silent` is true.\n\n#### rule\n\n- selectors: `Array` of `String`s. The list of selectors of the rule, split\n  on commas. Each selector is trimmed from whitespace and comments.\n- declarations: `Array` of nodes with the types `declaration` and `comment`.\n\n#### declaration\n\n- property: `String`. The property name, trimmed from whitespace and\n  comments. May not be empty.\n- value: `String`. The value of the property, trimmed from whitespace and\n  comments. Empty values are allowed.\n\n#### comment\n\nA rule-level or declaration-level comment. Comments inside selectors,\nproperties and values etc. are lost.\n\n- comment: `String`. The part between the starting `/*` and the ending `*/`\n  of the comment, including whitespace.\n\n#### charset\n\nThe `@charset` at-rule.\n\n- charset: `String`. The part following `@charset `.\n\n#### custom-media\n\nThe `@custom-media` at-rule.\n\n- name: `String`. The `--`-prefixed name.\n- media: `String`. The part following the name.\n\n#### document\n\nThe `@document` at-rule.\n\n- document: `String`. The part following `@document `.\n- vendor: `String` or `undefined`. The vendor prefix in `@document`, or\n  `undefined` if there is none.\n- rules: `Array` of nodes with the types `rule`, `comment` and any of the\n  at-rule types.\n\n#### font-face\n\nThe `@font-face` at-rule.\n\n- declarations: `Array` of nodes with the types `declaration` and `comment`.\n\n#### host\n\nThe `@host` at-rule.\n\n- rules: `Array` of nodes with the types `rule`, `comment` and any of the\n  at-rule types.\n\n#### import\n\nThe `@import` at-rule.\n\n- import: `String`. The part following `@import `.\n\n#### keyframes\n\nThe `@keyframes` at-rule.\n\n- name: `String`. The name of the keyframes rule.\n- vendor: `String` or `undefined`. The vendor prefix in `@keyframes`, or\n  `undefined` if there is none.\n- keyframes: `Array` of nodes with the types `keyframe` and `comment`.\n\n#### keyframe\n\n- values: `Array` of `String`s. The list of “selectors” of the keyframe rule,\n  split on commas. Each “selector” is trimmed from whitespace.\n- declarations: `Array` of nodes with the types `declaration` and `comment`.\n\n#### media\n\nThe `@media` at-rule.\n\n- media: `String`. The part following `@media `.\n- rules: `Array` of nodes with the types `rule`, `comment` and any of the\n  at-rule types.\n\n#### namespace\n\nThe `@namespace` at-rule.\n\n- namespace: `String`. The part following `@namespace `.\n\n#### page\n\nThe `@page` at-rule.\n\n- selectors: `Array` of `String`s. The list of selectors of the rule, split\n  on commas. Each selector is trimmed from whitespace and comments.\n- declarations: `Array` of nodes with the types `declaration` and `comment`.\n\n#### supports\n\nThe `@supports` at-rule.\n\n- supports: `String`. The part following `@supports `.\n- rules: `Array` of nodes with the types `rule`, `comment` and any of the\n  at-rule types.\n\n#### container\n\nThe `@container` at-rule.\n\n- type: `String` container\n- container: `String` container query\n- rules: `Array` of nodes with the types `rule`, `comment` and any of the\n    - selectors: `Array` of `String`s. The list of selectors of the rule, split\n      on commas. Each selector is trimmed from whitespace and comments.\n    - declarations: `Array` of nodes with the types `declaration` and `comment`.\n\n#### layer\n\nThe `@layer` at-rule.\n\n- type: `String`, layer\n- layer: `String` the layer name\n- rules: `Array` of nodes with the types `rule`, `comment` and any of the\n    - selectors: `Array` of `String`s. The list of selectors of the rule, split\n      on commas. Each selector is trimmed from whitespace and comments.\n    - declarations: `Array` of nodes with the types `declaration` and `comment`.\n\n\n### Example\n\nCSS:\n\n```css\nbody {\n  background: #eee;\n  color: #888;\n}\n```\n\nParse tree:\n\n```json\n{\n  \"type\": \"stylesheet\",\n  \"stylesheet\": {\n    \"rules\": [\n      {\n        \"type\": \"rule\",\n        \"selectors\": [\n          \"body\"\n        ],\n        \"declarations\": [\n          {\n            \"type\": \"declaration\",\n            \"property\": \"background\",\n            \"value\": \"#eee\",\n            \"position\": {\n              \"start\": {\n                \"line\": 2,\n                \"column\": 3\n              },\n              \"end\": {\n                \"line\": 2,\n                \"column\": 19\n              }\n            }\n          },\n          {\n            \"type\": \"declaration\",\n            \"property\": \"color\",\n            \"value\": \"#888\",\n            \"position\": {\n              \"start\": {\n                \"line\": 3,\n                \"column\": 3\n              },\n              \"end\": {\n                \"line\": 3,\n                \"column\": 14\n              }\n            }\n          }\n        ],\n        \"position\": {\n          \"start\": {\n            \"line\": 1,\n            \"column\": 1\n          },\n          \"end\": {\n            \"line\": 4,\n            \"column\": 2\n          }\n        }\n      }\n    ]\n  }\n}\n```\n\n## License\n\nMIT\n","readmeFilename":"Readme.md"}