
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@lezer/css
Advanced tools
@lezer/css is a parser for CSS written using the Lezer parser system. It provides a way to parse CSS code into a syntax tree, which can be useful for syntax highlighting, code analysis, and other tooling purposes.
Parsing CSS
This feature allows you to parse a CSS string into a syntax tree. The code sample demonstrates how to use the parser to convert a CSS string into a tree structure.
const {parser} = require('@lezer/css');
const input = 'body { color: red; }';
const tree = parser.parse(input);
console.log(tree.toString());
Syntax Tree Traversal
This feature allows you to traverse the syntax tree generated by the parser. The code sample shows how to use a TreeCursor to iterate over the nodes in the syntax tree.
const {parser} = require('@lezer/css');
const {TreeCursor} = require('@lezer/common');
const input = 'body { color: red; }';
const tree = parser.parse(input);
let cursor = tree.cursor();
do {
console.log(cursor.node.type.name);
} while (cursor.next());
PostCSS is a tool for transforming CSS with JavaScript plugins. It provides a way to parse CSS into an Abstract Syntax Tree (AST), which can then be manipulated and transformed. Compared to @lezer/css, PostCSS is more focused on transforming and processing CSS rather than just parsing it.
CSSTree is a tool for working with CSS, including parsing, generating, and analyzing CSS code. It provides a detailed AST and various utilities for manipulating CSS. CSSTree offers more comprehensive features for CSS analysis and transformation compared to @lezer/css.
Stylelint is a modern linter that helps you avoid errors and enforce conventions in your styles. While it also parses CSS, its primary focus is on linting and enforcing coding standards, which is different from the primary parsing focus of @lezer/css.
This is a CSS grammar for the lezer parser system.
The code is licensed under an MIT license.
1.3.0 (2025-07-07)
Values wrapped in brackets can now contain more types of tokens.
Properly support hex escapes in identifiers.
Support variable names as callees in call expressions.
Add support for @scope
syntax.
Add support for if
notation.
FAQs
lezer-based CSS grammar
The npm package @lezer/css receives a total of 898,904 weekly downloads. As such, @lezer/css popularity was classified as popular.
We found that @lezer/css demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.