Tidy support for JavaScript

View: New views
13 Messages — Rating Filter:   Alert me  

Tidy support for JavaScript

by Ivor O'Connor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

When writing generic, granola, open-standards web pages there are three components, html, css, and javascript. As far as I know tidy does not support javascript. If this is not on the list could this feature request be added? Perhaps for stand alone .js files to begin with?

Re: Tidy support for JavaScript

by Arnaud Desitter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

There is no plan to parse javascript. Try a different tool.

Regards,

On 05/05/2009, Ivor O'Connor <ivor.oconnor@...> wrote:
> When writing generic, granola, open-standards web pages there are three
> components, html, css, and javascript. As far as I know tidy does not
> support javascript. If this is not on the list could this feature request be
> added? Perhaps for stand alone .js files to begin with?
>



Parent Message unknown Fwd: Tidy support for JavaScript

by Ivor O'Connor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



---------- Forwarded message ----------
From: Ivor O'Connor <ivor.oconnor@...>
Date: Wed, May 6, 2009 at 7:46 AM
Subject: Re: Tidy support for JavaScript
To: Arnaud Desitter <arnaud02@...>


Hmmm. A tool for pretty printing html and no support for what is almost always contained in html?

Perhaps there are some who see this as a problem and would like to get it fixed?

Perhaps another developer would help here? Like myself? Seriously. This is a good tool. No other solutions compare to it that I know of. So I'd be willing to spend some time if I have a mentor who could point me in the right directions...


On Wed, May 6, 2009 at 12:53 AM, Arnaud Desitter <arnaud02@...> wrote:
Hi,

There is no plan to parse javascript. Try a different tool.

Regards,

On 05/05/2009, Ivor O'Connor <ivor.oconnor@...> wrote:
> When writing generic, granola, open-standards web pages there are three
> components, html, css, and javascript. As far as I know tidy does not
> support javascript. If this is not on the list could this feature request be
> added? Perhaps for stand alone .js files to begin with?
>



Re: Tidy support for JavaScript

by Arnaud Desitter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

You are very welcome to have a go. Tidy could do with new blood.
Tidy does not parse javascript but should not destroy it either in the
current state of thing. If you are aware of specific bugs, please fill
them in the tracker with complete test cases (which may be added to
the test suite). Then, patches to address these bugs are always
welcome.

Regards,

On 06/05/2009, Ivor O'Connor <ivor.oconnor@...> wrote:

>
>
> ---------- Forwarded message ----------
> From: Ivor O'Connor <ivor.oconnor@...>
> Date: Wed, May 6, 2009 at 7:46 AM
> Subject: Re: Tidy support for JavaScript
> To: Arnaud Desitter <arnaud02@...>
>
>
> Hmmm. A tool for pretty printing html and no support for what is almost
> always contained in html?
>
> Perhaps there are some who see this as a problem and would like to get it
> fixed?
>
> Perhaps another developer would help here? Like myself? Seriously. This is a
> good tool. No other solutions compare to it that I know of. So I'd be
> willing to spend some time if I have a mentor who could point me in the
> right directions...
>
>
>
> On Wed, May 6, 2009 at 12:53 AM, Arnaud Desitter
> <arnaud02@...> wrote:
> > Hi,
> >
> > There is no plan to parse javascript. Try a different tool.
> >
> > Regards,
> >
> >
> >
> >
> > On 05/05/2009, Ivor O'Connor <ivor.oconnor@...> wrote:
> > > When writing generic, granola, open-standards web pages there are three
> > > components, html, css, and javascript. As far as I know tidy does not
> > > support javascript. If this is not on the list could this feature
> request be
> > > added? Perhaps for stand alone .js files to begin with?
> > >
> >
>
>
>



Re: Tidy support for JavaScript

by Ivor O'Connor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't know of any bugs.

It's the parsing of the javascript I'm interested in adding.

I'm going to be out most of the day but I'll be back later. If there's somebody who can point me in setting up the needed environment and such, like a project lead, and lay out the steps I'll make my way through them. Adding the code, test cases, documentation, what not...

On Wed, May 6, 2009 at 8:03 AM, Arnaud Desitter <arnaud02@...> wrote:
Hi,

You are very welcome to have a go. Tidy could do with new blood.
Tidy does not parse javascript but should not destroy it either in the
current state of thing. If you are aware of specific bugs, please fill
them in the tracker with complete test cases (which may be added to
the test suite). Then, patches to address these bugs are always
welcome.

Regards,

On 06/05/2009, Ivor O'Connor <ivor.oconnor@...> wrote:
>
>
> ---------- Forwarded message ----------
> From: Ivor O'Connor <ivor.oconnor@...>
> Date: Wed, May 6, 2009 at 7:46 AM
> Subject: Re: Tidy support for JavaScript
> To: Arnaud Desitter <arnaud02@...>
>
>
> Hmmm. A tool for pretty printing html and no support for what is almost
> always contained in html?
>
> Perhaps there are some who see this as a problem and would like to get it
> fixed?
>
> Perhaps another developer would help here? Like myself? Seriously. This is a
> good tool. No other solutions compare to it that I know of. So I'd be
> willing to spend some time if I have a mentor who could point me in the
> right directions...
>
>
>
> On Wed, May 6, 2009 at 12:53 AM, Arnaud Desitter
> <arnaud02@...> wrote:
> > Hi,
> >
> > There is no plan to parse javascript. Try a different tool.
> >
> > Regards,
> >
> >
> >
> >
> > On 05/05/2009, Ivor O'Connor <ivor.oconnor@...> wrote:
> > > When writing generic, granola, open-standards web pages there are three
> > > components, html, css, and javascript. As far as I know tidy does not
> > > support javascript. If this is not on the list could this feature
> request be
> > > added? Perhaps for stand alone .js files to begin with?
> > >
> >
>
>
>


Re: Tidy support for JavaScript

by Arnaud Desitter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I still do not see why you want tidy to parse the javascript parts.
Is it for formatting, checking, ...?

Anyway, look at the tidy mailing list. I vaguely remember that
somebody tried to do something similar in the past (prior any
involvement of mine).

Regards,

On 06/05/2009, Ivor O'Connor <ivor.oconnor@...> wrote:

> I don't know of any bugs.
>
> It's the parsing of the javascript I'm interested in adding.
>
> I'm going to be out most of the day but I'll be back later. If there's
> somebody who can point me in setting up the needed environment and such,
> like a project lead, and lay out the steps I'll make my way through them.
> Adding the code, test cases, documentation, what not...
>
>
> On Wed, May 6, 2009 at 8:03 AM, Arnaud Desitter
> <arnaud02@...> wrote:
> > Hi,
> >
> > You are very welcome to have a go. Tidy could do with new blood.
> > Tidy does not parse javascript but should not destroy it either in the
> > current state of thing. If you are aware of specific bugs, please fill
> > them in the tracker with complete test cases (which may be added to
> > the test suite). Then, patches to address these bugs are always
> > welcome.
> >
> > Regards,
> >
> >
> >
> >
> > On 06/05/2009, Ivor O'Connor <ivor.oconnor@...> wrote:
> > >
> > >
> > > ---------- Forwarded message ----------
> > > From: Ivor O'Connor <ivor.oconnor@...>
> > > Date: Wed, May 6, 2009 at 7:46 AM
> > > Subject: Re: Tidy support for JavaScript
> > > To: Arnaud Desitter <arnaud02@...>
> > >
> > >
> > > Hmmm. A tool for pretty printing html and no support for what is almost
> > > always contained in html?
> > >
> > > Perhaps there are some who see this as a problem and would like to get
> it
> > > fixed?
> > >
> > > Perhaps another developer would help here? Like myself? Seriously. This
> is a
> > > good tool. No other solutions compare to it that I know of. So I'd be
> > > willing to spend some time if I have a mentor who could point me in the
> > > right directions...
> > >
> > >
> > >
> > > On Wed, May 6, 2009 at 12:53 AM, Arnaud Desitter
> > > <arnaud02@...> wrote:
> > > > Hi,
> > > >
> > > > There is no plan to parse javascript. Try a different tool.
> > > >
> > > > Regards,
> > > >
> > > >
> > > >
> > > >
> > > > On 05/05/2009, Ivor O'Connor <ivor.oconnor@...> wrote:
> > > > > When writing generic, granola, open-standards web pages there are
> three
> > > > > components, html, css, and javascript. As far as I know tidy does
> not
> > > > > support javascript. If this is not on the list could this feature
> > > request be
> > > > > added? Perhaps for stand alone .js files to begin with?
> > > > >
> > > >
> > >
> > >
> > >
> >
>
>



Re: Fwd: Tidy support for JavaScript

by Bjoern Hoehrmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Ivor O'Connor wrote:
>Perhaps another developer would help here? Like myself? Seriously. This is a
>good tool. No other solutions compare to it that I know of. So I'd be
>willing to spend some time if I have a mentor who could point me in the
>right directions...

There should be a number of tools that pretty print or otherwise trans-
form JavaScript. The way to support them from Tidy would be an option
that would call them before pretty printing, and replace <script> ele-
ments with their output. Of course, it would be much easier if you'd
just use external scripts in the first place.
--
Björn Höhrmann · mailto:bjoern@... · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 


Re: Fwd: Tidy support for JavaScript

by Ivor O'Connor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bjoern Hoehrmann: That's a good idea. However I don't know of any such tools. It would still require a little work to integrate them.

Arnaud Desitter: For formatting code, not proofing it.


Re: Fwd: Tidy support for JavaScript

by Ciro A. Alvarado :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Has anybody tried www.jslint.com to cleanup their JavaScript?
 
Ciro Alvarado

--- On Thu, 5/7/09, Ivor O'Connor <ivor.oconnor@...> wrote:
From: Ivor O'Connor <ivor.oconnor@...>
Subject: Re: Fwd: Tidy support for JavaScript
To: "Bjoern Hoehrmann" <derhoermi@...>, "Arnaud Desitter" <arnaud02@...>
Cc: html-tidy@...
Date: Thursday, May 7, 2009, 9:05 AM

Bjoern Hoehrmann: That's a good idea. However I don't know of any such tools. It would still require a little work to integrate them.

Arnaud Desitter: For formatting code, not proofing it.


Re: Fwd: Tidy support for JavaScript

by Arnaud Desitter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For formatting purposes, delegating to an external formatter seems
like the way to go.

Regards,

On 07/05/2009, Ivor O'Connor <ivor.oconnor@...> wrote:
> Bjoern Hoehrmann: That's a good idea. However I don't know of any such
> tools. It would still require a little work to integrate them.
>
> Arnaud Desitter: For formatting code, not proofing it.
>
>



Re: Fwd: Tidy support for JavaScript

by Lee Passey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ivor O'Connor wrote:

[snip]

> Hmmm. A tool for pretty printing html and no support for what is almost
> always contained in html?

I think this question demonstrates the fundamentally incorrect
assumption underlying your request.

Tidy is /not/ a tool for pretty printing HTML. Tidy is a tool for
evaluating HTML and automatically correcting invalid HTML when possible.

As it evaluates the HTML Tidy builds in memory a DOM tree representation
of the HTML. Some corrections are performed during parsing, and other
corrections are made to the in-memory DOM. At the end of processing, the
corrected HTML exists only as an in-memory DOM. A pretty-print routine
is required when simply for outputting the in-memory representation.

But...

Tidy's pretty print functionality is a consequence of its method of
evaluation and correction, and not the purpose of the program. It is
perhaps unfortunate that Tidy's pretty print function is so good that it
has led people to believe that reformatting was, in fact, the original
design goal, despite the fact that it wasn't.

Following the usual Linux/Unix practice, Tidy can read from stdin, and
write to stdout. If you need a true pretty print function you should try
to find one that can also read from stdin and then use Tidy to
validate/correct your HTML, piping the output from Tidy to the pretty
print program. Because XHTML output from Tidy is guaranteed to be
well-formed, just about any XML pretty print program should be able to
give you what you need.


Re: Fwd: Tidy support for JavaScript

by Ross Boylan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 2009-05-07 at 10:17 -0600, Lee Passey wrote:

> Ivor O'Connor wrote:
>
> [snip]
>
> > Hmmm. A tool for pretty printing html and no support for what is
> almost
> > always contained in html?
>
> I think this question demonstrates the fundamentally incorrect
> assumption underlying your request.
>
> Tidy is /not/ a tool for pretty printing HTML. Tidy is a tool for
> evaluating HTML and automatically correcting invalid HTML when
> possible.
Would cleaing up javascript be a reasonable, if ambitious, goal for
tidy?
Ross



Re: Tidy support for JavaScript

by Richard O'Keefe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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

>
>
> ---------- Forwarded message ----------
> From: Ivor O'Connor <ivor.oconnor@...>
> Date: Wed, May 6, 2009 at 7:46 AM
> Subject: Re: Tidy support for JavaScript
> To: Arnaud Desitter <arnaud02@...>
>
>
> 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.)