
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
css-simple-parser
Advanced tools
A (S)CSS parser that's tiny, blazing fast and (too) simple.
The big caveat is that this is not a full-blown CSS parser, it can only parse (S)CSS strings with the following limitations:
@charset
, @import
etc.{
, }
or ;
can be used inside strings, e.g. div[attr=";{}"]
, content: "{}"
etc.npm install css-simple-parser
The AST (Abstract Syntax Tree) provided by this library has the following shape:
type AST = ROOT_NODE;
type ROOT_NODE = {
parent: null,
children: NODE[]
};
type NODE = {
parent: ROOT_NODE | NODE,
index: number,
indexEnd: number,
selector: string,
selectorIndex: number,
selectorIndexEnd: number,
body: string,
bodyIndex: number,
bodyIndexEnd: number,
children: NODE[]
};
Parser.parse
This method computes an AST from the given CSS string.
import Parser from 'css-simple-parser';
const ast = Parser.parse ( '.foo {}' );
Parser.stringify
This method computes a CSS string given an AST.
import Parser from 'css-simple-parser';
const ast = Parser.parse ( '.foo {}' );
const css = Parser.stringify ( ast );
Parser.traverse
This method calls a function with each node found in the AST, the AST is being traversed depth-first.
import Parser from 'css-simple-parser';
const ast = Parser.parse ( '.foo {}' );
Parser.traverse ( ast, node => {
console.log ( node.selector );
});
&
placeholders are supported too.MIT © Fabio Spampinato
FAQs
A (S)CSS parser that's tiny, blazing fast and (too) simple.
The npm package css-simple-parser receives a total of 412 weekly downloads. As such, css-simple-parser popularity was classified as not popular.
We found that css-simple-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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 MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.