def highlight_words ( string , keywords , cls_name = 'highlighted' ) : if not keywords : return string if not string : return '' include , exclude = get_text_tokenizer ( keywords ) highlighted = highlight_text ( include , string , cls_name , words = True ) return highlighted
how to have python highlight some phrase
Given an list of words this function highlights the matched words in the given string .
def highlight_words(string, keywords, cls_name='highlighted'):
    """ Given an list of words, this function highlights the matched words in the given string. """

    if not keywords:
        return string
    if not string:
        return ''
    include, exclude = get_text_tokenizer(keywords)
    highlighted = highlight_text(include, string, cls_name, words=True)
    return highlighted