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.6.1 to 2.6.2

8

CHANGELOG.md

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

## [2.6.2](https://github.com/JiLiZART/bbob/compare/v2.5.8...v2.6.2) (2020-12-16)
**Note:** Version bump only for package @bbob/html
## [2.6.1](https://github.com/JiLiZART/bbob/compare/v2.5.8...v2.6.1) (2020-12-15)

@@ -8,0 +16,0 @@

90

dist/index.js

@@ -306,2 +306,23 @@ (function (global, factory) {

_proto.toTagStart = function toTagStart(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$openTag = _ref.openTag,
openTag = _ref$openTag === void 0 ? char_1.OPEN_BRAKET : _ref$openTag,
_ref$closeTag = _ref.closeTag,
closeTag = _ref$closeTag === void 0 ? char_1.CLOSE_BRAKET : _ref$closeTag;
var tagAttrs = getTagAttrs(this.tag, this.attrs);
return "" + openTag + tagAttrs + closeTag;
};
_proto.toTagEnd = function toTagEnd(_temp2) {
var _ref2 = _temp2 === void 0 ? {} : _temp2,
_ref2$openTag = _ref2.openTag,
openTag = _ref2$openTag === void 0 ? char_1.OPEN_BRAKET : _ref2$openTag,
_ref2$closeTag = _ref2.closeTag,
closeTag = _ref2$closeTag === void 0 ? char_1.CLOSE_BRAKET : _ref2$closeTag;
return "" + openTag + char_1.SLASH + this.tag + closeTag;
};
_proto.toTagNode = function toTagNode() {

@@ -311,16 +332,29 @@ return new TagNode(this.tag.toLowerCase(), this.attrs, this.content);

_proto.toString = function toString() {
var OB = char_1.OPEN_BRAKET;
var CB = char_1.CLOSE_BRAKET;
_proto.toString = function toString(_temp3) {
var _ref3 = _temp3 === void 0 ? {} : _temp3,
_ref3$openTag = _ref3.openTag,
openTag = _ref3$openTag === void 0 ? char_1.OPEN_BRAKET : _ref3$openTag,
_ref3$closeTag = _ref3.closeTag,
closeTag = _ref3$closeTag === void 0 ? char_1.CLOSE_BRAKET : _ref3$closeTag;
var isEmpty = this.content.length === 0;
var content = this.content.reduce(function (r, node) {
return r + node.toString();
return r + node.toString({
openTag: openTag,
closeTag: closeTag
});
}, '');
var tagAttrs = getTagAttrs(this.tag, this.attrs);
var tagStart = this.toTagStart({
openTag: openTag,
closeTag: closeTag
});
if (isEmpty) {
return "" + OB + tagAttrs + CB;
return tagStart;
}
return "" + OB + tagAttrs + CB + content + OB + char_1.SLASH + this.tag + CB;
return "" + tagStart + content + this.toTagEnd({
openTag: openTag,
closeTag: closeTag
});
};

@@ -1220,2 +1254,4 @@

function _interopRequireDefault(obj) {

@@ -1245,2 +1281,4 @@ return obj && obj.__esModule ? obj : {

var options = opts;
var openTag = options.openTag || char_1.OPEN_BRAKET;
var closeTag = options.closeTag || char_1.CLOSE_BRAKET;
var tokenizer = null;

@@ -1277,13 +1315,20 @@ /**

* Cache for nested tags checks
* @type {{}}
*/
var nestedTagsMap = {};
var nestedTagsMap = new Set();
/**
*
* @param token
* @returns {boolean}
*/
var isTokenNested = function isTokenNested(token) {
if (typeof nestedTagsMap[token.getValue()] === 'undefined') {
nestedTagsMap[token.getValue()] = tokenizer.isTokenNested(token);
var value = token.getValue();
if (!nestedTagsMap.has(value) && tokenizer.isTokenNested && tokenizer.isTokenNested(token)) {
nestedTagsMap.add(value);
return true;
}
return nestedTagsMap[token.getValue()];
return nestedTagsMap.has(value);
};

@@ -1297,3 +1342,3 @@ /**

var isTagNested = function isTagNested(tagName) {
return !!nestedTagsMap[tagName];
return Boolean(nestedTagsMap.has(tagName));
};

@@ -1355,3 +1400,16 @@ /**

} else {
items.push(node.toString());
items.push(node.toTagStart({
openTag: openTag,
closeTag: closeTag
}));
if (node.content.length) {
node.content.forEach(function (item) {
items.push(item);
});
items.push(node.toTagEnd({
openTag: openTag,
closeTag: closeTag
}));
}
}

@@ -1485,4 +1543,4 @@ } else {

onlyAllowTags: options.onlyAllowTags,
openTag: options.openTag,
closeTag: options.closeTag,
openTag: openTag,
closeTag: closeTag,
enableEscapeTags: options.enableEscapeTags

@@ -1489,0 +1547,0 @@ }); // eslint-disable-next-line no-unused-vars

2

dist/index.min.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).BbobHtml={})}(this,(function(t){"use strict";function e(){return(e=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function n(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e){return t(e={exports:{}},e.exports),e.exports}var i=r((function(t,e){e.__esModule=!0,e.BACKSLASH=e.PLACEHOLDER_SPACE=e.PLACEHOLDER_SPACE_TAB=e.SLASH=e.CLOSE_BRAKET=e.OPEN_BRAKET=e.SPACE=e.QUOTEMARK=e.EQ=e.TAB=e.R=e.F=e.N=void 0;e.N="\n";e.TAB="\t";e.F="\f";e.R="\r";e.EQ="=";e.QUOTEMARK='"';e.SPACE=" ";e.OPEN_BRAKET="[";e.CLOSE_BRAKET="]";e.SLASH="/";e.BACKSLASH="\\";e.PLACEHOLDER_SPACE_TAB=" ";e.PLACEHOLDER_SPACE=" "}));n(i);var o=r((function(t,e){e.__esModule=!0,e.isEOL=e.isStringNode=e.isTagNode=e.getUniqAttr=e.getNodeLength=e.escapeHTML=e.appendToNode=e.attrValue=e.attrsToString=void 0;var n=function(t){return"object"==typeof t&&!!t.tag};e.isTagNode=n;var r=function(t){return"string"==typeof t};e.isStringNode=r;e.isEOL=function(t){return t===i.N};var o=function(t,e,n){return Object.keys(t).reduce(e,n)};e.getNodeLength=function t(e){return n(e)?e.content.reduce((function(e,n){return e+t(n)}),0):r(e)?e.length:0};e.appendToNode=function(t,e){t.content.push(e)};var u=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/(javascript):/gi,"$1%3A")};e.escapeHTML=u;var a=function(t,e){var n=typeof e,r={boolean:function(){return e?""+t:""},number:function(){return t+'="'+e+'"'},string:function(){return t+'="'+u(e)+'"'},object:function(){return t+'="'+u(JSON.stringify(e))+'"'}};return r[n]?r[n]():""};e.attrValue=a;e.attrsToString=function(t){return null==t?"":o(t,(function(e,n){return[].concat(e,[a(n,t[n])])}),[""]).join(" ")};e.getUniqAttr=function(t){return o(t,(function(e,n){return t[n]===n?t[n]:null}),null)}}));n(o);var u=r((function(t,e){function n(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function r(){return(r=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}e.__esModule=!0,e.default=e.TagNode=void 0;var u=function(){function t(t,e,n){this.tag=t,this.attrs=e,this.content=Array.isArray(n)?n:[n]}var e,u,a,s=t.prototype;return s.attr=function(t,e){return void 0!==e&&(this.attrs[t]=e),this.attrs[t]},s.append=function(t){return(0,o.appendToNode)(this,t)},s.toTagNode=function(){return new t(this.tag.toLowerCase(),this.attrs,this.content)},s.toString=function(){var t=i.OPEN_BRAKET,e=i.CLOSE_BRAKET,n=0===this.content.length,u=this.content.reduce((function(t,e){return t+""+e}),""),a=function(t,e){var n=(0,o.getUniqAttr)(e);if(n){var i=(0,o.attrValue)(t,n),u=r({},e);return delete u[n],""+i+(0,o.attrsToString)(u)}return""+t+(0,o.attrsToString)(e)}(this.tag,this.attrs);return n?""+t+a+e:""+t+a+e+u+t+i.SLASH+this.tag+e},e=t,(u=[{key:"length",get:function(){return(0,o.getNodeLength)(this)}}])&&n(e.prototype,u),a&&n(e,a),t}();e.TagNode=u,u.create=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n=[]),new u(t,e,n)},u.isOf=function(t,e){return t.tag===e},e.default=u}));n(u);var a=r((function(t,e){e.__esModule=!0,e.default=e.Token=e.TYPE_NEW_LINE=e.TYPE_SPACE=e.TYPE_ATTR_VALUE=e.TYPE_ATTR_NAME=e.TYPE_TAG=e.TYPE_WORD=e.COLUMN_ID=e.LINE_ID=e.VALUE_ID=e.TYPE_ID=void 0;var n=function(t){return t&&void 0!==t.value?t.value:""},r=function(t){return n(t).charCodeAt(0)===i.SLASH.charCodeAt(0)},o=function(){function t(t,e,n,r){this.type=Number(t),this.value=e+"",this.line=Number(n),this.row=Number(r)}var e=t.prototype;return e.isEmpty=function(){return isNaN(this.type)},e.isText=function(){return!(!(t=this)||void 0===t.type||5!==t.type&&6!==t.type&&1!==t.type);var t},e.isTag=function(){return!(!(t=this)||void 0===t.type)&&2===t.type;var t},e.isAttrName=function(){return!(!(t=this)||void 0===t.type)&&3===t.type;var t},e.isAttrValue=function(){return!(!(t=this)||void 0===t.type)&&4===t.type;var t},e.isStart=function(){return!r(this)},e.isEnd=function(){return r(this)},e.getName=function(){return e=n(t=this),r(t)?e.slice(1):e;var t,e},e.getValue=function(){return n(this)},e.getLine=function(){return(t=this)&&t.line||0;var t},e.getColumn=function(){return(t=this)&&t.row||0;var t},e.toString=function(){return t=i.OPEN_BRAKET,t+=n(this),t+=i.CLOSE_BRAKET;var t},t}();e.Token=o;e.TYPE_ID="type";e.VALUE_ID="value";e.LINE_ID="line";e.COLUMN_ID="row";e.TYPE_WORD=1;e.TYPE_TAG=2;e.TYPE_ATTR_NAME=3;e.TYPE_ATTR_VALUE=4;e.TYPE_SPACE=5;e.TYPE_NEW_LINE=6,e.default=o}));n(a);var s=r((function(t,e){function n(t,e){var n={pos:0,len:t.length},r=function(){return n.len>n.pos},i=function(t,r){void 0===t&&(t=1),n.pos+=t,e&&e.onSkip&&!r&&e.onSkip()},o=function(){return t[n.pos]};this.skip=i,this.hasNext=r,this.getCurr=o,this.getRest=function(){return t.substr(n.pos)},this.getNext=function(){var e=n.pos+1;return e>t.length-1?null:t[e]},this.getPrev=function(){var e=n.pos-1;return void 0!==t[e]?t[e]:null},this.isLast=function(){return n.pos===n.len},this.includes=function(e){return t.indexOf(e,n.pos)>=0},this.grabWhile=function(e,u){var a=0;if(r())for(a=n.pos;r()&&e(o());)i(1,u);return t.substr(a,n.pos-a)},this.substrUntilChar=function(e){var r=n.pos,i=t.indexOf(e,r);return 0>i?"":t.substr(r,i-r)}}e.__esModule=!0,e.createList=e.unquote=e.trimChar=e.createCharGrabber=void 0;e.createCharGrabber=function(t,e){return new n(t,e)};e.trimChar=function(t,e){for(;t.charAt(0)===e;)t=t.substring(1);for(;t.charAt(t.length-1)===e;)t=t.substring(0,t.length-1);return t};function r(t){void 0===t&&(t=[]);var e=t;this.push=function(t){return e.push(t)},this.toArray=function(){return e},this.getLast=function(){return Array.isArray(e)&&e.length>0&&void 0!==e[e.length-1]?e[e.length-1]:null},this.flushLast=function(){return!!e.length&&e.pop()}}e.unquote=function(t){return t.replace(i.BACKSLASH+i.QUOTEMARK,i.QUOTEMARK)};e.createList=function(t){return void 0===t&&(t=[]),new r(t)}}));n(s);var c=r((function(t,e){e.__esModule=!0,e.createLexer=function(t,e){void 0===e&&(e={});var r=0,o=0,u=-1,c=0,f=0,l=Array(Math.floor(t.length)),p=e.openTag||i.OPEN_BRAKET,g=e.closeTag||i.CLOSE_BRAKET,A=!!e.enableEscapeTags,d=e.onToken||function(){},T=[g,p,i.QUOTEMARK,i.BACKSLASH,i.SPACE,i.TAB,i.EQ,i.N,"!"],E=[p,i.SPACE,i.TAB,i.N],v=[i.SPACE,i.TAB],h=[i.EQ,i.SPACE,i.TAB],_=function(t){return v.indexOf(t)>=0},L=function(t){return-1===E.indexOf(t)},y=function(t){return t===i.BACKSLASH},S=function(){o++},O=function(t){return(0,s.unquote)((0,s.trimChar)(t,i.QUOTEMARK))},N=(0,s.createCharGrabber)(t,{onSkip:S});function P(t,e){var i=n(t,e,r,o);d(i),l[u+=1]=i}function b(t,e){if(1===f){var n=t.grabWhile((function(t){return!(t===i.EQ||_(t))})),r=t.isLast(),o=t.getCurr()!==i.EQ;return t.skip(),r||o?P(a.TYPE_ATTR_VALUE,O(n)):P(a.TYPE_ATTR_NAME,n),r?0:o?1:2}if(2===f){var u=!1,s=t.grabWhile((function(n){var r=n===i.QUOTEMARK,o=t.getPrev(),a=t.getNext(),s=o===i.BACKSLASH,c=a===i.EQ,f=_(n),l=_(a);return!(!u||!function(t){return h.indexOf(t)>=0}(n))||!!(!r||s||(u=!u)||c||l)&&(!!e||!1===f)}));return t.skip(),P(a.TYPE_ATTR_VALUE,O(s)),t.isLast()?0:1}var c=t.grabWhile((function(e){return!(e===i.EQ||_(e)||t.isLast())}));return P(a.TYPE_TAG,c),t.skip(),e?2:t.includes(i.EQ)?1:2}function C(){var t=N.getCurr();if(t===p){var e=N.getNext();N.skip();var n=N.substrUntilChar(g),r=0===n.length||n.indexOf(p)>=0;if(T.indexOf(e)>=0||r||N.isLast())return P(a.TYPE_WORD,t),0;if(-1===n.indexOf(i.EQ)||n[0]===i.SLASH){var o=N.grabWhile((function(t){return t!==g}));return N.skip(),P(a.TYPE_TAG,o),0}return 2}return 0}function R(){var t=N.grabWhile((function(t){return t!==g}),!0),e=(0,s.createCharGrabber)(t,{onSkip:S}),n=e.includes(i.SPACE);for(f=0;e.hasNext();)f=b(e,!n);return N.skip(),0}function k(){if(N.getCurr()===i.N)return P(a.TYPE_NEW_LINE,N.getCurr()),N.skip(),o=0,r++,0;if(_(N.getCurr()))return P(a.TYPE_SPACE,N.grabWhile(_)),0;if(N.getCurr()===p)return N.includes(g)?1:(P(a.TYPE_WORD,N.getCurr()),N.skip(),0);if(A){if(y(N.getCurr())){var t=N.getCurr(),e=N.getNext();return N.skip(),function(t){return t===p||t===g||t===i.BACKSLASH}(e)?(N.skip(),P(a.TYPE_WORD,e),0):(P(a.TYPE_WORD,t),0)}return P(a.TYPE_WORD,N.grabWhile((function(t){return L(t)&&!y(t)}))),0}return P(a.TYPE_WORD,N.grabWhile(L)),0}return{tokenize:function(){for(c=0;N.hasNext();)switch(c){case 1:c=C();break;case 2:c=R();break;case 0:c=k();break;default:c=0}return l.length=u+1,l},isTokenNested:function(e){var n=p+i.SLASH+e.getValue();return t.indexOf(n)>-1}}},e.createTokenOfType=void 0;var n=function(t,e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),new a.Token(t,e,n,r)};e.createTokenOfType=n}));n(c);var f=r((function(t,e){e.__esModule=!0,e.default=e.parse=void 0;var n,r=(n=u)&&n.__esModule?n:{default:n};var i=function(t,e){void 0===e&&(e={});var n=e,i=null,u=(0,s.createList)(),a=(0,s.createList)(),f=(0,s.createList)(),l=(0,s.createList)(),p={},g=function(){f.flushLast()&&l.flushLast()},A=function(t){var e,r,i=(e=a.getLast())&&Array.isArray(e.content)?e.content:u.toArray();Array.isArray(i)&&((0,o.isTagNode)(t)?(r=t.tag,n.onlyAllowTags&&n.onlyAllowTags.length&&0>n.onlyAllowTags.indexOf(r)?i.push(""+t):i.push(t.toTagNode())):i.push(t))},d=function(t){g();var e=r.default.create(t.getValue()),n=function(t){return void 0===p[t.getValue()]&&(p[t.getValue()]=i.isTokenNested(t)),p[t.getValue()]}(t);f.push(e),n?a.push(e):A(e)},T=function(t){t.isStart()&&d(t),t.isEnd()&&function(t){g();var e=a.flushLast();if(e)A(e);else if("function"==typeof n.onError){var r=t.getValue(),i=t.getLine(),o=t.getColumn();n.onError({message:"Inconsistent tag '"+r+"' on line "+i+" and column "+o,tagName:r,lineNumber:i,columnNumber:o})}}(t)},E=function(t){var e=f.getLast(),n=t.getValue(),r=!!p[t];if(e)if(t.isAttrName())l.push(n),e.attr(l.getLast(),"");else if(t.isAttrValue()){var i=l.getLast();i?(e.attr(i,n),l.flushLast()):e.attr(n,n)}else t.isText()?r?e.append(n):A(n):t.isTag()&&A(""+t);else t.isText()?A(n):t.isTag()&&A(""+t)};(i=(e.createTokenizer?e.createTokenizer:c.createLexer)(t,{onToken:function(t){t.isTag()?T(t):E(t)},onlyAllowTags:n.onlyAllowTags,openTag:n.openTag,closeTag:n.closeTag,enableEscapeTags:n.enableEscapeTags})).tokenize();return u.toArray()};e.parse=i,e.default=i}));n(f);var l=r((function(t,e){e.__esModule=!0,e.TagNode=e.parse=e.default=void 0;var n=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var e=r();if(e&&e.has(t))return e.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var u=i?Object.getOwnPropertyDescriptor(t,o):null;u&&(u.get||u.set)?Object.defineProperty(n,o,u):n[o]=t[o]}n.default=t,e&&e.set(t,n);return n}(f);function r(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return r=function(){return t},t}e.default=n.default,e.parse=n.parse,e.TagNode=u.TagNode}));n(l);var p=r((function(t,e){e.__esModule=!0,e.iterate=r,e.match=function(t,e){return r(this,Array.isArray(t)?function(n){for(var r=0;t.length>r;r++)if(i(t[r],n))return e(n);return n}:function(n){return i(t,n)?e(n):n})};var n=function(t){return"object"==typeof t};function r(t,e){var i=t;if(Array.isArray(i))for(var o=0;i.length>o;o++)i[o]=r(e(i[o]),e);else i&&n(i)&&i.content&&r(i.content,e);return i}function i(t,e){return typeof t==typeof e&&(n(t)&&null!==t?Array.isArray(t)?t.every((function(t){return[].some.call(e,(function(e){return i(t,e)}))})):Object.keys(t).every((function(r){var o=e[r],u=t[r];return n(u)&&null!==u&&null!==o?i(u,o):"boolean"==typeof u?u!==(null===o):o===u})):t===e)}}));n(p);var g=n(r((function(t,e){function n(t){return(0,p.iterate)(this,t)}e.__esModule=!0,e.default=function(t){var e="function"==typeof t?[t]:t||[],r={skipParse:!1};return{process:function(t,i){var o=(r=i||{}).parser||l.parse,u=r.render,a=r.data||null;if("function"!=typeof o)throw Error('"parser" is not a function, please pass to "process(input, { parser })" right function');var s=r.skipParse?t||[]:o(t,r),c=s;return s.messages=[],s.options=r,s.walk=n,s.match=p.match,e.forEach((function(t){s=t(s,{parse:o,render:u,iterate:p.iterate,match:p.match,data:a})||s})),{get html(){if("function"!=typeof u)throw Error('"render" function not defined, please pass to "process(input, { render })"');return u(s,s.options)},tree:s,raw:c,messages:s.messages}}}}}))),A=r((function(t,e){e.__esModule=!0,e.BACKSLASH=e.PLACEHOLDER_SPACE=e.PLACEHOLDER_SPACE_TAB=e.SLASH=e.CLOSE_BRAKET=e.OPEN_BRAKET=e.SPACE=e.QUOTEMARK=e.EQ=e.TAB=e.R=e.F=e.N=void 0;e.N="\n";e.TAB="\t";e.F="\f";e.R="\r";e.EQ="=";e.QUOTEMARK='"';e.SPACE=" ";e.OPEN_BRAKET="[";e.CLOSE_BRAKET="]";e.SLASH="/";e.BACKSLASH="\\";e.PLACEHOLDER_SPACE_TAB=" ";e.PLACEHOLDER_SPACE=" "}));n(A);var d=r((function(t,e){e.__esModule=!0,e.isEOL=e.isStringNode=e.isTagNode=e.getUniqAttr=e.getNodeLength=e.escapeHTML=e.appendToNode=e.attrValue=e.attrsToString=void 0;var n=function(t){return"object"==typeof t&&!!t.tag};e.isTagNode=n;var r=function(t){return"string"==typeof t};e.isStringNode=r;e.isEOL=function(t){return t===A.N};var i=function(t,e,n){return Object.keys(t).reduce(e,n)};e.getNodeLength=function t(e){return n(e)?e.content.reduce((function(e,n){return e+t(n)}),0):r(e)?e.length:0};e.appendToNode=function(t,e){t.content.push(e)};var o=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/(javascript):/gi,"$1%3A")};e.escapeHTML=o;var u=function(t,e){var n=typeof e,r={boolean:function(){return e?""+t:""},number:function(){return t+'="'+e+'"'},string:function(){return t+'="'+o(e)+'"'},object:function(){return t+'="'+o(JSON.stringify(e))+'"'}};return r[n]?r[n]():""};e.attrValue=u;e.attrsToString=function(t){return null==t?"":i(t,(function(e,n){return[].concat(e,[u(n,t[n])])}),[""]).join(" ")};e.getUniqAttr=function(t){return i(t,(function(e,n){return t[n]===n?t[n]:null}),null)}}));n(d);var T=d.attrsToString,E="/>",v="</",h="<",_=">",L=function(t,e){var n=e.stripTags,r=void 0!==n&&n;if(!t)return"";var i=typeof t;return"string"===i||"number"===i?t:"object"===i?!0===r?y(t.content,{stripTags:r}):null===t.content?""+h+t.tag+T(t.attrs)+E:""+h+t.tag+T(t.attrs)+_+y(t.content)+v+t.tag+_:Array.isArray(t)?y(t,{stripTags:r}):""},y=function(t,e){var n=(void 0===e?{}:e).stripTags,r=void 0!==n&&n;return[].concat(t).reduce((function(t,e){return t+L(e,{stripTags:r})}),"")},S=y;t.default=function(t,n,r){return g(n).process(t,e({},r,{render:y})).html},t.render=S,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).BbobHtml={})}(this,(function(t){"use strict";function e(){return(e=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function n(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e){return t(e={exports:{}},e.exports),e.exports}var o=r((function(t,e){e.__esModule=!0,e.BACKSLASH=e.PLACEHOLDER_SPACE=e.PLACEHOLDER_SPACE_TAB=e.SLASH=e.CLOSE_BRAKET=e.OPEN_BRAKET=e.SPACE=e.QUOTEMARK=e.EQ=e.TAB=e.R=e.F=e.N=void 0;e.N="\n";e.TAB="\t";e.F="\f";e.R="\r";e.EQ="=";e.QUOTEMARK='"';e.SPACE=" ";e.OPEN_BRAKET="[";e.CLOSE_BRAKET="]";e.SLASH="/";e.BACKSLASH="\\";e.PLACEHOLDER_SPACE_TAB=" ";e.PLACEHOLDER_SPACE=" "}));n(o);var i=r((function(t,e){e.__esModule=!0,e.isEOL=e.isStringNode=e.isTagNode=e.getUniqAttr=e.getNodeLength=e.escapeHTML=e.appendToNode=e.attrValue=e.attrsToString=void 0;var n=function(t){return"object"==typeof t&&!!t.tag};e.isTagNode=n;var r=function(t){return"string"==typeof t};e.isStringNode=r;e.isEOL=function(t){return t===o.N};var i=function(t,e,n){return Object.keys(t).reduce(e,n)};e.getNodeLength=function t(e){return n(e)?e.content.reduce((function(e,n){return e+t(n)}),0):r(e)?e.length:0};e.appendToNode=function(t,e){t.content.push(e)};var u=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/(javascript):/gi,"$1%3A")};e.escapeHTML=u;var a=function(t,e){var n=typeof e,r={boolean:function(){return e?""+t:""},number:function(){return t+'="'+e+'"'},string:function(){return t+'="'+u(e)+'"'},object:function(){return t+'="'+u(JSON.stringify(e))+'"'}};return r[n]?r[n]():""};e.attrValue=a;e.attrsToString=function(t){return null==t?"":i(t,(function(e,n){return[].concat(e,[a(n,t[n])])}),[""]).join(" ")};e.getUniqAttr=function(t){return i(t,(function(e,n){return t[n]===n?t[n]:null}),null)}}));n(i);var u=r((function(t,e){function n(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function r(){return(r=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}e.__esModule=!0,e.default=e.TagNode=void 0;var u=function(){function t(t,e,n){this.tag=t,this.attrs=e,this.content=Array.isArray(n)?n:[n]}var e,u,a,s=t.prototype;return s.attr=function(t,e){return void 0!==e&&(this.attrs[t]=e),this.attrs[t]},s.append=function(t){return(0,i.appendToNode)(this,t)},s.toTagStart=function(t){var e=void 0===t?{}:t,n=e.openTag,u=e.closeTag,a=void 0===u?o.CLOSE_BRAKET:u;return""+(void 0===n?o.OPEN_BRAKET:n)+function(t,e){var n=(0,i.getUniqAttr)(e);if(n){var o=(0,i.attrValue)(t,n),u=r({},e);return delete u[n],""+o+(0,i.attrsToString)(u)}return""+t+(0,i.attrsToString)(e)}(this.tag,this.attrs)+a},s.toTagEnd=function(t){var e=void 0===t?{}:t,n=e.openTag,r=e.closeTag;return""+(void 0===n?o.OPEN_BRAKET:n)+o.SLASH+this.tag+(void 0===r?o.CLOSE_BRAKET:r)},s.toTagNode=function(){return new t(this.tag.toLowerCase(),this.attrs,this.content)},s.toString=function(t){var e=void 0===t?{}:t,n=e.openTag,r=void 0===n?o.OPEN_BRAKET:n,i=e.closeTag,u=void 0===i?o.CLOSE_BRAKET:i,a=0===this.content.length,s=this.content.reduce((function(t,e){return t+e.toString({openTag:r,closeTag:u})}),""),c=this.toTagStart({openTag:r,closeTag:u});return a?c:""+c+s+this.toTagEnd({openTag:r,closeTag:u})},e=t,(u=[{key:"length",get:function(){return(0,i.getNodeLength)(this)}}])&&n(e.prototype,u),a&&n(e,a),t}();e.TagNode=u,u.create=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n=[]),new u(t,e,n)},u.isOf=function(t,e){return t.tag===e},e.default=u}));n(u);var a=r((function(t,e){e.__esModule=!0,e.default=e.Token=e.TYPE_NEW_LINE=e.TYPE_SPACE=e.TYPE_ATTR_VALUE=e.TYPE_ATTR_NAME=e.TYPE_TAG=e.TYPE_WORD=e.COLUMN_ID=e.LINE_ID=e.VALUE_ID=e.TYPE_ID=void 0;var n=function(t){return t&&void 0!==t.value?t.value:""},r=function(t){return n(t).charCodeAt(0)===o.SLASH.charCodeAt(0)},i=function(){function t(t,e,n,r){this.type=Number(t),this.value=e+"",this.line=Number(n),this.row=Number(r)}var e=t.prototype;return e.isEmpty=function(){return isNaN(this.type)},e.isText=function(){return!(!(t=this)||void 0===t.type||5!==t.type&&6!==t.type&&1!==t.type);var t},e.isTag=function(){return!(!(t=this)||void 0===t.type)&&2===t.type;var t},e.isAttrName=function(){return!(!(t=this)||void 0===t.type)&&3===t.type;var t},e.isAttrValue=function(){return!(!(t=this)||void 0===t.type)&&4===t.type;var t},e.isStart=function(){return!r(this)},e.isEnd=function(){return r(this)},e.getName=function(){return e=n(t=this),r(t)?e.slice(1):e;var t,e},e.getValue=function(){return n(this)},e.getLine=function(){return(t=this)&&t.line||0;var t},e.getColumn=function(){return(t=this)&&t.row||0;var t},e.toString=function(){return t=o.OPEN_BRAKET,t+=n(this),t+=o.CLOSE_BRAKET;var t},t}();e.Token=i;e.TYPE_ID="type";e.VALUE_ID="value";e.LINE_ID="line";e.COLUMN_ID="row";e.TYPE_WORD=1;e.TYPE_TAG=2;e.TYPE_ATTR_NAME=3;e.TYPE_ATTR_VALUE=4;e.TYPE_SPACE=5;e.TYPE_NEW_LINE=6,e.default=i}));n(a);var s=r((function(t,e){function n(t,e){var n={pos:0,len:t.length},r=function(){return n.len>n.pos},o=function(t,r){void 0===t&&(t=1),n.pos+=t,e&&e.onSkip&&!r&&e.onSkip()},i=function(){return t[n.pos]};this.skip=o,this.hasNext=r,this.getCurr=i,this.getRest=function(){return t.substr(n.pos)},this.getNext=function(){var e=n.pos+1;return e>t.length-1?null:t[e]},this.getPrev=function(){var e=n.pos-1;return void 0!==t[e]?t[e]:null},this.isLast=function(){return n.pos===n.len},this.includes=function(e){return t.indexOf(e,n.pos)>=0},this.grabWhile=function(e,u){var a=0;if(r())for(a=n.pos;r()&&e(i());)o(1,u);return t.substr(a,n.pos-a)},this.substrUntilChar=function(e){var r=n.pos,o=t.indexOf(e,r);return 0>o?"":t.substr(r,o-r)}}e.__esModule=!0,e.createList=e.unquote=e.trimChar=e.createCharGrabber=void 0;e.createCharGrabber=function(t,e){return new n(t,e)};e.trimChar=function(t,e){for(;t.charAt(0)===e;)t=t.substring(1);for(;t.charAt(t.length-1)===e;)t=t.substring(0,t.length-1);return t};function r(t){void 0===t&&(t=[]);var e=t;this.push=function(t){return e.push(t)},this.toArray=function(){return e},this.getLast=function(){return Array.isArray(e)&&e.length>0&&void 0!==e[e.length-1]?e[e.length-1]:null},this.flushLast=function(){return!!e.length&&e.pop()}}e.unquote=function(t){return t.replace(o.BACKSLASH+o.QUOTEMARK,o.QUOTEMARK)};e.createList=function(t){return void 0===t&&(t=[]),new r(t)}}));n(s);var c=r((function(t,e){e.__esModule=!0,e.createLexer=function(t,e){void 0===e&&(e={});var r=0,i=0,u=-1,c=0,f=0,l=Array(Math.floor(t.length)),g=e.openTag||o.OPEN_BRAKET,p=e.closeTag||o.CLOSE_BRAKET,T=!!e.enableEscapeTags,d=e.onToken||function(){},E=[p,g,o.QUOTEMARK,o.BACKSLASH,o.SPACE,o.TAB,o.EQ,o.N,"!"],A=[g,o.SPACE,o.TAB,o.N],v=[o.SPACE,o.TAB],h=[o.EQ,o.SPACE,o.TAB],_=function(t){return v.indexOf(t)>=0},L=function(t){return-1===A.indexOf(t)},y=function(t){return t===o.BACKSLASH},S=function(){i++},O=function(t){return(0,s.unquote)((0,s.trimChar)(t,o.QUOTEMARK))},N=(0,s.createCharGrabber)(t,{onSkip:S});function P(t,e){var o=n(t,e,r,i);d(o),l[u+=1]=o}function C(t,e){if(1===f){var n=t.grabWhile((function(t){return!(t===o.EQ||_(t))})),r=t.isLast(),i=t.getCurr()!==o.EQ;return t.skip(),r||i?P(a.TYPE_ATTR_VALUE,O(n)):P(a.TYPE_ATTR_NAME,n),r?0:i?1:2}if(2===f){var u=!1,s=t.grabWhile((function(n){var r=n===o.QUOTEMARK,i=t.getPrev(),a=t.getNext(),s=i===o.BACKSLASH,c=a===o.EQ,f=_(n),l=_(a);return!(!u||!function(t){return h.indexOf(t)>=0}(n))||!!(!r||s||(u=!u)||c||l)&&(!!e||!1===f)}));return t.skip(),P(a.TYPE_ATTR_VALUE,O(s)),t.isLast()?0:1}var c=t.grabWhile((function(e){return!(e===o.EQ||_(e)||t.isLast())}));return P(a.TYPE_TAG,c),t.skip(),e?2:t.includes(o.EQ)?1:2}function b(){var t=N.getCurr();if(t===g){var e=N.getNext();N.skip();var n=N.substrUntilChar(p),r=0===n.length||n.indexOf(g)>=0;if(E.indexOf(e)>=0||r||N.isLast())return P(a.TYPE_WORD,t),0;if(-1===n.indexOf(o.EQ)||n[0]===o.SLASH){var i=N.grabWhile((function(t){return t!==p}));return N.skip(),P(a.TYPE_TAG,i),0}return 2}return 0}function R(){var t=N.grabWhile((function(t){return t!==p}),!0),e=(0,s.createCharGrabber)(t,{onSkip:S}),n=e.includes(o.SPACE);for(f=0;e.hasNext();)f=C(e,!n);return N.skip(),0}function k(){if(N.getCurr()===o.N)return P(a.TYPE_NEW_LINE,N.getCurr()),N.skip(),i=0,r++,0;if(_(N.getCurr()))return P(a.TYPE_SPACE,N.grabWhile(_)),0;if(N.getCurr()===g)return N.includes(p)?1:(P(a.TYPE_WORD,N.getCurr()),N.skip(),0);if(T){if(y(N.getCurr())){var t=N.getCurr(),e=N.getNext();return N.skip(),function(t){return t===g||t===p||t===o.BACKSLASH}(e)?(N.skip(),P(a.TYPE_WORD,e),0):(P(a.TYPE_WORD,t),0)}return P(a.TYPE_WORD,N.grabWhile((function(t){return L(t)&&!y(t)}))),0}return P(a.TYPE_WORD,N.grabWhile(L)),0}return{tokenize:function(){for(c=0;N.hasNext();)switch(c){case 1:c=b();break;case 2:c=R();break;case 0:c=k();break;default:c=0}return l.length=u+1,l},isTokenNested:function(e){var n=g+o.SLASH+e.getValue();return t.indexOf(n)>-1}}},e.createTokenOfType=void 0;var n=function(t,e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),new a.Token(t,e,n,r)};e.createTokenOfType=n}));n(c);var f=r((function(t,e){e.__esModule=!0,e.default=e.parse=void 0;var n,r=(n=u)&&n.__esModule?n:{default:n};var a=function(t,e){void 0===e&&(e={});var n=e,u=n.openTag||o.OPEN_BRAKET,a=n.closeTag||o.CLOSE_BRAKET,f=null,l=(0,s.createList)(),g=(0,s.createList)(),p=(0,s.createList)(),T=(0,s.createList)(),d=new Set,E=function(){p.flushLast()&&T.flushLast()},A=function(t){var e,r,o=(e=g.getLast())&&Array.isArray(e.content)?e.content:l.toArray();Array.isArray(o)&&((0,i.isTagNode)(t)?(r=t.tag,n.onlyAllowTags&&n.onlyAllowTags.length&&0>n.onlyAllowTags.indexOf(r)?(o.push(t.toTagStart({openTag:u,closeTag:a})),t.content.length&&(t.content.forEach((function(t){o.push(t)})),o.push(t.toTagEnd({openTag:u,closeTag:a})))):o.push(t.toTagNode())):o.push(t))},v=function(t){E();var e=r.default.create(t.getValue()),n=function(t){var e=t.getValue();return!d.has(e)&&f.isTokenNested&&f.isTokenNested(t)?(d.add(e),!0):d.has(e)}(t);p.push(e),n?g.push(e):A(e)},h=function(t){t.isStart()&&v(t),t.isEnd()&&function(t){E();var e=g.flushLast();if(e)A(e);else if("function"==typeof n.onError){var r=t.getValue(),o=t.getLine(),i=t.getColumn();n.onError({message:"Inconsistent tag '"+r+"' on line "+o+" and column "+i,tagName:r,lineNumber:o,columnNumber:i})}}(t)},_=function(t){var e=p.getLast(),n=t.getValue(),r=!!d.has(t);if(e)if(t.isAttrName())T.push(n),e.attr(T.getLast(),"");else if(t.isAttrValue()){var o=T.getLast();o?(e.attr(o,n),T.flushLast()):e.attr(n,n)}else t.isText()?r?e.append(n):A(n):t.isTag()&&A(""+t);else t.isText()?A(n):t.isTag()&&A(""+t)};(f=(e.createTokenizer?e.createTokenizer:c.createLexer)(t,{onToken:function(t){t.isTag()?h(t):_(t)},onlyAllowTags:n.onlyAllowTags,openTag:u,closeTag:a,enableEscapeTags:n.enableEscapeTags})).tokenize();return l.toArray()};e.parse=a,e.default=a}));n(f);var l=r((function(t,e){e.__esModule=!0,e.TagNode=e.parse=e.default=void 0;var n=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var e=r();if(e&&e.has(t))return e.get(t);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var u=o?Object.getOwnPropertyDescriptor(t,i):null;u&&(u.get||u.set)?Object.defineProperty(n,i,u):n[i]=t[i]}n.default=t,e&&e.set(t,n);return n}(f);function r(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return r=function(){return t},t}e.default=n.default,e.parse=n.parse,e.TagNode=u.TagNode}));n(l);var g=r((function(t,e){e.__esModule=!0,e.iterate=r,e.match=function(t,e){return r(this,Array.isArray(t)?function(n){for(var r=0;t.length>r;r++)if(o(t[r],n))return e(n);return n}:function(n){return o(t,n)?e(n):n})};var n=function(t){return"object"==typeof t};function r(t,e){var o=t;if(Array.isArray(o))for(var i=0;o.length>i;i++)o[i]=r(e(o[i]),e);else o&&n(o)&&o.content&&r(o.content,e);return o}function o(t,e){return typeof t==typeof e&&(n(t)&&null!==t?Array.isArray(t)?t.every((function(t){return[].some.call(e,(function(e){return o(t,e)}))})):Object.keys(t).every((function(r){var i=e[r],u=t[r];return n(u)&&null!==u&&null!==i?o(u,i):"boolean"==typeof u?u!==(null===i):i===u})):t===e)}}));n(g);var p=n(r((function(t,e){function n(t){return(0,g.iterate)(this,t)}e.__esModule=!0,e.default=function(t){var e="function"==typeof t?[t]:t||[],r={skipParse:!1};return{process:function(t,o){var i=(r=o||{}).parser||l.parse,u=r.render,a=r.data||null;if("function"!=typeof i)throw Error('"parser" is not a function, please pass to "process(input, { parser })" right function');var s=r.skipParse?t||[]:i(t,r),c=s;return s.messages=[],s.options=r,s.walk=n,s.match=g.match,e.forEach((function(t){s=t(s,{parse:i,render:u,iterate:g.iterate,match:g.match,data:a})||s})),{get html(){if("function"!=typeof u)throw Error('"render" function not defined, please pass to "process(input, { render })"');return u(s,s.options)},tree:s,raw:c,messages:s.messages}}}}}))),T=r((function(t,e){e.__esModule=!0,e.BACKSLASH=e.PLACEHOLDER_SPACE=e.PLACEHOLDER_SPACE_TAB=e.SLASH=e.CLOSE_BRAKET=e.OPEN_BRAKET=e.SPACE=e.QUOTEMARK=e.EQ=e.TAB=e.R=e.F=e.N=void 0;e.N="\n";e.TAB="\t";e.F="\f";e.R="\r";e.EQ="=";e.QUOTEMARK='"';e.SPACE=" ";e.OPEN_BRAKET="[";e.CLOSE_BRAKET="]";e.SLASH="/";e.BACKSLASH="\\";e.PLACEHOLDER_SPACE_TAB=" ";e.PLACEHOLDER_SPACE=" "}));n(T);var d=r((function(t,e){e.__esModule=!0,e.isEOL=e.isStringNode=e.isTagNode=e.getUniqAttr=e.getNodeLength=e.escapeHTML=e.appendToNode=e.attrValue=e.attrsToString=void 0;var n=function(t){return"object"==typeof t&&!!t.tag};e.isTagNode=n;var r=function(t){return"string"==typeof t};e.isStringNode=r;e.isEOL=function(t){return t===T.N};var o=function(t,e,n){return Object.keys(t).reduce(e,n)};e.getNodeLength=function t(e){return n(e)?e.content.reduce((function(e,n){return e+t(n)}),0):r(e)?e.length:0};e.appendToNode=function(t,e){t.content.push(e)};var i=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/(javascript):/gi,"$1%3A")};e.escapeHTML=i;var u=function(t,e){var n=typeof e,r={boolean:function(){return e?""+t:""},number:function(){return t+'="'+e+'"'},string:function(){return t+'="'+i(e)+'"'},object:function(){return t+'="'+i(JSON.stringify(e))+'"'}};return r[n]?r[n]():""};e.attrValue=u;e.attrsToString=function(t){return null==t?"":o(t,(function(e,n){return[].concat(e,[u(n,t[n])])}),[""]).join(" ")};e.getUniqAttr=function(t){return o(t,(function(e,n){return t[n]===n?t[n]:null}),null)}}));n(d);var E=d.attrsToString,A="/>",v="</",h="<",_=">",L=function(t,e){var n=e.stripTags,r=void 0!==n&&n;if(!t)return"";var o=typeof t;return"string"===o||"number"===o?t:"object"===o?!0===r?y(t.content,{stripTags:r}):null===t.content?""+h+t.tag+E(t.attrs)+A:""+h+t.tag+E(t.attrs)+_+y(t.content)+v+t.tag+_:Array.isArray(t)?y(t,{stripTags:r}):""},y=function(t,e){var n=(void 0===e?{}:e).stripTags,r=void 0!==n&&n;return[].concat(t).reduce((function(t,e){return t+L(e,{stripTags:r})}),"")},S=y;t.default=function(t,n,r){return p(n).process(t,e({},r,{render:y})).html},t.render=S,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "@bbob/html",
"version": "2.6.1",
"version": "2.6.2",
"description": "HTML renderer for @bbob bbcode parser",
"keywords": [],
"dependencies": {
"@bbob/core": "^2.6.1",
"@bbob/plugin-helper": "^2.6.1"
"@bbob/core": "^2.6.2",
"@bbob/plugin-helper": "^2.6.2"
},

@@ -56,3 +56,3 @@ "main": "lib/index.js",

],
"gitHead": "58e6fba8ac5ac8fe368cade48d439671f86e727d"
"gitHead": "689d5a84cc6b88e96fe74481bb82997d924799fd"
}
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