
Hello, I have the following bb function
function bb($string) {
$string = trim($string);
$search = array(
'@\<(?i)latex\>(.*?)\</(?i)latex\>@si',
'@\<(?i)b\>(.*?)\</(?i)b\>@si',
'@\<(?i)i\>(.*?)\</(?i)i\>@si',
'@\<(?i)u\>(.*?)\</(?i)u\>@si',
'@\<(?i)blockquote\>(.*?)\</(?i)blockquote\>@si',
'@\<(?i)pre\>(.*?)\</(?i)pre\>@si'
);
$replace = array(
'<img src="cgi/mathtex.cgi?\\1">',
'<b>\\1</b>',
'<i>\\1</i>',
'<u>\\1</u>',
'<blockquote>\\1</blockquote>',
'<pre>\\1</pre>'
);
$string = strtr($string, array("\n" => '<br>'));
$string = preg_replace($search ,$replace, $string);
return $string;
}
The problem is that if one enters newlines within latex tags (to make latex more clearly arranged), the function replaces the \n by <br>, which then becomes of course invalid latex code.
How to disable the encoding of code which is within latex tags?

fixed!
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.