Re: Tidy bug
Ger Hobbelt <[email protected]> Sat, 21 Nov 2009 09:08:49 +0100
| Newsgroups | gmane.comp.web.html-tidy.devel |
|---|---|
| Message-ID | <[email protected]> |
Gentlemen,
The first edit; it's not perfect, but at least we're getting
somewhere. It's currently coded and under test, so criticisms are
welcomed.
(Note that these changes are not in CVS; for that to happen I'd need
to finish the edit + file a patch + get it accepted. It's local copy
only just now.)
Note that in sample A two grave mistakes in the HTML (missing table +
missing td) cause tidy to infer a <table>, then run into
table-'illegal' content after the </tr> which is pushed to the front
of the table as per standing rules (I didn't touch that part ;-) ), so
the result is far from perfect -- eyeballing the input, one would
/not/ expect the extra 'gobbledigook' text to land /before/ the table,
but that's what tidy does; after all, it treats 'inferred' tables just
like the real thing.
I'm thinking about changing that last bit of logic too when time
allows tomorrow, i.e. terminate inferred <tables> as soon as 'illegal'
content like that is found, instead of moving that 'illegal' content
around -- which is A-okay for real tables.
[OT: And then there's that extra single whitespace which might have
been introduced between 'bla' and 'and' if tidy were a truly bright
boy... but that's harder to accomplish because that requires knowledge
about which tags introduce some sort of hor/vert whitespace... wait,
that's what CM_BLOCK tells us. Hmmmm]
Sample B shows a double sample: the first half is sample A without the
extra text between the 'tables', so it doesn't show the damage to the
extent visible in A, while the second half is more what one might
expect: a missing <table> tag but otherwise the content properly
placed within <td>'s. And that's correctly rendered -- if the extra
table is indeed considered acceptable behaviour.
---input A (original but with a bit of content in TD)---
<html>
<body>
<tr>Bla bla bla</tr>
and some more gobbledigook...
<table id="companyAccountsTable">
<tbody><tr><td>jschmoe</td></tr></tbody>
</table>
</body>
</html>
----------------
---output A (original but with a bit of content in TD)---
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 3 column 1 - Warning: <tr> isn't allowed in <body> elements
line 2 column 1 - Info: <body> previously mentioned
line 3 column 1 - Warning: inserting implicit <table>
line 3 column 5 - Warning: plain text isn't allowed in <tr> elements
line 3 column 1 - Info: <tr> previously mentioned
line 3 column 16 - Warning: missing <td>
line 4 column 1 - Warning: plain text isn't allowed in <table> elements
line 3 column 1 - Info: <table> previously mentioned
line 2 column 1 - Warning: inserting missing 'title' element
line 3 column 1 - Warning: <table> lacks "summary" attribute
line 5 column 1 - Warning: <table> lacks "summary" attribute
line 10 column 1 - Warning: empty 'title' element and no header found:
'title' remains empty
Info: Document content looks like HTML 4.01 Strict
Info: No system identifier in emitted doctype
10 warnings, 0 errors were found!
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
<title></title>
</head>
<body>
Bla bla blaand some more gobbledigook...
<table>
<tr>
<td></td>
</tr>
</table>
<table id="companyAccountsTable">
<tbody>
<tr>
<td>jschmoe</td>
</tr>
</tbody>
</table>
</body>
</html>
-----------------
---input B (without and with TD in leading TR)---
<html>
<body>
<!-- two wrongs in one line: table + td... -->
<tr>Bla bla bla</tr>
<table id="companyAccountsTable">
<tbody><tr><td>jschmoe</td></tr></tbody>
</table>
<hr />
<!-- and now with only a single mistake: <table> missing -->
<hr />
<tr><td>Bla (bis 3x)</tr>
<table id="companyAccountsTable">
<tbody><tr><td>jschmoe</td></tr></tbody>
</table>
</body>
</html>
----------------
---output B (without and with TD in leading TR)---
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 4 column 1 - Warning: <tr> isn't allowed in <body> elements
line 2 column 1 - Info: <body> previously mentioned
line 4 column 1 - Warning: inserting implicit <table>
line 4 column 5 - Warning: plain text isn't allowed in <tr> elements
line 4 column 1 - Info: <tr> previously mentioned
line 4 column 16 - Warning: missing <td>
line 11 column 1 - Warning: <tr> isn't allowed in <body> elements
line 2 column 1 - Info: <body> previously mentioned
line 11 column 1 - Warning: inserting implicit <table>
line 2 column 1 - Warning: inserting missing 'title' element
line 4 column 1 - Warning: <table> lacks "summary" attribute
line 5 column 1 - Warning: <table> lacks "summary" attribute
line 11 column 1 - Warning: <table> lacks "summary" attribute
line 12 column 1 - Warning: <table> anchor "companyAccountsTable"
already defined
line 12 column 1 - Warning: <table> lacks "summary" attribute
line 17 column 1 - Warning: empty 'title' element and no header found:
'title' remains empty
Info: Document content looks like HTML 4.01 Strict
Info: No system identifier in emitted doctype
14 warnings, 0 errors were found!
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
<title></title>
</head>
<body>
<!-- two wrongs in one line: table + td... -->
Bla bla bla
<table>
<tr>
<td></td>
</tr>
</table>
<table id="companyAccountsTable">
<tbody>
<tr>
<td>jschmoe</td>
</tr>
</tbody>
</table>
<hr>
<!-- and now with only a single mistake: <table> missing -->
<hr>
<table>
<tr>
<td>Bla (bis 3x)</td>
</tr>
</table>
<table id="companyAccountsTable">
<tbody>
<tr>
<td>jschmoe</td>
</tr>
</tbody>
</table>
</body>
</html>
-----------------
--
Met vriendelijke groeten / Best regards,
Ger Hobbelt
--------------------------------------------------
web: http://www.hobbelt.com/
http://www.hebbut.net/
mail: [email protected]
mobile: +31-6-11 120 978
--------------------------------------------------
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july