![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
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 422 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.