completely rewritten, much improved bbcode parser