doddsey_65 Posted January 10, 2011 Share Posted January 10, 2011 i am wanting to add a code tag to my bbcode list. Anything within this tag will be printed as is(like the html code). I have tried using htmlspecialchars() but it isnt printing the code. Here is the parser section for the tag: $patern = "#\[code = ([^\]]*)\]([^\[]*)\[/code\]#i"; $replace = "<table class=\"code\"> <tr> <th>\\1</th> </tr> <tr> <td>".htmlspecialchars('\\2')."</td> </tr> </table>"; $str=preg_replace($patern, $replace, $str); Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/224023-bbcode-parsing/ Share on other sites More sharing options...
doddsey_65 Posted January 11, 2011 Author Share Posted January 11, 2011 i have tried using the <code> html tage but this doesnt work either. I am able to see exactly what it looks like in a post because of the jquery preview box on the same page which updates when the text in the textarea is changed. <script type="text/javascript"> $(document).ready(function(){ $("#message").bbcode({tag_bold:true,tag_italic:true,tag_underline:true,tag_link:true,tag_image:true,button_image:true, tag_code:true}); process(); }); var bbcode=""; function process() { if (bbcode != $("#message").val()) { bbcode = $("#message").val(); $.get('./bbParser.php', { bbcode: bbcode }, function(txt){ $("#preview").html(txt); }) } setTimeout("process()", 10); } </script> with everything in the preview box being printed as html with: $("#preview").html(txt); could this be the problem? This is what i am doing: [code = php]<a href="">This isnt a link</a>[ / code] Quote Link to comment https://forums.phpfreaks.com/topic/224023-bbcode-parsing/#findComment-1157678 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.