--- tables.module.orig	2007-06-26 10:54:56.000000000 -0700
+++ tables.module	2007-06-26 13:06:42.000000000 -0700
@@ -59,7 +59,10 @@
       }
       $j++;
     }
+    $header = array();
+    $rows = array();
     for ($j=$num_rows-1; $j>=0; $j--) {   // find any cols rows that span  row=j, col=k
+      $row = array();
       for ($k=$num_cols-1; $k>=0; $k--) {
         if ($cells[$j][$k]=='&') {
           if (isset($colspan[$j][$k]) && $k>0) {
@@ -77,11 +80,40 @@
             $rowspan[$j-1][$k]=2;
           }
         }
+        
+        if($cells[$j][$k][0]=='!') {
+          $hd = TRUE;
+          $cells[$j][$k]=substr($cells[$j][$k],1);
+        }
+        else {
+          $hd = FALSE;
+        }
+
+        if($cells[$j][$k][0]=='`') {
+          $align='right';
+          $cells[$j][$k]=substr($cells[$j][$k],1);
+        }
+        elseif($cells[$j][$k][0]=='~') {
+          $align='center';
+          $cells[$j][$k]=substr($cells[$j][$k],1);
+        }
+        else {
+          $align='left';
+        }
+        
+        if($j == 0)
+          array_unshift($header, array('data' => $cells[$j][$k]));
+        else
+          if($hd)
+            array_unshift($row, array('data' => $cells[$j][$k], 'header' => TRUE, 'align' => $align));
+          else
+            array_unshift($row, array('data' => $cells[$j][$k], 'align' => $align));
       }
+      array_unshift($rows, $row);
     }
     if (isset($class) && strtolower($class)=='theme') {
       //create a table themed using Drupal Themed table function
-       $outtext=theme_table(array_shift($cells), $cells);
+      $outtext=theme_table($header , $rows); //array_shift($cells), $cells);
     }
     else {
       if (isset($class) && strlen($class)>0) {
@@ -103,13 +135,26 @@
             $cell_type='td';
           }
 
+          if ($cells[$j][$k][0]=='`') {
+            $align=' align="right"';
+            $cells[$j][$k]=substr($cells[$j][$k],1);
+          }
+          elseif(($cells[$j][$k][0]=='~') {
+            $align=' align="center"';
+            $cells[$j][$k]=substr($cells[$j][$k],1);
+          }
+          else {
+            $align=' align="left"';
+          }
+
           if ($cells[$j][$k]!='^' && $cells[$j][$k]!='&') {
             $outtext.="<$cell_type";
             if (isset($rowspan[$j][$k])) $outtext .= ' ROWSPAN='.$rowspan[$j][$k];
             if (isset($colspan[$j][$k])) $outtext .= ' COLSPAN='.$colspan[$j][$k];
-            if ($k==0) $outtext .= ' class="firstcol">';
-            elseif ($k % 2 == 0) $outtext.= ' class="oddcol">';
-            else $outtext.= ' class="evencol">';
+            if ($k==0) $outtext .= ' class="firstcol"';
+            elseif ($k % 2 == 0) $outtext.= ' class="oddcol"';
+            else $outtext.= ' class="evencol"';
+            $outtext.= "$align>";
             if (strlen($cells[$j][$k])>0) $outtext .=$cells[$j][$k]."</$cell_type>";
             else $outtext .= "&nbsp;</$cell_type>";
           }
@@ -146,8 +191,7 @@
       else {
         return $text;
       }
-      
-
+     
     case 'prepare':
       return $text;
      
