inline-style-2-json

1.1.0 • Public • Published

inline-style-2-json

Greenkeeper badge Build Status

Convert CSS inline styles to JSON

This is a small function that takes the content of a style tag (as a string) and outputs an object or a JSON string. This is useful if you are piping HTML through xml-objects or something similar and you want finer granularity.

Install

$ npm install --save inline-style-2-json

Usage

var inlineStyle2Json = require('inline-style-2-json');
 
inlineStyle2Json('position:absolute;h-index:9001;');
//=> "{ position: 'absolute', 'h-index': '9001'}"
 
inlineStyle2Json('position:absolute;h-index:9001;', {stringify: true});
//=> '{"position":"absolute","h-index":"9001"}'

API

inlineStyle2Json(input, [options])

input

Type: string

This should be your inline style string.

options

stringify

Type: boolean
Default: false

Return stringified object.

Contribute

Sure! Open an issue, open a PR.

License

MIT © 2018 Richard Littauer

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.05latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.05
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i inline-style-2-json

Weekly Downloads

5

Version

1.1.0

License

MIT

Unpacked Size

4.01 kB

Total Files

4

Last publish

Collaborators

  • richardlitt