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
working_with_tokens.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录