jdavisclark / JsFormat

Javascript formatting for Sublime Text 2 & 3
1.42k stars 222 forks source link

Support formatting of inline javascript in HTML files #156

Open maurice-schleussinger opened 9 years ago

maurice-schleussinger commented 9 years ago

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.

jdavisclark commented 9 years ago

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 notifications@github.com 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.

maurice-schleussinger commented 9 years ago

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

jdavisclark commented 9 years ago

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 < notifications@github.com> 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.

maurice-schleussinger commented 8 years ago

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
jdavisclark commented 8 years ago

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