本文整理汇总了Python中pygments.token.Other方法的典型用法代码示例。如果您正苦于以下问题:Python token.Other方法的具体用法?Python token.Other怎么用?Python token.Other使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.token
的用法示例。
在下文中一共展示了token.Other方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pygments import token [as 别名]
# 或者: from pygments.token import Other [as 别名]
def __init__(self, _root_lexer, _language_lexer, _needle=Other, **options):
self.root_lexer = _root_lexer(**options)
self.language_lexer = _language_lexer(**options)
self.needle = _needle
Lexer.__init__(self, **options)
示例2: get_bodypart_tokens
# 需要导入模块: from pygments import token [as 别名]
# 或者: from pygments.token import Other [as 别名]
def get_bodypart_tokens(self, text):
# return if:
# * no content
# * no content type specific
# * content encoding is not readable
# * max recurrsion exceed
if not text.strip() or not self.content_type:
return [(0, Other, text)]
cte = self.content_transfer_encoding
if cte and cte not in {"8bit", "7bit", "quoted-printable"}:
return [(0, Other, text)]
if self.max_nested_level == 0:
return [(0, Other, text)]
# get lexer
try:
lexer = get_lexer_for_mimetype(self.content_type)
except ClassNotFound:
return [(0, Other, text)]
if isinstance(lexer, type(self)):
lexer.max_nested_level = self.max_nested_level - 1
return lexer.get_tokens_unprocessed(text)