[bbcode] fix function scope