diff --git a/lib/Tokenizer.js b/lib/Tokenizer.js index 93996c5..cd0d27f 100644 --- a/lib/Tokenizer.js +++ b/lib/Tokenizer.js @@ -503,19 +503,17 @@ Parser.prototype._write = function(chunk, encoding, cb){ this._emitIfToken("text"); this._buffer = null; this._index = 0; + } else if(this._sectionStart === this._index - 1){ + //the section just started + this._buffer = null; + this._index = 0; } else { - if(this._sectionStart === this._index - 1){ - //the section just started - this._buffer = null; - this._index = 0; - } else { - //remove everything unnecessary - this._buffer = this._buffer.slice(this._sectionStart); - this._index -= this._sectionStart; - } - - this._sectionStart = 0; + //remove everything unnecessary + this._buffer = this._buffer.slice(this._sectionStart); + this._index -= this._sectionStart; } + + this._sectionStart = 0; } cb();