Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
filter-css
Advanced tools
Readme
Filter CSS rules
$ npm install --save filter-css
var filterCss = require('filter-css');
var filtered = filterCss(<input>, <pattern>, <options>);
Required
Type: String
Can be a path to the CSS file or a raw CSS string
Required
Type String
,RegExp
, Function
or an Array
containing it.
Patterns used to discard specific parts of the CSS. The function is invoked with three arguments (context, value, node).
context
Current matching context. Could be one of ['type','media','selector','declarationProperty','declarationValue']
.value
Current value.node
The currently processed AST node generated by css
.Return true if the element should be discarded.
Per default filter-css
will be applied to all parts of the CSS. This behavior can be customized by disabling specific matchers
Name | Type | Description |
---|---|---|
matchSelectors | boolean | Enable / disable matching of CSS selectors. |
matchTypes | boolean | Enable / disable matching of AST Node types like font-face |
matchDeclarationProperties | boolean | Enable / disable matching of CSS properties like background-image |
matchDeclarationValues | boolean | Enable / disable matching of CSS values like url(...) |
matchMedia | boolean | Enable / disable matching of media queries like min-device-pixel-ratio: 2 |
.bigBackground {
width: 100%;
height: 100%;
background-image: url('some/big/image.png');
}
@font-face {
font-family: 'My awesome font';
}
@media print {
...
}
var filterCss = require('filter-css');
filterCss('test/fixtures/test.css',[/url\(/,'@font-face',/print/]);
.bigBackground {
width: 100%;
height: 100%;
}
var filterCss = require('filter-css');
filterCss('test/fixtures/test.css',/.*/,{
matchSelectors: false,
matchTypes: false,
matchDeclarationProperties: false,
matchDeclarationValues: false,
matchMedia: true
});
var filterCss = require('filter-css');
filterCss('test/fixtures/test.css',function(context, value, node) {
return context === 'declarationValue' && value === "url('some/big/image.png')"
});
filterCss('test/fixtures/test.css', {
types: ['@font-face'],
selectors: ['.my-selector > p'],
declarations: [/url/]
});
filter-css works well with standard input.
$ cat test/fixture/test.css | filtercss --ignore @font-face
You can also pass in the file as an option.
$ filtercss test/fixture/test.css --ignore @font-face
See filtercss --help
for a full list of options.
MIT © Ben Zörb
FAQs
Filter CSS rules
We found that filter-css 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.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).