Jump to content

bbcode parsing


doddsey_65

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/224023-bbcode-parsing/
Share on other sites

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]

Link to comment
https://forums.phpfreaks.com/topic/224023-bbcode-parsing/#findComment-1157678
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.