Version: 3.2.2 (using KDE 3.2.2, SuSE) Compiler: gcc version 3.3.1 (SuSE Linux) OS: Linux (i686) release 2.4.21-215-default If a <PRE> tag is followed by a space and then the end of the line, the space is not ignored; it is prepended to the start of the first line of the PRE's content. I suspect that this was caused by an attempt to fix bug 47241 that deleted the end-of-line, but not the white space before it. Here is a test file. ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <style> PRE {background-color: red}; </style> <body> <p>The start tag of this PRE element is followed by a space and then the end of the line.</p> <pre> An improperly formatted PRE element. </pre> <p>The start tag of this PRE element is immediately followed by the end of the line.</p> <pre> A properly formatted PRE element. </pre> <p>Note the space at the left margin of the first element.</p> </body> </html>
Created attachment 5965 [details] Testcase from above.
I can confirm this bug.
On closer examination the correct behavior is to preserve every white-space when it is not a line-feed that follows the tag immediately.
CVS commit by carewolf: Correct parsing of white-space immediately after pre tag. BUG: 81393 M +4 -0 ChangeLog 1.406 M +6 -8 html/htmltokenizer.cpp 1.299 --- kdelibs/khtml/ChangeLog #1.405:1.406 @@ -1,2 +1,6 @@ +2005-03-21 Allan Sandfeld Jensen <kde@carewolf.com> + + * html/htmltokenizer.cpp: Only skip first LF if immediately after PRE tag + 2005-03-18 Allan Sandfeld Jensen <kde@carewolf.com> --- kdelibs/khtml/html/htmltokenizer.cpp #1.298:1.299 @@ -1136,6 +1136,6 @@ void HTMLTokenizer::parseTag(TokenizerSt switch( tagID ) { case ID_PRE: - discard = LFDiscard; prePos = 0; + discard = AllDiscard; break; case ID_SCRIPT: @@ -1365,10 +1365,8 @@ void HTMLTokenizer::write( const Tokeniz if ( pending ) { // pre context always gets its spaces/linefeeds - if ( pre ) - addPending(); // only add in existing inline context or if // we just started one, i.e. we're about to insert real text - else if ( !parser->selectMode() && - ( !parser->noSpaces() || dest > buffer )) { + if ( pre || script || (!parser->selectMode() && + ( !parser->noSpaces() || dest > buffer ))) { addPending(); discard = AllDiscard;