//处理空行(由于转义带来)
if(typeof(codeArr[i])=="undefined"||codeArr[i].length==0){
continue;
}
//处理空格
if (codeArr[i] == " "){
htmlTxt[htmlTxt.length] = (" ");
//处理关键字
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isKeyword(codeArr[i])){
htmlTxt[htmlTxt.length] = ("<span>" + codeArr[i] + "</span>");
//处理普通对象
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isCommonObject(codeArr[i])){
htmlTxt[htmlTxt.length] = ("<span>" + codeArr[i] + "</span>");
//处理标记
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && tag_opened && this.isTag(codeArr[i])){
htmlTxt[htmlTxt.length] = ("<span>" + codeArr[i] + "</span>");
//处理换行
} else if (codeArr[i] == "\r"){
if (slash_slash_comment_opened){
htmlTxt[htmlTxt.length] = ("</span>");
slash_slash_comment_opened = false;
}
htmlTxt[htmlTxt.length] = ("<br/>");
line_num++;
//处理双引号(引号前不能为转义字符)
} else if (this._quotation.contains(codeArr[i])&&!slash_star_comment_opened&&!slash_slash_comment_opened){
if (quote_opened){
//是相应的引号
if (quote_char==codeArr[i]){
if(tag_opened){
htmlTxt[htmlTxt.length] = (codeArr[i]+"</span><span>");
} else {
htmlTxt[htmlTxt.length] = (codeArr[i]+"</span>");
}
quote_opened = false;
quote_char = "";
} else {
htmlTxt[htmlTxt.length] = codeArr[i].replace(/\</g,"<");
}
} else {
if (tag_opened){
htmlTxt[htmlTxt.length] = ("</span><span>"+codeArr[i]);
} else {
htmlTxt[htmlTxt.length] = ("<span>"+codeArr[i]);
}
quote_opened = true;
quote_char = codeArr[i];
}
//处理转义字符
} else if(codeArr[i] == this._escape){
htmlTxt[htmlTxt.length] = (codeArr[i]);
if (i<word_index){
if (codeArr[i+1].charCodeAt(0)>=32&&codeArr[i+1].charCodeAt(0)<=127){
htmlTxt[htmlTxt.length] = codeArr[i+1].substr(0,1);
codeArr[i+1] = codeArr[i+1].substr(1);
}
}
//处理Tab
} else if (codeArr[i] == "\t") {
htmlTxt[htmlTxt.length] = (" ");
//处理多行注释的开始
} else if (this.isStartWith(this._commentOn,codeArr,i)&&!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened){
slash_star_comment_opened = true;
htmlTxt[htmlTxt.length] = ("<span>" + this._commentOn.replace(/\</g,"<"));
i = i + this._commentOn.length-1;
//处理单行注释
} else if (this.isStartWith(this._lineComment,codeArr,i)&&!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened){
slash_slash_comment_opened = true;
htmlTxt[htmlTxt.length] = ("<span>" + this._lineComment);
i = i + this._lineComment.length-1;
//处理忽略词
} else if (this.isStartWith(this._ignore,codeArr,i)&&!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened){
slash_slash_comment_opened = true;
htmlTxt[htmlTxt.length] = ("<span>" + this._ignore.replace(/\</g,"<"));
i = i + this._ignore.length-1;
//处理多行注释结束
} else if (this.isStartWith(this._commentOff,codeArr,i)&&!quote_opened&&!slash_slash_comment_opened){
if (slash_star_comment_opened) {
slash_star_comment_opened = false;
htmlTxt[htmlTxt.length] = (this._commentOff +"</span>");
i = i + this._commentOff.length-1;
}
//处理左标记
} else if (this._dealTag&&!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&codeArr[i] == "<") {
htmlTxt[htmlTxt.length] = "<<span>";
tag_opened = true;
//处理右标记
} else if (this._dealTag&&tag_opened&&codeArr[i] == ">") {
htmlTxt[htmlTxt.length] = "</span>>";
tag_opened = false;
//处理HTML转义符号
} else if (codeArr[i] == "&") {
htmlTxt[htmlTxt.length] = "&";
} else {
htmlTxt[htmlTxt.length] = codeArr[i].replace(/\</g,"<");
}
}
htmlTxt[htmlTxt.length] = ("</div>");
return htmlTxt.join("");
}