An open API service indexing awesome lists of open source software.

https://github.com/reshape/beautify

a reshape plugin that pretty-prints your html
https://github.com/reshape/beautify

Last synced: 12 months ago
JSON representation

a reshape plugin that pretty-prints your html

Awesome Lists containing this project

README

          

# Reshape Beautify

[![npm](https://img.shields.io/npm/v/reshape-beautify.svg?style=flat-square)](https://npmjs.com/package/reshape-beautify)
[![tests](https://img.shields.io/travis/reshape/beautify.svg?style=flat-square)](https://travis-ci.org/reshape/beautify?branch=master)
[![dependencies](https://img.shields.io/david/reshape/beautify.svg?style=flat-square)](https://david-dm.org/reshape/beautify)
[![coverage](https://img.shields.io/coveralls/reshape/beautify.svg?style=flat-square)](https://coveralls.io/r/reshape/beautify?branch=master)

A reshape plugin that pretty-prints your html

> **Note:** This project is in early development, and versioning is a little different. [Read this](http://markup.im/#q4_cRZ1Q) for more details.

### Installation

`npm install reshape-beautify --save`

> **Note:** This project is compatible with node v6+ only

### Usage

Add it as a reshape plugin:

```js
const reshape = require('reshape')
const beautify = require('reshape-beautify')

reshape({ plugins: beautify(/* options */) })
.process(htmlString)
.then((res) => console.log(res.output()))
```

...and that's it! You can specify any options as listed below to customize the behavior.

This plugin will ensure that all tags are correctly indented. However, it will not make changes to any tag that contains a plain text node, because this could interfere with the way the content looks. For example, this crappy html:

```html

bad indentation


hi there




```

Would be transformed as such:

```html

bad indentation


hi there


```

Wow, so clean! It will do the same for minified html:

```html

hi there

this is minified

```

Is transformed to:

```html

hi there


this is minified

```

However, if you have something like this:

```html

hello there!
this is great

```

We won't alter the spaces inside your section content, because this would change the way it looks on the page, so it would turn out exactly the same as the input.

### Options

| Name | Description | Default |
| ---- | ----------- | ------- |
| **indent** | Number of spaces to indent your elements | `2` |

### License & Contributing

- Details on the license [can be found here](LICENSE.md)
- Details on running tests and contributing [can be found here](contributing.md)