npm install prettify-xml> Pretty print xml.
This is a small package that synchronously pretty prints XML/HTML.
js
const prettifyXml = require('prettify-xml')const input = '
foo
bar
'const expectedOutput = [
'
',
' foo
',
' bar
',
'',
].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)
``