Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translated chinese comments #265

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ module.exports = function(grunt) {
date = new Date();
}
var map = {
"M": date.getMonth() + 1, //月份
"d": date.getDate(), //
"h": date.getHours(), //小时
"m": date.getMinutes(), //
"s": date.getSeconds(), //
"q": Math.floor((date.getMonth() + 3) / 3), //季度
"S": date.getMilliseconds() //毫秒
"M": date.getMonth() + 1, // Monat
"d": date.getDate(), // Tag
"h": date.getHours(), // Hour
"m": date.getMinutes(), // Minute
"s": date.getSeconds(), // Second
"q": Math.floor((date.getMonth() + 3) / 3), // Quarter
"S": date.getMilliseconds() // Millisecond
};
format = format.replace(/([yMdhmsqS])(\1)*/g, function(all, t){
var v = map[t];
Expand Down
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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