working_with_tokens.py 文件源码

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

项目:diff-highlight-tokens 作者: Met48 项目源码 文件源码
def tokenize(text, lexer=None):
    """
    Split text into (token_type, token_text) pairs using the given lexer

    When there is no lexer, it will split by words instead.

    """
    if lexer is None:
        return [(pygments.token.Text, word) for word in split_words(text)]

    tokens = lexer.get_tokens(text)
    tokens = group_tokens(tokens)

    return tokens
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号