# File lib/facet/bbcode.rb, line 180
    def BBCode.bbcode_to_ansi(string, usecolors = true)
        return "" if string.nil? || string.to_s.strip.empty?
        result = ""

        return BBCode.strip_bbcode(string) if !usecolors

        ## Iterate over lines
        string.split("\n").each do |line|

            ## TODO: stacking? other styles!
            ANSINAME2BBCODE.each do |key,val|
                line.gsub!(/\[#{val}\]/, ANSINAME2CODE[key])
                line.gsub!(/\[\/#{val}\]/, ANSINAME2CODE["reset"])
            end

            ## Fonttypes and sizes not available
            line.gsub!(/\[SIZE=\d\]/, "")
            line.gsub!(/\[\/SIZE\]/, "")
            line.gsub!(/\[FONT=[^\]]*\]/, "")
            line.gsub!(/\[\/FONT\]/, "")

            ## Color-mapping
            colors = line.scan(/\[COLOR=(.*?)\]/i)
            colors = colors.collect{|s|  s[0].to_s} if !colors.nil?
            colors.each do |col|  
                name = BBCOLOR2ANSI[col.downcase]
                name = BBCOLOR2ANSI["white"] if name.nil?
                code = ANSINAME2CODE[name]

                line.gsub!(/\[COLOR=#{col}\]/i, code)
            end
            line.gsub!(/\[\/COLOR\]/, ANSINAME2CODE["reset"])

            ## TODO: Alignment
            ## TODO: IMGs
            ## TODO: EMAILs
            ## TODO: URLs
            ## TODO: QUOTEs
            ## TODO: LISTs

            result << sprintf("%s\n", line)
        end

        return result
    end