--- tables.module Tue Nov 29 00:07:36 2005 +++ tables.module Sun Apr 23 22:51:42 2006 @@ -63,14 +63,21 @@ else { $class=variable_get('tables_default_style', 'tables-elegant'); } - $rows=explode("\n", $tablein); + + // Before pulling rows rows out, remove empty rows. Also remove leading + // and trailing empty rows, since these will mess up the header. + preg_replace("/\n\+/m", "\n", $tablein); + $rows=explode("\n", trim($tablein)); + $j=0; $num_rows=count($rows); $num_cols=0; while (isset($rows[$j])) { $cells[$j]=explode('|', $rows[$j]); $cells[$j]=array_map('trim', $cells[$j]); - if (count($cells[$j]>$num_cols)) { + + // Grow column count, if this row has more columns. + if (count($cells[$j]) > $num_cols) { $num_cols=count($cells[$j]); } $j++;