Example #1
0
 /**
  *    Turns HTML into text browser visible text. Images
  *    are converted to their alt text and tags are supressed.
  *    Entities are converted to their visible representation.
  *    @param string $html        HTML to convert.
  *    @return string             Plain text.
  *    @access public
  *    @static
  */
 function normalise($html)
 {
     $text = preg_replace('|<img.*?alt\\s*=\\s*"(.*?)".*?>|', ' \\1 ', $html);
     $text = preg_replace('|<img.*?alt\\s*=\\s*\'(.*?)\'.*?>|', ' \\1 ', $text);
     $text = preg_replace('|<img.*?alt\\s*=\\s*([a-zA-Z_]+).*?>|', ' \\1 ', $text);
     $text = preg_replace('|<.*?>|', '', $text);
     $text = SimpleSaxParser::decodeHtml($text);
     $text = preg_replace('|\\s+|', ' ', $text);
     return trim($text);
 }