Skip to content

Commit

Permalink
*5568* Added String::html2text method
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Jul 19, 2010
1 parent b7ad9a8 commit 1ea73bd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions classes/core/String.inc.php
Expand Up @@ -458,6 +458,20 @@ function stripUnsafeHtml($input) {
return $html;
}

/**
* Convert limited HTML into a string.
* @param $html string
* @return string
*/
function html2text($html) {
$html = String::regexp_replace('/<[\/]?p>/', "\n", $html);
$html = String::regexp_replace('/<li>/', '&bull; ', $html);
$html = String::regexp_replace('/<\/li>/', "\n", $html);
$html = String::regexp_replace('/<br[ ]?[\/]?>/', "\n", $html);
$html = String::html2utf(strip_tags($html));
return $html;
}

//
// Wrappers for UTF-8 validation routines
// See the phputf8 documentation for usage.
Expand Down

0 comments on commit 1ea73bd

Please sign in to comment.