Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

posthtml-render

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

posthtml-render - npm Package Compare versions

Comparing version 1.0.7 to 1.1.0

21

lib/posthtml-render.js

@@ -28,2 +28,3 @@ (function(global) {

var singleTags = {};
var regexpSingleTags = [];

@@ -36,3 +37,7 @@ for (var i = 0, leni = SINGLE_TAGS.length; i < leni; i++) {

for (var j = 0, lenj = optSingleTags.length; j < lenj; j++) {
singleTags[optSingleTags[j]] = 1;
if (optSingleTags[j] instanceof RegExp) {
regexpSingleTags.push(optSingleTags[j]);
} else {
singleTags[optSingleTags[j]] = 1;
}
}

@@ -65,3 +70,3 @@ }

var tag = node.tag || 'div';
if (singleTags[tag]) {
if (isSingleTag(tag, singleTags, regexpSingleTags)) {
buf += '<'+ tag + attrs(node.attrs);

@@ -113,2 +118,14 @@ switch (closingSingleTag) {

function isSingleTag(tag, strings, regexps) {
if (strings[tag]) {
return true;
}
for (var i = 0; i < regexps.length; i++) {
if (tag.match(regexps[i])) {
return true;
}
}
return false;
}
var defineAsGlobal = true;

@@ -115,0 +132,0 @@

2

package.json
{
"name": "posthtml-render",
"version": "1.0.7",
"version": "1.1.0",
"description": "Render PostHTMLTree to HTML/XML",

@@ -5,0 +5,0 @@ "main": "lib/posthtml-render.js",

@@ -1,1 +0,1 @@

!function(global){function postHTMLRender(tree,options){for(var optSingleTags=(options=options||{}).singleTags,closingSingleTag=options.closingSingleTag,SINGLE_TAGS=["area","base","br","col","command","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],singleTags={},i=0,leni=SINGLE_TAGS.length;i<leni;i++)singleTags[SINGLE_TAGS[i]]=1;if(optSingleTags)for(var j=0,lenj=optSingleTags.length;j<lenj;j++)singleTags[optSingleTags[j]]=1;return function html(tree){var buf="";!function traverse(tree,cb){if(Array.isArray(tree))for(var i=0,len=tree.length;i<len;i++)traverse(cb(tree[i]),cb);else"object"==typeof tree&&tree.hasOwnProperty("content")&&traverse(tree.content,cb);return tree}([].concat(tree),function(node){if(node)if("string"!=typeof node&&"number"!=typeof node){if("boolean"==typeof node.tag&&!node.tag)return"object"!=typeof node.content&&(buf+=node.content),node.content;if(Array.isArray(node))buf+=html(node);else{var tag=node.tag||"div";if(singleTags[tag])switch(buf+="<"+tag+attrs(node.attrs),closingSingleTag){case"slash":buf+=" />";break;case"tag":buf+="></"+tag+">";break;default:buf+=">"}else buf+="<"+tag+(node.attrs?attrs(node.attrs):"")+">"+(node.content?html(node.content):"")+"</"+tag+">"}}else buf+=node});return buf;function attrs(obj){var attr="";for(var key in obj)"boolean"==typeof obj[key]&&obj[key]?attr+=" "+key:"string"!=typeof obj[key]&&"number"!=typeof obj[key]||(attr+=" "+key+'="'+obj[key]+'"');return attr}}(tree)}var defineAsGlobal=!0;"object"==typeof module&&"object"==typeof module.exports&&(module.exports=postHTMLRender,defineAsGlobal=!1),"object"==typeof modules&&"function"==typeof modules.define&&(modules.define("postHTMLRender",function(provide){provide(postHTMLRender)}),defineAsGlobal=!1),"function"==typeof define&&(define(function(require,exports,module){module.exports=postHTMLRender}),defineAsGlobal=!1),defineAsGlobal&&(global.postHTMLRender=postHTMLRender)}("undefined"!=typeof window?window:global);
!function(global){function postHTMLRender(tree,options){for(var optSingleTags=(options=options||{}).singleTags,closingSingleTag=options.closingSingleTag,SINGLE_TAGS=["area","base","br","col","command","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],singleTags={},regexpSingleTags=[],i=0,leni=SINGLE_TAGS.length;i<leni;i++)singleTags[SINGLE_TAGS[i]]=1;if(optSingleTags)for(var j=0,lenj=optSingleTags.length;j<lenj;j++)optSingleTags[j]instanceof RegExp?regexpSingleTags.push(optSingleTags[j]):singleTags[optSingleTags[j]]=1;return function html(tree){var buf="";!function traverse(tree,cb){if(Array.isArray(tree))for(var i=0,len=tree.length;i<len;i++)traverse(cb(tree[i]),cb);else"object"==typeof tree&&tree.hasOwnProperty("content")&&traverse(tree.content,cb);return tree}([].concat(tree),function(node){if(node)if("string"!=typeof node&&"number"!=typeof node){if("boolean"==typeof node.tag&&!node.tag)return"object"!=typeof node.content&&(buf+=node.content),node.content;if(Array.isArray(node))buf+=html(node);else{var tag=node.tag||"div";if(function(tag,strings,regexps){if(strings[tag])return!0;for(var i=0;i<regexps.length;i++)if(tag.match(regexps[i]))return!0;return!1}(tag,singleTags,regexpSingleTags))switch(buf+="<"+tag+attrs(node.attrs),closingSingleTag){case"slash":buf+=" />";break;case"tag":buf+="></"+tag+">";break;default:buf+=">"}else buf+="<"+tag+(node.attrs?attrs(node.attrs):"")+">"+(node.content?html(node.content):"")+"</"+tag+">"}}else buf+=node});return buf;function attrs(obj){var attr="";for(var key in obj)"boolean"==typeof obj[key]&&obj[key]?attr+=" "+key:"string"!=typeof obj[key]&&"number"!=typeof obj[key]||(attr+=" "+key+'="'+obj[key]+'"');return attr}}(tree)}var defineAsGlobal=!0;"object"==typeof module&&"object"==typeof module.exports&&(module.exports=postHTMLRender,defineAsGlobal=!1),"object"==typeof modules&&"function"==typeof modules.define&&(modules.define("postHTMLRender",function(provide){provide(postHTMLRender)}),defineAsGlobal=!1),"function"==typeof define&&(define(function(require,exports,module){module.exports=postHTMLRender}),defineAsGlobal=!1),defineAsGlobal&&(global.postHTMLRender=postHTMLRender)}("undefined"!=typeof window?window:global);

@@ -56,7 +56,7 @@ # posthtml-render

### singleTags
Array tags for extend default list single tags
Array tags for extend default list single tags. Values can be strings or regular expressions.
__Default__: `[]`
*Options* `{ singleTags: ['rect', 'custom'] }`
*Options* `{ singleTags: ['rect', 'custom', /^%.*%$/] }`

@@ -69,2 +69,3 @@ ```html

<custom>
<%=title%>
</div>

@@ -71,0 +72,0 @@ ```

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