gulp plugin formatting html via js-beautify.
npm install gulp-format-html

``shell`
npm install gulp-format-html -D
`shell`
yarn add gulp-format-html -D
`shell`
pnpm add gulp-format-html -D
`jsgulp-format-html
const gulp = require('gulp')
const formatHTML = require('gulp-format-html')
// or
// const { formatHTML } = require()
function views() {
return gulp.src('views/*/.html').pipe(formatHTML()).pipe(gulp.dest('dist'))
}
exports.dev = gulp.series(views)
`
`ts
import gulp from 'gulp'
import formatHTML from 'gulp-format-html'
// or
// import { formatHTML } from 'gulp-format-html'
function views() {
return gulp.src('views/*/.html').pipe(formatHTML()).pipe(gulp.dest('dist'))
}
export const dev = gulp.series(views)
`
Input:
spanbstrongem
`html`I am h1 in header
Output:
`html
span
b
strong
em
Options
gulp-format-html is based on js-beautify, Check it's HTML options for detail.
$3
- type
boolean
- default false`Display name of file from stream that is being formatting
- gulp-diffable-html Zero config HTML formatter to make HTML more readable and to indent HTML tag text in a single newline.