Index: tables.module
===================================================================
--- tables.module	(revision 2181)
+++ tables.module	(working copy)
@@ -76,12 +76,20 @@
 
 function _tables_prepare($intext) {
   $out=FALSE;
+  $html_mode = variable_get('tables_html_mode', FALSE);
   $tableexp = '/\[table([^\[\]]+ )* \] /x';
   preg_match_all($tableexp, $intext, $matches);
   $i=0;
   while (isset($matches[1][$i])) {
     $out[0][$i] = $matches[0][$i];
     $tablein = $matches[1][$i];
+    if ($html_mode) {
+      // Convert <p> and <br> tags to newlines.
+      $tablein = str_replace(array("\n", "\r"), array('', ''), $tablein);
+      $tablein = preg_replace('/\\<br[^\\>]*\\>/si', "\n", $tablein);
+      $tablein = preg_replace('/\\<\\/p\\>/si', "\n", $tablein);
+      $tablein = preg_replace('/\\<\\/?(p|br)[^\\>]*\\>/si', '', $tablein);
+    }
     $rowspan=$colspan=array();    
     if ($tablein[0] == '=') {  //class is set
       preg_match('/^=([a-zA-Z0-9-]*)/', $tablein, $cmatches);
@@ -249,5 +257,12 @@
     '#maxlength' => 255,
     '#description' => t("Set the default style sheet to use if no style sheet is set in the specific table. "),
   );
+  $form['tables_filter']['tables_html_mode'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('HTML mode'),
+    '#default_value' => variable_get('tables_html_mode', FALSE),
+    '#description' => t('Allow tables formatting within HTML.'),
+  );
+
   return $form;
 }
