#NEWLINE# def bbcode_formatter( element , children , site ) : #NEWLINE# #INDENT# if ( element . tag == 'br' ) : #NEWLINE# #INDENT# return '\n' #NEWLINE# #UNINDENT# if ( element . tag == 'a' ) : #NEWLINE# #INDENT# return '[url={site}/redirect.php?url={link}]{text}[/url]' . format ( site = site , link = element . href , text = children ) #NEWLINE# #UNINDENT# if ( element . tag == 'img' ) : #NEWLINE# #INDENT# return '[img={link}]{text}[/img]' . format ( link = element . src , text = children ) #NEWLINE# #UNINDENT# if ( element . tag in [ 'b' , 'strong' ] ) : #NEWLINE# #INDENT# return '[b]{text}[/b]' . format ( text = children ) #NEWLINE# #UNINDENT# if ( element . tag in [ 'em' , 'i' ] ) : #NEWLINE# #INDENT# return '[i]{text}[/i]' . format ( text = children ) #NEWLINE# #UNINDENT# if ( element . tag in [ 'del' , 's' ] ) : #NEWLINE# #INDENT# return '[s]{text}[/s]' . format ( text = children ) #NEWLINE# #UNINDENT# if ( element . tag == 'u' ) : #NEWLINE# #INDENT# return '[u]{text}[/u]' . format ( text = children ) #NEWLINE# #UNINDENT# if ( element . tag == 'title' ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# if children : #NEWLINE# #INDENT# return children