style-parser
A Node.js library to parse the inline css styles.
Tutorial
const parse = require('style-parser');
parse('font-size:13px;');
Use cases
Here we would list possible use cases that this library might be used.
Working with cherrio
cherrio is server-side jQuery implementation that scraper would use, but the
jQuery/cherrio API doesn't provide the ability to get structured style object
from the style
attribute like the below example:
The HTML:
<div style="font-size:13px;width:50px"></div>
And the cherrio code:
cherrio(html).attr('style');
So with the library style-parser, we can do:
const parse = require('style-parser')
parse(cherrio(html).attr('style'));
Working on browsers
Because the only dependency are Parsimmon which is in pure JavaScript, that
you are able to build it for browser environments and make it work with
browser-side jQuery or other useful lands.
Installation
$ npm install style-parser --save
License
MIT