{"name":"@csstools/css-tokenizer","version":"4.0.1","keywords":["css","tokenizer"],"license":"MIT","_id":"@csstools/css-tokenizer@4.0.1","maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"alaguna","email":"sombragriselros@gmail.com"},{"name":"romainmenke","email":"romainmenke@gmail.com"}],"contributors":[{"url":"https://antonio.laguna.es","name":"Antonio Laguna","email":"antonio@laguna.es"},{"name":"Romain Menke","email":"romainmenke@gmail.com"}],"homepage":"https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer#readme","bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"dist":{"shasum":"e07075c22009bfa71ac6d6d1b090cf713d6d835c","tarball":"http://registry-npm.ywwl.com/@csstools/css-tokenizer/download/@csstools/css-tokenizer-4.0.1.tgz","fileCount":6,"integrity":"sha512-bPlN9S9O1A0euCpEWE4qnvB5YDuyYVsUTrxSgmAM1Is0j4tICHoVyOVAXfWMP/kS9ZrjvyIXWV2PmomiAXXqOw==","signatures":[{"sig":"MEUCIQDsbuQEYHSD/L2R4OKl/CqjVjOe/Hz861KzFxe2tJPqpAIgdGO6zkAQ4WPN9DlO1uFhdxJtCIY2DmziTscUeMH+AtI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQCbrXpRrrE7sjrQU96bK/ArcEvz6Lq0rG2i7Y89moN8xgIhAO8Nf2pQs/1uONIP0dFQb4CSbsvGU2KJzDqmeSsI62qh","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41008,"size":10458,"noattachment":false,"key":"/@csstools/css-tokenizer/-/@csstools/css-tokenizer-4.0.1.tgz"},"type":"module","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.mjs"}},"funding":[{"url":"https://github.com/sponsors/csstools","type":"github"},{"url":"https://opencollective.com/csstools","type":"opencollective"}],"gitHead":"34f8f55151bd9906c7a1203a3744e1252f2453f4","scripts":{},"_npmUser":{"name":"romainmenke","email":"romainmenke@gmail.com"},"repository":{"url":"git+https://github.com/csstools/postcss-plugins.git","type":"git","directory":"packages/css-tokenizer"},"_npmVersion":"11.13.0","description":"Tokenize CSS","directories":{},"_nodeVersion":"26.1.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/css-tokenizer_4.0.1_1789710428323_0.820190753253905","host":"s3://npm-registry-packages-npm-production"},"readme":"# CSS Tokenizer <img src=\"https://cssdb.org/images/css.svg\" alt=\"for CSS\" width=\"90\" height=\"90\" align=\"right\">\n\n[<img alt=\"npm version\" src=\"https://img.shields.io/npm/v/@csstools/css-tokenizer.svg\" height=\"20\">][npm-url]\n[<img alt=\"Build Status\" src=\"https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main\" height=\"20\">][cli-url]\n[<img alt=\"Discord\" src=\"https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white\">][discord]\n\nImplemented from : https://drafts.csswg.org/css-syntax/\n\n## API\n\n[Read the API docs](./docs/css-tokenizer.md)\n\n## Usage\n\nAdd [CSS Tokenizer] to your project:\n\n```bash\nnpm install @csstools/css-tokenizer --save-dev\n```\n\n```js\nimport { tokenize } from '@csstools/css-tokenizer';\n\nconst myCSS =  `@media only screen and (min-width: 768rem) {\n\t.foo {\n\t\tcontent: 'Some content!' !important;\n\t}\n}\n`;\n\nconst tokens = tokenize({\n\tcss: myCSS,\n});\n\nconsole.log(tokens);\n```\n\nOr use the streaming interface:\n\n```js\nimport { tokenizer, TokenType } from '@csstools/css-tokenizer';\n\nconst myCSS = `@media only screen and (min-width: 768rem) {\n\t.foo {\n\t\tcontent: 'Some content!' !important;\n\t}\n}\n`;\n\nconst t = tokenizer({\n\tcss: myCSS,\n});\n\nwhile (true) {\n\tconst token = t.nextToken();\n\tif (token[0] === TokenType.EOF) {\n\t\tbreak;\n\t}\n\n\tconsole.log(token);\n}\n```\n\n### Options\n\n```ts\n{\n\tonParseError?: (error: ParseError) => void\n}\n```\n\n#### `onParseError`\n\nThe tokenizer is forgiving and won't stop when a parse error is encountered.\n\nTo receive parsing error information you can set a callback.\n\n```js\nimport { tokenizer, TokenType } from '@csstools/css-tokenizer';\n\nconst t = tokenizer({\n\tcss: '\\\\',\n}, { onParseError: (err) => console.warn(err) });\n\nwhile (true) {\n\tconst token = t.nextToken();\n\tif (token[0] === TokenType.EOF) {\n\t\tbreak;\n\t}\n}\n```\n\nParser errors will try to inform you where in the tokenizer logic the error happened.\nThis tells you what kind of error occurred.\n\n## Order of priorities\n\n1. specification compliance\n2. correctness\n3. reliability\n4. tokenizing and serializing must round trip losslessly\n5. exposing useful aspects about the source code\n6. runtime performance\n7. package size\n\n\n[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test\n[discord]: https://discord.gg/bUadyRwkJS\n[npm-url]: https://www.npmjs.com/package/@csstools/css-tokenizer\n\n[CSS Tokenizer]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer\n","publish_time":1789710428401,"_cnpm_publish_time":1789710428401,"dist-tags":{"latest":"4.0.3"}}