Skip to content

Commit

Permalink
add:
Browse files Browse the repository at this point in the history
1. support detect file encoding in cli

fix:

1. title-require(rule): report error when `<html><title>test</title><head></head><body></body></html>`
  • Loading branch information
yaniswang committed Oct 9, 2015
1 parent 9e0e780 commit 54a5193
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
12 changes: 11 additions & 1 deletion CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
HTMLHint change log
====================

## ver 0.9.9 (2015-10-10)
## ver 0.9.10 (2015-10-9)

add:

1. support detect file encoding in cli

fix:

1. title-require(rule): report error when `<html><title>test</title><head></head><body></body></html>`

## ver 0.9.9 (2015-10-9)

add:

Expand Down
9 changes: 7 additions & 2 deletions bin/htmlhint
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var fs = require('fs');
var path = require('path');
var stripJsonComments = require('strip-json-comments');
var async = require('async');
var jschardet = require("jschardet");
var iconv = require('iconv-lite');

var HTMLHint = require("../index").HTMLHint;
var pkg = require('../package.json');
Expand Down Expand Up @@ -272,8 +274,11 @@ function walkPath(dir, callback, onFinish) {

// hint file
function hintFile(filepath, ruleset){
var html = fs.readFileSync(filepath, 'utf-8');
return HTMLHint.verify(html, ruleset);
var content = fs.readFileSync(filepath);
// detect encoding
var encoding = jschardet.detect(content).encoding || 'utf-8';
content = iconv.decode(content, encoding);
return HTMLHint.verify(content, ruleset);
}

// repeat string
Expand Down
16 changes: 8 additions & 8 deletions lib/htmlhint.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "htmlhint",
"version": "0.9.9",
"version": "0.9.10",
"description": "A Static Code Analysis Tool for HTML",
"main": "./index",
"dependencies": {
"async": "1.4.2",
"colors": "1.0.3",
"commander": "2.6.0",
"csslint": "0.10.0",
"iconv-lite": "^0.4.13",
"jschardet": "1.3.0",
"jshint": "2.8.0",
"strip-json-comments": "1.0.4"
},
Expand Down

0 comments on commit 54a5193

Please sign in to comment.