You are here

function htmltidy_filter in HTML Tidy 6

Same name and namespace in other branches
  1. 5 htmltidy.module \htmltidy_filter()

Implementation of hook_filter().

File

./htmltidy.module, line 154
The theme system, which controls the output of Drupal. The htmltidy module uses Tidy (http://tidy.sf.net) to properly format HTML for saving and display.

Code

function htmltidy_filter($op, $delta = 0, $format = NULL, $text = '') {
  switch ($op) {
    case 'list':
      return array(
        0 => t('HTML Tidy'),
      );
    case 'description':
      return t('Corrects faulty and invalid HTML according to htmltidy configuration rules.');
    case 'no cache':
      return FALSE;

    // TRUE = No caching for tidy, this way we can test it (only updates when format is saved)
    case 'process':
      global $_htmltidy_filter;
      $errors = array();
      $warnings = array();
      $cleaned = htmltidy_fragment($text, $format, $errors, $warnings);
      $_htmltidy_filter['filtered'] = TRUE;
      $_htmltidy_filter['errors'] = $errors;
      $_htmltidy_filter['warnings'] = $warnings;
      return $cleaned;
    case 'settings':
      return _htmltidy_settings($format);
      break;
    default:
      return $text;
  }
}