Re: Tidy support for JavaScript

"Richard O'Keefe" <[email protected]>
Newsgroups gmane.comp.web.html-tidy.user
Message-ID <[email protected]>
On 7 May 2009, at 2:51 am, Ivor O'Connor wrote:

>
>
> ---------- Forwarded message ----------
> From: Ivor O'Connor <[email protected]>
> Date: Wed, May 6, 2009 at 7:46 AM
> Subject: Re: Tidy support for JavaScript
> To: Arnaud Desitter <[email protected]>
>
>
> 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.)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.