working_with_tokens.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:diff-highlight-tokens 作者: Met48 项目源码 文件源码
def fill_highlighting_text(tokens, highlight=FORMAT_INVERT, reset=FORMAT_RESET_INVERT):
    """
    Given a stream of tokens, yield tokens where highlighting tokens
    have formatting text

    """
    for token in tokens:
        token_type = get_token_type(token)
        if token_type == 'START_HIGHLIGHT':
            yield ('START_HIGHLIGHT', highlight)
        elif token_type == 'END_HIGHLIGHT':
            yield ('END_HIGHLIGHT', reset)
        else:
            yield token
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号