diff --git a/.htmllintrc b/.htmllintrc
new file mode 100644
index 00000000..8dd595d8
--- /dev/null
+++ b/.htmllintrc
@@ -0,0 +1,8 @@
+{
+ "doctype-first": "none",
+ "line-end-style": "none",
+ "spec-char-escape": true,
+ "id-no-dup": true,
+ "class-style": "none",
+ "attr-name-style": "none"
+}
\ No newline at end of file
diff --git a/bower.json b/bower.json
index cfb3d350..78e5cd9b 100644
--- a/bower.json
+++ b/bower.json
@@ -8,6 +8,9 @@
"type": "git",
"url": "https://github.com/OfficeDev/Office-UI-Fabric"
},
+ "dependencies": {
+ "htmltidy": "https://github.com/battletoilet/gulp-htmltidy.git"
+ },
"private": false,
"ignore": [
"node_modules",
diff --git a/gulp/FabricComponents.js b/gulp/FabricComponents.js
index 2a039a42..f321d2fd 100644
--- a/gulp/FabricComponents.js
+++ b/gulp/FabricComponents.js
@@ -35,32 +35,37 @@ gulp.task('FabricComponents-copyAssets', function () {
.pipe(gulp.dest(Config.paths.distComponents));
});
-
-function htmllintReporter(filepath, issues) {
- if (issues.length > 0) {
- issues.forEach(function (issue) {
- gulputil.log(gulputil.colors.cyan('[gulp-htmllint] ') + gulputil.colors.white(filepath + ' [' + issue.line + ',' + issue.column + ']: ') + gulputil.colors.red('(' + issue.code + ') ' + issue.msg));
- });
-
- process.exitCode = 1;
- }
-}
-
gulp.task('FabricComponents-copyAndParseHTML', function () {
// Copy all Components files.
return gulp.src(Config.paths.componentsPath + '/**/*.html')
// Run HTML Tidy
- .pipe(Plugins.htmllint({
- config: {
- 'doctype-first': false,
- 'line-end-style': false,
- 'spec-char-escape': true,
- 'id-no-dup': true,
- 'class-style': false,
- 'attr-name-style': false
- }
- }, htmllintReporter))
+ // .pipe(Plugins.htmllint({config: Config.htmlLintPath}, ErrorHandling.handlHTMLLintError))
+ .pipe(Plugins.verifyHTML({
+ showErrors: true,
+ showWarnings: true,
+ "doctype": "omit",
+ "drop-empty-elements": false,
+ "drop-empty-paras": false,
+ }, function(err, html) {
+ var newError = '';
+ // console.log(err);
+
+ newError = err.replace('About this fork of Tidy: http://w3c.github.com/tidy-html5/', '');
+ newError = newError.replace('Bug reports and comments: https://github.com/w3c/tidy-html5/issues/', '');
+ newError = newError.replace('Or send questions and comments to html-tidy@w3.org', '');
+ newError = newError.replace('Latest HTML specification: http://dev.w3.org/html5/spec-author-view/', '');
+ newError = newError.replace('HTML language reference: http://dev.w3.org/html5/markup/', '');
+ newError = newError.replace('Validate your HTML5 documents: http://validator.w3.org/nu/', '');
+ newError = newError.replace('Lobby your company to join the W3C: http://www.w3.org/Consortium', '');
+
+ if(newError.indexOf("\n") > -1) {
+ console.log("Found error");
+ }
+
+ console.log(newError);
+
+ }))
.on('error', ErrorHandling.onErrorInPipe)
.pipe(Plugins.changed(Config.paths.distComponents))
.on('error', ErrorHandling.onErrorInPipe)
diff --git a/gulp/gulpPlugins/GulpVerifyHTML.js b/gulp/gulpPlugins/GulpVerifyHTML.js
index d8b33a66..5fa2550f 100644
--- a/gulp/gulpPlugins/GulpVerifyHTML.js
+++ b/gulp/gulpPlugins/GulpVerifyHTML.js
@@ -1,10 +1,10 @@
var gutil = require('gulp-util');
var through = require('through2');
-var tidy = require("tidy-html5").tidy_html5;
+var tidy = require("htmltidy").tidy;
const PLUGIN_NAME = 'GulpVerifyHTML';
-var VerifyHTML = function(options) {
+var VerifyHTML = function(options, callback) {
return through.obj(function (fileChunk, enc, cb) {
if (!options) {
@@ -21,7 +21,7 @@ var VerifyHTML = function(options) {
return cb();
}
- var result = tidy(fileChunk.contents, options);
+ var result = tidy(fileChunk.contents, options, callback);
fileChunk.contents = new Buffer(String(result));
this.push(fileChunk);
diff --git a/gulp/modules/Config.js b/gulp/modules/Config.js
index 30510537..5494906c 100644
--- a/gulp/modules/Config.js
+++ b/gulp/modules/Config.js
@@ -5,6 +5,9 @@ var Config = function() {
//Debug Mode
this.debugMode = false;
+ // HTML Linting Configuration path
+ this.htmlLintPath = '.htmllintrc';
+
// Define paths.
this.distPath = 'dist';
this.srcPath = 'src';
diff --git a/gulp/modules/ErrorHandling.js b/gulp/modules/ErrorHandling.js
index f05c8471..564c40d3 100644
--- a/gulp/modules/ErrorHandling.js
+++ b/gulp/modules/ErrorHandling.js
@@ -1,4 +1,6 @@
var path = require('path');
+var gulputil = require('gulp-util');
+
var ErrorHandling = function() {
this.onErrorInPipe = function(error) {
console.log(error);
@@ -7,6 +9,15 @@ var ErrorHandling = function() {
console.log(error);
console.log("Html error occured");
}
+ this.handlHTMLLintError = function(filepath, issues) {
+ if (issues.length > 0) {
+ issues.forEach(function (issue) {
+ gulputil.log(gulputil.colors.cyan('[gulp-htmllint] ') + gulputil.colors.white(filepath + ' [' + issue.line + ',' + issue.column + ']: ') + gulputil.colors.red('(' + issue.code + ') ' + issue.msg));
+ });
+
+ process.exitCode = 1;
+ }
+ }
}
module.exports = new ErrorHandling();
\ No newline at end of file
diff --git a/package.json b/package.json
index 20382fc5..ebd6f838 100644
--- a/package.json
+++ b/package.json
@@ -50,6 +50,7 @@
"gulp-wrap": "^0.11.0",
"gulp-zip": "^3.0.2",
"htmltidy": "0.0.6",
+ "htmltidy2": "^0.1.4",
"lodash": "^3.10.1",
"merge-stream": "^1.0.0",
"pretty-hrtime": "0.2.2",