I can’t believe I never announced this here. I have a custom coded
forum ( http://forum.fangamer.com/ ) built on Rails. Most of the
popular open source PHP forums just have their own interpretation for
BBCode, but not a common library. What’s interesting is that there are
no good BBCode libraries or implementations for Ruby. The closest
thing I could find was a simple regex implementation that had all
kinds of problems.
I wanted to support Textile because Textile is awesome, but I needed
the old BBCode since older “pro” users would eviscerate me if I didn’t
support it. I originally had a crappy regex on top of RedCloth, but it
was causing all kinds of weird page breaks with broken coding. So one
day during Christmas break, I forked RedCloth and wrote a whole path
that properly parses BBCode.
It’s available here: http://github.com/ROFISH/redcloth
To invoke, use the bbcode option.
r = RedCloth.new( “Some text is meant to be bold, others [i]italic[/
i].”, [:bbcode] )
r.to_html
#=> “
Some text is meant to be bold, others
italic.
There’s also a :bbcode_only option that completely ignores Textile for
users that want to use a “Disable Textile” mode. A near complete test
set is available at test/bbcode.yml.
I dunno if this is any use for anybody here, but I had a fun time
learning Ragel and it’s been running cleanly on my production server
for a couple months now.
Ryan Alyea
[email protected]