Skip to content

Commit

Permalink
style: translated chinese comments (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami authored and thedaviddias committed Aug 24, 2018
1 parent 24fb1cd commit 4115caa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/core.js
Expand Up @@ -12,7 +12,7 @@ var HTMLHint = (function (undefined) {

HTMLHint.rules = {};

//默认配置
// standard configuration
HTMLHint.defaultRuleset = {
'tagname-lowercase': true,
'attr-lowercase': true,
Expand Down
18 changes: 9 additions & 9 deletions src/htmlparser.js
Expand Up @@ -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,
Expand All @@ -72,7 +72,7 @@ var HTMLParser = (function(undefined){
arrCDATA = null;
}
if(!tagCDATA){
//标签结束
// End of label
saveBlock('tagend', match[0], matchIndex, {
'tagName': tagName
});
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -126,7 +126,7 @@ var HTMLParser = (function(undefined){
}

if(html.length > lastIndex){
//结尾文本
// End text
text = html.substring(lastIndex, html.length);
saveBlock('text', text, lastIndex);
}
Expand All @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion src/rules/tag-pair.js
Expand Up @@ -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;
Expand Down

0 comments on commit 4115caa

Please sign in to comment.