function geshifilter_highlight_string_process in GeSHi Filter for syntax highlighting 6
Same name and namespace in other branches
- 5.2 geshifilter.pages.inc \geshifilter_highlight_string_process()
- 7 geshifilter.pages.inc \geshifilter_highlight_string_process()
geshifilter wrapper for highlight_string() processing of PHP
1 call to geshifilter_highlight_string_process()
- geshifilter_process in ./
geshifilter.pages.inc - General geshifilter processing function
File
- ./
geshifilter.pages.inc, line 397
Code
function geshifilter_highlight_string_process($source_code, $inline_mode) {
// Make sure that the source code starts with < ?php and ends with ? >
$text = trim($source_code);
if (substr($text, 0, 5) != '<?php') {
$source_code = '<?php' . $source_code;
}
if (substr($text, -2) != '?>') {
$source_code = $source_code . '?>';
}
// Use the right container
$container = $inline_mode ? 'span' : 'div';
// Process with highlight_string()
$text = '<' . $container . ' class="codeblock geshifilter">' . highlight_string($source_code, TRUE) . '</' . $container . '>';
// Remove newlines (added by highlight_string()) to avoid issues with the linebreak filter
$text = str_replace("\n", '', $text);
return $text;
}