本文整理汇总了Python中pygments.lexers.get_all_lexers方法的典型用法代码示例。如果您正苦于以下问题:Python lexers.get_all_lexers方法的具体用法?Python lexers.get_all_lexers怎么用?Python lexers.get_all_lexers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.lexers
的用法示例。
在下文中一共展示了lexers.get_all_lexers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import get_all_lexers [as 别名]
def main():
uses = {}
for name, aliases, filenames, mimetypes in get_all_lexers():
cls = find_lexer_class(name)
if not cls.aliases:
print(cls, "has no aliases")
for f in filenames:
if f not in uses:
uses[f] = []
uses[f].append(cls)
ret = 0
for k, v in uses.items():
if len(v) > 1:
#print "Multiple for", k, v
for i in v:
if i.analyse_text is None:
print(i, "has a None analyse_text")
ret |= 1
elif Lexer.analyse_text.__doc__ == i.analyse_text.__doc__:
print(i, "needs analyse_text, multiple lexers for", k)
ret |= 2
return ret
示例2: list_languages
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import get_all_lexers [as 别名]
def list_languages() -> Dict[str, str]:
# Start with converting the pygments lexers index into a dict.
lexers = {lexer[1][0]: lexer[0] for lexer in get_all_lexers()}
# Add autodetection option
lexers["autodetect"] = "Autodetect"
# Since dicts are sorted since Python 3.7 (and 3.6 per implementation
# detail) and the Pygments ordering is a bit inane we sort and turn back
# into a dict here.
return dict(sorted(lexers.items(), key=lambda x: x[1]))
示例3: index
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import get_all_lexers [as 别名]
def index():
contenttypes = [
'text/x-bepasty-redirect', # redirect / link shortener service
]
for lexer_info in get_all_lexers():
contenttypes.extend(lexer_info[3])
return render_template('index.html', contenttypes=contenttypes)