jsformat-atom icon indicating copy to clipboard operation
jsformat-atom copied to clipboard

Support formatting JavaScript inside <script></script> tags

Open jeffschwartz opened this issue 10 years ago • 5 comments

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.

jeffschwartz avatar Dec 11 '14 17:12 jeffschwartz

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?

ilanbiala avatar Dec 11 '14 18:12 ilanbiala

I think you are right. There are none that I can think of I will edit the original request and remove that part.

jeffschwartz avatar Dec 11 '14 18:12 jeffschwartz

I've edited the original request and remove the part in question.

jeffschwartz avatar Dec 11 '14 18:12 jeffschwartz

@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.

ilanbiala avatar Dec 24 '14 20:12 ilanbiala

i agree, if the html file doesn't contain script tags there's nothing to format. Not sure abut the AST though.

jeffschwartz avatar Dec 25 '14 12:12 jeffschwartz