js-beautify indent block of JavaScript compared to HTML


js-beautify indent block of JavaScript compared to HTML



I am using js-beautify to format eynamically generated HTML that includes a script block that contains JavaScript. Sense the method to format HTML is different than formatting JS, I do this:


htmlText1 = html_beautify(htmlText1, { "indent_size": 2 });
jsText = js_beautify(jsText, { "indent_size": 2 });
htmlText2 = html_beautify(htmlText2, { "indent_size": 2 });
allFormattedCode = htmlText1 + 'n' + jsText + 'n' + htmlText2;



It is formatted nicely, except the JS is at the left margin. Is there some way to indent all the code in the script block X number of spaces?



Thanks!
-Matt









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?