Re: Tidy [Inferred Table] Bug
Christopher Woods <[email protected]> Mon, 23 Nov 2009 07:58:22 -0800 (PST)
| Newsgroups | gmane.comp.web.html-tidy.devel |
|---|---|
| Message-ID | <[email protected]> |
Are you sure that the browsers are actually turning the <tr> content before the table into a table? If I remember correctly, when I did some tests on this back in Feb 2006 the browsers just basically stripped the <tr> (or maybe I only had checked <td>) before any table away and discarded it. I put in a feature request to add a new option to disable Tidy's "inferred table" functionality: https://sourceforge.net/tracker/?func=detail&aid=1429519&group_id=27659&atid=390966 It's a bit dated now as the request was filed in late Feb 2006 but I did note which versions of the code the diffs were created from. You *might* want to check this and see if the behavior is visually more consistent. -Chris Message: 1 Date: Sat, 21 Nov 2009 09:08:49 +0100 From: Ger Hobbelt <[email protected]> Subject: Re: [Tidy-dev] Tidy bug To: [email protected] Message-ID: <[email protected]> Content-Type: text/plain; charset=ISO-8859-1 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 -------------------------------------------------- ------------------------------ Message: 2 Date: Sun, 22 Nov 2009 21:59:27 -0800 From: Ben McCann <[email protected]> Subject: Re: [Tidy-dev] Tidy bug To: Ger Hobbelt <[email protected]> Cc: [email protected] Message-ID: <[email protected]> Content-Type: text/plain; charset="iso-8859-1" Thanks Ger! I really appreciate you taking the time to look at this. I agree I would not expect the extra 'gobbledigook' text to land before the table. And if the <tr>content</tr> is going to be turned into a full table then I imagine I would expect the content to remain within the table. I think what you've changed thus far is an improvement over the previous functioning though since we are not losing any data as before (the table id). Thanks! Ben On Sat, Nov 21, 2009 at 12:08 AM, Ger Hobbelt <[email protected]> wrote: > 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 > _______________________________________________ > Tidy-develop mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/tidy-develop > -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ ------------------------------------------------------------------------------ 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 ------------------------------ _______________________________________________ Tidy-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tidy-develop End of Tidy-develop Digest, Vol 22, Issue 3 ******************************************* ------------------------------------------------------------------------------ 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