本文整理匯總了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)