Socket
Socket
Sign inDemoInstall

html-parse-stringify

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-parse-stringify - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

8

index.js

@@ -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();
});
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