function drush_html_to_text

8.0.x output.inc drush_html_to_text($html, $allowed_tags = NULL)
6.x output.inc drush_html_to_text($html, $allowed_tags = NULL)
7.x output.inc drush_html_to_text($html, $allowed_tags = NULL)
4.x drush.inc drush_html_to_text($html, $allowed_tags = NULL)
5.x output.inc drush_html_to_text($html, $allowed_tags = NULL)
master output.inc drush_html_to_text($html, $allowed_tags = NULL)

Convert html to readable text. Compatible API to drupal_html_to_text, but less functional. Caller might prefer to call drupal_html_to_text if there is a bootstrapped Drupal site available.

Parameters

string $html: The html text to convert.

Return value

string The plain-text representation of the input.

Related topics

2 calls to drush_html_to_text()
drush_print_file in includes/drush.inc
Print the contents of a file.
_drush_pm_releasenotes in commands/pm/pm.drush.inc
Internal function: prints release notes for given drupal projects.

File

includes/drush.inc, line 664
The drush API implementation and helpers.

Code

function drush_html_to_text($html, $allowed_tags = NULL) {
  $replacements = array(
    '<hr>' => '------------------------------------------------------------------------------',
    '<li>' => '  * ',
    '<h1>' => '===== ',
    '</h1>' => ' =====',
    '<h2>' => '---- ',
    '</h2>' => ' ----',
    '<h3>' => '::: ',
    '</h3>' => ' :::',
    '<br/>' => "\n",
  );
  $text = str_replace(array_keys($replacements), array_values($replacements), $html);
  return html_entity_decode(preg_replace('/ *<[^>]*> */', ' ', $text));
}