Exemple #1
0
Tokenizer.prototype._parseLegacyEntity = function() {
	var start = this._sectionStart + 1,
		limit = this._index - start;

	if( limit > 6 ) limit = 6; //the max length of legacy entities is 6

	while( limit >= 2 ) { //the min length of legacy entities is 2
		var entity = this._buffer.substr( start, limit );

		if( legacyMap.hasOwnProperty( entity ) ) {
			this._emitPartial( legacyMap[entity] );
			this._sectionStart += limit + 1;
			return;
		} else {
			limit--;
		}
	}
};
function whitespace(e){return" "===e||"\n"===e||"	"===e||"\f"===e||"\r"===e}function characterState(e,n){return function(t){t===e&&(this._state=n)}}function ifElseState(e,n,t){var r=e.toLowerCase();return e===r?function(e){e===r?this._state=n:(this._state=t,this._index--)}:function(a){a===r||a===e?this._state=n:(this._state=t,this._index--)}}function consumeSpecialNameChar(e,n){var t=e.toLowerCase();return function(r){r===t||r===e?this._state=n:(this._state=IN_TAG_NAME,this._index--)}}function Tokenizer(e,n){this._state=TEXT,this._buffer="",this._sectionStart=0,this._index=0,this._bufferOffset=0,this._baseState=TEXT,this._special=SPECIAL_NONE,this._cbs=n,this._running=!0,this._ended=!1,this._xmlMode=!(!e||!e.xmlMode),this._decodeEntities=!(!e||!e.decodeEntities)}module.exports=Tokenizer;var decodeCodePoint=require("entities/lib/decode_codepoint.js"),entityMap=require("entities/maps/entities.json"),legacyMap=require("entities/maps/legacy.json"),xmlMap=require("entities/maps/xml.json"),i=0,TEXT=i++,BEFORE_TAG_NAME=i++,IN_TAG_NAME=i++,IN_SELF_CLOSING_TAG=i++,BEFORE_CLOSING_TAG_NAME=i++,IN_CLOSING_TAG_NAME=i++,AFTER_CLOSING_TAG_NAME=i++,BEFORE_ATTRIBUTE_NAME=i++,IN_ATTRIBUTE_NAME=i++,AFTER_ATTRIBUTE_NAME=i++,BEFORE_ATTRIBUTE_VALUE=i++,IN_ATTRIBUTE_VALUE_DQ=i++,IN_ATTRIBUTE_VALUE_SQ=i++,IN_ATTRIBUTE_VALUE_NQ=i++,BEFORE_DECLARATION=i++,IN_DECLARATION=i++,IN_PROCESSING_INSTRUCTION=i++,BEFORE_COMMENT=i++,IN_COMMENT=i++,AFTER_COMMENT_1=i++,AFTER_COMMENT_2=i++,BEFORE_CDATA_1=i++,BEFORE_CDATA_2=i++,BEFORE_CDATA_3=i++,BEFORE_CDATA_4=i++,BEFORE_CDATA_5=i++,BEFORE_CDATA_6=i++,IN_CDATA=i++,AFTER_CDATA_1=i++,AFTER_CDATA_2=i++,BEFORE_SPECIAL=i++,BEFORE_SPECIAL_END=i++,BEFORE_SCRIPT_1=i++,BEFORE_SCRIPT_2=i++,BEFORE_SCRIPT_3=i++,BEFORE_SCRIPT_4=i++,BEFORE_SCRIPT_5=i++,AFTER_SCRIPT_1=i++,AFTER_SCRIPT_2=i++,AFTER_SCRIPT_3=i++,AFTER_SCRIPT_4=i++,AFTER_SCRIPT_5=i++,BEFORE_STYLE_1=i++,BEFORE_STYLE_2=i++,BEFORE_STYLE_3=i++,BEFORE_STYLE_4=i++,AFTER_STYLE_1=i++,AFTER_STYLE_2=i++,AFTER_STYLE_3=i++,AFTER_STYLE_4=i++,BEFORE_ENTITY=i++,BEFORE_NUMERIC_ENTITY=i++,IN_NAMED_ENTITY=i++,IN_NUMERIC_ENTITY=i++,IN_HEX_ENTITY=i++,j=0,SPECIAL_NONE=j++,SPECIAL_SCRIPT=j++,SPECIAL_STYLE=j++;Tokenizer.prototype._stateText=function(e){"<"===e?(this._index>this._sectionStart&&this._cbs.ontext(this._getSection()),this._state=BEFORE_TAG_NAME,this._sectionStart=this._index):this._decodeEntities&&this._special===SPECIAL_NONE&&"&"===e&&(this._index>this._sectionStart&&this._cbs.ontext(this._getSection()),this._baseState=TEXT,this._state=BEFORE_ENTITY,this._sectionStart=this._index)},Tokenizer.prototype._stateBeforeTagName=function(e){"/"===e?this._state=BEFORE_CLOSING_TAG_NAME:">"===e||this._special!==SPECIAL_NONE||whitespace(e)?this._state=TEXT:"!"===e?(this._state=BEFORE_DECLARATION,this._sectionStart=this._index+1):"?"===e?(this._state=IN_PROCESSING_INSTRUCTION,this._sectionStart=this._index+1):"<"===e?(this._cbs.ontext(this._getSection()),this._sectionStart=this._index):(this._state=this._xmlMode||"s"!==e&&"S"!==e?IN_TAG_NAME:BEFORE_SPECIAL,this._sectionStart=this._index)},Tokenizer.prototype._stateInTagName=function(e){("/"===e||">"===e||whitespace(e))&&(this._emitToken("onopentagname"),this._state=BEFORE_ATTRIBUTE_NAME,this._index--)},Tokenizer.prototype._stateBeforeCloseingTagName=function(e){whitespace(e)||(">"===e?this._state=TEXT:this._special!==SPECIAL_NONE?"s"===e||"S"===e?this._state=BEFORE_SPECIAL_END:(this._state=TEXT,this._index--):(this._state=IN_CLOSING_TAG_NAME,this._sectionStart=this._index))},Tokenizer.prototype._stateInCloseingTagName=function(e){(">"===e||whitespace(e))&&(this._emitToken("onclosetag"),this._state=AFTER_CLOSING_TAG_NAME,this._index--)},Tokenizer.prototype._stateAfterCloseingTagName=function(e){">"===e&&(this._state=TEXT,this._sectionStart=this._index+1)},Tokenizer.prototype._stateBeforeAttributeName=function(e){">"===e?(this._cbs.onopentagend(),this._state=TEXT,this._sectionStart=this._index+1):"/"===e?this._state=IN_SELF_CLOSING_TAG:whitespace(e)||(this._state=IN_ATTRIBUTE_NAME,this._sectionStart=this._index)},Tokenizer.prototype._stateInSelfClosingTag=function(e){">"===e?(this._cbs.onselfclosingtag(),this._state=TEXT,this._sectionStart=this._index+1):whitespace(e)||(this._state=BEFORE_ATTRIBUTE_NAME,this._index--)},Tokenizer.prototype._stateInAttributeName=function(e){("="===e||"/"===e||">"===e||whitespace(e))&&(this._cbs.onattribname(this._getSection()),this._sectionStart=-1,this._state=AFTER_ATTRIBUTE_NAME,this._index--)},Tokenizer.prototype._stateAfterAttributeName=function(e){"="===e?this._state=BEFORE_ATTRIBUTE_VALUE:"/"===e||">"===e?(this._cbs.onattribend(),this._state=BEFORE_ATTRIBUTE_NAME,this._index--):whitespace(e)||(this._cbs.onattribend(),this._state=IN_ATTRIBUTE_NAME,this._sectionStart=this._index)},Tokenizer.prototype._stateBeforeAttributeValue=function(e){'"'===e?(this._state=IN_ATTRIBUTE_VALUE_DQ,this._sectionStart=this._index+1):"'"===e?(this._state=IN_ATTRIBUTE_VALUE_SQ,this._sectionStart=this._index+1):whitespace(e)||(this._state=IN_ATTRIBUTE_VALUE_NQ,this._sectionStart=this._index,this._index--)},Tokenizer.prototype._stateInAttributeValueDoubleQuotes=function(e){'"'===e?(this._emitToken("onattribdata"),this._cbs.onattribend(),this._state=BEFORE_ATTRIBUTE_NAME):this._decodeEntities&&"&"===e&&(this._emitToken("onattribdata"),this._baseState=this._state,this._state=BEFORE_ENTITY,this._sectionStart=this._index)},Tokenizer.prototype._stateInAttributeValueSingleQuotes=function(e){"'"===e?(this._emitToken("onattribdata"),this._cbs.onattribend(),this._state=BEFORE_ATTRIBUTE_NAME):this._decodeEntities&&"&"===e&&(this._emitToken("onattribdata"),this._baseState=this._state,this._state=BEFORE_ENTITY,this._sectionStart=this._index)},Tokenizer.prototype._stateInAttributeValueNoQuotes=function(e){whitespace(e)||">"===e?(this._emitToken("onattribdata"),this._cbs.onattribend(),this._state=BEFORE_ATTRIBUTE_NAME,this._index--):this._decodeEntities&&"&"===e&&(this._emitToken("onattribdata"),this._baseState=this._state,this._state=BEFORE_ENTITY,this._sectionStart=this._index)},Tokenizer.prototype._stateBeforeDeclaration=function(e){this._state="["===e?BEFORE_CDATA_1:"-"===e?BEFORE_COMMENT:IN_DECLARATION},Tokenizer.prototype._stateInDeclaration=function(e){">"===e&&(this._cbs.ondeclaration(this._getSection()),this._state=TEXT,this._sectionStart=this._index+1)},Tokenizer.prototype._stateInProcessingInstruction=function(e){">"===e&&(this._cbs.onprocessinginstruction(this._getSection()),this._state=TEXT,this._sectionStart=this._index+1)},Tokenizer.prototype._stateBeforeComment=function(e){"-"===e?(this._state=IN_COMMENT,this._sectionStart=this._index+1):this._state=IN_DECLARATION},Tokenizer.prototype._stateInComment=function(e){"-"===e&&(this._state=AFTER_COMMENT_1)},Tokenizer.prototype._stateAfterComment1=function(e){"-"===e?this._state=AFTER_COMMENT_2:this._state=IN_COMMENT},Tokenizer.prototype._stateAfterComment2=function(e){">"===e?(this._cbs.oncomment(this._buffer.substring(this._sectionStart,this._index-2)),this._state=TEXT,this._sectionStart=this._index+1):"-"!==e&&(this._state=IN_COMMENT)},Tokenizer.prototype._stateBeforeCdata1=ifElseState("C",BEFORE_CDATA_2,IN_DECLARATION),Tokenizer.prototype._stateBeforeCdata2=ifElseState("D",BEFORE_CDATA_3,IN_DECLARATION),Tokenizer.prototype._stateBeforeCdata3=ifElseState("A",BEFORE_CDATA_4,IN_DECLARATION),Tokenizer.prototype._stateBeforeCdata4=ifElseState("T",BEFORE_CDATA_5,IN_DECLARATION),Tokenizer.prototype._stateBeforeCdata5=ifElseState("A",BEFORE_CDATA_6,IN_DECLARATION),Tokenizer.prototype._stateBeforeCdata6=function(e){"["===e?(this._state=IN_CDATA,this._sectionStart=this._index+1):(this._state=IN_DECLARATION,this._index--)},Tokenizer.prototype._stateInCdata=function(e){"]"===e&&(this._state=AFTER_CDATA_1)},Tokenizer.prototype._stateAfterCdata1=characterState("]",AFTER_CDATA_2),Tokenizer.prototype._stateAfterCdata2=function(e){">"===e?(this._cbs.oncdata(this._buffer.substring(this._sectionStart,this._index-2)),this._state=TEXT,this._sectionStart=this._index+1):"]"!==e&&(this._state=IN_CDATA)},Tokenizer.prototype._stateBeforeSpecial=function(e){"c"===e||"C"===e?this._state=BEFORE_SCRIPT_1:"t"===e||"T"===e?this._state=BEFORE_STYLE_1:(this._state=IN_TAG_NAME,this._index--)},Tokenizer.prototype._stateBeforeSpecialEnd=function(e){this._special!==SPECIAL_SCRIPT||"c"!==e&&"C"!==e?this._special!==SPECIAL_STYLE||"t"!==e&&"T"!==e?this._state=TEXT:this._state=AFTER_STYLE_1:this._state=AFTER_SCRIPT_1},Tokenizer.prototype._stateBeforeScript1=consumeSpecialNameChar("R",BEFORE_SCRIPT_2),Tokenizer.prototype._stateBeforeScript2=consumeSpecialNameChar("I",BEFORE_SCRIPT_3),Tokenizer.prototype._stateBeforeScript3=consumeSpecialNameChar("P",BEFORE_SCRIPT_4),Tokenizer.prototype._stateBeforeScript4=consumeSpecialNameChar("T",BEFORE_SCRIPT_5),Tokenizer.prototype._stateBeforeScript5=function(e){("/"===e||">"===e||whitespace(e))&&(this._special=SPECIAL_SCRIPT),this._state=IN_TAG_NAME,this._index--},Tokenizer.prototype._stateAfterScript1=ifElseState("R",AFTER_SCRIPT_2,TEXT),Tokenizer.prototype._stateAfterScript2=ifElseState("I",AFTER_SCRIPT_3,TEXT),Tokenizer.prototype._stateAfterScript3=ifElseState("P",AFTER_SCRIPT_4,TEXT),Tokenizer.prototype._stateAfterScript4=ifElseState("T",AFTER_SCRIPT_5,TEXT),Tokenizer.prototype._stateAfterScript5=function(e){">"===e||whitespace(e)?(this._special=SPECIAL_NONE,this._state=IN_CLOSING_TAG_NAME,this._sectionStart=this._index-6,this._index--):this._state=TEXT},Tokenizer.prototype._stateBeforeStyle1=consumeSpecialNameChar("Y",BEFORE_STYLE_2),Tokenizer.prototype._stateBeforeStyle2=consumeSpecialNameChar("L",BEFORE_STYLE_3),Tokenizer.prototype._stateBeforeStyle3=consumeSpecialNameChar("E",BEFORE_STYLE_4),Tokenizer.prototype._stateBeforeStyle4=function(e){("/"===e||">"===e||whitespace(e))&&(this._special=SPECIAL_STYLE),this._state=IN_TAG_NAME,this._index--},Tokenizer.prototype._stateAfterStyle1=ifElseState("Y",AFTER_STYLE_2,TEXT),Tokenizer.prototype._stateAfterStyle2=ifElseState("L",AFTER_STYLE_3,TEXT),Tokenizer.prototype._stateAfterStyle3=ifElseState("E",AFTER_STYLE_4,TEXT),Tokenizer.prototype._stateAfterStyle4=function(e){">"===e||whitespace(e)?(this._special=SPECIAL_NONE,this._state=IN_CLOSING_TAG_NAME,this._sectionStart=this._index-5,this._index--):this._state=TEXT},Tokenizer.prototype._stateBeforeEntity=ifElseState("#",BEFORE_NUMERIC_ENTITY,IN_NAMED_ENTITY),Tokenizer.prototype._stateBeforeNumericEntity=ifElseState("X",IN_HEX_ENTITY,IN_NUMERIC_ENTITY),Tokenizer.prototype._parseNamedEntityStrict=function(){if(this._sectionStart+1<this._index){var e=this._buffer.substring(this._sectionStart+1,this._index),n=this._xmlMode?xmlMap:entityMap;n.hasOwnProperty(e)&&(this._emitPartial(n[e]),this._sectionStart=this._index+1)}},Tokenizer.prototype._parseLegacyEntity=function(){var e=this._sectionStart+1,n=this._index-e;for(n>6&&(n=6);n>=2;){var t=this._buffer.substr(e,n);if(legacyMap.hasOwnProperty(t))return this._emitPartial(legacyMap[t]),void(this._sectionStart+=n+1);n--}},Tokenizer.prototype._stateInNamedEntity=function(e){";"===e?(this._parseNamedEntityStrict(),this._sectionStart+1<this._index&&!this._xmlMode&&this._parseLegacyEntity(),this._state=this._baseState):("a">e||e>"z")&&("A">e||e>"Z")&&("0">e||e>"9")&&(this._xmlMode||this._sectionStart+1===this._index||(this._baseState!==TEXT?"="!==e&&this._parseNamedEntityStrict():this._parseLegacyEntity()),this._state=this._baseState,this._index--)},Tokenizer.prototype._decodeNumericEntity=function(e,n){var t=this._sectionStart+e;if(t!==this._index){var r=this._buffer.substring(t,this._index),a=parseInt(r,n);this._emitPartial(decodeCodePoint(a)),this._sectionStart=this._index}else this._sectionStart--;this._state=this._baseState},Tokenizer.prototype._stateInNumericEntity=function(e){";"===e?(this._decodeNumericEntity(2,10),this._sectionStart++):("0">e||e>"9")&&(this._xmlMode?this._state=this._baseState:this._decodeNumericEntity(2,10),this._index--)},Tokenizer.prototype._stateInHexEntity=function(e){";"===e?(this._decodeNumericEntity(3,16),this._sectionStart++):("a">e||e>"f")&&("A">e||e>"F")&&("0">e||e>"9")&&(this._xmlMode?this._state=this._baseState:this._decodeNumericEntity(3,16),this._index--)},Tokenizer.prototype._cleanup=function(){this._sectionStart<0?(this._buffer="",this._index=0,this._bufferOffset+=this._index):this._running&&(this._state===TEXT?(this._sectionStart!==this._index&&this._cbs.ontext(this._buffer.substr(this._sectionStart)),this._buffer="",this._index=0,this._bufferOffset+=this._index):this._sectionStart===this._index?(this._buffer="",this._index=0,this._bufferOffset+=this._index):(this._buffer=this._buffer.substr(this._sectionStart),this._index-=this._sectionStart,this._bufferOffset+=this._sectionStart),this._sectionStart=0)},Tokenizer.prototype.write=function(e){this._ended&&this._cbs.onerror(Error(".write() after done!")),this._buffer+=e,this._parse()},Tokenizer.prototype._parse=function(){for(;this._index<this._buffer.length&&this._running;){var e=this._buffer.charAt(this._index);this._state===TEXT?this._stateText(e):this._state===BEFORE_TAG_NAME?this._stateBeforeTagName(e):this._state===IN_TAG_NAME?this._stateInTagName(e):this._state===BEFORE_CLOSING_TAG_NAME?this._stateBeforeCloseingTagName(e):this._state===IN_CLOSING_TAG_NAME?this._stateInCloseingTagName(e):this._state===AFTER_CLOSING_TAG_NAME?this._stateAfterCloseingTagName(e):this._state===IN_SELF_CLOSING_TAG?this._stateInSelfClosingTag(e):this._state===BEFORE_ATTRIBUTE_NAME?this._stateBeforeAttributeName(e):this._state===IN_ATTRIBUTE_NAME?this._stateInAttributeName(e):this._state===AFTER_ATTRIBUTE_NAME?this._stateAfterAttributeName(e):this._state===BEFORE_ATTRIBUTE_VALUE?this._stateBeforeAttributeValue(e):this._state===IN_ATTRIBUTE_VALUE_DQ?this._stateInAttributeValueDoubleQuotes(e):this._state===IN_ATTRIBUTE_VALUE_SQ?this._stateInAttributeValueSingleQuotes(e):this._state===IN_ATTRIBUTE_VALUE_NQ?this._stateInAttributeValueNoQuotes(e):this._state===BEFORE_DECLARATION?this._stateBeforeDeclaration(e):this._state===IN_DECLARATION?this._stateInDeclaration(e):this._state===IN_PROCESSING_INSTRUCTION?this._stateInProcessingInstruction(e):this._state===BEFORE_COMMENT?this._stateBeforeComment(e):this._state===IN_COMMENT?this._stateInComment(e):this._state===AFTER_COMMENT_1?this._stateAfterComment1(e):this._state===AFTER_COMMENT_2?this._stateAfterComment2(e):this._state===BEFORE_CDATA_1?this._stateBeforeCdata1(e):this._state===BEFORE_CDATA_2?this._stateBeforeCdata2(e):this._state===BEFORE_CDATA_3?this._stateBeforeCdata3(e):this._state===BEFORE_CDATA_4?this._stateBeforeCdata4(e):this._state===BEFORE_CDATA_5?this._stateBeforeCdata5(e):this._state===BEFORE_CDATA_6?this._stateBeforeCdata6(e):this._state===IN_CDATA?this._stateInCdata(e):this._state===AFTER_CDATA_1?this._stateAfterCdata1(e):this._state===AFTER_CDATA_2?this._stateAfterCdata2(e):this._state===BEFORE_SPECIAL?this._stateBeforeSpecial(e):this._state===BEFORE_SPECIAL_END?this._stateBeforeSpecialEnd(e):this._state===BEFORE_SCRIPT_1?this._stateBeforeScript1(e):this._state===BEFORE_SCRIPT_2?this._stateBeforeScript2(e):this._state===BEFORE_SCRIPT_3?this._stateBeforeScript3(e):this._state===BEFORE_SCRIPT_4?this._stateBeforeScript4(e):this._state===BEFORE_SCRIPT_5?this._stateBeforeScript5(e):this._state===AFTER_SCRIPT_1?this._stateAfterScript1(e):this._state===AFTER_SCRIPT_2?this._stateAfterScript2(e):this._state===AFTER_SCRIPT_3?this._stateAfterScript3(e):this._state===AFTER_SCRIPT_4?this._stateAfterScript4(e):this._state===AFTER_SCRIPT_5?this._stateAfterScript5(e):this._state===BEFORE_STYLE_1?this._stateBeforeStyle1(e):this._state===BEFORE_STYLE_2?this._stateBeforeStyle2(e):this._state===BEFORE_STYLE_3?this._stateBeforeStyle3(e):this._state===BEFORE_STYLE_4?this._stateBeforeStyle4(e):this._state===AFTER_STYLE_1?this._stateAfterStyle1(e):this._state===AFTER_STYLE_2?this._stateAfterStyle2(e):this._state===AFTER_STYLE_3?this._stateAfterStyle3(e):this._state===AFTER_STYLE_4?this._stateAfterStyle4(e):this._state===BEFORE_ENTITY?this._stateBeforeEntity(e):this._state===BEFORE_NUMERIC_ENTITY?this._stateBeforeNumericEntity(e):this._state===IN_NAMED_ENTITY?this._stateInNamedEntity(e):this._state===IN_NUMERIC_ENTITY?this._stateInNumericEntity(e):this._state===IN_HEX_ENTITY?this._stateInHexEntity(e):this._cbs.onerror(Error("unknown _state"),this._state),this._index++}this._cleanup()},Tokenizer.prototype.pause=function(){this._running=!1},Tokenizer.prototype.resume=function(){this._running=!0,this._index<this._buffer.length&&this._parse(),this._ended&&this._finish()},Tokenizer.prototype.end=function(e){this._ended&&this._cbs.onerror(Error(".end() after done!")),e&&this.write(e),this._ended=!0,this._running&&this._finish()},Tokenizer.prototype._finish=function(){this._sectionStart<this._index&&this._handleTrailingData(),this._cbs.onend()},Tokenizer.prototype._handleTrailingData=function(){var e=this._buffer.substr(this._sectionStart);this._state===IN_CDATA||this._state===AFTER_CDATA_1||this._state===AFTER_CDATA_2?this._cbs.oncdata(e):this._state===IN_COMMENT||this._state===AFTER_COMMENT_1||this._state===AFTER_COMMENT_2?this._cbs.oncomment(e):this._state!==IN_NAMED_ENTITY||this._xmlMode?this._state!==IN_NUMERIC_ENTITY||this._xmlMode?this._state!==IN_HEX_ENTITY||this._xmlMode?this._state!==IN_TAG_NAME&&this._state!==BEFORE_ATTRIBUTE_NAME&&this._state!==BEFORE_ATTRIBUTE_VALUE&&this._state!==AFTER_ATTRIBUTE_NAME&&this._state!==IN_ATTRIBUTE_NAME&&this._state!==IN_ATTRIBUTE_VALUE_SQ&&this._state!==IN_ATTRIBUTE_VALUE_DQ&&this._state!==IN_ATTRIBUTE_VALUE_NQ&&this._state!==IN_CLOSING_TAG_NAME&&this._cbs.ontext(e):(this._decodeNumericEntity(3,16),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData())):(this._decodeNumericEntity(2,10),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData())):(this._parseLegacyEntity(),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData()))},Tokenizer.prototype.reset=function(){Tokenizer.call(this,{xmlMode:this._xmlMode,decodeEntities:this._decodeEntities},this._cbs)},Tokenizer.prototype.getAbsoluteIndex=function(){return this._bufferOffset+this._index},Tokenizer.prototype._getSection=function(){return this._buffer.substring(this._sectionStart,this._index)},Tokenizer.prototype._emitToken=function(e){this._cbs[e](this._getSection()),this._sectionStart=-1},Tokenizer.prototype._emitPartial=function(e){this._baseState!==TEXT?this._cbs.onattribdata(e):this._cbs.ontext(e)};