def safe_clean(text): from flask import Markup from bleach import clean tags = ['b','i','font','br'] attrs = { '*':['style'], 'font':['color'] } styles = ['color'] return Markup(clean(text,tags = tags, attributes = attrs, styles = styles))
自定义filter过滤器