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

3 calls to drush_html_to_text()
drush_engine_topic_command in includes/engines.inc
Implementation of command hook for docs-output-formats
drush_print_file in includes/output.inc
Print the contents of a file.
Project::getReleaseNotes in lib/Drush/UpdateService/Project.php
Prints release notes for given projects.

File

includes/output.inc, line 211

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));
}