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

@bbob/html

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbob/html - npm Package Compare versions

Comparing version 2.3.2 to 2.4.0

27

CHANGELOG.md

@@ -6,2 +6,29 @@ # Change Log

<a name="2.4.0"></a>
# [2.4.0](https://github.com/JiLiZART/bbob/compare/v2.3.4...v2.4.0) (2019-03-29)
### Features
* **html:** [@bbob](https://github.com/bbob)/html now can be used without [@bbob](https://github.com/bbob)/core ([c9e1dab](https://github.com/JiLiZART/bbob/commit/c9e1dab))
<a name="2.3.4"></a>
## [2.3.4](https://github.com/JiLiZART/bbob/compare/v2.3.2...v2.3.4) (2019-03-29)
**Note:** Version bump only for package @bbob/html
<a name="2.3.3"></a>
## [2.3.3](https://github.com/JiLiZART/bbob/compare/v2.3.2...v2.3.3) (2019-03-29)
**Note:** Version bump only for package @bbob/html
<a name="2.3.2"></a>

@@ -8,0 +35,0 @@ ## [2.3.2](https://github.com/JiLiZART/bbob/compare/v2.3.1...v2.3.2) (2019-03-09)

65

dist/index.js

@@ -71,3 +71,3 @@ (function (global, factory) {

exports.__esModule = true;
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getNodeLength = exports.appendToNode = exports.attrValue = undefined;
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getNodeLength = exports.appendToNode = exports.attrValue = exports.attrsToString = undefined;

@@ -98,2 +98,7 @@

/**
* Appends value to Tag Node
* @param {TagNode} node
* @param value
*/
var appendToNode = function appendToNode(node, value) {

@@ -103,2 +108,6 @@ node.content.push(value);

/**
* Replaces " to &qquot;
* @param {String} value
*/
var escapeQuote = function escapeQuote(value) {

@@ -108,2 +117,8 @@ return value.replace(/"/g, '&quot;');

/**
* Acept name and value and return valid html5 attribute string
* @param {String} name
* @param {String} value
* @return {string}
*/
var attrValue = function attrValue(name, value) {

@@ -130,2 +145,13 @@ var type = typeof value;

/**
* Transforms attrs to html params string
* @param values
*/
var attrsToString = function attrsToString(values) {
return Object.keys(values).reduce(function (arr, key) {
return [].concat(arr, [attrValue(key, values[key])]);
}, ['']).join(' ');
};
exports.attrsToString = attrsToString;
exports.attrValue = attrValue;

@@ -146,2 +172,3 @@ exports.appendToNode = appendToNode;

var lib_6 = lib.attrValue;
var lib_7 = lib.attrsToString;

@@ -1078,2 +1105,4 @@ var TagNode_1 = createCommonjsModule(function (module, exports) {

tree.messages = [];
tree.options = options;
tree.walk = walk;

@@ -1106,2 +1135,6 @@ tree.match = match;

/**
* Replaces " to &qquot;
* @param {String} value
*/
var escapeQuote = function escapeQuote(value) {

@@ -1111,2 +1144,8 @@ return value.replace(/"/g, '&quot;');

/**
* Acept name and value and return valid html5 attribute string
* @param {String} name
* @param {String} value
* @return {string}
*/
var attrValue = function attrValue(name, value) {

@@ -1137,3 +1176,3 @@ var type = typeof value;

*/
var attrs = function attrs(values) {
var attrsToString = function attrsToString(values) {
return Object.keys(values).reduce(function (arr, key) {

@@ -1144,2 +1183,16 @@ return [].concat(arr, [attrValue(key, values[key])]);

var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
var SELFCLOSE_END_TAG = '/>';

@@ -1168,7 +1221,7 @@ var CLOSE_START_TAG = '</';

if (node.content === null) {
return [START_TAG, node.tag, attrs(node.attrs), SELFCLOSE_END_TAG].join('');
return [START_TAG, node.tag, attrsToString(node.attrs), SELFCLOSE_END_TAG].join('');
}
// eslint-disable-next-line no-use-before-define
return [START_TAG, node.tag, attrs(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
return [START_TAG, node.tag, attrsToString(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
}

@@ -1194,4 +1247,4 @@

var toHTML = function toHTML(source, plugins) {
return bbob(plugins).process(source, { render: renderNodes }).html;
var toHTML = function toHTML(source, plugins, options) {
return bbob(plugins).process(source, _extends({}, options, { render: renderNodes })).html;
};

@@ -1198,0 +1251,0 @@

2

dist/index.min.js

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

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.BbobHtml={})}(this,function(t){"use strict";function n(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t,n){return t(n={exports:{}},n.exports),n.exports}var u=e(function(t,n){n.__esModule=!0;n.N="\n",n.F="\f",n.R="\r",n.TAB="\t",n.EQ="=",n.QUOTEMARK='"',n.SPACE=" ",n.OPEN_BRAKET="[",n.CLOSE_BRAKET="]",n.SLASH="/",n.PLACEHOLDER_SPACE_TAB=" ",n.PLACEHOLDER_SPACE=" ",n.BACKSLASH="\\"});n(u);var A=u.N,a=u.TAB,b=u.EQ,E=u.QUOTEMARK,N=u.SPACE,L=u.OPEN_BRAKET,m=u.CLOSE_BRAKET,O=u.SLASH,S=u.BACKSLASH,o=e(function(t,n){n.__esModule=!0,n.isEOL=n.isStringNode=n.isTagNode=n.getNodeLength=n.appendToNode=n.attrValue=void 0;var r=function(t){return"object"==typeof t&&!!t.tag},o=function(t){return"string"==typeof t},i=function(t){return t.replace(/"/g,"&quot;")};n.attrValue=function(t,n){var e=typeof n,r={boolean:function(){return n?""+t:""},number:function(){return t+'="'+n+'"'},string:function(){return t+'="'+i(n)+'"'},object:function(){return t+'="'+i(JSON.stringify(n))+'"'}};return r[e]?r[e]():""},n.appendToNode=function(t,n){t.content.push(n)},n.getNodeLength=function e(t){return r(t)?t.content.reduce(function(t,n){return t+e(n)},0):o(t)?t.length:0},n.isTagNode=r,n.isStringNode=o,n.isEOL=function(t){return t===u.N}});n(o);var r=e(function(t,n){n.__esModule=!0,n.TagNode=void 0;var e=function(){function r(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(t,n,e){return n&&r(t.prototype,n),e&&r(t,e),t}}();var r=function(){function r(t,n,e){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,r),this.tag=t,this.attrs=n,this.content=[].concat(e)}return r.prototype.attr=function(t,n){return void 0!==n&&(this.attrs[t]=n),this.attrs[t]},r.prototype.append=function(t){return(0,o.appendToNode)(this,t)},r.prototype.toString=function(){var t=u.OPEN_BRAKET,n=u.CLOSE_BRAKET;return t+this.tag+n+this.content.reduce(function(t,n){return t+""+n},"")+t+u.SLASH+this.tag+n},e(r,[{key:"length",get:function(){return(0,o.getNodeLength)(this)}}]),r}();r.create=function(t){return new r(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},2<arguments.length&&void 0!==arguments[2]?arguments[2]:[])},r.isOf=function(t,n){return t.tag===n},n.TagNode=r,n.default=r}),h=n(r);var i="type",s="value",f="line",c="word",l="attr-name",g="attr-value",p="space",d="new-line",v=function(t){return t[s]},y=function(t){return v(t).charCodeAt(0)==O.charCodeAt(0)},T=function(){function o(t,n,e,r){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,o),this[i]=t+"",this[s]=n+"",this[f]=+e,this.row=+r}return o.prototype.isEmpty=function(){return!!this[i]},o.prototype.isText=function(){return(t=this)[i]===p||t[i]===d||t[i]===c;var t},o.prototype.isTag=function(){return"tag"===this[i]},o.prototype.isAttrName=function(){return this[i]===l},o.prototype.isAttrValue=function(){return this[i]===g},o.prototype.isStart=function(){return!y(this)},o.prototype.isEnd=function(){return y(this)},o.prototype.getName=function(){return n=v(t=this),y(t)?n.slice(1):n;var t,n},o.prototype.getValue=function(){return v(this)},o.prototype.getLine=function(){return this[f]},o.prototype.getColumn=function(){return this.row},o.prototype.toString=function(){return t=L,t+=v(this),t+=m;var t},o}(),x=c,k=function(e){var t=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).onSkip,r=0,o=function(){r+=1,t&&t()},i=function(){return r<e.length},u=function(){return e.substr(r)},a=function(){return e[r]};return{skip:o,hasNext:i,isLast:function(){return r===e.length},grabWhile:function(t){for(var n=r;i()&&t(a());)o();return e.substr(n,r-n)},getNext:function(){return e[r+1]},getPrev:function(){return e[r-1]},getCurr:a,getRest:u,substrUntilChar:function(t){var n=u(),e=n.indexOf(t);return e<0?"":n.substr(0,e)}}},w=function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return{getLast:function(){return n.length?n[n.length-1]:null},flushLast:function(){return!!n.length&&n.pop()},push:function(t){return n.push(t)},toArray:function(){return n}}},C=function(t,n){return new T(t,n,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,3<arguments.length&&void 0!==arguments[3]?arguments[3]:0)};function _(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},f=0,c=0,r=-1,o=Array(Math.floor(e.length)),s=n.openTag||L,l=n.closeTag||m,g=[l,s,E,S,N,a,b,A,"!"],i=[s,N,a,A],u=[N,a],p=[b,N,a],h=function(t){return 0<=u.indexOf(t)},d=function(t){return-1==i.indexOf(t)},v=function(t){n.onToken&&n.onToken(t),o[r+=1]=t},y=function(t){for(var u=null,a=!1,r=[],s=k(t),o=function(t){var n=t===b,e=h(t),r=s.getPrev(),o=s.getNext(),i=r===S;return null===u?!1===(n||e||s.isLast()):!(!a||p.indexOf(t)<0)||!!(t!==E||i||(a=!a)||o===b||h(o))&&!1===(n||e)},n=function(){var t=s.grabWhile(o),n=s.getCurr();if(null===u)u=t;else if(h(n)||n===E||!s.hasNext()){var e=function(t,n){for(;t.charAt(0)===n;)t=t.substring(1);for(;t.charAt(t.length-1)===n;)t=t.substring(0,t.length-1);return t}(t,E).replace(S+E,E);r.push(C("attr-value",e,f,c))}else r.push(C("attr-name",t,f,c));s.skip()};s.hasNext();)n();return{tag:u,attrs:r}},T=k(e,{onSkip:function(){c++}}),t=function(){var t=T.getCurr();if(t===A)T.skip(),v(C("new-line",t,++f,c=0));else if(h(t)){var n=T.grabWhile(h);v(C("space",n,f,c))}else if(t===s){var e=T.getNext();T.skip();var r=T.substrUntilChar(l),o=0===r.length||0<=r.indexOf(s);if(0<=g.indexOf(e)||o||T.isLast())v(C(x,t,f,c));else{var i=T.grabWhile(function(t){return t!==l});if(T.skip(),-1==i.indexOf(b)||i[0]===O)v(C("tag",i,f,c));else{var u=y(i);v(C("tag",u.tag,f,c)),u.attrs.map(v)}}}else if(t===l)T.skip(),v(C(x,t,f,c));else if(d(t)){var a=T.grabWhile(d);v(C(x,a,f,c))}};return{tokenize:function(){for(;T.hasNext();)t();return o.length=r+1,o},isTokenNested:function(t){var n=s+O+t.getValue();return-1<e.indexOf(n)}}}var P=function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=n,o=null,e=w(),u=w(),a=w(),s=w(),f={},c=function(){a.flushLast()&&s.flushLast()},l=function(t){var n;(n=u.getLast(),n?n.content:e.toArray()).push(t)},r=function(t){c();var n,e=h.create(t.getValue()),r=(void 0===f[(n=t).getValue()]&&(f[n.getValue()]=o.isTokenNested(n)),f[n.getValue()]);a.push(e),r?u.push(e):l(e)},g=function(t){t.isStart()&&r(t),t.isEnd()&&function(t){c();var n=u.flushLast();if(n)l(n);else if(i.onError){var e=t.getValue(),r=t.getLine(),o=t.getColumn();i.onError({message:"Inconsistent tag '"+e+"' on line "+r+" and column "+o,tagName:e,lineNumber:r,columnNumber:o})}}(t)},p=function(t){var n=a.getLast(),e=t.getValue(),r=!!f[t];if(n)if(t.isAttrName())s.push(e),n.attr(s.getLast(),"");else if(t.isAttrValue()){var o=s.getLast();o?(n.attr(o,e),s.flushLast()):n.attr(e,e)}else t.isText()?r?n.append(e):l(e):t.isTag()&&l(""+t);else t.isText()?l(e):t.isTag()&&l(""+t)};(o=(n.createTokenizer?n.createTokenizer:_)(t,{onToken:function(t){var n;!t.isTag()||(n=t.getName(),i.onlyAllowTags&&i.onlyAllowTags.length&&i.onlyAllowTags.indexOf(n)<0)?p(t):g(t)},onlyAllowTags:i.onlyAllowTags,openTag:i.openTag,closeTag:i.closeTag})).tokenize();return e.toArray()},j=function(t){return"object"==typeof t},B=function(t){return"boolean"==typeof t};function R(t,n){var e=t;if(Array.isArray(e))for(var r=0;r<e.length;r++)e[r]=R(n(e[r]),n);else e&&j(e)&&e.content&&R(e.content,n);return e}function V(r,o){return typeof r==typeof o&&(j(r)&&null!==r?Array.isArray(r)?r.every(function(n){return[].some.call(o,function(t){return V(n,t)})}):Object.keys(r).every(function(t){var n=o[t],e=r[t];return j(e)&&null!==e&&null!==n?V(e,n):B(e)?e!==(null===n):n===e}):r===o)}function K(e,r){return R(this,Array.isArray(e)?function(t){for(var n=0;n<e.length;n++)if(V(e[n],t))return r(t);return t}:function(t){return V(e,t)?r(t):t})}function H(t){return R(this,t)}var M=function(t){return t.replace(/"/g,"&quot;")},W=function(u){return Object.keys(u).reduce(function(t,n){return[].concat(t,[(e=n,r=u[n],o=typeof r,i={boolean:function(){return r?""+e:""},number:function(){return e+'="'+r+'"'},string:function(){return e+'="'+M(r)+'"'},object:function(){return e+'="'+M(JSON.stringify(r))+'"'}},i[o]?i[o]():"")]);var e,r,o,i},[""]).join(" ")},z="/>",Q="</",U="<",q=">",D=function(t){var n=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).stripTags,e=void 0!==n&&n;return[].concat(t).reduce(function(t,n){return t+function(t,n){var e=n.stripTags,r=void 0!==e&&e;if(!t)return"";var o=typeof t;return"string"===o||"number"===o?t:"object"===o?!0===r?D(t.content,{stripTags:r}):null===t.content?""+U+t.tag+W(t.attrs)+z:""+U+t.tag+W(t.attrs)+q+D(t.content)+Q+t.tag+q:Array.isArray(t)?D(t,{stripTags:r}):""}(n,{stripTags:e})},"")};t.render=D,t.default=function(t,n){return(e=n,u="function"==typeof e?[e]:e||[],a={skipParse:!1},{process:function(t,n){var e=(a=n||{}).parser||P,r=a.render;if("function"!=typeof e)throw Error('"parser" is not a function, please pass to "process(input, { parser })" right function');var o=a.skipParse?t||[]:e(t,a),i=o;return o.walk=H,o.match=K,u.forEach(function(t){o=t(o,{parse:e,render:r,iterate:R,match:K})||o}),{get html(){if("function"!=typeof r)throw Error('"render" function not defined, please pass to "process(input, { render })"');return r(o,o.options)},tree:o,raw:i,messages:o.messages}}}).process(t,{render:D}).html;var e,u,a},Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.BbobHtml={})}(this,function(t){"use strict";function n(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t,n){return t(n={exports:{}},n.exports),n.exports}var a=e(function(t,n){n.__esModule=!0;n.N="\n",n.F="\f",n.R="\r",n.TAB="\t",n.EQ="=",n.QUOTEMARK='"',n.SPACE=" ",n.OPEN_BRAKET="[",n.CLOSE_BRAKET="]",n.SLASH="/",n.PLACEHOLDER_SPACE_TAB=" ",n.PLACEHOLDER_SPACE=" ",n.BACKSLASH="\\"});n(a);var A=a.N,b=a.TAB,E=a.EQ,N=a.QUOTEMARK,O=a.SPACE,m=a.OPEN_BRAKET,L=a.CLOSE_BRAKET,S=a.SLASH,k=a.BACKSLASH,o=e(function(t,n){n.__esModule=!0,n.isEOL=n.isStringNode=n.isTagNode=n.getNodeLength=n.appendToNode=n.attrValue=n.attrsToString=void 0;var r=function(t){return"object"==typeof t&&!!t.tag},o=function(t){return"string"==typeof t},i=function(t){return t.replace(/"/g,"&quot;")},u=function(t,n){var e=typeof n,r={boolean:function(){return n?""+t:""},number:function(){return t+'="'+n+'"'},string:function(){return t+'="'+i(n)+'"'},object:function(){return t+'="'+i(JSON.stringify(n))+'"'}};return r[e]?r[e]():""};n.attrsToString=function(e){return Object.keys(e).reduce(function(t,n){return[].concat(t,[u(n,e[n])])},[""]).join(" ")},n.attrValue=u,n.appendToNode=function(t,n){t.content.push(n)},n.getNodeLength=function e(t){return r(t)?t.content.reduce(function(t,n){return t+e(n)},0):o(t)?t.length:0},n.isTagNode=r,n.isStringNode=o,n.isEOL=function(t){return t===a.N}});n(o);var r=e(function(t,n){n.__esModule=!0,n.TagNode=void 0;var e=function(){function r(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(t,n,e){return n&&r(t.prototype,n),e&&r(t,e),t}}();var r=function(){function r(t,n,e){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,r),this.tag=t,this.attrs=n,this.content=[].concat(e)}return r.prototype.attr=function(t,n){return void 0!==n&&(this.attrs[t]=n),this.attrs[t]},r.prototype.append=function(t){return(0,o.appendToNode)(this,t)},r.prototype.toString=function(){var t=a.OPEN_BRAKET,n=a.CLOSE_BRAKET;return t+this.tag+n+this.content.reduce(function(t,n){return t+""+n},"")+t+a.SLASH+this.tag+n},e(r,[{key:"length",get:function(){return(0,o.getNodeLength)(this)}}]),r}();r.create=function(t){return new r(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},2<arguments.length&&void 0!==arguments[2]?arguments[2]:[])},r.isOf=function(t,n){return t.tag===n},n.TagNode=r,n.default=r}),h=n(r);var i="type",u="value",s="line",f="word",c="attr-name",l="attr-value",g="space",p="new-line",d=function(t){return t[u]},v=function(t){return d(t).charCodeAt(0)==S.charCodeAt(0)},y=function(){function o(t,n,e,r){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,o),this[i]=t+"",this[u]=n+"",this[s]=+e,this.row=+r}return o.prototype.isEmpty=function(){return!!this[i]},o.prototype.isText=function(){return(t=this)[i]===g||t[i]===p||t[i]===f;var t},o.prototype.isTag=function(){return"tag"===this[i]},o.prototype.isAttrName=function(){return this[i]===c},o.prototype.isAttrValue=function(){return this[i]===l},o.prototype.isStart=function(){return!v(this)},o.prototype.isEnd=function(){return v(this)},o.prototype.getName=function(){return n=d(t=this),v(t)?n.slice(1):n;var t,n},o.prototype.getValue=function(){return d(this)},o.prototype.getLine=function(){return this[s]},o.prototype.getColumn=function(){return this.row},o.prototype.toString=function(){return t=m,t+=d(this),t+=L;var t},o}(),x=f,w=function(e){var t=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).onSkip,r=0,o=function(){r+=1,t&&t()},i=function(){return r<e.length},u=function(){return e.substr(r)},a=function(){return e[r]};return{skip:o,hasNext:i,isLast:function(){return r===e.length},grabWhile:function(t){for(var n=r;i()&&t(a());)o();return e.substr(n,r-n)},getNext:function(){return e[r+1]},getPrev:function(){return e[r-1]},getCurr:a,getRest:u,substrUntilChar:function(t){var n=u(),e=n.indexOf(t);return e<0?"":n.substr(0,e)}}},T=function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return{getLast:function(){return n.length?n[n.length-1]:null},flushLast:function(){return!!n.length&&n.pop()},push:function(t){return n.push(t)},toArray:function(){return n}}},C=function(t,n){return new y(t,n,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,3<arguments.length&&void 0!==arguments[3]?arguments[3]:0)};function _(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},f=0,c=0,r=-1,o=Array(Math.floor(e.length)),s=n.openTag||m,l=n.closeTag||L,g=[l,s,N,k,O,b,E,A,"!"],i=[s,O,b,A],u=[O,b],p=[E,O,b],h=function(t){return 0<=u.indexOf(t)},d=function(t){return-1==i.indexOf(t)},v=function(t){n.onToken&&n.onToken(t),o[r+=1]=t},y=function(t){for(var u=null,a=!1,r=[],s=w(t),o=function(t){var n=t===E,e=h(t),r=s.getPrev(),o=s.getNext(),i=r===k;return null===u?!1===(n||e||s.isLast()):!(!a||p.indexOf(t)<0)||!!(t!==N||i||(a=!a)||o===E||h(o))&&!1===(n||e)},n=function(){var t=s.grabWhile(o),n=s.getCurr();if(null===u)u=t;else if(h(n)||n===N||!s.hasNext()){var e=function(t,n){for(;t.charAt(0)===n;)t=t.substring(1);for(;t.charAt(t.length-1)===n;)t=t.substring(0,t.length-1);return t}(t,N).replace(k+N,N);r.push(C("attr-value",e,f,c))}else r.push(C("attr-name",t,f,c));s.skip()};s.hasNext();)n();return{tag:u,attrs:r}},T=w(e,{onSkip:function(){c++}}),t=function(){var t=T.getCurr();if(t===A)T.skip(),v(C("new-line",t,++f,c=0));else if(h(t)){var n=T.grabWhile(h);v(C("space",n,f,c))}else if(t===s){var e=T.getNext();T.skip();var r=T.substrUntilChar(l),o=0===r.length||0<=r.indexOf(s);if(0<=g.indexOf(e)||o||T.isLast())v(C(x,t,f,c));else{var i=T.grabWhile(function(t){return t!==l});if(T.skip(),-1==i.indexOf(E)||i[0]===S)v(C("tag",i,f,c));else{var u=y(i);v(C("tag",u.tag,f,c)),u.attrs.map(v)}}}else if(t===l)T.skip(),v(C(x,t,f,c));else if(d(t)){var a=T.grabWhile(d);v(C(x,a,f,c))}};return{tokenize:function(){for(;T.hasNext();)t();return o.length=r+1,o},isTokenNested:function(t){var n=s+S+t.getValue();return-1<e.indexOf(n)}}}var P=function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=n,o=null,e=T(),u=T(),a=T(),s=T(),f={},c=function(){a.flushLast()&&s.flushLast()},l=function(t){var n;(n=u.getLast(),n?n.content:e.toArray()).push(t)},r=function(t){c();var n,e=h.create(t.getValue()),r=(void 0===f[(n=t).getValue()]&&(f[n.getValue()]=o.isTokenNested(n)),f[n.getValue()]);a.push(e),r?u.push(e):l(e)},g=function(t){t.isStart()&&r(t),t.isEnd()&&function(t){c();var n=u.flushLast();if(n)l(n);else if(i.onError){var e=t.getValue(),r=t.getLine(),o=t.getColumn();i.onError({message:"Inconsistent tag '"+e+"' on line "+r+" and column "+o,tagName:e,lineNumber:r,columnNumber:o})}}(t)},p=function(t){var n=a.getLast(),e=t.getValue(),r=!!f[t];if(n)if(t.isAttrName())s.push(e),n.attr(s.getLast(),"");else if(t.isAttrValue()){var o=s.getLast();o?(n.attr(o,e),s.flushLast()):n.attr(e,e)}else t.isText()?r?n.append(e):l(e):t.isTag()&&l(""+t);else t.isText()?l(e):t.isTag()&&l(""+t)};(o=(n.createTokenizer?n.createTokenizer:_)(t,{onToken:function(t){var n;!t.isTag()||(n=t.getName(),i.onlyAllowTags&&i.onlyAllowTags.length&&i.onlyAllowTags.indexOf(n)<0)?p(t):g(t)},onlyAllowTags:i.onlyAllowTags,openTag:i.openTag,closeTag:i.closeTag})).tokenize();return e.toArray()},j=function(t){return"object"==typeof t},B=function(t){return"boolean"==typeof t};function R(t,n){var e=t;if(Array.isArray(e))for(var r=0;r<e.length;r++)e[r]=R(n(e[r]),n);else e&&j(e)&&e.content&&R(e.content,n);return e}function V(r,o){return typeof r==typeof o&&(j(r)&&null!==r?Array.isArray(r)?r.every(function(n){return[].some.call(o,function(t){return V(n,t)})}):Object.keys(r).every(function(t){var n=o[t],e=r[t];return j(e)&&null!==e&&null!==n?V(e,n):B(e)?e!==(null===n):n===e}):r===o)}function K(e,r){return R(this,Array.isArray(e)?function(t){for(var n=0;n<e.length;n++)if(V(e[n],t))return r(t);return t}:function(t){return V(e,t)?r(t):t})}function H(t){return R(this,t)}var M=function(t){return t.replace(/"/g,"&quot;")},W=function(u){return Object.keys(u).reduce(function(t,n){return[].concat(t,[(e=n,r=u[n],o=typeof r,i={boolean:function(){return r?""+e:""},number:function(){return e+'="'+r+'"'},string:function(){return e+'="'+M(r)+'"'},object:function(){return e+'="'+M(JSON.stringify(r))+'"'}},i[o]?i[o]():"")]);var e,r,o,i},[""]).join(" ")},z=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},Q="/>",U="</",q="<",D=">",J=function(t){var n=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).stripTags,e=void 0!==n&&n;return[].concat(t).reduce(function(t,n){return t+function(t,n){var e=n.stripTags,r=void 0!==e&&e;if(!t)return"";var o=typeof t;return"string"===o||"number"===o?t:"object"===o?!0===r?J(t.content,{stripTags:r}):null===t.content?""+q+t.tag+W(t.attrs)+Q:""+q+t.tag+W(t.attrs)+D+J(t.content)+U+t.tag+D:Array.isArray(t)?J(t,{stripTags:r}):""}(n,{stripTags:e})},"")};t.render=J,t.default=function(t,n,e){return(r=n,u="function"==typeof r?[r]:r||[],a={skipParse:!1},{process:function(t,n){var e=(a=n||{}).parser||P,r=a.render;if("function"!=typeof e)throw Error('"parser" is not a function, please pass to "process(input, { parser })" right function');var o=a.skipParse?t||[]:e(t,a),i=o;return o.messages=[],o.options=a,o.walk=H,o.match=K,u.forEach(function(t){o=t(o,{parse:e,render:r,iterate:R,match:K})||o}),{get html(){if("function"!=typeof r)throw Error('"render" function not defined, please pass to "process(input, { render })"');return r(o,o.options)},tree:o,raw:i,messages:o.messages}}}).process(t,z({},e,{render:J})).html;var r,u,a},Object.defineProperty(t,"__esModule",{value:!0})});

@@ -0,14 +1,6 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
import core from '@bbob/core';
import { attrValue } from '@bbob/plugin-helper';
import { attrsToString } from '@bbob/plugin-helper';
/**
* Transforms attrs to html params string
* @param values
*/
var attrs = function attrs(values) {
return Object.keys(values).reduce(function (arr, key) {
return [].concat(arr, [attrValue(key, values[key])]);
}, ['']).join(' ');
};
var SELFCLOSE_END_TAG = '/>';

@@ -37,7 +29,7 @@ var CLOSE_START_TAG = '</';

if (node.content === null) {
return [START_TAG, node.tag, attrs(node.attrs), SELFCLOSE_END_TAG].join('');
return [START_TAG, node.tag, attrsToString(node.attrs), SELFCLOSE_END_TAG].join('');
}
// eslint-disable-next-line no-use-before-define
return [START_TAG, node.tag, attrs(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
return [START_TAG, node.tag, attrsToString(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
}

@@ -63,4 +55,4 @@

var toHTML = function toHTML(source, plugins) {
return core(plugins).process(source, { render: renderNodes }).html;
var toHTML = function toHTML(source, plugins, options) {
return core(plugins).process(source, _extends({}, options, { render: renderNodes })).html;
};

@@ -67,0 +59,0 @@

@@ -6,2 +6,4 @@ 'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _core = require('@bbob/core');

@@ -15,12 +17,2 @@

/**
* Transforms attrs to html params string
* @param values
*/
var attrs = function attrs(values) {
return Object.keys(values).reduce(function (arr, key) {
return [].concat(arr, [(0, _pluginHelper.attrValue)(key, values[key])]);
}, ['']).join(' ');
};
var SELFCLOSE_END_TAG = '/>';

@@ -49,7 +41,7 @@ var CLOSE_START_TAG = '</';

if (node.content === null) {
return [START_TAG, node.tag, attrs(node.attrs), SELFCLOSE_END_TAG].join('');
return [START_TAG, node.tag, (0, _pluginHelper.attrsToString)(node.attrs), SELFCLOSE_END_TAG].join('');
}
// eslint-disable-next-line no-use-before-define
return [START_TAG, node.tag, attrs(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
return [START_TAG, node.tag, (0, _pluginHelper.attrsToString)(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
}

@@ -75,4 +67,4 @@

var toHTML = function toHTML(source, plugins) {
return (0, _core2.default)(plugins).process(source, { render: renderNodes }).html;
var toHTML = function toHTML(source, plugins, options) {
return (0, _core2.default)(plugins).process(source, _extends({}, options, { render: renderNodes })).html;
};

@@ -79,0 +71,0 @@

{
"name": "@bbob/html",
"version": "2.3.2",
"version": "2.4.0",
"description": "HTML renderer for @bbob bbcode parser",
"keywords": [],
"dependencies": {
"@bbob/core": "^2.3.2",
"@bbob/plugin-helper": "^2.3.2"
"@bbob/core": "^2.4.0",
"@bbob/plugin-helper": "^2.4.0"
},

@@ -10,0 +10,0 @@ "main": "lib/index.js",

import core from '@bbob/core';
import { attrValue } from '@bbob/plugin-helper';
import { attrsToString } from '@bbob/plugin-helper';
/**
* Transforms attrs to html params string
* @param values
*/
const attrs = values =>
Object.keys(values)
.reduce((arr, key) => [...arr, attrValue(key, values[key])], [''])
.join(' ');
const SELFCLOSE_END_TAG = '/>';

@@ -33,7 +24,7 @@ const CLOSE_START_TAG = '</';

if (node.content === null) {
return [START_TAG, node.tag, attrs(node.attrs), SELFCLOSE_END_TAG].join('');
return [START_TAG, node.tag, attrsToString(node.attrs), SELFCLOSE_END_TAG].join('');
}
// eslint-disable-next-line no-use-before-define
return [START_TAG, node.tag, attrs(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
return [START_TAG, node.tag, attrsToString(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
}

@@ -53,5 +44,6 @@

const toHTML = (source, plugins) => core(plugins).process(source, { render: renderNodes }).html;
const toHTML = (source, plugins, options) => core(plugins)
.process(source, { ...options, render: renderNodes }).html;
export const render = renderNodes;
export default toHTML;
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