? dif
cvs diff: Diffing .
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimemail/README.txt,v
retrieving revision 1.1
diff -u -p -r1.1 README.txt
--- README.txt	17 Nov 2005 02:56:38 -0000	1.1
+++ README.txt	13 May 2008 19:19:41 -0000
@@ -1,5 +1,9 @@
 $Id: README.txt,v 1.1 2005/11/17 02:56:38 vauxia Exp $
 
+REQUIREMENTS
+  This module requires the html_to_text module.  Please install that first.
+  http://drupal.org/project/html_to_text
+
 INSTALLATION
 	Hopefully, you know the drill by now :)
 	1. Place the entire mimemail directory into your Drupal modules 
@@ -38,4 +42,4 @@ CREDITS
 	  Original mail and mime code
 	  
   * Robert Castelo
-    	HTML to Text and other functionality 
\ No newline at end of file
+    	HTML to Text and other functionality 
Index: mimemail.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimemail/mimemail.inc,v
retrieving revision 1.24
diff -u -p -r1.24 mimemail.inc
--- mimemail.inc	18 Feb 2008 00:43:36 -0000	1.24
+++ mimemail.inc	13 May 2008 19:19:41 -0000
@@ -60,39 +60,18 @@ function mimemail_headers($headers, $fro
 /**
  * Converts html to utf-8 encoded text.
  *
- * @param $txt html text that needs formatting.
- * @param $inline Optional. If TRUE put links in the text, 
- *               if FALSE put a footnote into the text and
- *               a list of links below it. Default: FALSE
- *
- * @return formatted text encoded in utf-8
- */
-function mimemail_html_to_text($txt, $inline = FALSE) {
-  $pattern = '@(<a href="(.\S+?)"[^>]*>(.+?)</a>)@emi';
-  if ($inline) {
-    $txt = preg_replace($pattern, "_mimemail_uri('\\2', '\\3')", $txt);
-  }
-  else {
-    $txt = preg_replace($pattern, "'\\3 ['. _mimemail_urls('\\2') .']'", $txt);
-    $urls = _mimemail_urls();
-    if (count($urls)) {
-      $txt .= "\n";
-      $i = 0;
-      for ($max = count($urls); $i < $max; $i++) {
-        $url = preg_replace('/^mailto:(.+@.+)(\?.*)?/', '\1', $urls[$i]);
-        $txt .= '['. ($i + 1) .'] '. $url ."\n";
-      }
-    }
-    _mimemail_urls(0, TRUE);
-  }
-
-  // some basic html to text conversion
-  $replace = _mimemail_html2text();
+ * Mostly, this just relies on the drupal_html_to_text() function.
+ * However, we need to strip out any <style> and <script> tags first.
+ *
+ * @see drupal_html_to_text()
+ */
+function mimemail_html_to_text($txt) {
+  $replace = array(
+    '/<script[^>]*>.*?<\/script>/i'  => '',
+    '/<style[^>]*>.*?<\/style>/i'    => '',
+  );
   $txt = preg_replace(array_keys($replace), $replace, $txt);
-  $txt = preg_replace("/\n\s+\n/", "\n\n", $txt);
-  $txt = strip_tags($txt);
-  $txt = decode_entities($txt);
-  return wordwrap($txt, 80);
+  return drupal_html_to_text($txt);
 }
 
 /**
@@ -482,21 +461,6 @@ function mimemail_parse_attachment($part
 /**
  * Helper function to format urls
  *
- */
-function _mimemail_uri($href, $link) {
-  $href = _mimemail_url($href);
-  if ($href == $link) {
-    $output = '['. $href .']';
-  }
-  else {
-    $output = $link .' ['. $href .']';
-  }
-  return $output;
-}
-
-/**
- * Helper function to format urls
- *
  * @param $url an url
  *
  * @return an absolute url, sans mailto:
@@ -523,77 +487,6 @@ function _mimemail_url($url) {
 }
 
 /**
- * Helper function to store processed urls.
- *
- * @param $url Optional. 
- * @param $refresh Optional. If TRUE refresh the cache.
- *
- * @return a count of stored if $url evaluates to false, the stored urls ortherwise.
- */
-function _mimemail_urls($url = 0, $refresh = FALSE) {
-  static $urls = array();
-
-  if ($refresh) {
-    $urls = array();
-  }
-
-  if ($url) {
-    $urls[] = _mimemail_url($url);
-    return count($urls);
-  }
-
-  return $urls;
-}
-
-function _mimemail_html2text() {
-  return array(
-    "/\r/"                              => '',
-    "/[\t]+/"                           => '  ',
-    '/<script[^>]*>.*?<\/script>/i'     => '',
-    '/<style[^>]*>.*?<\/style>/i'       => '',
-    '!<h1[^>]*>(.+?)</h1>!ie'           => "\"\n\" .strtoupper('\\1').\"\n============================================================\n\"",
-    '!<h2[^>]*>(.+?)</h2>!ie'           => "\"\n------------------------------------------------------------\n\" .'\\1'.\"\n------------------------------------------------------------\n\"",
-    '/<h3[^>]*>(.+?)<\/h3>/ie'          => "\"\n\n\\1\n\n\"",
-    '/<h[456][^>]*>(.+?)<\/h[456]>/ie'  => "\"\n\\1\n\"",
-    '!<blockquote[^>]*>!i'              => "\n\n\t",
-    '!</blockquote>!i'                  => "\n\n",
-    '!</?p[^>]*>!i'                     => "\n\n",
-    '/<br[^>]*>/i'                      => "\n",
-    '/(<(u|o|d)l[^>]*>|<\/(u|o|d)l>)/i' => "\n\n",
-    '!<(li|dt)[^>]*>!i'                 => "  * ",
-    '!<dd[^>]*>!i'                      => "    ",
-    '!</(li|dt|dd)>!i'                  => "\n",
-    '/<hr[^>]*>/i'                      => "\n-------------------------\n",
-    '/(<table[^>]*>|<\/table>)/i'       => "\n\n",
-    '/(<tr[^>]*>|<\/tr>)/i'             => "\n",
-    '/<td[^>]*>(.+?)<\/td>/i'           => "\t\t\\1\n",
-    '/<th[^>]*>(.+?)<\/th>/i'           => "\"\t\t\\1\n\"",
-    '/&nbsp;/i'                         => " ",
-    '/&quot;/i'                         => '"',
-    '/&gt;/i'                           => '>',
-    '/&lt;/i'                           => '<',
-    '/&amp;/i'                          => '&',
-    '/&copy;/i'                         => '(c)',
-    '/&trade;/i'                        => '(tm)',
-    '/&#8220;/'                         => '"',
-    '/&#8221;/'                         => '"',
-    '/&#8211;/'                         => '-',
-    '/&#8217;/'                         => "'",
-    '/&#38;/'                           => '&',
-    '/&#169;/'                          => '(c)',
-    '/&#8482;/'                         => '(tm)',
-    '/&#151;/'                          => '--',
-    '/&#145;/'                          => '\'',
-    '/&#147;/'                          => '"',
-    '/&#148;/'                          => '"',
-    '/&#149;/'                          => '*',
-    '/&reg;/i'                          => '(R)',
-    '/&bull;/i'                         => '*',
-    '/&[&;]+;/i'                        => '',
-  );
-}
-
-/**
  * Attempt to determine the mimetime from or filename .  While not ideal, 
  * using the filename as a fallback ensures that images will appear inline
  * in HTML messages
Index: mimemail.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimemail/mimemail.info,v
retrieving revision 1.1
diff -u -p -r1.1 mimemail.info
--- mimemail.info	5 Jan 2007 05:44:09 -0000	1.1
+++ mimemail.info	13 May 2008 19:19:41 -0000
@@ -2,3 +2,4 @@
 name = Mime Mail
 description = E-mail with HTML and attachments
 package = Mail
+dependencies = html_to_text
cvs diff: Diffing po
