Search

I'm currently working on a BBCode formatter with a bit of a twist: it allows a programmer to manage a BBCode snippet in much the same way as you would a HTML document with a JavaScript library like JQuery. Of course, BBCode doesn't need that level of complexity, but now it'll be possible to easily define custom BBCode formats and parse them correctly.

Usage is something like this:

<?php

    include "ibbcode.php";

    class ExampleElement extends IBBCElement {
        public function __toString() {
            $content = parent::__toString();

            return "<{$this->name()}>{$content}</{$this->name()}>";
        }
    }

    $parser = new IBBCParser();
    $parser->addElement("i", "ExampleElement");
    $parser->addElement("b", "ExampleElement");

    $document = $parser->parse("[i]foo[b]bar[/i] dude!");
    $document->childLast()->value("!")->wrap(new ExampleElement(null, "i", array()));
    $document->wrap(new ExampleElement(null, "p", array()));

    echo $document;

    //<p><i>foo<b>bar</b></i><i>!</i></p>

?>

Now, the library isn't ready for release just yet, but it won't be long. What I need to know are what BBCode elements people think should be included by default, even the obvious ones. So, if you're interested, please give some examples of what BBCodes you'd expect to find.

I should be ready for the first release by this weekend.

ibb code :)

Some examples might be:

[b]bold[/b]

[i]italic[/i]

[u]underline[u]

[url]http://www.url.com[/url]

[url=http://www.url.com]text here[/url]

[img]http://www.url.com/image.jpg[/img]

[img=http://www.url.com/image.jpg]alt text[/img]

I would think you have thought of these for yourself.

Yeah, that and [quote=whoever/whatever] ... [/quote]

I guess just the basics will do for now, anything specific can be added later.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details