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
- Host: GitHub
- URL: https://github.com/reshape/beautify
- Owner: reshape
- License: other
- Created: 2016-08-23T17:18:09.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-02-05T12:45:43.000Z (over 7 years ago)
- Last Synced: 2025-06-13T20:53:30.038Z (about 1 year ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 9
- Watchers: 1
- Forks: 8
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Contributing: contributing.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Reshape Beautify
[](https://npmjs.com/package/reshape-beautify)
[](https://travis-ci.org/reshape/beautify?branch=master)
[](https://david-dm.org/reshape/beautify)
[](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)