Skip to content

Commit

Permalink
Change Tokenizer to recognise inequalities and parse them as text
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbrzn committed Jan 26, 2018
1 parent 3880c5c commit 38ac8da
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/Tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ function Tokenizer(options, cbs){
this._xmlMode = !!(options && options.xmlMode);
this._decodeEntities = !!(options && options.decodeEntities);
this._isMarkdownCode = false;
this._isInequality = false;
}

Tokenizer.prototype._stateText = function(c){
// Parse open tag if it is not Markdown
if(c === "<" && !this._isMarkdownCode){
// Parse open tag if it is not Markdown and not part of an inequality
if(c === "<" && !this._isMarkdownCode && !this._isInequality){
if(this._index > this._sectionStart){
this._cbs.ontext(this._getSection());
}
Expand All @@ -162,6 +163,9 @@ Tokenizer.prototype._stateText = function(c){
this._baseState = TEXT;
this._state = BEFORE_ENTITY;
this._sectionStart = this._index;
} else if(this._isInequality){
// Next character should be parsed normally
this._isInequality = !this._isInequality;
}
};

Expand Down Expand Up @@ -640,6 +644,11 @@ Tokenizer.prototype._parse = function(){
// Detect Markdown code so that it is parsed as text instead of HTML
if(c === '`'){
this._isMarkdownCode = !this._isMarkdownCode;
} else if(c === '<'){
var nextChar = this._buffer.charAt(this._index + 1);
if(nextChar === '='){
this._isInequality = !this._isInequality;
}
}
if(this._state === TEXT) {
this._stateText(c);
Expand Down

0 comments on commit 38ac8da

Please sign in to comment.