Home

Awesome

posthtml-beautify

A posthtml plugin to beautify you html files

Travis Build Statusnodenpm versionDependency StatusXO code styleCoveralls status

npm downloadsnpmPackage Quality

Why?

Format your html and inline css markup according to the HTML5 syntax Style Guide, Code Guide. Full list of supported options:

Install

npm i -S posthtml posthtml-beautify

Note: This project is compatible with node v10+

Usage

import {readFileSync, writeFileSync} from 'fs';
import posthtml from 'posthtml';
import beautify from 'posthtml-beautify';

const html = readFileSync('input.html', 'utf8');

posthtml()
  .use(beautify({rules: {indent: 4}}))
  .process(html)
  .then(result => {
    writeFileSync('output.html', result.html);
  });

Returns html-formatted according to rules based on the use HTML5 syntax Style Guide, Code Guide with custom settings indent: 4

Example

Options

rules

Type: Object
Default:

mini

Type: Object
Default:

jsBeautifyOptions

Type: Object
Default: All options as per package js-beautify except, indent_level because calculated and set according to context

Related