html-parse-stringify
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,8 +0,4 @@ | ||
var parse = require('./lib/parse'); | ||
var stringify = require('./lib/stringify'); | ||
module.exports = { | ||
parse: parse, | ||
stringify: stringify | ||
parse: require('./lib/parse'), | ||
stringify: require('./lib/stringify') | ||
}; |
@@ -17,5 +17,9 @@ var tagRE = /<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>/g; | ||
html.replace(tagRE, function (tag, index) { | ||
if (inComponent && tag !== ('</' + current.name + '>')) { | ||
return; | ||
} | ||
if (inComponent) { | ||
if (tag !== ('</' + current.name + '>')) { | ||
return; | ||
} else { | ||
inComponent = false; | ||
} | ||
} | ||
var isOpen = tag.charAt(1) !== '/'; | ||
@@ -37,3 +41,3 @@ var start = index + tag.length; | ||
if (nextChar !== '<') { | ||
if (!inComponent && nextChar !== '<') { | ||
current.children.push({ | ||
@@ -40,0 +44,0 @@ type: 'text', |
{ | ||
"name": "html-parse-stringify", | ||
"description": "Parses well-formed HTML (meaning all tags closed) into an AST and back. quickly.", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -161,3 +161,37 @@ var test = require('tape'); | ||
html = '<div><my-component thing="one">ok</my-component><my-component thing="two">ok</my-component></div>'; | ||
parsed = HTML.parse(html, { | ||
components: { | ||
'my-component': 'something' | ||
} | ||
}); | ||
t.deepEqual(parsed, { | ||
type: 'tag', | ||
name: 'div', | ||
attrs: {}, | ||
selfClosing: false, | ||
children: [ | ||
{ | ||
type: 'component', | ||
name: 'my-component', | ||
attrs: { | ||
thing: 'one' | ||
}, | ||
selfClosing: false, | ||
children: [] | ||
}, | ||
{ | ||
type: 'component', | ||
name: 'my-component', | ||
attrs: { | ||
thing: 'two' | ||
}, | ||
selfClosing: false, | ||
children: [] | ||
} | ||
] | ||
}) | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16112
346