本文整理匯總了Python中pygments.token.STANDARD_TYPES.keys方法的典型用法代碼示例。如果您正苦於以下問題:Python STANDARD_TYPES.keys方法的具體用法?Python STANDARD_TYPES.keys怎麽用?Python STANDARD_TYPES.keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pygments.token.STANDARD_TYPES
的用法示例。
在下文中一共展示了STANDARD_TYPES.keys方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_pygments_tokens
# 需要導入模塊: from pygments.token import STANDARD_TYPES [as 別名]
# 或者: from pygments.token.STANDARD_TYPES import keys [as 別名]
def get_pygments_tokens(page, elem, uid):
"""inserts a table containing all existent token types and corresponding
css class, with an example"""
# The original div in the raw html page may contain some text
# as a visual reminder that we need to remove here.
elem.text = ''
elem.attrib['class'] = CRUNCHY_PYGMENTS
table = SubElement(elem, 'table')
row = SubElement(table, 'tr')
for title in ['Token type', 'css class']:
column = SubElement(row, 'th')
column.text = title
keys = list(STANDARD_TYPES.keys())
keys.sort()
for token in keys:
if len(repr(token)) == 5: # token = Token
continue
row = SubElement(table, 'tr')
column1 = SubElement(row, 'td')
column1.text = repr(token)[6:] # remove "Token."
column2 = SubElement(row, 'td')
token_class = STANDARD_TYPES[token]
column2.text = token_class.split('_')[0]
column3 = SubElement(row, 'td')
span = SubElement(column3, 'span')
span.attrib['class'] = token_class
span.text = " * test * "
column4 = SubElement(row, 'td')
_code = SubElement(column4, 'code')
_code.attrib['class'] = token_class
_code.text = " * test * "
column5 = SubElement(row, 'td')
var = SubElement(column5, 'var')
var.attrib['class'] = token_class
var.text = " * test * "
return