jsformat-atom
jsformat-atom copied to clipboard
Support formatting JavaScript inside <script></script> tags
It would be advantageous to supporting the formatting of JavaScript within tags embedded inside of file types other than .js. This would allow embed JavaScript formatting inside of .html/htm documents. The way I envision this working is that some key mapping would be used to trigger the request. The cursor would need to be within the boundaries of an opening/closing pair of script tags which would define the content to be formatted.
JSON and JS are recognized right now. Which ones are missing? I'm thinking that it would just see if there's a script tag and then format whatever's inside the script tag, but maybe that isn't the best idea. Thoughts?
I think you are right. There are none that I can think of I will edit the original request and remove that part.
I've edited the original request and remove the part in question.
@jeffschwartz the main issue is parsing the HTML and making sure a valid <script>
and </script>
are found, and that it makes sense to format. Not sure of any HTML parsers that generate an AST though.
i agree, if the html file doesn't contain script tags there's nothing to format. Not sure abut the AST though.