Tidy Changing non-empty Paragraph to Break

Post here if your message doesn't fit into another forum but is still about web development. Includes site critiques, web hosting and server questions, helpful software and resources, and more.
Post Reply
c24m48
Rank II - Novice
Rank II - Novice
Posts: 26
Joined: Fri Jun 17, 2005 5:05 pm

Tidy Changing non-empty Paragraph to Break

Post by c24m48 » Wed Aug 31, 2005 8:20 pm

I'm really only playing around with the Tidy option. I have a question about one thing it flags. It wants to change a <p> to a <br> when I think it probably shouldn't.

In particular, I have something like

<p class="whatever">
Some text goes here, in fact a whole paragraph's worth.
</p>

Tidy wants to replace the <p class="whatever"> with a <br>, and then it wants to delete the </p> because it's not preceded by a <p>. Am I doing something wrong, or is Tidy?

Thanks,
Jerry Bryan

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3417
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Post by Albert Wiersch » Mon Sep 19, 2005 10:53 pm

Hi Jerry,

While I can't provide in-depth support for HTML Tidy because I didn't develop it, I am still able to offer some assistance in certain circumstances, so I'll give it a shot.

I did try this and could not get HTML Tidy to do what you say:

Code: Select all

<p class="whatever">Some text goes here, in fact a whole paragraph's worth.</p>
HTML Tidy did not change the "p" tag to "br" and remove the end tag for "p". I suspect that it may be something to do with the specific paragraph. Can you post the entire paragraph that you are having trouble with and tell me exactly what you did to encounter this issue? I will try to reproduce it and see if I can figure out why HTML Tidy is doing what it's doing.
Image
Albert Wiersch

User avatar
Lou
Rank V - Professional
Rank V - Professional
Posts: 277
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Post by Lou » Tue Sep 20, 2005 6:12 am

Jerry,
I couldn't dup what you report eather. couldn't find a option to change to make it happen.

Have you checked http://tidy.sourceforge.net/ a link from the tidy help

User avatar
MikeGale
Rank VI - Professional
Rank VI - Professional
Posts: 709
Joined: Mon Dec 13, 2004 1:50 pm
Location: Tannhauser Gate

Tidy has it's limits

Post by MikeGale » Mon Oct 31, 2005 4:47 pm

There are things that Tidy seems unable to do.

(I last ran through it some time ago, I've done this maybe 4 times over the life of tidy, I've spent a few hours, so I'm pretty sure.)

My conclusion is that tidy settings interact with each other and that at least one setting changes two different things. This last is pretty hard when you don't want to do what tidy thinks is the one true and righteous path.

Having said that, Tidy does have it's place. With careful setup it gives a very good first cut that doesn't need much clean up.

Other tools:

1) Homesite does a pretty good job, might take a lot of setup, but seems to also fail on some perfectly reasonable cases. Better than Tidy. Big problem Adobe/Macromedia appear not to have spent a development cent in years so this version is probably "end of life".

2) The best I've ever used took some publicly available .NET code and enhanced it. It takes horribly buggy XHTML/HTML and turns it into something that passes validation. In the process it can output a standard indented XML format which I've come to accept, though it has some unnecessary whitespace in there! Not for the faint of heart.

c24m48
Rank II - Novice
Rank II - Novice
Posts: 26
Joined: Fri Jun 17, 2005 5:05 pm

Post by c24m48 » Tue Jan 03, 2006 3:28 pm

First, I may not have been totally clear in my original explanation. I'm not really talking about the Tidy Tool. I'm talking about the Enable HTML Tidy validator option. I'm sure that the Enable HTML Tidy validator option is a part of the same package as the Tidy Tool.

Second, I can recreate the problem as follows:

<pre class="class1">

<p class="class2">

</p>


</pre>

It is arguable whether you really want the <p></p> pair inside the <pre></pre> pair, and indeed whether this is really valid HTML. But nobody complained except for the HTML Tidy Validator when the option was enabled. In this particular case, both IE and Firefox rendered my HTML the way I wanted. Namely, some of the attributes of "class1" such as color were inherited into the paragraph, plus the "pre-formatted" aspects of the <pre> text were temporarily suspended when the <p> tag was encountered, and the "pre-formatted" aspects of the <pre> text were resumed when when the </p> tag was encountered. So everything was rendered exactly the way I wanted it. But HTML Tidy wanted to change the <p> to a <br />, which wouldn't at all have been the effect that I wanted.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3417
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Post by Albert Wiersch » Tue Jan 03, 2006 5:19 pm

Technically, "p" should not be in "pre" in HTML 4.01. CSE HTML Validator is more lenient about this. You may want to try using something like this instead:

Code: Select all

<div style="font-family: monospace; white-space: pre" class="class1">
<p class="class2">
</p>
</div>
That is, use "div" instead of "pre".
Image
Albert Wiersch

Post Reply