本文整理汇总了Python中pygments.formatters.html._get_ttype_class方法的典型用法代码示例。如果您正苦于以下问题:Python html._get_ttype_class方法的具体用法?Python html._get_ttype_class怎么用?Python html._get_ttype_class使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.formatters.html
的用法示例。
在下文中一共展示了html._get_ttype_class方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __iter__
# 需要导入模块: from pygments.formatters import html [as 别名]
# 或者: from pygments.formatters.html import _get_ttype_class [as 别名]
def __iter__(self):
"""parse code string and yield "clasified" tokens
"""
try:
tokens = self.lex()
except IOError:
log.info("Pygments lexer not found, using fallback")
# TODO: write message to INFO
yield ('', self.code)
return
for ttype, value in self.join(tokens):
yield (_get_ttype_class(ttype), value)
# code_block_directive
# --------------------
# ::
示例2: __iter__
# 需要导入模块: from pygments.formatters import html [as 别名]
# 或者: from pygments.formatters.html import _get_ttype_class [as 别名]
def __iter__(self):
"""Parse self.code and yield "classified" tokens.
"""
if self.lexer is None:
yield ([], self.code)
return
tokens = pygments.lex(self.code, self.lexer)
for tokentype, value in self.merge(tokens):
if self.tokennames == 'long': # long CSS class args
classes = str(tokentype).lower().split('.')
else: # short CSS class args
classes = [_get_ttype_class(tokentype)]
classes = [cls for cls in classes if cls not in unstyled_tokens]
yield (classes, value)