2017-06-27 10:09:59 -07:00
|
|
|
function _interopDefault$1(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function createCommonjsModule(e,t){return t={exports:{}},e(t,t.exports),t.exports}function enquoteDoctypeId(e){var t=-1!==e.indexOf('"')?"'":'"';return t+e+t}function hasPrefix(e,t){for(var n=0;n<t.length;n++)if(0===e.indexOf(t[n]))return!0;return!1}function parse(e){const t=index;try{const n=!/^\s*<(!doctype|html|head|body)/i.test(e),r=(n?t.parseFragment:t.parse)(e,{treeAdapter:t.treeAdapters.htmlparser2,locationInfo:!0});return extendAst(r)}catch(e){throw e}}function extendAst(e){if(!e||!e.children)return e;for(const t of e.children)extendAst(t),t.attribs&&(t.attributes=convertAttribs(t.attribs));return e}function convertAttribs(e){return Object.keys(e).map(t=>({type:"attribute",key:t,value:e[t]}))}var require$$0=_interopDefault$1(require$$0); var require$$1=_interopDefault$1(require$$1); var REPLACEMENT_CHARACTER="�"; var CODE_POINTS={EOF:-1,NULL:0,TABULATION:9,CARRIAGE_RETURN:13,LINE_FEED:10,FORM_FEED:12,SPACE:32,EXCLAMATION_MARK:33,QUOTATION_MARK:34,NUMBER_SIGN:35,AMPERSAND:38,APOSTROPHE:39,HYPHEN_MINUS:45,SOLIDUS:47,DIGIT_0:48,DIGIT_9:57,SEMICOLON:59,LESS_THAN_SIGN:60,EQUALS_SIGN:61,GREATER_THAN_SIGN:62,QUESTION_MARK:63,LATIN_CAPITAL_A:65,LATIN_CAPITAL_F:70,LATIN_CAPITAL_X:88,LATIN_CAPITAL_Z:90,GRAVE_ACCENT:96,LATIN_SMALL_A:97,LATIN_SMALL_F:102,LATIN_SMALL_X:120,LATIN_SMALL_Z:122,REPLACEMENT_CHARACTER:65533}; var CODE_POINT_SEQUENCES={DASH_DASH_STRING:[45,45],DOCTYPE_STRING:[68,79,67,84,89,80,69],CDATA_START_STRING:[91,67,68,65,84,65,91],CDATA_END_STRING:[93,93,62],SCRIPT_STRING:[115,99,114,105,112,116],PUBLIC_STRING:[80,85,66,76,73,67],SYSTEM_STRING:[83,89,83,84,69,77]}; var unicode={REPLACEMENT_CHARACTER:REPLACEMENT_CHARACTER,CODE_POINTS:CODE_POINTS,CODE_POINT_SEQUENCES:CODE_POINT_SEQUENCES}; var preprocessor=createCommonjsModule(function(e){function t(e,t){return e>=55296&&e<=56319&&t>=56320&&t<=57343}function n(e,t){return 1024*(e-55296)+9216+t}var r=unicode.CODE_POINTS,i=e.exports=function(){this.html=null,this.pos=-1,this.lastGapPos=-1,this.lastCharPos=-1,this.droppedBufferSize=0,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=65536;};Object.defineProperty(i.prototype,"sourcePos",{get:function(){return this.droppedBufferSize+this.pos}}),i.prototype.dropParsedChunk=function(){this.pos>this.bufferWaterline&&(this.lastCharPos-=this.pos,this.droppedBufferSize+=this.pos,this.html=this.html.substring(this.pos),this.pos=0,this.lastGapPos=-1,this.gapStack=[]);},i.prototype._addGap=function(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos;},i.prototype._processHighRangeCodePoint=function(e){if(this.pos!==this.lastCharPos){var i=this.html.charCodeAt(this.pos+1);t(e,i)&&(this.pos++,e=n(e,i),this._addGap());}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,r.EOF;return e},i.prototype.write=function(e,t){this.html?this.html+=e:this.html=e,this.lastCharPos=this.html.length-1,this.endOfChunkHit=!1,this.lastChunkWritten=t;},i.prototype.insertHtmlAtCurrentPos=function(e){this.html=this.html.substring(0,this.pos+1)+e+this.html.substring(this.pos+1,this.html.length),this.lastCharPos=this.html.length-1,this.endOfChunkHit=!1;},i.prototype.advance=function(){if(++this.pos>this.lastCharPos)return this.lastChunkWritten||(this.endOfChunkHit=!0),r.EOF;var e=this.html.charCodeAt(this.pos);return this.skipNextNewLine&&e===r.LINE_FEED?(this.skipNextNewLine=!1,this._addGap(),this.advance()):e===r.CARRIAGE_RETURN?(this.skipNextNewLine=!0,r.LINE_FEED):(this.skipNextNewLine=!1,e>=55296?this._processHighRangeCodePoint(e):e)},i.prototype.retreat=function(){this.pos===this.lastGapPos&&(this.lastGapPos=this.gapStack.pop(),this.pos--),this.pos--;};}); var UNICODE=unicode; var $=UNICODE.CODE_POINTS; var assign=function(e){function t(e){e.location={line:s,col:i,startOffset:r,endOffset:-1};}var n=Object.getPrototypeOf(e),r=-1,i=-1,s=1,o=!1,T=0,a=-1,E=1;e._consume=function(){var e=n._consume.call(this);return o&&(o=!1,E++,T=this.preprocessor.sourcePos),e===$.LINE_FEED&&(o=!0),a=
|