{"id":16983129,"url":"https://github.com/rtsao/cssparse","last_synced_at":"2025-07-03T07:32:53.213Z","repository":{"id":146089852,"uuid":"300122247","full_name":"rtsao/cssparse","owner":"rtsao","description":"A css parser powered by the style crate from Servo","archived":false,"fork":false,"pushed_at":"2020-10-01T05:53:45.000Z","size":31,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T11:14:53.603Z","etag":null,"topics":["css","css-parser","parser","servo-browser"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rtsao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-10-01T02:56:50.000Z","updated_at":"2022-09-29T12:58:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"eebae36e-7747-45d0-8ff2-af8dc414f083","html_url":"https://github.com/rtsao/cssparse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rtsao/cssparse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtsao%2Fcssparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtsao%2Fcssparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtsao%2Fcssparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtsao%2Fcssparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rtsao","download_url":"https://codeload.github.com/rtsao/cssparse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtsao%2Fcssparse/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263282918,"owners_count":23442268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","css-parser","parser","servo-browser"],"created_at":"2024-10-14T02:27:46.110Z","updated_at":"2025-07-03T07:32:53.199Z","avatar_url":"https://github.com/rtsao.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cssparse\n\nA CSS parser powered by the style crate from Servo.\n\n## Why?\n\nI was unable to find a single Node.js library that could reliably parse shorthand CSS property values without using Web APIs.\n\nMy desired use case was expanding shorthand properties into their constituent longform properties. For example:\n\n\u003c!-- prettier-ignore --\u003e\n```css\nbackground: center / contain no-repeat url(\"../foo.svg\"), #eee 35% url(\"../bar.png\");\n```\n\nThe libraries I tested all failed to address my use case, for the following reasons:\n\n1. Doesn't parse property values at all\n   - [`postcss@8.1.1`](https://github.com/postcss/postcss)\n2. Doesn't support `background` property values at all\n   - [`inline-style-expand-shorthand@1.2.0`](https://github.com/robinweser/inline-style-expand-shorthand)\n   - [`css-shorthand-expanders@1.1.0`](https://github.com/kripod/css-shorthand-expanders)\n3. Merely tokenizes `background` property values, failing to parse the value into sufficiently useful information\n   - [`tree-sitter-css@0.16.0`](https://github.com/tree-sitter/tree-sitter-css)\n   - [`postcss-value-parser@4.1.0`](https://github.com/TrySound/postcss-value-parser)\n   - [`postcss-values-parser@4.0.0`](https://github.com/shellscape/postcss-values-parser)\n4. Fails when parsing valid `background` values (such as the example above)\n   - [`css-shorthand-expand@1.2.0`](https://github.com/kapetan/css-shorthand-expand)\n   - [`css-property-parser@1.0.6`](https://github.com/mahirshah/css-property-parser)\n5. Relies on browser-specific APIs such as [`CSSStyleDeclaration`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration)\n   - [`css-background-parser@0.1.0`](https://github.com/gilmoreorless/css-background-parser)\n\nAfter many failed attempts, I have come to the conclusion that the most accurate and reliable way to parse CSS is to simply use the parser from a production-grade web browser. The style crate from Servo is a good choice because it has been [integrated into Firefox](https://hacks.mozilla.org/2017/08/inside-a-super-fast-css-engine-quantum-css-aka-stylo/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtsao%2Fcssparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtsao%2Fcssparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtsao%2Fcssparse/lists"}