function _codefilter_process in Code Filter 7
Implements hook_filter_FILTER_process().
1 string reference to '_codefilter_process'
- codefilter_filter_info in ./
codefilter.module - Implements hook_filter_info().
File
- ./
codefilter.module, line 184 - Text filter for highlighting PHP source code.
Code
function _codefilter_process($text, $format) {
if ($format->settings['codefilter_prism'] && function_exists('_codefilter_prism_process_code_callback')) {
$text = preg_replace_callback('@\\[codefilter_prism_code( [^\\]]+)?\\](.+?)\\[/codefilter_prism_code\\]@s', '_codefilter_prism_process_code_callback', $text);
$text = preg_replace_callback('@\\[codefilter_prism_php\\](.+?)\\[/codefilter_prism_php\\]@s', '_codefilter_prism_process_php_callback', $text);
}
else {
$text = preg_replace_callback('@\\[codefilter_code( [^\\]]+)?\\](.+?)\\[/codefilter_code\\]@s', '_codefilter_process_code_callback', $text);
$text = preg_replace_callback('@\\[codefilter_php\\](.+?)\\[/codefilter_php\\]@s', '_codefilter_process_php_callback', $text);
}
// A hack, so we can conditionally nowrap based on filter settings.
// @todo Refactor how replacements are done so we can do this more cleanly.
if ($format->settings['nowrap_expand']) {
$text = str_replace('class="codeblock"', 'class="codeblock nowrap-expand"', $text);
}
return $text;
}