Search code examples
javascriptpluginsjs-beautify

How to use options in js-beautify plugin


JS noob here. I'm currently using js-beautify(https://github.com/beautify-web/js-beautify) plugin to properly indent/format a long string of HTML code. This is how I'm using it

html_beautify(HTML);

HTML is a variable containing regular HTML code. How can I pass options like disabling word-wrap or removing empty lines?


Solution

  • It looks like you can add an object as the second parameter to handle your options:

    html_beautify(elHTML, { preserve_newlines: false, wrap_line_length: 0 });