JsFormat icon indicating copy to clipboard operation
JsFormat copied to clipboard

Support formatting of inline javascript in HTML files

Open maurice-schleussinger opened this issue 9 years ago • 5 comments

It would be nice to be able to format inline javascript in HTML files by selecting a code block and pressing a key combination or entering a command in the command palette.

maurice-schleussinger avatar Nov 02 '15 15:11 maurice-schleussinger

i would be ok with this. you used to be able to do this, but too many people tried to format the whole file, which obviously screwed up html content.

I dont want to start doing any html parsing right now though. So, we would need to only allow formatting of highlighted code in html files.

On Mon, Nov 2, 2015, 9:38 AM Maurice Schleußinger [email protected] wrote:

It would be nice to be able to format inline javascript in HTML files by selecting a code block and pressing a key combination or entering a command in the command palette.

— Reply to this email directly or view it on GitHub https://github.com/jdc0589/JsFormat/issues/156.

jdavisclark avatar Nov 02 '15 15:11 jdavisclark

Well people should be able to decide themselves when to use the formatter, right (not talking about format-on-save)? If they do it wrong manually, undo is just a step away...

maurice-schleussinger avatar Nov 02 '15 16:11 maurice-schleussinger

agreed, but I don't see a reason to ever allow formatting an entire html file without a selection (feel free to correct me if I'm missing something though).

Ideally, we could parse out javascript tags from the current html file and format all of those, but I'm not sure if I want to do that right now.

On Mon, Nov 2, 2015 at 10:02 AM Maurice Schleußinger < [email protected]> wrote:

Well people should be able to decide themselves when to use the formatter, right (not talking about format-on-save)? If they do it wrong manually, undo is just a step away...

— Reply to this email directly or view it on GitHub https://github.com/jdc0589/JsFormat/issues/156#issuecomment-153062425.

jdavisclark avatar Nov 02 '15 17:11 jdavisclark

i would be ok with this. you used to be able to do this, but too many people tried to format the whole file, which obviously screwed up html content.

How about just allowing it via the command palette then?

HTMLBeautify allows formatting of select text like this:

screenshot 2016-05-24 15 32 04

maurice-schleussinger avatar May 24 '16 13:05 maurice-schleussinger

@M4urice I think I'm ok with that. It also solves the problem of quickly formatting some throw-away content being a 2-step process (set syntax, format).

jdavisclark avatar May 24 '16 13:05 jdavisclark