當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。