Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

style-parser

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

style-parser

css style parser in Node.js

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
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

Package last updated on 03 May 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc