Re: Table moved to end of file

I <bwaijers@tiscali.nl> wrote:

> When I use HTML-tidy to clean an html file, all the <table>s contained
> in such a file get moved to the end, after the </body> tag.

> Example (input):

> <body>
> <table summary="sum">
> <tr>
> <td>col_1
> <td>col_2
> </table>
> <h1>header</h1>
> <p>Text
> <br>Text
> </body>

> [...] my layout gets completely messed up like this. What am I
> doing wrong?

Actually, the Tidy output of the above code is:

1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
1 <html>
1 <head>
1 <title></title>
1 </head>
1 <body>
1 <h1>header</h1>
1
1 <p>Text<br>
1 Text</p>
1
1 <table summary="sum">
1 <tr>
1 <td>col_1</td>
1 <td>col_2</td>
1 </tr>
1 </table>
1 </body>
1 </html>

I noticed that when I add a </tr> line, most things work as expected, and
the outcome is:

2 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
2 <html>
2 <head>
2 <title></title>
2 </head>
2 <body>
2 <table summary="sum">
2 <tr>
2 <td>col_1</td>
2 <td>col_2</td>
2 </tr>
2 </table>
2
2 <h1>header</h1>
2
2 <p>Text<br>
2 Text</p>
2 </body>
2 </html>

Now, the table stays in place, where it should be. The </td>'s are added
automatically. Why not the </tr>'s?  I seem to recall that in earlier
versions, these were added correctly.

If I use the "hide-endtags" option, the following input:

1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
1 <title></title>
1
1 <table summary="sum">
1 <tr>
1 <td>col_1
1 <td>col_2
1 </tr>
1 </table>
1 <h1>header</h1>
1 <p>Text<br>
1 Text

results in the </tr> tag being removed, while running it again on that
output would result in the table being placed at the end of the output:

2 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
2 <title></title>
2
2 <h1>header</h1>
2 <p>Text<br>
2 Text
2 <table summary="sum">
2 <tr>
2 <td>col_1
2 <td>col_2
2
2 </table>

The </tr> tag is once again removed.

Boudewijn Waijers (bwaijers at tiscali.nl).

There are 10 types of people in the world:
those who understand binary, and those who don't.

Received on Sunday, 10 August 2003 19:55:32 UTC