SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Implementing Wikipedia-style Editing

    I have created a simple content management system for my web site and I would like to use Wikipedia-style coding in the editing of pages.

    Is there an easy way to obtain/use the string replace function that Wikipedia uses to change things like '''this''' into bold text and to make [site.com This Text] a link?

    Would there be anything wrong with just writing a function that has a bunch of str_replace that changes things like three apostrophies into <b> and </b>.

    I'm not experienced with regular expressions enough to know how to use them, but I think it could help in this situation, right? For example, how would I change the first set of three apostrophies into <b> and the second set into </b> ? Or, determine that [http://site.com This Link] is a link when [this is not] ?

    Cheers,
    - Fotinakis

  2. #2
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Regina, SK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to look at using BB_Code, there's a PHP class available at:

    http://pear.php.net/package/HTML_BBCodeParser

    That can get you started.
    Reduce or eliminate spam on your sites without CAPTHCAs
    - maybe it is possible: http://formantispam.thekerrs.ca/

  3. #3
    SitePoint Guru Ruben K.'s Avatar
    Join Date
    Jun 2005
    Location
    Alkmaar, The Netherlands
    Posts
    693
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nos
    You might want to look at using BB_Code, there's a PHP class available at:

    http://pear.php.net/package/HTML_BBCodeParser

    That can get you started.
    HTML_BBCode Parser is actually not a good idea.
    It is quite buggy and you still need to nl2br() and filter evil html chars out.

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys,
    Since I only require a few different expressions (and I prefer the wikipedia-type syntax over bbcode syntax anyway), I'm just going to write a function to str_replace and preg_replace what I need. Thanks again.
    - Fotinakis


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •