Socket
Socket
Sign inDemoInstall

style-parser

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    style-parser

css style parser in Node.js


Version published
Weekly downloads
3.9K
decreased by-22.87%
Maintainers
1
Install size
51.3 kB
Created
Weekly downloads
 

Readme

Source

style-parser

NPM version Build status Dependency Status Test coverage Downloads

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');
// this will only return in string

So with the library style-parser, we can do:

const parse = require('style-parser')
parse(cherrio(html).attr('style'));
// this will return an object: {'font-size': '13px', 'width': '50px'}

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

FAQs

Last updated on 03 May 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc