gulp-htmltidy
v0.2.4
Published
Node Wrapper for HTML Tidy
Downloads
353
Readme
gulp-htmltidy
HTML Tidy is an open source program for checking and generating clean XHTML/HTML. It cleans up coding errors in HTML files and fixes bad formatting. It can output files in the HTML, XHTML or XML file format.
Using HTML Tidy, developers can programatically clean up and fix poorly-written HTML pages. Another use is to convert HTML to XHTML or XML. These files can then be easily processed using the tools in the traditional XML chain, such as XSL transforms.
Uses the htmltidy2 library.
How It Works
/path/to/file.html
:
<html>
<head>
<style>
p { color: red; }
</style>
</head>
<body>
<!-- ===== body ====== -->
<p>Test</p>
</body>
<!--Default Zone
-->
<!--Default Zone End-->
</html>
Output:
<!DOCTYPE html>
<html>
<head>
<style>
p { color: red; }
</style>
<title></title>
</head>
<body>
<p>Test</p>
</body>
</html>
Install
Install with npm
npm install --save-dev gulp-htmltidy
Usage
var gulp = require('gulp'),
htmltidy = require('gulp-htmltidy');
gulp.task('default', function() {
return gulp.src('./*.html')
.pipe(htmltidy())
.pipe(gulp.dest('build/'));;
});
With options:
var gulp = require('gulp'),
htmltidy = require('htmltidy');
gulp.task('default', function() {
return gulp.src('./*.html')
.pipe(htmltidy({doctype: 'html5',
hideComments: true,
indent: false}))
.pipe(gulp.dest('build/'));;
});
Clean html like text according optional configuration tidy options.
API
htmltidy(options)
options.doctype
Type: String
options.hideComments
Type: Boolean
Default: false
options.indent
Type: Boolean
Default: false