forked from validator/grunt-html
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7eb5537
Showing
11 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2012 Jörn Zaefferer | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# grunt-html | ||
|
||
[Grunt][grunt] plugin for html validation, using [Mike Smith's vnu.jar][vnujar]. | ||
|
||
## Getting Started | ||
Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-html` | ||
|
||
Then add this line to your project's `grunt.js` gruntfile: | ||
|
||
```javascript | ||
grunt.loadNpmTasks('grunt-html'); | ||
``` | ||
|
||
Then specify what files to validate in your config: | ||
|
||
```javascript | ||
grunt.initConfig({ | ||
html: { | ||
all: ["demos/**/*.html", "tests/**/*.html"] | ||
} | ||
}); | ||
``` | ||
|
||
For fast validation, keep that in a single group, as the validator initialization takes a few seconds. | ||
|
||
[grunt]: https://github.com/cowboy/grunt | ||
[getting_started]: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md | ||
[vnujar]: https://bitbucket.org/sideshowbarker/vnu/ | ||
|
||
## Release History | ||
* 0.1.0 First Release | ||
|
||
## License | ||
Copyright (c) 2012 Jörn Zaefferer | ||
Licensed under the MIT license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module.exports = function(grunt) { | ||
|
||
// Project configuration. | ||
grunt.initConfig({ | ||
html: { | ||
valid: "test/valid.html", | ||
invalid: "test/*.html" | ||
}, | ||
test: { | ||
files: ['test/**/*.js'] | ||
}, | ||
lint: { | ||
files: ['grunt.js', 'tasks/**/*.js', 'test/**/*.js'] | ||
}, | ||
watch: { | ||
files: '<config:lint.files>', | ||
tasks: 'default' | ||
}, | ||
jshint: { | ||
options: { | ||
curly: true, | ||
eqeqeq: true, | ||
immed: true, | ||
latedef: true, | ||
newcap: true, | ||
noarg: true, | ||
sub: true, | ||
undef: true, | ||
boss: true, | ||
eqnull: true, | ||
node: true, | ||
es5: true | ||
}, | ||
globals: {} | ||
} | ||
}); | ||
|
||
// Load local tasks. | ||
grunt.loadTasks('tasks'); | ||
|
||
// Default task. | ||
grunt.registerTask('default', 'lint test'); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "grunt-html", | ||
"description": "Grunt plugin for html validation, using vnu.jar for the actual validation", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/jzaefferer/grunt-html", | ||
"author": { | ||
"name": "Jörn Zaefferer", | ||
"email": "[email protected]" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/jzaefferer/grunt-html.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/jzaefferer/grunt-html/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/jzaefferer/grunt-html/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"main": "grunt.js", | ||
"engines": { | ||
"node": "*" | ||
}, | ||
"scripts": { | ||
"test": "grunt test" | ||
}, | ||
"dependencies": { | ||
"grunt": "~0.3.9" | ||
}, | ||
"devDependencies": { | ||
"grunt": "~0.3.9" | ||
}, | ||
"keywords": [ | ||
"gruntplugin" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* grunt-html | ||
* https://github.com/jzaefferer/grunnt-html | ||
* | ||
* Copyright (c) 2012 Jörn Zaefferer | ||
* Licensed under the MIT license. | ||
*/ | ||
|
||
module.exports = function(grunt) { | ||
|
||
// Please see the grunt documentation for more information regarding task and | ||
// helper creation: https://github.com/cowboy/grunt/blob/master/docs/toc.md | ||
|
||
// ========================================================================== | ||
// TASKS | ||
// ========================================================================== | ||
|
||
grunt.registerMultiTask('html', 'Validate html files', function() { | ||
var done = this.async(), | ||
files = grunt.file.expand(this.file.src); | ||
grunt.helper('html', files, function(error, result) { | ||
if (error) { | ||
grunt.log.error(error); | ||
done(false); | ||
return; | ||
} | ||
if (!result.length) { | ||
grunt.log.writeln(files.length + ' file(s) valid'); | ||
done(); | ||
return; | ||
} | ||
grunt.log.writeln(result.join('\n')); | ||
done(false); | ||
}); | ||
}); | ||
|
||
// ========================================================================== | ||
// HELPERS | ||
// ========================================================================== | ||
|
||
grunt.registerHelper('html', function(files, done) { | ||
var jar = __dirname + '/../vnu.jar'; | ||
grunt.utils.spawn({ | ||
cmd: 'java', | ||
args: ['-Dnu.validator.client.quiet=yes', '-jar', jar].concat(files) | ||
}, function(error, output) { | ||
if (error) { | ||
done(error); | ||
return; | ||
} | ||
var result = []; | ||
if (output.stdout) { | ||
result = output.stdout.split('\n'); | ||
} | ||
done(null, result); | ||
}); | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var grunt = require('grunt'); | ||
|
||
exports['html'] = { | ||
setUp: function(done) { | ||
// setup here | ||
done(); | ||
}, | ||
'helper': function(test) { | ||
test.expect(1); | ||
// tests here | ||
grunt.helper('html', ['test/valid.html', 'test/invalid.html'], function(error, result) { | ||
if (error) { | ||
throw error; | ||
} | ||
test.deepEqual(result, [ | ||
'"test/invalid.html":10.1-10.81: error: An "img" element must have an "alt" attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images.', | ||
'"test/invalid.html":12.1-12.19: error: The "clear" attribute on the "br" element is obsolete. Use CSS instead.', | ||
'"test/invalid.html": info warning: The character encoding of the document was not declared.' | ||
], 'three errors from test/invalid.html'); | ||
test.done(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>jQuery UI Autocomplete - Custom data and display</title> | ||
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> | ||
<script src="../../jquery-1.7.2.js"></script> | ||
</head> | ||
<body> | ||
|
||
<img id="project-icon" src="images/transparent_1x1.png" class="ui-state-default"> | ||
|
||
<br clear="both" /> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>jQuery UI Autocomplete - Custom data and display</title> | ||
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> | ||
<script src="../../jquery-1.7.2.js"></script> | ||
</head> | ||
<body> | ||
|
||
<img id="project-icon" src="images/transparent_1x1.png" class="ui-state-default" alt="default"> | ||
|
||
<br style="clear:both" /> | ||
|
||
</body> | ||
</html> |
Binary file not shown.