You are here

function _mimemail_html_to_text_pad in Mime Mail 5

Helper function for mimemail_html_to_text().

Pad the last line with the given character.

1 call to _mimemail_html_to_text_pad()
mimemail_html_to_text in ./html_to_text.inc
Transform an HTML string into plain text, preserving the structure of the markup. Useful for preparing the body of a node to be sent by e-mail.

File

./html_to_text.inc, line 282

Code

function _mimemail_html_to_text_pad($text, $pad, $prefix = '') {

  // Remove last line break.
  $text = substr($text, 0, -1);

  // Calculate needed padding space and add it.
  if (($p = strrpos($text, "\n")) === FALSE) {
    $p = -1;
  }
  $n = max(0, 79 - (strlen($text) - $p));

  // Add prefix and padding, and restore linebreak.
  return $text . $prefix . str_repeat($pad, $n - strlen($prefix)) . "\n";
}