You are here

protected function Html2Text::convertPre in Swift Mailer 7

1 call to Html2Text::convertPre()
Html2Text::converter in includes/classes/Html2Text.inc

File

includes/classes/Html2Text.inc, line 425

Class

Html2Text

Code

protected function convertPre(&$text) {

  // get the content of PRE element
  while (preg_match('/<pre[^>]*>(.*)<\\/pre>/ismU', $text, $matches)) {
    $this->preContent = $matches[1];

    // Run our defined tags search-and-replace with callback
    $this->preContent = preg_replace_callback($this->callbackSearch, array(
      $this,
      'pregCallback',
    ), $this->preContent);

    // convert the content
    $this->preContent = sprintf('<div><br>%s<br></div>', preg_replace($this->preSearch, $this->preReplace, $this->preContent));

    // replace the content (use callback because content can contain $0 variable)
    $text = preg_replace_callback('/<pre[^>]*>.*<\\/pre>/ismU', array(
      $this,
      'pregPreCallback',
    ), $text, 1);

    // free memory
    $this->preContent = '';
  }
}