What is the D6 equivalent of D7's hook_filter_info? I am backporting a module from D7 to D6, and I am not familiar with Drupal 6.

The following three lines runs a chunk of text in the variable $input through the Markdown filter to produce $output.

$filters = module_invoke('markdown', 'filter_info');
$info = $filters['filter_markdown'];
$output = $info['process callback']($input, NULL);


Provided the Markdown filter module is enabled, it works fine on Drupal 7.  On D6, the call to module_invoke returns NULL (so the rest fails).

The cause is obvious, hook_filter_info did not exist for Drupal 6, so this is invoking a non-existing hook.

It looks like hook_filter is supposed to do the same thing in D6, so I try:

$filters = module_invoke('markdown', 'filter', 'list');


This results in the following array filters[0]['Markdown'].  I don't know how this helps, or - if it is the right start - where to proceed.

Can anyone tell me how to run a chunk of text through a text filter in Drupal 6?
In Drupal 6, filter modules just implement hook_filter(). In particular, to process text from a filter, you should use code similar to the following one.

$result = module_invoke('markdown', 'filter', 'prepare', 0, -1, $input);
$result = module_invoke('markdown', 'filter', 'process', 0, -1, $result);


I assume the delta for the input filter is 0, which means selecting the first input filter implemented by the module.
The first call to module_invoke() could be not necessary, but most input filter prepare the text that is going to be preprocessed, mostly to avoid conflicts with other filters, including the ones implemented by Drupal core. In fact, check_markup() uses the following code.

// Give filters the chance to escape HTML-like data such as code or formulas.
foreach ($filters as $filter) {
  $text = module_invoke($filter-&gt;module, 'filter', 'prepare', $filter-&gt;delta, $format, $text, $cache_id);
}

// Perform filtering.
foreach ($filters as $filter) {
  $text = module_invoke($filter-&gt;module, 'filter', 'process', $filter-&gt;delta, $format, $text, $cache_id);
}