diff --git a/src/core.js b/src/core.js index f9da415b8..3a3da57fe 100644 --- a/src/core.js +++ b/src/core.js @@ -12,7 +12,7 @@ var HTMLHint = (function (undefined) { HTMLHint.rules = {}; - //默认配置 + // standard configuration HTMLHint.defaultRuleset = { 'tagname-lowercase': true, 'attr-lowercase': true, diff --git a/src/htmlparser.js b/src/htmlparser.js index 0b2302a7a..9b6da399f 100644 --- a/src/htmlparser.js +++ b/src/htmlparser.js @@ -49,19 +49,19 @@ var HTMLParser = (function(undefined){ while((match = regTag.exec(html))){ matchIndex = match.index; - if(matchIndex > lastIndex){//保存前面的文本或者CDATA + if(matchIndex > lastIndex){// Save the previous text or CDATA text = html.substring(lastIndex, matchIndex); if(tagCDATA){ arrCDATA.push(text); } - else{//文本 + else{// text saveBlock('text', text, lastIndex); } } lastIndex = regTag.lastIndex; if((tagName = match[1])){ - if(tagCDATA && tagName === tagCDATA){//结束标签前输出CDATA + if(tagCDATA && tagName === tagCDATA){// Output CDATA before closing the label text = arrCDATA.join(''); saveBlock('cdata', text, lastCDATAIndex, { 'tagName': tagCDATA, @@ -72,7 +72,7 @@ var HTMLParser = (function(undefined){ arrCDATA = null; } if(!tagCDATA){ - //标签结束 + // End of label saveBlock('tagend', match[0], matchIndex, { 'tagName': tagName }); @@ -84,7 +84,7 @@ var HTMLParser = (function(undefined){ arrCDATA.push(match[0]); } else{ - if((tagName = match[4])){//标签开始 + if((tagName = match[4])){// Label start arrAttrs = []; var attrs = match[5], attrMatch, @@ -112,11 +112,11 @@ var HTMLParser = (function(undefined){ lastCDATAIndex = lastIndex; } } - else{//如果出现漏匹配,则把当前内容匹配为text + else{// If a miss match occurs, the current content is matched to text saveBlock('text', match[0], matchIndex); } } - else if(match[2] || match[3]){//注释标签 + else if(match[2] || match[3]){// Comment tag saveBlock('comment', match[0], matchIndex, { 'content': match[2] || match[3], 'long': match[2]?true:false @@ -126,7 +126,7 @@ var HTMLParser = (function(undefined){ } if(html.length > lastIndex){ - //结尾文本 + // End text text = html.substring(lastIndex, html.length); saveBlock('text', text, lastIndex); } @@ -137,7 +137,7 @@ var HTMLParser = (function(undefined){ col: html.length - lastLineIndex + 1 }); - //存储区块 + // Memory block function saveBlock(type, raw, pos, data){ var col = pos - lastLineIndex + 1; if(data === undefined){ diff --git a/src/rules/tag-pair.js b/src/rules/tag-pair.js index 060e941b9..bb51e2108 100644 --- a/src/rules/tag-pair.js +++ b/src/rules/tag-pair.js @@ -21,7 +21,7 @@ HTMLHint.addRule({ }); parser.addListener('tagend', function(event){ var tagName = event.tagName.toLowerCase(); - //向上寻找匹配的开始标签 + // Look up the matching start tag for(var pos = stack.length-1;pos >= 0; pos--){ if(stack[pos].tagName === tagName){ break;