![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
cssparser
Advanced tools
Readme
cssparser.js is a parser that generates json matched with source css structure.
Just want to use cssparser.js? Nothing needed.
If want generating parser, install 'jison' before it.
First of all, you should install cssparser.
$ npm install cssparser
or
$ npm install cssparser -g
Then execute and you can generate JSON file from command-line.
$ cssparser cssFile
or
$ cssparser cssFile -o output_file
You can generate javascript object from your javascript module.
// getting parser module
var cssparser = require("cssparser");
// create new instance of Parser
var parser = new cssparser.Parser();
// parse
var ast = parser.parse(raw)
// getting json
var json = ast.toJSON(type)
$ git clone https://github.com/cwdoh/cssparser.js.git
$ npm install
$ npm run build
There are 3 types of JSON format.
Example is tested with rulesets of http://css3please.com
cssparser example/test.css --console -i 4
@charset 'utf-8';
@import url("fineprint.css") print;
@media screen {
* {
position: absolute;
}
}
.footer {
position: fixed;
bottom: 0 !important;
width: 1rem;
}
[
{
"type": "@charset",
"value": "'utf-8'"
},
{
"type": "@import",
"value": "url(\"fineprint.css\")",
"mediaQuery": [
"print"
]
},
{
"type": "@media",
"value": [
"screen"
],
"nestedRules": [
{
"type": "rule",
"selectors": [
"*"
],
"declarations": {
"position": "absolute"
}
}
]
},
{
"type": "rule",
"selectors": [
".footer"
],
"declarations": {
"position": "fixed",
"bottom": "0 !important",
"width": "1rem"
}
}
]
####Type 'deep'
{
"type": "STYLESHEET",
"value": [
{
"type": "AT_RULE",
"rule": "charset",
"value": "'utf-8'"
},
{
"type": "AT_RULE",
"rule": "import",
"value": "url(\"fineprint.css\")",
"nextExpression": [
"print"
]
},
{
"type": "AT_RULE",
"rule": "media",
"value": [
"screen"
],
"nestedRules": [
{
"type": "QUALIFIED_RULE",
"value": {
"type": "DECLARATION_LIST",
"value": [
{
"type": "DECLARATION",
"property": "position",
"value": "absolute"
}
]
},
"selectors": [
"*"
]
}
]
},
{
"type": "QUALIFIED_RULE",
"value": {
"type": "DECLARATION_LIST",
"value": [
{
"type": "DECLARATION",
"property": "position",
"value": "fixed"
},
{
"type": "DECLARATION",
"property": "bottom",
"value": 0,
"important": true
},
{
"type": "DECLARATION",
"property": "width",
"value": "1rem"
}
]
},
"selectors": [
".footer"
]
}
]
}
{
"type": "STYLESHEET",
"value": [
{
"type": "AT_RULE",
"rule": {
"type": "ID",
"value": "charset",
"prefix": "@"
},
"value": {
"type": "STRING",
"value": "'utf-8'"
}
},
{
"type": "AT_RULE",
"rule": {
"type": "ID",
"value": "import",
"prefix": "@"
},
"value": {
"type": "URL",
"name": {
"type": "ID",
"value": "url"
},
"value": "\"fineprint.css\""
},
"nextExpression": {
"type": "MEDIA_QUERY_LIST",
"value": [
{
"type": "MEDIA_QUERY",
"mediaType": {
"type": "ID",
"value": "print"
}
}
]
}
},
{
"type": "AT_RULE",
"rule": {
"type": "ID",
"value": "media",
"prefix": "@"
},
"value": {
"type": "MEDIA_QUERY_LIST",
"value": [
{
"type": "MEDIA_QUERY",
"mediaType": {
"type": "ID",
"value": "screen"
}
}
]
},
"nestedRules": [
{
"type": "QUALIFIED_RULE",
"value": {
"type": "DECLARATION_LIST",
"value": [
{
"type": "DECLARATION",
"property": {
"type": "ID",
"value": "position"
},
"value": {
"type": "ID",
"value": "absolute"
}
}
]
},
"selectors": {
"type": "SELECTOR_LIST",
"value": [
{
"type": "UNIVERSAL_SELECTOR",
"value": "*"
}
]
}
}
]
},
{
"type": "QUALIFIED_RULE",
"value": {
"type": "DECLARATION_LIST",
"value": [
{
"type": "DECLARATION",
"property": {
"type": "ID",
"value": "position"
},
"value": {
"type": "ID",
"value": "fixed"
}
},
{
"type": "DECLARATION",
"property": {
"type": "ID",
"value": "bottom"
},
"value": {
"type": "NUMBER",
"value": 0
},
"important": true
},
{
"type": "DECLARATION",
"property": {
"type": "ID",
"value": "width"
},
"value": {
"type": "DIMENSION",
"value": 1,
"unit": "rem"
}
}
]
},
"selectors": {
"type": "SELECTOR_LIST",
"value": [
{
"type": "CLASS_SELECTOR",
"value": ".footer"
}
]
}
}
]
}
FAQs
parsing CSS document and transforming to JSON format
The npm package cssparser receives a total of 283 weekly downloads. As such, cssparser popularity was classified as not popular.
We found that cssparser demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.