Based on https://pypi.python.org/pypi/bbcode