function codefilter_escape in Code Filter 6
Same name and namespace in other branches
- 5 codefilter.module \codefilter_escape()
- 7 codefilter.module \codefilter_escape()
Escape code blocks during input filter 'prepare'.
Parameters
$text: The string to escape.
$type: The type of code block, either 'code' or 'php'.
Return value
The escaped string.
2 calls to codefilter_escape()
- _codefilter_escape_code_tag in ./
codefilter.module - Callback to replace <code> elements.
- _codefilter_escape_php_tag in ./
codefilter.module - Callback to replace <?php ?>, [?php ?], <% %>, and [% %] elements.
File
- ./
codefilter.module, line 96
Code
function codefilter_escape($text, $type = 'code') {
// Note, pay attention to odd preg_replace-with-/e behaviour on slashes
$text = check_plain(str_replace('\\"', '"', $text));
// Protect newlines from line break converter
$text = str_replace(array(
"\r",
"\n",
), array(
'',
' ',
), $text);
// Add codefilter escape tags
$text = "[codefilter_{$type}]{$text}[/codefilter_{$type}]";
return $text;
}