Jump to content


Photo

bbcode parsing


  • Please log in to reply
2 replies to this topic

#1 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 26 July 2006 - 02:11 AM

I've been trying to implement bbcode onto my website, but it's not working out. I just don't understand how to do it, and just about all the tutorials i come across are terribly written/wrong.

I did find a custom made file that parses tags, but the if you miss off a closing tag or make a similar mistake, it would destroy the page's layout, and i don't want to user input pages to be able to do that.

Can somebody point me towards some good documentation for using the PEAR bbcode parser or possibly explain how i go about using it themselves?

Thankyou for any help.

#2 High_-_Tek

High_-_Tek
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 26 July 2006 - 02:24 AM

Please point out any holes in my function but this is a simple version of what i've been using lately:

<?php

function parse_BBCode($input_str) {

  preg_match("#\[b\](.*?)\[b\]#i", $input_str, $matches);
  $input_str = preg_replace("#\[b\](.*?)\[\\b\]#i", "<b>".$matches[1]."</b>", $input_str);

  ... more BBCode->HTML regexs
return $input_str;
  }
?>

#3 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 26 July 2006 - 02:56 AM

Wouldn't it be easier to use the PEAR bbcode parser?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users