本文整理汇总了Python中pygments.lexers.get_all_lexers函数的典型用法代码示例。如果您正苦于以下问题:Python get_all_lexers函数的具体用法?Python get_all_lexers怎么用?Python get_all_lexers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_all_lexers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_context_data
def get_context_data(self, **kwargs):
context = super(SyntaxView, self).get_context_data(**kwargs)
context['syntax_list'] = sorted(
[(i[1][0], i[0]) for i in get_all_lexers()] +
[('rrst', 'Restructured Text (Rendered)'),
('md', 'Markdown (Rendered)')])
return context
开发者ID:algby,项目名称:snippt,代码行数:7,代码来源:views.py
示例2: index
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,代码行数:7,代码来源:index.py
示例3: _get_pygments_lexers
def _get_pygments_lexers(add_empty=True):
r = {}
if add_empty:
r[""] = ""
for lexer in get_all_lexers():
r[lexer[1][0]] = lexer[0]
return r
开发者ID:aether-space,项目名称:pinnwand,代码行数:7,代码来源:helpers.py
示例4: __init__
def __init__(self, parent):
Gtk.Dialog.__init__(self, "Insert code", parent, 0, use_header_bar=True,
buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
self.set_modal(True)
self.set_default_size(500, 350)
cancel_button = self.get_header_bar().get_children()[0]
self.set_focus(cancel_button)
ok_button = self.get_header_bar().get_children()[1]
ok_button.set_name("Insert")
ok_button.get_style_context().add_class("suggested-action")
box = self.get_content_area()
combobox = Gtk.ComboBoxText.new_with_entry()
combobox_entry = combobox.get_child()
completion = Gtk.EntryCompletion()
completion.set_model(combobox.get_model())
completion.set_text_column(0)
combobox_entry.set_completion(completion)
combobox_entry.set_placeholder_text("Select language")
# Fill combobox with languages
for item in get_all_lexers():
combobox.append(item[1][0], item[0])
box.add(combobox)
textview = Gtk.TextView()
textview.props.expand = True
box.add(textview)
self.show_all()
开发者ID:myrddin669,项目名称:simpleblogger,代码行数:32,代码来源:insert_code.py
示例5: lexerlist
def lexerlist(with_fnames=False):
lst = list(lexers.get_all_lexers()) + [("ANSI", ["ansi"], [], None)]
for name, aliases, fnames, _ in sorted(lst):
if with_fnames:
yield aliases, fnames
else:
yield aliases[0], name
开发者ID:piranha,项目名称:piu,代码行数:7,代码来源:utils.py
示例6: load_lexers
def load_lexers():
global lexers
# load available pygments lexers
lexers = []
try:
global get_lexer_by_name
from pygments.lexers import get_lexer_by_name
global highlight
from pygments import highlight
global Terminal256Formatter
from pygments.formatters import Terminal256Formatter
global TerminalFormatter
from pygments.formatters import TerminalFormatter
from pygments.lexers import get_all_lexers
except ImportError:
logging.warning("the pygments module has not been found, syntax coloring is not available")
pass
else:
for lexer in get_all_lexers():
try:
lexers.append(lexer[1][0])
except IndexError:
logging.warning("cannot load lexer: %s" % lexer[0])
pass
else:
logging.debug("loaded lexer %s" % lexer[1][0])
lexers.sort()
开发者ID:dmerejkowsky,项目名称:colout,代码行数:31,代码来源:colout.py
示例7: index
def index():
from flask import render_template
contenttypes = []
for lexer_info in get_all_lexers():
contenttypes.extend(lexer_info[3])
return render_template('index.html',
contenttypes=contenttypes)
开发者ID:ana-balica,项目名称:bepasty-server,代码行数:7,代码来源:index.py
示例8: lexers
def lexers():
"""
Return the list of the pigments lexers.
"""
result = [(lexer[0], lexer[1][0]) for lexer in get_all_lexers()]
result.sort()
return result
开发者ID:Mika64,项目名称:paulla.paste,代码行数:7,代码来源:views.py
示例9: get_all_languages
def get_all_languages():
all_languages = ['none']
for lexers in get_all_lexers():
all_languages.extend(lexers[1])
return all_languages
开发者ID:fviolette,项目名称:docs-tools,代码行数:7,代码来源:helper.py
示例10: __init__
def __init__(self, lexers):
"""
Constructor
@param lexers reference to the lexers dictionary
"""
super(EditorHighlightersPage, self).__init__()
self.setupUi(self)
self.setObjectName("EditorHighlightersPage")
self.editorLexerList.headerItem().setText(self.editorLexerList.columnCount(), "")
header = self.editorLexerList.header()
if qVersion() >= "5.0.0":
header.setSectionResizeMode(QHeaderView.ResizeToContents)
else:
header.setResizeMode(QHeaderView.ResizeToContents)
header.setSortIndicator(0, Qt.AscendingOrder)
try:
self.extsep = os.extsep
except AttributeError:
self.extsep = "."
self.extras = ["-----------", self.tr("Alternative")]
languages = [""] + sorted(lexers.keys()) + self.extras
self.editorLexerCombo.addItems(languages)
pygmentsLexers = [""] + sorted([l[0] for l in get_all_lexers()])
self.pygmentsLexerCombo.addItems(pygmentsLexers)
# set initial values
lexerAssocs = Preferences.getEditorLexerAssocs()
for ext in lexerAssocs:
QTreeWidgetItem(self.editorLexerList, [ext, lexerAssocs[ext]])
self.editorLexerList.sortByColumn(0, Qt.AscendingOrder)
开发者ID:chiamingyen,项目名称:kmol2016,代码行数:35,代码来源:EditorHighlightersPage.py
示例11: __init__
def __init__(self, *args, **kwargs):
kwargs['initial'] = dict(kwargs.get('initial', {}), language='cpp')
super(HighlighterForm, self).__init__(*args, **kwargs)
choices = []
for name, aliases, filetypes, mimetypes in get_all_lexers():
choices.append((aliases[0], name))
self.fields['language'].choices = choices
开发者ID:uranusjr,项目名称:bbshighlighter,代码行数:7,代码来源:forms.py
示例12: index
def index():
code = request.form.get('code', "print 'hello world!'")
lexer = (
request.form.get('lexer', '') or
unquote(request.cookies.get('lexer', 'python')))
lexers = [(l[1][0], l[0]) for l in get_all_lexers()]
lexers = sorted(lexers, lambda a, b: cmp(a[1].lower(), b[1].lower()))
style = (
request.form.get('style', '') or
unquote(request.cookies.get('style', 'colorful')))
styles = sorted(get_all_styles(), key=str.lower)
linenos = (
request.form.get('linenos', '') or
request.method == 'GET' and
unquote(request.cookies.get('linenos', ''))) or ''
divstyles = request.form.get(
'divstyles', unquote(request.cookies.get('divstyles', '')))
divstyles = divstyles or get_default_style()
html = hilite_me(code, lexer, {}, style, linenos, divstyles)
response = make_response(render_template('index.html', **locals()))
next_year = datetime.datetime.now() + datetime.timedelta(days=365)
response.set_cookie('lexer', quote(lexer), expires=next_year)
response.set_cookie('style', quote(style), expires=next_year)
response.set_cookie('linenos', quote(linenos), expires=next_year)
response.set_cookie('divstyles', quote(divstyles), expires=next_year)
return response
开发者ID:Noxalus,项目名称:hilite.me,代码行数:29,代码来源:main.py
示例13: __init__
def __init__(self, lexers):
"""
Constructor
@param lexers reference to the lexers dictionary
"""
ConfigurationPageBase.__init__(self)
self.setupUi(self)
self.setObjectName("EditorHighlightersPage")
self.editorLexerList.headerItem().setText(self.editorLexerList.columnCount(), "")
header = self.editorLexerList.header()
header.setResizeMode(QHeaderView.ResizeToContents)
header.setSortIndicator(0, Qt.AscendingOrder)
try:
self.extsep = os.extsep
except AttributeError:
self.extsep = "."
self.extras = ["-----------", self.trUtf8("Alternative")]
languages = [''] + sorted(lexers.keys()) + self.extras
for lang in languages:
self.editorLexerCombo.addItem(lang)
pygmentsLexers = [''] + sorted([l[0] for l in get_all_lexers()])
for pygmentsLexer in pygmentsLexers:
self.pygmentsLexerCombo.addItem(pygmentsLexer)
# set initial values
lexerAssocs = Preferences.getEditorLexerAssocs()
for ext in lexerAssocs.keys():
QTreeWidgetItem(self.editorLexerList,
QStringList() << ext << lexerAssocs[ext])
self.editorLexerList.sortByColumn(0, Qt.AscendingOrder)
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:35,代码来源:EditorHighlightersPage.py
示例14: _lexer_alias_name_map
def _lexer_alias_name_map(self):
lexer_alias_name_map = {}
for lexer_name, aliases, _, _ in get_all_lexers():
name = aliases[0] if aliases else lexer_name
for alias in aliases:
lexer_alias_name_map[alias] = name
return lexer_alias_name_map
开发者ID:pkdevbox,项目名称:trac,代码行数:7,代码来源:pygments.py
示例15: get_legal_pygments_lexers
def get_legal_pygments_lexers():
from pygments.lexers import get_all_lexers
lexers = []
for classname, names, dummy, dymmy in list(get_all_lexers()):
for name in names:
lexers.append(name)
return lexers
开发者ID:sakhan007,项目名称:doconce,代码行数:7,代码来源:common.py
示例16: load_lexers
def load_lexers():
global context
# load available pygments lexers
lexers = []
try:
global get_lexer_by_name
from pygments.lexers import get_lexer_by_name
global highlight
from pygments import highlight
global Terminal256Formatter
from pygments.formatters import Terminal256Formatter
global TerminalFormatter
from pygments.formatters import TerminalFormatter
from pygments.lexers import get_all_lexers
except ImportError:
logging.warning("the pygments module has not been found, syntax coloring is not available")
else:
try:
for lexer in get_all_lexers():
try:
lexers.append(lexer[1][0])
except IndexError:
logging.warning("cannot load lexer: %s" % lexer[1][0])
pass
except:
logging.warning("error while executing the pygment module, syntax coloring is not available")
lexers.sort()
logging.debug("loaded %i lexers: %s" % (len(lexers), ", ".join(lexers)))
context["lexers"] = lexers
开发者ID:nojhan,项目名称:colout,代码行数:35,代码来源:colout.py
示例17: PreparePygmentsFileList
def PreparePygmentsFileList(dirname):
'''
Use the lexer list and file extensions from the Pygments and prepare the list of files for which
lexers are available.
'''
from pygments.lexers import get_all_lexers
import fnmatch
#Prepare a list of fnmatch patterns from lexers
fnmatchpatlist = []
for lexer in get_all_lexers():
fnmatchpatlist = fnmatchpatlist+[pat for pat in lexer[2]]
rawfilelist = GetDirFileList(dirname)
#since one fnmatch pattern can exist in multiple lexers. We need remove duplicates from the fnmatch pattern list
fnmatchpatlist=set(fnmatchpatlist)
filelist = []
for fname in rawfilelist:
for pattern in fnmatchpatlist:
if(fnmatch.fnmatch(fname,pattern)):
filelist.append(fname)
#match is found.now break out of pattern matching loop
#but continue the outer loop
break
return(filelist)
开发者ID:renemilk,项目名称:tctoolkit,代码行数:27,代码来源:common.py
示例18: get_lexers
def get_lexers():
"""Get the supported language list.
Yield tuples containing the language Displayable name and the language
lexer name: ('Display Name', 'Lexer Name')
"""
for lexer in get_all_lexers():
yield lexer[0], lexer[1][0]
开发者ID:Kozea,项目名称:PastaBin,代码行数:8,代码来源:pastabin.py
示例19: language_list
def language_list(selfcls):
'''
get the support languages short name list from the pygments.
'''
langlist = ['%s (Names : %s)' % (lexer[0], ','.join(lexer[1]))
for lexer in get_all_lexers()]
langlist = sorted(langlist)
return langlist
开发者ID:Pranav1210,项目名称:tctoolkit,代码行数:8,代码来源:sourcetokenizer.py
示例20: handle_all_languages
def handle_all_languages(self):
all_lexers = list(lexers.get_all_lexers())
ret = []
for l in all_lexers:
if l[1][0] != "text":
ret.append((l[1][0],l[0],))
ret.sort()
return [('text', 'Plain text',)] + ret
开发者ID:benoitc,项目名称:epygments,代码行数:8,代码来源:highlight.py
注:本文中的pygments.lexers.get_all_lexers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论