For a while now I’ve been working on a little blog engine in PHP. As part of the post rendering, I’ve settled on BBCode to do all markup and layout.
This meant I would need a BBCode parser. So, I started writing one. And because my projects always go this way, I ended up sinking more time into the BBCode parser than the blog engine itself – trying to get every weird corner case and not produce malformed HTML on output. The primary goals were:
- Easy to use (one file with one function)
- Correct (Unicode safe, always-valid HTML, reasonable fallbacks)
- Easy to understand (avoid massive regexes)
Eventually, I ended up just splitting this piece off into its own project, since it may be useful beyond just my tiny blog.
I know there are a million BBCode parsers out there (and even a PHP extension to do it), some extensible and so on. This one is mine. Would love pull requests.