Skip to content

boushley/metalsmith-beautify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

metalsmith-beautify

A Metalsmith plugin to format html, css and js.

Installation

$ npm install metalsmith-beautify

Config options

You can pass general options in the options object that will be used for all types of beautification. To see what options are available check the js-beautify tool.

For options that are specific to one language type create a nested object with that types name. To disable formatting of a specific file type set that type to false.

The three file types that are supported are html, javascript and css.

Example Configs

If you want to avoid formatting css and html you would pass this options object:

{
    "css": false,
    "html": false
}

If you want to use four spaces for most indentation, but only two spaces in javascript you would pass this:

{
    "indent_size": 4,
    "indent_char": " ",
    "js": {
        "indent_size": 2
    }
}

CLI Usage

Install via npm and then add the metalsmith-beautify key to your metalsmith.json plugins with any js-beautify options you want, like so:

{
  "plugins": {
    "metalsmith-beautify": {
        "css": false,
        "preserve_newlines": false
    }
  }
}

Javascript Usage

Pass options to the beautify plugin and pass it to Metalsmith with the use method:

var beautify = require('metalsmith-beautify');

metalsmith.use(beautify({
    "js": false,
    "html": {
        "wrap_line_length": 80
    }
}));

License

MIT

Credit

The credit for the heavy lifting here goes to the js-beautify tool.

About

A Metalsmith plugin to format html / js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published