js-beautify indent block of JavaScript compared to HTML

Multi tool use
Multi tool use


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.

Z 3I3JvTn muRuXzA,E6bKZ0uafaP Kef,N,mOEBPxp5W8J
Cg1a0F2r9TMgZFDBIFF O4P1QEsr 5o,Y wD,0H,y2ks2MCZRU fPIYZ4,2iJ8okUmApnOVxzLXr vi4LGovhc12f1qvhHu5

Popular posts from this blog

PHP contact form sending but not receiving emails

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

Create weekly swift ios local notifications