Re: Tidy support for JavaScript

On 7 May 2009, at 2:51 am, Ivor O'Connor wrote:

>
>
> ---------- Forwarded message ----------
> From: Ivor O'Connor <ivor.oconnor@gmail.com>
> Date: Wed, May 6, 2009 at 7:46 AM
> Subject: Re: Tidy support for JavaScript
> To: Arnaud Desitter <arnaud02@users.sourceforge.net>
>
>
> Hmmm. A tool for pretty printing html and no support for what is  
> almost always contained in html?

(1) Tidy is NOT a tool for pretty-printing HTML.
     It is a tool for FIXING broken HTML, as produced
     by far too many tools (including commercial ones).

(2) It may be the case that JavaScript is almost always
     contained in HTML -- the JavaScript that I've done
     isn't, but let it pass -- but it does not follow that
     HTML almost always contains JavaScript.  I just wrote
     a wee program to check for "<script " and got found
     that about 41% of >100,000 HTML files on my machine
     contained scripts.  YMMV of course.

(3) JavaScript syntax is much more complicated than HTML syntax
     and has changed quite a bit over the last 10 years.
     At least for HTML, there is a rough consensus about what
     pretty-printing amounts to -- although it _is_ only a
     _rough_ consensus -- while for programming languages like
     JavaScript there is much less agreement.

(4) If you keep your JavaScript in separate .js files, where
     it belongs, you can use http://jsbeautifier.org/ to
     tidy it.  (Or any of several others, of course.)

Received on Tuesday, 12 May 2009 00:47:02 UTC