welovewordpress / SublimeHtmlTidy

Tidy, clean and prettify your HTML code with this plugin for Sublime Text 2
GNU General Public License v2.0
88 stars 15 forks source link

comment formatting way off #26

Open robdodson opened 11 years ago

robdodson commented 11 years ago

everything seems to work great except for when I try to format a page with comments. maybe this is just a problem with Tidy in general?

welovewordpress commented 11 years ago

I'm afraid you are right. Tidy does work well only if it's dealing with pure html. Embedded comments seem to be handled the same as embedded javascipt or php - which is not well.

Some time ago I had the idea of writing a kind of "pre / post processor" which would let Tidy only tidy the HTML while sending embedded snippets of PHP and JS to phptidy etc. But never found the time so far...

If anyone has an idea or advice for some improvement in this area, I'd appreciate it.

Matt

robdodson commented 11 years ago

It seems like there's no HTML formatting option out there that can handle comments well. At least nothing that works with Sublime. Sounds like a pre/post processor is the best option. Capturing comments and other snippets of code, indicating their spot in the markup, running tidy and inserting them again at the right indentation level. I feel like I could write something like this in Ruby but my Python knowledge is next to non-existent. Would a Ruby script help you?