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.
$ npm install --save inline-style-2-json
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"}'
Type: string
This should be your inline style string.
Type: boolean
Default: false
Return stringified object.
Sure! Open an issue, open a PR.
MIT © 2018 Richard Littauer