问题
I am having some trouble (again :P) with my BB-code system. I finally got [code]
tags working using Syntax Highlighter. Now there is one problem, that when "enter" is pressed inside the script (AKA next line), the bb-code causes that enter to be replaced with <br>
which means the script does not correctly render the code using Syntax Highlighter.
Example picture:
How do I create an exception in my code, that ignores the <br>
when it is inside [code]
lines?
My current bbcode.php (there are more things in those arrays, but they are not relevant):
function bbcode($input) {
$find = array(
"@\n@",
"/\[code\=(.+?)\](.+?)\[\/code\]/is"
);
$replace = array(
"<br />",
"<pre class='brush: $1;'>$2</pre>"
);
$input = htmlspecialchars($input);
$input= preg_replace($find, $replace, $input);
return $input;
}
To sum it up: How do I prevent <br>
from parsing inside my [code]
tags?
Thanks ahead!
来源:https://stackoverflow.com/questions/23583075/how-do-i-prevent-br-from-parsing-inside-my-code-tags