@bbob/parser
Advanced tools
Comparing version 2.5.6 to 2.5.7
@@ -6,2 +6,10 @@ # Change Log | ||
## [2.5.7](https://github.com/JiLiZART/bbob/compare/v2.5.6...v2.5.7) (2020-07-05) | ||
**Note:** Version bump only for package @bbob/parser | ||
## [2.5.6](https://github.com/JiLiZART/bbob/compare/v2.5.5...v2.5.6) (2020-04-12) | ||
@@ -8,0 +16,0 @@ |
@@ -66,3 +66,3 @@ (function (global, factory) { | ||
exports.__esModule = true; | ||
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getUniqAttr = exports.getNodeLength = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0; | ||
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getUniqAttr = exports.getNodeLength = exports.escapeHTML = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0; | ||
@@ -122,4 +122,5 @@ | ||
var escapeQuote = function escapeQuote(value) { | ||
return value.replace(/"/g, '"'); | ||
var escapeHTML = function escapeHTML(value) { | ||
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') // eslint-disable-next-line no-script-url | ||
.replace('javascript:', 'javascript%3A'); | ||
}; | ||
@@ -134,2 +135,4 @@ /** | ||
exports.escapeHTML = escapeHTML; | ||
var attrValue = function attrValue(name, value) { | ||
@@ -145,6 +148,6 @@ var type = typeof value; | ||
string: function string() { | ||
return name + "=\"" + escapeQuote(value) + "\""; | ||
return name + "=\"" + escapeHTML(value) + "\""; | ||
}, | ||
object: function object() { | ||
return name + "=\"" + escapeQuote(JSON.stringify(value)) + "\""; | ||
return name + "=\"" + escapeHTML(JSON.stringify(value)) + "\""; | ||
} | ||
@@ -198,5 +201,6 @@ }; | ||
var lib_5 = lib.getNodeLength; | ||
var lib_6 = lib.appendToNode; | ||
var lib_7 = lib.attrValue; | ||
var lib_8 = lib.attrsToString; | ||
var lib_6 = lib.escapeHTML; | ||
var lib_7 = lib.appendToNode; | ||
var lib_8 = lib.attrValue; | ||
var lib_9 = lib.attrsToString; | ||
@@ -391,3 +395,3 @@ var TagNode_1 = createCommonjsModule(function (module, exports) { | ||
exports.__esModule = true; | ||
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getUniqAttr = exports.getNodeLength = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0; | ||
exports.isEOL = exports.isStringNode = exports.isTagNode = exports.getUniqAttr = exports.getNodeLength = exports.escapeHTML = exports.appendToNode = exports.attrValue = exports.attrsToString = void 0; | ||
@@ -447,4 +451,5 @@ | ||
var escapeQuote = function escapeQuote(value) { | ||
return value.replace(/"/g, '"'); | ||
var escapeHTML = function escapeHTML(value) { | ||
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') // eslint-disable-next-line no-script-url | ||
.replace('javascript:', 'javascript%3A'); | ||
}; | ||
@@ -459,2 +464,4 @@ /** | ||
exports.escapeHTML = escapeHTML; | ||
var attrValue = function attrValue(name, value) { | ||
@@ -470,6 +477,6 @@ var type = typeof value; | ||
string: function string() { | ||
return name + "=\"" + escapeQuote(value) + "\""; | ||
return name + "=\"" + escapeHTML(value) + "\""; | ||
}, | ||
object: function object() { | ||
return name + "=\"" + escapeQuote(JSON.stringify(value)) + "\""; | ||
return name + "=\"" + escapeHTML(JSON.stringify(value)) + "\""; | ||
} | ||
@@ -523,5 +530,6 @@ }; | ||
var es_5 = es.getNodeLength; | ||
var es_6 = es.appendToNode; | ||
var es_7 = es.attrValue; | ||
var es_8 = es.attrsToString; | ||
var es_6 = es.escapeHTML; | ||
var es_7 = es.appendToNode; | ||
var es_8 = es.attrValue; | ||
var es_9 = es.attrsToString; | ||
@@ -528,0 +536,0 @@ var TOKEN_TYPE_ID = 'type'; // 0; |
@@ -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=t||self).BbobParser={})}(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 r=e((function(t,n){n.__esModule=!0,n.BACKSLASH=n.PLACEHOLDER_SPACE=n.PLACEHOLDER_SPACE_TAB=n.SLASH=n.CLOSE_BRAKET=n.OPEN_BRAKET=n.SPACE=n.QUOTEMARK=n.EQ=n.TAB=n.R=n.F=n.N=void 0;n.N="\n";n.TAB="\t";n.F="\f";n.R="\r";n.EQ="=";n.QUOTEMARK='"';n.SPACE=" ";n.OPEN_BRAKET="[";n.CLOSE_BRAKET="]";n.SLASH="/";n.BACKSLASH="\\";n.PLACEHOLDER_SPACE_TAB=" ";n.PLACEHOLDER_SPACE=" "}));n(r);var o=r.BACKSLASH,i=r.SLASH,u=r.CLOSE_BRAKET,a=r.OPEN_BRAKET,s=r.SPACE,f=r.QUOTEMARK,c=r.EQ,l=r.TAB,g=r.N,p=e((function(t,n){n.__esModule=!0,n.isEOL=n.isStringNode=n.isTagNode=n.getUniqAttr=n.getNodeLength=n.appendToNode=n.attrValue=n.attrsToString=void 0;var e=function(t){return"object"==typeof t&&!!t.tag};n.isTagNode=e;var o=function(t){return"string"==typeof t};n.isStringNode=o;n.isEOL=function(t){return t===r.N};n.getNodeLength=function t(n){return e(n)?n.content.reduce((function(n,e){return n+t(e)}),0):o(n)?n.length:0};n.appendToNode=function(t,n){t.content.push(n)};var i=function(t){return t.replace(/"/g,""")},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.attrValue=u;n.attrsToString=function(t){return void 0===t?"":Object.keys(t).reduce((function(n,e){return[].concat(n,[u(e,t[e])])}),[""]).join(" ")};n.getUniqAttr=function(t){return Object.keys(t).reduce((function(n,e){return t[e]===e?t[e]:null}),null)}}));n(p);var d=e((function(t,n){function e(t,n){for(var e=0;n.length>e;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)}}function o(){return(o=Object.assign||function(t){for(var n=1;arguments.length>n;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t}).apply(this,arguments)}n.__esModule=!0,n.default=n.TagNode=void 0;var i=function(){function t(t,n,e){this.tag=t,this.attrs=n,this.content=[].concat(e)}var n,i,u,a=t.prototype;return a.attr=function(t,n){return void 0!==n&&(this.attrs[t]=n),this.attrs[t]},a.append=function(t){return(0,p.appendToNode)(this,t)},a.toTagNode=function(){return new t(this.tag.toLowerCase(),this.attrs,this.content)},a.toString=function(){var t=r.OPEN_BRAKET,n=r.CLOSE_BRAKET,e=0===this.content.length,i=this.content.reduce((function(t,n){return t+""+n}),""),u=function(t,n){var e=(0,p.getUniqAttr)(n);if(e){var r=(0,p.attrValue)(t,e),i=o({},n);return delete i[e],""+r+(0,p.attrsToString)(i)}return""+t+(0,p.attrsToString)(n)}(this.tag,this.attrs);return e?""+t+u+n:""+t+u+n+i+t+r.SLASH+this.tag+n},n=t,(i=[{key:"length",get:function(){return(0,p.getNodeLength)(this)}}])&&e(n.prototype,i),u&&e(n,u),t}();n.TagNode=i,i.create=function(t,n,e){return void 0===n&&(n={}),void 0===e&&(e=[]),new i(t,n,e)},i.isOf=function(t,n){return t.tag===n},n.default=i})),h=n(d),A=d.TagNode,v=e((function(t,n){n.__esModule=!0,n.BACKSLASH=n.PLACEHOLDER_SPACE=n.PLACEHOLDER_SPACE_TAB=n.SLASH=n.CLOSE_BRAKET=n.OPEN_BRAKET=n.SPACE=n.QUOTEMARK=n.EQ=n.TAB=n.R=n.F=n.N=void 0;n.N="\n";n.TAB="\t";n.F="\f";n.R="\r";n.EQ="=";n.QUOTEMARK='"';n.SPACE=" ";n.OPEN_BRAKET="[";n.CLOSE_BRAKET="]";n.SLASH="/";n.BACKSLASH="\\";n.PLACEHOLDER_SPACE_TAB=" ";n.PLACEHOLDER_SPACE=" "}));n(v);var T=e((function(t,n){n.__esModule=!0,n.isEOL=n.isStringNode=n.isTagNode=n.getUniqAttr=n.getNodeLength=n.appendToNode=n.attrValue=n.attrsToString=void 0;var e=function(t){return"object"==typeof t&&!!t.tag};n.isTagNode=e;var r=function(t){return"string"==typeof t};n.isStringNode=r;n.isEOL=function(t){return t===v.N};n.getNodeLength=function t(n){return e(n)?n.content.reduce((function(n,e){return n+t(e)}),0):r(n)?n.length:0};n.appendToNode=function(t,n){t.content.push(n)};var o=function(t){return t.replace(/"/g,""")},i=function(t,n){var e=typeof n,r={boolean:function(){return n?""+t:""},number:function(){return t+'="'+n+'"'},string:function(){return t+'="'+o(n)+'"'},object:function(){return t+'="'+o(JSON.stringify(n))+'"'}};return r[e]?r[e]():""};n.attrValue=i;n.attrsToString=function(t){return void 0===t?"":Object.keys(t).reduce((function(n,e){return[].concat(n,[i(e,t[e])])}),[""]).join(" ")};n.getUniqAttr=function(t){return Object.keys(t).reduce((function(n,e){return t[e]===e?t[e]:null}),null)}}));n(T);var E=T.isTagNode,S=function(t){return t&&void 0!==t.value?t.value:""},L=function(t){return S(t).charCodeAt(0)===i.charCodeAt(0)},N=function(){function t(t,n,e,r){this.type=t+"",this.value=n+"",this.line=Number(e),this.row=Number(r)}var n=t.prototype;return n.isEmpty=function(){return!!this.type},n.isText=function(){return!(!(t=this)||void 0===t.type||"space"!==t.type&&"new-line"!==t.type&&"word"!==t.type);var t},n.isTag=function(){return!(!(t=this)||void 0===t.type)&&"tag"===t.type;var t},n.isAttrName=function(){return!(!(t=this)||void 0===t.type)&&"attr-name"===t.type;var t},n.isAttrValue=function(){return!(!(t=this)||void 0===t.type)&&"attr-value"===t.type;var t},n.isStart=function(){return!L(this)},n.isEnd=function(){return L(this)},n.getName=function(){return n=S(t=this),L(t)?n.slice(1):n;var t,n},n.getValue=function(){return S(this)},n.getLine=function(){return(t=this)&&t.line||0;var t},n.getColumn=function(){return(t=this)&&t.row||0;var t},n.toString=function(){return t=a,t+=S(this),t+=u;var t},t}(),y=function(t,n){var e={pos:0,length:t.length},r=function(){e.pos+=1,n&&n.onSkip&&n.onSkip()},o=function(){return e.length>e.pos},i=function(){return t.substr(e.pos)},u=function(){return t[e.pos]};return{skip:r,hasNext:o,isLast:function(){return e.pos===e.length},grabWhile:function(n){var i=0;if(o())for(i=e.pos;o()&&n(u());)r();return t.substr(i,e.pos-i)},getNext:function(){var n=e.pos+1;return n>t.length-1?null:t[n]},getPrev:function(){var n=e.pos-1;return void 0!==t[n]?t[n]:null},getCurr:u,getRest:i,substrUntilChar:function(t){var n=i(),e=n.indexOf(t);return 0>e?"":n.substr(0,e)}}},O=function(t){void 0===t&&(t=[]);var n=t;return{getLast:function(){return Array.isArray(n)&&n.length>0&&void 0!==n[n.length-1]?n[n.length-1]:null},flushLast:function(){return!!n.length&&n.pop()},push:function(t){return n.push(t)},toArray:function(){return n}}},b=function(t,n,e,r){return void 0===e&&(e=0),void 0===r&&(r=0),new N(t,n,e,r)};function C(t,n){void 0===n&&(n={});var e=0,r=0,p=-1,d=Array(Math.floor(t.length)),h=n.openTag||a,A=n.closeTag||u,v=n.enableEscapeTags,T=[A,h,f,o,s,l,c,g,"!"],E=[h,s,l,g],S=[s,l],L=[c,s,l],N=function(t){return S.indexOf(t)>=0},O=function(t){return-1===E.indexOf(t)},C=function(t){return t===h||t===A||t===o},_=function(t){return t===o},P=function(t){n.onToken&&n.onToken(t),d[p+=1]=t},R=function(t){for(var n=null,i=!1,u=[],a=y(t),s=function(t){var e=t===c,r=N(t),u=a.getPrev(),s=a.getNext(),l=u===o;return null===n?!1===(e||r||a.isLast()):!(!i||!function(t){return L.indexOf(t)>=0}(t))||!!(t!==f||l||(i=!i)||s===c||N(s))&&!1===(e||r)},l=function(){var t=a.grabWhile(s),i=a.getCurr();if(null===n)n=t;else if(N(i)||i===f||!a.hasNext()){var c=function(t){return t.replace(o+f,f)}(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,f));u.push(b("attr-value",c,e,r))}else u.push(b("attr-name",t,e,r));a.skip()};a.hasNext();)l();return{tag:n,attrs:u}},k=y(t,{onSkip:function(){r++}}),B=function(){var t=k.getCurr(),n=k.getNext();if(t===g)k.skip(),e++,P(b("new-line",t,e,r=0));else if(N(t)){var o=k.grabWhile(N);P(b("space",o,e,r))}else if(v&&_(t)&&C(n))k.skip(),k.skip(),P(b("word",n,e,r));else if(t===h){k.skip();var u=k.substrUntilChar(A),a=0===u.length||u.indexOf(h)>=0;if(T.indexOf(n)>=0||a||k.isLast())P(b("word",t,e,r));else{var s=k.grabWhile((function(t){return t!==A}));if(k.skip(),-1===s.indexOf(c)||s[0]===i)P(b("tag",s,e,r));else{var f=R(s);P(b("tag",f.tag,e,r)),f.attrs.map(P)}}}else if(t===A)k.skip(),P(b("word",t,e,r));else if(O(t))if(v&&_(t)&&!C(n))k.skip(),P(b("word",t,e,r));else{var l=k.grabWhile((function(t){return v?O(t)&&!_(t):O(t)}));P(b("word",l,e,r))}};return{tokenize:function(){for(;k.hasNext();)B();return d.length=p+1,d},isTokenNested:function(n){var e=h+i+n.getValue();return t.indexOf(e)>-1}}}var _=function(t,n){void 0===n&&(n={});var e=n,r=null,o=O(),i=O(),u=O(),a=O(),s={},f=function(){u.flushLast()&&a.flushLast()},c=function(t){var n,r,u=(n=i.getLast())&&Array.isArray(n.content)?n.content:o.toArray();Array.isArray(u)&&(E(t)?(r=t.tag,e.onlyAllowTags&&e.onlyAllowTags.length&&0>e.onlyAllowTags.indexOf(r)?u.push(""+t):u.push(t.toTagNode())):u.push(t))},l=function(t){f();var n=h.create(t.getValue()),e=function(t){return void 0===s[t.getValue()]&&(s[t.getValue()]=r.isTokenNested(t)),s[t.getValue()]}(t);u.push(n),e?i.push(n):c(n)},g=function(t){t.isStart()&&l(t),t.isEnd()&&function(t){f();var n=i.flushLast();if(n)c(n);else if("function"==typeof e.onError){var r=t.getValue(),o=t.getLine(),u=t.getColumn();e.onError({message:"Inconsistent tag '"+r+"' on line "+o+" and column "+u,tagName:r,lineNumber:o,columnNumber:u})}}(t)},p=function(t){var n=u.getLast(),e=t.getValue(),r=!!s[t];if(n)if(t.isAttrName())a.push(e),n.attr(a.getLast(),"");else if(t.isAttrValue()){var o=a.getLast();o?(n.attr(o,e),a.flushLast()):n.attr(e,e)}else t.isText()?r?n.append(e):c(e):t.isTag()&&c(""+t);else t.isText()?c(e):t.isTag()&&c(""+t)};(r=(n.createTokenizer?n.createTokenizer:C)(t,{onToken:function(t){t.isTag()?g(t):p(t)},onlyAllowTags:e.onlyAllowTags,openTag:e.openTag,closeTag:e.closeTag,enableEscapeTags:e.enableEscapeTags})).tokenize();return o.toArray()};t.TagNode=A,t.default=_,t.parse=_,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).BbobParser={})}(this,(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function n(t,e){return t(e={exports:{}},e.exports),e.exports}var r=n((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=" "}));e(r);var o=r.BACKSLASH,i=r.SLASH,u=r.CLOSE_BRAKET,a=r.OPEN_BRAKET,s=r.SPACE,c=r.QUOTEMARK,f=r.EQ,l=r.TAB,g=r.N,p=n((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 o=function(t){return"string"==typeof t};e.isStringNode=o;e.isEOL=function(t){return t===r.N};e.getNodeLength=function t(e){return n(e)?e.content.reduce((function(e,n){return e+t(n)}),0):o(e)?e.length:0};e.appendToNode=function(t,e){t.content.push(e)};var i=function(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace("javascript:","javascript%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 void 0===t?"":Object.keys(t).reduce((function(e,n){return[].concat(e,[u(n,t[n])])}),[""]).join(" ")};e.getUniqAttr=function(t){return Object.keys(t).reduce((function(e,n){return t[n]===n?t[n]:null}),null)}}));e(p);var d=n((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 o(){return(o=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 i=function(){function t(t,e,n){this.tag=t,this.attrs=e,this.content=[].concat(n)}var e,i,u,a=t.prototype;return a.attr=function(t,e){return void 0!==e&&(this.attrs[t]=e),this.attrs[t]},a.append=function(t){return(0,p.appendToNode)(this,t)},a.toTagNode=function(){return new t(this.tag.toLowerCase(),this.attrs,this.content)},a.toString=function(){var t=r.OPEN_BRAKET,e=r.CLOSE_BRAKET,n=0===this.content.length,i=this.content.reduce((function(t,e){return t+""+e}),""),u=function(t,e){var n=(0,p.getUniqAttr)(e);if(n){var r=(0,p.attrValue)(t,n),i=o({},e);return delete i[n],""+r+(0,p.attrsToString)(i)}return""+t+(0,p.attrsToString)(e)}(this.tag,this.attrs);return n?""+t+u+e:""+t+u+e+i+t+r.SLASH+this.tag+e},e=t,(i=[{key:"length",get:function(){return(0,p.getNodeLength)(this)}}])&&n(e.prototype,i),u&&n(e,u),t}();e.TagNode=i,i.create=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n=[]),new i(t,e,n)},i.isOf=function(t,e){return t.tag===e},e.default=i})),v=e(d),h=d.TagNode,A=n((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=" "}));e(A);var T=n((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};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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace("javascript:","javascript%3A")};e.escapeHTML=o;var i=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=i;e.attrsToString=function(t){return void 0===t?"":Object.keys(t).reduce((function(e,n){return[].concat(e,[i(n,t[n])])}),[""]).join(" ")};e.getUniqAttr=function(t){return Object.keys(t).reduce((function(e,n){return t[n]===n?t[n]:null}),null)}}));e(T);var E=T.isTagNode,L=function(t){return t&&void 0!==t.value?t.value:""},S=function(t){return L(t).charCodeAt(0)===i.charCodeAt(0)},N=function(){function t(t,e,n,r){this.type=t+"",this.value=e+"",this.line=Number(n),this.row=Number(r)}var e=t.prototype;return e.isEmpty=function(){return!!this.type},e.isText=function(){return!(!(t=this)||void 0===t.type||"space"!==t.type&&"new-line"!==t.type&&"word"!==t.type);var t},e.isTag=function(){return!(!(t=this)||void 0===t.type)&&"tag"===t.type;var t},e.isAttrName=function(){return!(!(t=this)||void 0===t.type)&&"attr-name"===t.type;var t},e.isAttrValue=function(){return!(!(t=this)||void 0===t.type)&&"attr-value"===t.type;var t},e.isStart=function(){return!S(this)},e.isEnd=function(){return S(this)},e.getName=function(){return e=L(t=this),S(t)?e.slice(1):e;var t,e},e.getValue=function(){return L(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=a,t+=L(this),t+=u;var t},t}(),y=function(t,e){var n={pos:0,length:t.length},r=function(){n.pos+=1,e&&e.onSkip&&e.onSkip()},o=function(){return n.length>n.pos},i=function(){return t.substr(n.pos)},u=function(){return t[n.pos]};return{skip:r,hasNext:o,isLast:function(){return n.pos===n.length},grabWhile:function(e){var i=0;if(o())for(i=n.pos;o()&&e(u());)r();return t.substr(i,n.pos-i)},getNext:function(){var e=n.pos+1;return e>t.length-1?null:t[e]},getPrev:function(){var e=n.pos-1;return void 0!==t[e]?t[e]:null},getCurr:u,getRest:i,substrUntilChar:function(t){var e=i(),n=e.indexOf(t);return 0>n?"":e.substr(0,n)}}},O=function(t){void 0===t&&(t=[]);var e=t;return{getLast:function(){return Array.isArray(e)&&e.length>0&&void 0!==e[e.length-1]?e[e.length-1]:null},flushLast:function(){return!!e.length&&e.pop()},push:function(t){return e.push(t)},toArray:function(){return e}}},b=function(t,e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),new N(t,e,n,r)};function C(t,e){void 0===e&&(e={});var n=0,r=0,p=-1,d=Array(Math.floor(t.length)),v=e.openTag||a,h=e.closeTag||u,A=e.enableEscapeTags,T=[h,v,c,o,s,l,f,g,"!"],E=[v,s,l,g],L=[s,l],S=[f,s,l],N=function(t){return L.indexOf(t)>=0},O=function(t){return-1===E.indexOf(t)},C=function(t){return t===v||t===h||t===o},_=function(t){return t===o},P=function(t){e.onToken&&e.onToken(t),d[p+=1]=t},R=function(t){for(var e=null,i=!1,u=[],a=y(t),s=function(t){var n=t===f,r=N(t),u=a.getPrev(),s=a.getNext(),l=u===o;return null===e?!1===(n||r||a.isLast()):!(!i||!function(t){return S.indexOf(t)>=0}(t))||!!(t!==c||l||(i=!i)||s===f||N(s))&&!1===(n||r)},l=function(){var t=a.grabWhile(s),i=a.getCurr();if(null===e)e=t;else if(N(i)||i===c||!a.hasNext()){var f=function(t){return t.replace(o+c,c)}(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}(t,c));u.push(b("attr-value",f,n,r))}else u.push(b("attr-name",t,n,r));a.skip()};a.hasNext();)l();return{tag:e,attrs:u}},k=y(t,{onSkip:function(){r++}}),B=function(){var t=k.getCurr(),e=k.getNext();if(t===g)k.skip(),n++,P(b("new-line",t,n,r=0));else if(N(t)){var o=k.grabWhile(N);P(b("space",o,n,r))}else if(A&&_(t)&&C(e))k.skip(),k.skip(),P(b("word",e,n,r));else if(t===v){k.skip();var u=k.substrUntilChar(h),a=0===u.length||u.indexOf(v)>=0;if(T.indexOf(e)>=0||a||k.isLast())P(b("word",t,n,r));else{var s=k.grabWhile((function(t){return t!==h}));if(k.skip(),-1===s.indexOf(f)||s[0]===i)P(b("tag",s,n,r));else{var c=R(s);P(b("tag",c.tag,n,r)),c.attrs.map(P)}}}else if(t===h)k.skip(),P(b("word",t,n,r));else if(O(t))if(A&&_(t)&&!C(e))k.skip(),P(b("word",t,n,r));else{var l=k.grabWhile((function(t){return A?O(t)&&!_(t):O(t)}));P(b("word",l,n,r))}};return{tokenize:function(){for(;k.hasNext();)B();return d.length=p+1,d},isTokenNested:function(e){var n=v+i+e.getValue();return t.indexOf(n)>-1}}}var _=function(t,e){void 0===e&&(e={});var n=e,r=null,o=O(),i=O(),u=O(),a=O(),s={},c=function(){u.flushLast()&&a.flushLast()},f=function(t){var e,r,u=(e=i.getLast())&&Array.isArray(e.content)?e.content:o.toArray();Array.isArray(u)&&(E(t)?(r=t.tag,n.onlyAllowTags&&n.onlyAllowTags.length&&0>n.onlyAllowTags.indexOf(r)?u.push(""+t):u.push(t.toTagNode())):u.push(t))},l=function(t){c();var e=v.create(t.getValue()),n=function(t){return void 0===s[t.getValue()]&&(s[t.getValue()]=r.isTokenNested(t)),s[t.getValue()]}(t);u.push(e),n?i.push(e):f(e)},g=function(t){t.isStart()&&l(t),t.isEnd()&&function(t){c();var e=i.flushLast();if(e)f(e);else if("function"==typeof n.onError){var r=t.getValue(),o=t.getLine(),u=t.getColumn();n.onError({message:"Inconsistent tag '"+r+"' on line "+o+" and column "+u,tagName:r,lineNumber:o,columnNumber:u})}}(t)},p=function(t){var e=u.getLast(),n=t.getValue(),r=!!s[t];if(e)if(t.isAttrName())a.push(n),e.attr(a.getLast(),"");else if(t.isAttrValue()){var o=a.getLast();o?(e.attr(o,n),a.flushLast()):e.attr(n,n)}else t.isText()?r?e.append(n):f(n):t.isTag()&&f(""+t);else t.isText()?f(n):t.isTag()&&f(""+t)};(r=(e.createTokenizer?e.createTokenizer:C)(t,{onToken:function(t){t.isTag()?g(t):p(t)},onlyAllowTags:n.onlyAllowTags,openTag:n.openTag,closeTag:n.closeTag,enableEscapeTags:n.enableEscapeTags})).tokenize();return o.toArray()};t.TagNode=h,t.default=_,t.parse=_,Object.defineProperty(t,"__esModule",{value:!0})})); |
@@ -13,4 +13,3 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/* eslint-disable no-plusplus,no-param-reassign */ | ||
// for cases <!-- --> | ||
@@ -26,5 +25,11 @@ var EM = '!'; | ||
var createToken = function createToken(type, value) { | ||
var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; | ||
var cl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; | ||
var createToken = function createToken(type, value, r, cl) { | ||
if (r === void 0) { | ||
r = 0; | ||
} | ||
if (cl === void 0) { | ||
cl = 0; | ||
} | ||
return new _Token.Token(type, value, r, cl); | ||
@@ -55,6 +60,9 @@ }; | ||
function createLexer(buffer) { | ||
function createLexer(buffer, options) { | ||
var _modeMap; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var row = 0; | ||
@@ -206,3 +214,3 @@ var col = 0; | ||
var modeMap = (_modeMap = {}, _defineProperty(_modeMap, STATE_WORD, processWord), _defineProperty(_modeMap, STATE_TAG, processTag), _defineProperty(_modeMap, STATE_ATTR_NAME, processAttrName), _defineProperty(_modeMap, STATE_ATTR_VALUE, processAttrValue), _modeMap); | ||
var modeMap = (_modeMap = {}, _modeMap[STATE_WORD] = processWord, _modeMap[STATE_TAG] = processTag, _modeMap[STATE_ATTR_NAME] = processAttrName, _modeMap[STATE_ATTR_VALUE] = processAttrValue, _modeMap); | ||
@@ -209,0 +217,0 @@ var tokenize = function tokenize() { |
{ | ||
"name": "@bbob/parser", | ||
"version": "2.5.6", | ||
"version": "2.5.7", | ||
"description": "Just parses BBcode to AST array. Part of @bbob bbcode parser", | ||
@@ -16,3 +16,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@bbob/plugin-helper": "^2.5.6" | ||
"@bbob/plugin-helper": "^2.5.7" | ||
}, | ||
@@ -66,3 +66,3 @@ "main": "lib/index.js", | ||
], | ||
"gitHead": "5af63e4158f252f901b76ba54cfa7f1bbc246ec8" | ||
"gitHead": "fe6a16b6d9850bdfe3569649583c9957bf8ebe9c" | ||
} |
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
3817
135115
Updated@bbob/plugin-helper@^2.5.7