prettify-xml
Version:
Pretty-print XML.
34 lines (24 loc) • 1.49 kB
Markdown
# prettify-xml
[](https://travis-ci.org/jonathanewerner/prettify-xml)
[](https://codecov.io/github/jonathanewerner/prettify-xml)
[](http://npm.im/prettify-xml)
[](http://npm-stat.com/charts.html?package=prettify-xml&from=2015-08-01)
[](http://opensource.org/licenses/MIT)
[](http://makeapullrequest.com)
[](http://commitizen.github.io/cz-cli/)
> Pretty print xml.
This is a small package that synchronously pretty prints XML/HTML.
## Usage
```js
const prettifyXml = require('prettify-xml')
const input = '<div><p>foo</p><p>bar</p></div>'
const expectedOutput = [
'<div>',
' <p>foo</p>',
' <p>bar</p>',
'</div>',
].join('\n')
const options = {indent: 2, newline: '\n'} // 2 spaces is default, newline defaults to require('os').EOL
const output = prettifyXml(input, options) // options is optional
assert(output === expectedOutput)
```