3.0.0 • Published 5 months ago

@ntnyq/gulp-prettyhtml v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@ntnyq/gulp-prettyhtml

NPM VERSION NPM DOWNLOADS

Install

npm install @ntnyq/gulp-prettyhtml -D
yarn add @ntnyq/gulp-prettyhtml -D
pnpm add @ntnyq/gulp-prettyhtml -D

Setup

const gulp = require('gulp')
const prettyHTML = require('@ntnyq/gulp-prettyhtml')
// or
// const { prettyHTML } = require(`@ntnyq/gulp-prettyhtml`)

function views() {
  return gulp.src('views/**/*.html').pipe(prettyHTML()).pipe(gulp.dest('dist'))
}

exports.dev = gulp.series(views)
import gulp from 'gulp'
import prettyHTML from '@ntnyq/gulp-prettyhtml'
// or
// import { prettyHTML } from '@ntnyq/gulp-prettyhtml'

function views() {
  return gulp.src('views/**/*.html').pipe(prettyHTML()).pipe(gulp.dest('dist'))
}

export const dev = gulp.series(views)

Example

Input:

<!DOCTYPE html><!--[if IE 9]>.... some HTML here ....<![endif]--><html lang="en"><head><meta charset="UTF-8"><title>@ntnyq/gulp-prettyhtml</title></head><body><header><h1><span>I am h1 in header</span></h1></header><main><p><!----><span></span><b>b</b><strong>strong</strong><em>&copy;</em></p></main><footer><p><a href="https://github.com/ntnyq/gulp-plugins/tree/main/packages/@ntnyq/gulp-prettyhtml" target="_blank" rel="noopener" >gulp-prettyhtml</a></p></footer></body></html>

Output:

<!doctype html>
<!--[if IE 9]>.... some HTML here ....<![endif]-->

<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>@ntnyq/gulp-prettyhtml</title>
</head>
<body>
  <header>
    <h1>
      <span>I am h1 in header</span>
    </h1>
  </header>
  <main>
    <p>
      <!---->
      <span></span>
      <b>b</b>
      <strong>strong</strong>
      <em>&copy;</em>
    </p>
  </main>
  <footer>
    <p>
      <a
        href="https://github.com/ntnyq/gulp-plugins/tree/main/packages/gulp-prettyhtml"
        target="_blank"
        rel="noopener"
      >@ntnyq/gulp-prettyhtml</a>
    </p>
  </footer>
</body>
</html>

Options

@ntnyq/gulp-prettyhtml is based on @starptech/prettyhtml. All it's options is supported.

verbose

  • type boolean
  • default false

Display name of file from stream that is being formatting

Related

  • gulp-diffable-html Zero config HTML formatter to make HTML more readable and to indent HTML tag text in a single newline.