himalaya
Advanced tools
Comparing version 0.1.1 to 0.1.2
29
index.js
@@ -42,3 +42,3 @@ | ||
} else { | ||
if(!str.indexOf(commentStart)) { | ||
if(startsWithCommentStart(str)) { | ||
// comment | ||
@@ -99,3 +99,3 @@ var end = str.indexOf(commentEnd); | ||
if(!str.indexOf('/>')) { | ||
if(startsWithSelfClose(str)) { | ||
str = str.slice(2); | ||
@@ -136,3 +136,3 @@ } else { | ||
attrs.style = parseStyle(value); | ||
} else if (!property.indexOf('data-')) { | ||
} else if (startsWithDataDash(property)) { | ||
attrs.dataset = attrs.dataset || {}; | ||
@@ -209,2 +209,25 @@ var key = camelCase(property.slice(5)); | ||
function startsWithCommentStart(s) { | ||
return ( | ||
s.charAt(0) === '<' && | ||
s.charAt(1) === '!' && | ||
s.charAt(2) === '-' && | ||
s.charAt(3) === '-'); | ||
} | ||
function startsWithSelfClose(s) { | ||
return ( | ||
s.charAt(0) === '/' && | ||
s.charAt(1) === '>'); | ||
} | ||
function startsWithDataDash(s) { | ||
return ( | ||
s.charAt(0) === 'd' && | ||
s.charAt(1) === 'a' && | ||
s.charAt(2) === 't' && | ||
s.charAt(3) === 'a' && | ||
s.charAt(4) === '-'); | ||
} | ||
module.exports = { | ||
@@ -211,0 +234,0 @@ parse: parse, |
{ | ||
"name": "himalaya", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "HTML to JSON parser", | ||
"main": "index.js", | ||
"bin": { | ||
"himalaya": "./bin/himalaya.js" | ||
}, | ||
"scripts": { | ||
@@ -7,0 +10,0 @@ "test": "mocha" |
@@ -11,3 +11,3 @@ # Himalaya | ||
```javascript | ||
```js | ||
var himalaya = require('himalaya'); | ||
@@ -18,2 +18,10 @@ var html = require('fs').readFileSync('/webpage.html'); | ||
Installed globally, Himalaya can also be used from the command-line to convert HTML files to JSON files. | ||
```bash | ||
himalaya webpage.html webpage.json | ||
``` | ||
Run `himalaya --help` for more information. | ||
## Parser AST Specification | ||
@@ -20,0 +28,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
20684
8
476
116
1