Okay there's a few different things contributing to the whitespace/line-break formatting problems. I had to hack quite a bit to fix all this, so I've just uploaded my edited gehsi.php --
http://www.brothercake.com/clients/geshi.zip
All the changes I made begin with a comment that says "20070518 -- brothercake". Apart from fixing these issues, I've also removed the list markup (because line-numbers were being copied into the clipboard in some browsers), while retaining fancy lines (alternate line highlighting). And I've also stripped out some of the markup it generates - everything apart from what's actually needed!
To make these changes work I also had to comment out four lines from the product (the code inside the XML file):
PHP Code:
//################################################################
//20070518 -- brothercake mod commented these lines so we can control from geshi.php directly
// $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
// $tabs = 4;
// $geshi->set_header_type(GESHI_HEADER_DIV);
// $geshi->set_tab_width($tabs);
//################################################################
Hope this is useful

It's all pretty brutal, but it works!