@thenja/html-parser
Version:
A simple forgiving html parser
2 lines • 20.7 kB
JavaScript
!function(t){var e={};function r(a){if(e[a])return e[a].exports;var s=e[a]={i:a,l:!1,exports:{}};return t[a].call(s.exports,s,s.exports,r),s.l=!0,s.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(a,s,function(e){return t[e]}.bind(null,s));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/dist/",r(r.s=5)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(){}return t.prototype.removeWhitespace=function(t){return t=(t=(t=(t=(t=(t=(t=t.trim()).split(" ").join("")).split("\t").join("")).split(" ").join("")).split("\n").join("")).split("\r").join("")).split("\n").join("")},t.prototype.isWhitespace=function(t){return"\t"===t||" "===t||" "===t||"\n"===t||"\r"===t||"\n"===t},t.prototype.textOnlyContainsWhitespace=function(t){var e=!0;if(!t)return e;for(var r=0;r<t.length;r++)if(!this.isWhitespace(t[r])){e=!1;break}return e},t.prototype.isLetter=function(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"},t.prototype.isStartOfTag=function(t,e){return!(!t||!e)&&("<"===t&&this.isLetter(e))},t.prototype.isEndOfTag=function(t,e){return!(!t||!e)&&("<"===t&&"/"===e)},t.prototype.isStartOfComment=function(t){return 0===t.indexOf("\x3c!--")},t}();e.Utility=a;var s=new a;e.utility=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ELEMENT_TYPES={TAG:"tag",TEXT:"text",COMMENT:"comment"},e.EMPTY_TAGS={area:1,base:1,basefont:1,br:1,col:1,frame:1,hr:1,img:1,input:1,isindex:1,link:1,meta:1,param:1,embed:1},e.MODE_TYPES={TEXT:"text",TAG:"tag",STYLE:"style",SCRIPT:"script"},e.TAG_TYPES={EMPTY:"empty",DEFAULT:"default",SCRIPT:"script",STYLE:"style",COMMENT:"comment"},e.QUOTE_TYPES={SINGLE:1,DOUBLE:2}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=r(0),s="reading-attr-name",i="reading-attr-value",n=function(){function t(){this.state={text:"",currentPos:0,mode:s,attrName:"",attrValue:""}}return t.prototype.reset=function(){this.state={text:"",currentPos:0,mode:"reading-attr-name",attrName:"",attrValue:""}},t.prototype.getNextChar=function(){var t=null;return this.state.currentPos<this.state.text.length&&(t=this.state.text.charAt(this.state.currentPos),this.state.currentPos++),t},t.prototype._parse=function(t){var e={};for(this.state.text=t;;){var r=this.getNextChar();if(null===r){this.state.attrName&&(e[this.state.attrName]=this.state.attrValue?this.state.attrValue:null);break}this.state.mode===s?this.handleReadingAttrName(r,e):this.state.mode===i&&this.handleReadingAttrValue(r,e)}return e},t.prototype.handleReadingAttrName=function(t,e){"="===t?this.state.mode=i:"/"===t||(a.utility.isWhitespace(t)?this.state.attrName&&(e[this.state.attrName]=null,this.state.attrName=""):this.state.attrName=this.state.attrName+t)},t.prototype.handleReadingAttrValue=function(t,e){if(a.utility.isWhitespace(t)){var r=this.state.attrValue[0],i=this.state.attrValue[this.state.attrValue.length-1];"'"!==r&&'"'!==r||r===i?(e[this.state.attrName]=this.state.attrValue,this.state.mode=s,this.state.attrName="",this.state.attrValue=""):this.state.attrValue=this.state.attrValue+t}else this.state.attrValue=this.state.attrValue+t},t.prototype.parse=function(t){this.reset();var e={},r=t.indexOf(" "),a=t.lastIndexOf(">");if(r>-1&&r<a){var s=t.substring(r,a);s=s.trim(),e=this._parse(s)}return e},t.prototype.reverse=function(t){var e="";for(var r in t)null===t[r]?e+=" "+r:e+=" "+r+"="+t[r];return e.trim()},t}();e.AttributeParser=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=r(1),s=r(0),i=function(){function t(){}return t.prototype.setOptions=function(t){t=t||{},this.removeEmptyTags=void 0===t.removeEmptyTags||t.removeEmptyTags,this.removeEmptyTextNodes=void 0===t.removeEmptyTextNodes||t.removeEmptyTextNodes},t.prototype.parseAndRemoveEmptyText=function(t,e){if(!(t>=e.length)){var r=e[t];r.type===a.ELEMENT_TYPES.TEXT&&s.utility.textOnlyContainsWhitespace(r.data)?(e.splice(t,1),t--):r.type===a.ELEMENT_TYPES.TAG&&r.children&&r.children.length>0&&this.parseAndRemoveEmptyText(0,r.children),this.parseAndRemoveEmptyText(++t,e)}},t.prototype.parseAndRemoveEmptyTags=function(t,e){if(!(t>=e.length)){var r=e[t];if(r.type===a.ELEMENT_TYPES.TAG){r.children&&r.children.length>0&&this.parseAndRemoveEmptyTags(0,r.children);var s=!r.children||r.children.length<=0;r.tagType===a.TAG_TYPES.DEFAULT&&s&&(e.splice(t,1),t--)}this.parseAndRemoveEmptyTags(++t,e)}},t.prototype.parse=function(t,e){return this.setOptions(e),this.removeEmptyTextNodes&&this.parseAndRemoveEmptyText(0,t),this.removeEmptyTags&&this.parseAndRemoveEmptyTags(0,t),t},t}();e.CleanParser=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=r(1);e.ELEMENT_TYPES=a.ELEMENT_TYPES,e.TAG_TYPES=a.TAG_TYPES;var s=r(9);e.HtmlParser=s.HtmlParser},function(t,e,r){var a=r(6);a.keys().forEach(a)},function(t,e,r){var a={"./attribute-parser.spec":7,"./clear-parser.spec":8,"./html-parser.spec":10,"./utility.spec":11};function s(t){var e=i(t);return r(e)}function i(t){if(!r.o(a,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return a[t]}s.keys=function(){return Object.keys(a)},s.resolve=i,t.exports=s,s.id=6},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=r(2);describe("Attribute parser",(function(){var t=new a.AttributeParser;describe("parse()",(function(){it("should parse attributes with double quotes",(function(){var e=t.parse('<p class="class-one" custom-attr="one two" txt="\'one\'">');expect(JSON.stringify(e)).toEqual(JSON.stringify({class:'"class-one"',"custom-attr":'"one two"',txt:"\"'one'\""}))})),it("should work with single quotes",(function(){var e=t.parse("<span class='cls' cus-attr='one two'>");expect(JSON.stringify(e)).toEqual(JSON.stringify({class:"'cls'","cus-attr":"'one two'"}))})),it("should handle values with no quotes",(function(){var e=t.parse("<div show=true hide=false>");expect(JSON.stringify(e)).toEqual(JSON.stringify({show:"true",hide:"false"}))})),it("should work with attributes with no values",(function(){var e=t.parse("<input required cus='one' />");expect(JSON.stringify(e)).toEqual(JSON.stringify({required:null,cus:"'one'"}))})),it("should handle no attributes",(function(){var e="<div>",r=t.parse(e);expect(JSON.stringify(r)).toEqual("{}"),e="<br/>",r=t.parse(e),expect(JSON.stringify(r)).toEqual("{}"),e="<br />",r=t.parse(e),expect(JSON.stringify(r)).toEqual("{}")})),it("should parse complex attributes",(function(){var t=(new a.AttributeParser).parse("<p class='abc db' aria-label=\"Easy one two\" custom=\"'text'\" val='' required custom-again=true abc-d='1'>");expect(JSON.stringify(t)).toEqual(JSON.stringify({class:"'abc db'","aria-label":'"Easy one two"',custom:"\"'text'\"",val:"''",required:null,"custom-again":"true","abc-d":"'1'"}))})),it("should parse attributes over different lines",(function(){var e=t.parse("<p class=\"hi\"\n custom='123' required \n cust=true >");expect(JSON.stringify(e)).toEqual(JSON.stringify({class:'"hi"',custom:"'123'",required:null,cust:"true"}))})),it("should parse attributes with greater than symbol in attribute text",(function(){var e=t.parse("<img alt='5>6' custom='d<f' />");expect(JSON.stringify(e)).toEqual(JSON.stringify({alt:"'5>6'",custom:"'d<f'"}))}))})),describe("reverse()",(function(){it("should reverse attributes object returned from parse function",(function(){var e=t.parse("<p class='one two' required custom=\"hi\">"),r=t.reverse(e);expect(r).toEqual("class='one two' required custom=\"hi\"")}))}))}))},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=r(3),s=r(4);describe("CleanParser",(function(){var t=new s.HtmlParser,e=new a.CleanParser;describe("parse()",(function(){it("should remove empty tags (basic)",(function(){var r=t.parse("<div>hi <div><span></span></div></div>");r=e.parse(r,{removeEmptyTextNodes:!1});expect(t.reverse(r)).toEqual("<div>hi </div>")})),it("should remove empty tags",(function(){var r=t.parse("<div>hi <span></span> there, <br /> how are you<p></p></div>");r=e.parse(r,{removeEmptyTextNodes:!1});expect(t.reverse(r)).toEqual("<div>hi there, <br /> how are you</div>")})),it("should remove empty text nodes",(function(){var r=t.parse("<div><span></span>hi<span> </span> </div>");r=e.parse(r,{removeEmptyTags:!1});expect(t.reverse(r)).toEqual("<div><span></span>hi<span></span></div>")}))}))}))},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=r(0),s=r(1),i=r(2),n=r(3),o=function(){function t(){this.errorCb=null,this.addNodeCb=null,this.stringifyNodeCb=null}return t.prototype.reset=function(){this.state={mode:s.MODE_TYPES.TEXT,html:"",currentPos:0,output:[]}},t.prototype.addNodeElement=function(t,e){this.addNodeCb&&this.addNodeCb(t,e),e?(e.children||(e.children=[]),e.children.push(t)):this.state.output.push(t)},t.prototype.createTextNode=function(t){return{type:s.ELEMENT_TYPES.TEXT,data:t}},t.prototype.createCommentNode=function(t){return{type:s.ELEMENT_TYPES.COMMENT,data:t}},t.prototype.createTagNode=function(t){var e=t.indexOf(" "),r=t.indexOf(">"),i=e>-1&&e<r?e:r,n=t.substring(1,i);return n=a.utility.removeWhitespace(n),{type:s.ELEMENT_TYPES.TAG,tagType:this.getTagType(n),name:n,attributes:this.parseAttributes(t),children:[]}},t.prototype.getTagType=function(t){return t=t.toLowerCase(),s.EMPTY_TAGS[t]?s.TAG_TYPES.EMPTY:t===s.TAG_TYPES.STYLE?s.TAG_TYPES.STYLE:t===s.TAG_TYPES.SCRIPT?s.TAG_TYPES.SCRIPT:t===s.TAG_TYPES.COMMENT?s.TAG_TYPES.COMMENT:s.TAG_TYPES.DEFAULT},t.prototype.getNextTag=function(t){for(var e=0;e<t.length;){if(a.utility.isStartOfTag(t[e],t[e+1]))return{type:"start",pos:e};if(a.utility.isEndOfTag(t[e],t[e+1]))return{type:"end",pos:e};if(a.utility.isStartOfComment(t.substr(e)))return{type:"comment",pos:e};e++}return{type:"no-tag"}},t.prototype.parseText=function(t){var e=this.state.html.substring(this.state.currentPos),r=this.getNextTag(e);if("start"===r.type)this.handleStartTagInText(r,e,t);else if("end"===r.type)this.handleEndTagInText(r,e,t);else if("comment"===r.type)this.handleCommentInText(r,e,t);else if(e.length>0){var a=this.createTextNode(e);this.addNodeElement(a,t)}},t.prototype.handleStartTagInText=function(t,e,r){if(t.pos>0){var a=e.substring(0,t.pos),i=this.createTextNode(a);this.addNodeElement(i,r)}this.state.mode=s.MODE_TYPES.TAG,this.state.currentPos=this.state.currentPos+t.pos,this._parse(r)},t.prototype.handleEndTagInText=function(t,e,r){if(t.pos>0){var a=e.substring(0,t.pos),i=this.createTextNode(a);this.addNodeElement(i,r)}var n=e.indexOf(">",t.pos)+1,o=e.substring(t.pos,n).replace("</","").replace(">","");if(!r){var p=new Error("No start tag for end tag: "+o);this.errorCb&&this.errorCb(p)}if(r.name.toLowerCase()!==o.toLowerCase()){p=Error("Start tag ("+r.name+") and end tag ("+o+") do not match");this.errorCb&&this.errorCb(p)}this.state.mode=s.MODE_TYPES.TEXT,this.state.currentPos=this.state.currentPos+n;var u=r.parentElement;delete r.parentElement,this._parse(u)},t.prototype.handleCommentInText=function(t,e,r){if(t.pos>0){var a=e.substring(0,t.pos),i=this.createTextNode(a);this.addNodeElement(i,r)}var n=e.indexOf("--\x3e");if(!n){var o=new Error("Comment does not have an end tag");this.errorCb&&this.errorCb(o)}var p=e.substring(t.pos+4,n),u=this.createCommentNode(p);this.addNodeElement(u,r),this.state.mode=s.MODE_TYPES.TEXT,this.state.currentPos=this.state.currentPos+(n+3),this._parse(r)},t.prototype.parseTag=function(t){var e=this.state.html.substring(this.state.currentPos),r=this.findPositionOfClosingTag(e)+1,a=e.substring(0,r),i=this.createTagNode(a);this.state.currentPos=this.state.currentPos+r,this.addNodeElement(i,t),this.state.mode=s.MODE_TYPES.TEXT,i.tagType===s.TAG_TYPES.EMPTY?this._parse(t):i.tagType===s.TAG_TYPES.STYLE?(this.state.mode=s.MODE_TYPES.STYLE,i.parentElement=t,this._parse(i)):i.tagType===s.TAG_TYPES.SCRIPT?(this.state.mode=s.MODE_TYPES.SCRIPT,i.parentElement=t,this._parse(i)):(i.parentElement=t,this._parse(i))},t.prototype.findPositionOfClosingTag=function(t){var e=t.indexOf(" "),r=e>-1?e+1:0,a=t.indexOf(">");if(a<r)return a;for(var i=null,n=!1;;){var o=r<t.length?t[r]:null;if(">"===o&&!n)return r;if("'"===o)n&&i===s.QUOTE_TYPES.SINGLE?n=!1:n||(n=!0,i=s.QUOTE_TYPES.SINGLE);else if('"'===o)n&&i===s.QUOTE_TYPES.DOUBLE?n=!1:n||(n=!0,i=s.QUOTE_TYPES.DOUBLE);else if(null===o)break;r++}return t.length-1},t.prototype.parseAttributes=function(t){return(new i.AttributeParser).parse(t)},t.prototype.parseScript=function(t,e){var r=this.state.html.substring(this.state.currentPos),a=r.indexOf(e);if(a<0){var i=new Error("Script ("+t.name+" ) does not have an end tag");this.errorCb&&this.errorCb(i)}var n=r.substring(0,a),o=this.createTextNode(n);this.addNodeElement(o,t),this.state.currentPos=this.state.currentPos+(a+e.length),this.state.mode=s.MODE_TYPES.TEXT;var p=t.parentElement;delete t.parentElement,this._parse(p)},t.prototype._parse=function(t){switch(this.state.mode){case s.MODE_TYPES.TEXT:this.parseText(t);break;case s.MODE_TYPES.TAG:this.parseTag(t);break;case s.MODE_TYPES.STYLE:this.parseScript(t,"</style>");break;case s.MODE_TYPES.SCRIPT:this.parseScript(t,"<\/script>")}},t.prototype.parse=function(t,e,r){return this.errorCb=e||null,this.addNodeCb=r||null,this.reset(),this.state.html=t,this._parse(null),this.state.output},t.prototype.reverse=function(t,e){return this.stringifyNodeCb=e||null,this.reverseNodes(0,t,"")},t.prototype.reverseNodes=function(t,e,r){if(t>=e.length)return r;var a=e[t];if(this.stringifyNodeCb&&this.stringifyNodeCb(a),a.type===s.ELEMENT_TYPES.TEXT)r+=a.data;else if(a.type===s.ELEMENT_TYPES.COMMENT)r+="\x3c!--"+a.data+"--\x3e";else{var n=(new i.AttributeParser).reverse(a.attributes);if(n=n.length>0?" "+n:n,a.tagType===s.TAG_TYPES.EMPTY)r+="<"+a.name+n+" />";else{if(r+="<"+a.name+n+">",a.children&&a.children.length>0)r+=this.reverseNodes(0,a.children,"");r+="</"+a.name+">"}}return t++,this.reverseNodes(t,e,r)},t.prototype.clean=function(t,e){return(new n.CleanParser).parse(t,e)},t}();e.HtmlParser=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=r(4);describe("HtmlParser",(function(){var t=new a.HtmlParser;describe("parse()",(function(){it("should parse plain text",(function(){var e=t.parse("plain text ");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"text",data:"plain text "}]))})),it("should parse plain text with tag",(function(){var e=t.parse("plain text <br />");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"text",data:"plain text "},{type:"tag",tagType:"empty",name:"br",attributes:{},children:[]}]))})),it("should handle html comment",(function(){var e=t.parse("<div>\x3c!--This is not seen--\x3eHello world!</div>");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"tag",tagType:"default",name:"div",attributes:{},children:[{type:"comment",data:"This is not seen"},{type:"text",data:"Hello world!"}]}]))})),it("should parse script tag",(function(){var e=t.parse('<body><script type="javascript/text">var a = ( 5 > 2) ? 3 : 3;<\/script></body>');expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"tag",tagType:"default",name:"body",attributes:{},children:[{type:"tag",tagType:"script",name:"script",attributes:{type:'"javascript/text"'},children:[{type:"text",data:"var a = ( 5 > 2) ? 3 : 3;"}]}]}]))})),it("should parse style tag",(function(){var e=t.parse("<body><style>body > p {}</style></body>");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"tag",tagType:"default",name:"body",attributes:{},children:[{type:"tag",tagType:"style",name:"style",attributes:{},children:[{type:"text",data:"body > p {}"}]}]}]))})),it("should parse nested tags",(function(){var e=t.parse("<div><div><p> hi<span> there</span></p></div></div>");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"tag",tagType:"default",name:"div",attributes:{},children:[{type:"tag",tagType:"default",name:"div",attributes:{},children:[{type:"tag",tagType:"default",name:"p",attributes:{},children:[{type:"text",data:" hi"},{type:"tag",tagType:"default",name:"span",attributes:{},children:[{type:"text",data:" there"}]}]}]}]}]))})),it("should parse tags with attributes",(function(){var e=t.parse("<div class='one'><input required /></div>");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"tag",tagType:"default",name:"div",attributes:{class:"'one'"},children:[{type:"tag",tagType:"empty",name:"input",attributes:{required:null},children:[]}]}]))})),it("should pass error for invalid html",(function(){var e=0;t.parse("<div><p>hi</div>",(function(t){e++}));expect(e).toBeGreaterThan(0)})),it("should parse tags with capital letters",(function(){var e=t.parse("<SPAN><p>hi</P> there</SPAN>");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"tag",tagType:"default",name:"SPAN",attributes:{},children:[{type:"tag",tagType:"default",name:"p",attributes:{},children:[{type:"text",data:"hi"}]},{type:"text",data:" there"}]}]))})),it("should parse custom tags",(function(){var e=t.parse("<cust-tag>hello</cust-tag>");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"tag",tagType:"default",name:"cust-tag",attributes:{},children:[{type:"text",data:"hello"}]}]))})),it("should parse text content that has less than or greater than symbols",(function(){var e=t.parse("<p> 5 > 3 and 2 < 4 </p>");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"tag",tagType:"default",name:"p",attributes:{},children:[{type:"text",data:" 5 > 3 and 2 < 4 "}]}]))})),it("should handle greater than symbol in attribute",(function(){var e=t.parse("<img alt='5>6' custom='d<f' /><span class=d>f>hi</span>");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"tag",tagType:"empty",name:"img",attributes:{alt:"'5>6'",custom:"'d<f'"},children:[]},{type:"tag",tagType:"default",name:"span",attributes:{class:"d"},children:[{type:"text",data:"f>hi"}]}]))})),it("should handle quotes in attributes",(function(){var e=t.parse("<p custom=\"This's there ' s\"><span tag='\"hi there\"'></span></p>");expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"tag",tagType:"default",name:"p",attributes:{custom:"\"This's there ' s\""},children:[{type:"tag",tagType:"default",name:"span",attributes:{tag:"'\"hi there\"'"},children:[]}]}]))})),it("should parse tag split over lines",(function(){var e=t.parse('hi\n<p\n class="one">\n a paragraph\n</p>');expect(JSON.stringify(e)).toEqual(JSON.stringify([{type:"text",data:"hi\n"},{type:"tag",tagType:"default",name:"p",attributes:{class:'"one"'},children:[{type:"text",data:"\n a paragraph\n"}]}]))})),it("should fire event each time a node is added",(function(){var e=0;t.parse("<p class='one'>My <span>name is <strong>Nathan</strong></span></p>",null,(function(t,r){e++}));expect(e).toEqual(6)}))})),describe("reverse()",(function(){it("should reverse output from the parse function back into html",(function(){var e="<div class='one'><p>hi <span>there</span></p><br /></div>",r=t.parse(e),a=t.reverse(r);expect(a).toEqual(e)})),it("should fire event each time a node is stringified",(function(){var e=t.parse("<p class='one'>My <span>name is <strong>Nathan</strong></span></p>"),r=t.reverse(e,(function(t){"p"===t.name&&(t.attributes.class="'onne'")}));expect(r).toEqual("<p class='onne'>My <span>name is <strong>Nathan</strong></span></p>")}))})),describe("clean()",(function(){it("should clean and remove unwanted html",(function(){var e=t.parse("<div>\n<p>\n</p><p> Hello</p>\n <div><span></span>\n</div>\n<div>hi <br><span></span>\n</div><div><p><span> </span></p></div></div>");e=t.clean(e);expect(t.reverse(e)).toEqual("<div><p> Hello</p><div>hi <br /></div></div>")}))}))}))},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=r(0);describe("Utility",(function(){describe("removeWhitespace()",(function(){it("should remove all white space",(function(){var t=a.utility.removeWhitespace(" nathan\n");expect(t).toEqual("nathan"),t=a.utility.removeWhitespace(" \r\nnathan\n"),expect(t).toEqual("nathan"),t=a.utility.removeWhitespace(" \r\nnat han\n"),expect(t).toEqual("nathan")}))}))}))}]);
//# sourceMappingURL=spec.js.map