当前位置: 首页>>代码示例>>Python>>正文


Python lexers.get_all_lexers方法代码示例

本文整理汇总了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 
开发者ID:pygments,项目名称:pygments,代码行数:26,代码来源:detect_missing_analyse_text.py

示例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])) 
开发者ID:supakeen,项目名称:pinnwand,代码行数:13,代码来源:utility.py

示例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) 
开发者ID:bepasty,项目名称:bepasty-server,代码行数:9,代码来源:index.py


注:本文中的pygments.lexers.get_all_lexers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。