• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python styles.get_all_styles函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pygments.styles.get_all_styles函数的典型用法代码示例。如果您正苦于以下问题:Python get_all_styles函数的具体用法?Python get_all_styles怎么用?Python get_all_styles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_all_styles函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: handle

    def handle(self, scheme=None, **options):
        if not PYGMENTS:
            raise CommandError('Unable to load pygments. '
                               'Please install pygments to use this command.')

        if options['all_styles']:
            for scheme in get_all_styles():
                print HtmlFormatter(style=scheme)\
                .get_style_defs('.%s .codehilite' % scheme)
            # generated all styles, done and done
            sys.exit(0)

        if not scheme:
            print """
Usage: ./manage.py pygments_styles <scheme_name>
Available color schemes:
""" + '\n'.join(["  %s" % name for name in get_all_styles()])
        else:
            try:
                assert(scheme in list(get_all_styles()))
            except AssertionError:
                raise CommandError('Invalid scheme name "% s"\n' % scheme +
                                   'Please use one of the available color'
                                   ' schemes on your system:\n' +
                                   '\n'.join(["  %s" % name for name in \
                                              get_all_styles()]))
            print HtmlFormatter(style=scheme).get_style_defs('.codehilite')
            sys.exit(0)
开发者ID:Artivest,项目名称:mezzanine-pagedown,代码行数:28,代码来源:pygments_styles.py


示例2: 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


示例3: _discover_styles

def _discover_styles():
    import inspect
    from pygments.styles import get_all_styles, get_style_by_name

    # maps style 'name' (not the class name) and aliases to (module, classname) tuples
    default_names = {}
    names = {}
    styles = {"names": names}
    if DEBUG:
        from collections import defaultdict

        duplicates = defaultdict(set)
    for name in get_all_styles():
        cls = get_style_by_name(name)
        mod = inspect.getmodule(cls)
        val = (mod.__name__, cls.__name__)
        if DEBUG and name in names and names[name] != val and name not in default_names:
            duplicates[name].add(val)
            duplicates[name].add(names[name])
        names[name] = val
    # remove some ambiquity
    names.update(default_names)
    # print dumplicate message
    if DEBUG:
        _print_duplicate_message(duplicates)
    return styles
开发者ID:donnemartin,项目名称:gitsome,代码行数:26,代码来源:pygments_cache.py


示例4: get_all_code_styles

def get_all_code_styles():
    """
    Return a mapping from style names to their classes.
    """
    result = dict((name, get_style_by_name(name).styles) for name in get_all_styles())
    result['win32'] = win32_code_style
    return result
开发者ID:Python-PyBD,项目名称:ptpython,代码行数:7,代码来源:style.py


示例5: __init__

    def __init__(self, parser_state, outdir,
                 line_numbers=True,
                 formatter_style='default'):
        self.state = parser_state  # expect parser.ParserState instance
        self.outdir = outdir
        self.line_numbers = line_numbers

        self.formatter_style = formatter_style
        if not formatter_style in get_all_styles():
            raise CheckfortException("Invalid HtmlFormatter style - " + style)

        # vars to supply to all HTML templates
        self.default_context = {
            "to_root": "",
            "gen_date": strftime("%a, %d %b %Y %H:%M:%S", gmtime()),
            "project_url": project_url,
        }

        # default args for pygments.formatters.HtmlFormatter
        self.fmt_args = {
            "lineanchors": "line",
            "cssclass": "highlight",
            "style": formatter_style,
        }
        if self.line_numbers:
            self.fmt_args["linenos"] = "inline"

        # cache Event instances
        self.events = [
            Event(code, self.state.event_message[code], count)
            for code, count in sorted(self.state.event_counter.iteritems(),
                                      key=itemgetter(1), reverse=True)]
开发者ID:shawnchin,项目名称:checkfort,代码行数:32,代码来源:filegen.py


示例6: style_info

def style_info(request, response, function_info):
    """
    Listet alle Stylesheet-Namen auf und zwigt die jeweiligen Styles an.
    """
    style_list = list(get_all_styles())

    selected_style = None
    if function_info!=None:
        selected_style = function_info[0]
        if not selected_style in style_list:
            self.page_msg.red("Name Error!")
            selected_style = None

    context = {
        "styles": style_list,
        "selected_style": selected_style,
        "menu_link": request.URLs.actionLink("menu"),
    }
    request.templates.write("pygments_css", context, debug=False)

    if selected_style == None:
        # Es wurde kein Style ausgewählt
        return

    # CSS zum Style anzeigen
    stylesheet = HtmlFormatter(style=selected_style)
    stylesheet = stylesheet.get_style_defs('.pygments_code')

    request.render.highlight(
        ".css", stylesheet, pygments_style=selected_style
    )
开发者ID:Aaron1011,项目名称:python-code-snippets,代码行数:31,代码来源:pygments_info.py


示例7: register_options

 def register_options(cls, register):
   register('--code-style', choices=list(get_all_styles()), default='friendly',
            help='Use this stylesheet for code highlights.')
   register('--open', action='store_true',
            help='Open the generated documents in a browser.')
   register('--fragment', action='store_true',
            help='Generate a fragment of html to embed in a page.')
开发者ID:dominichamon,项目名称:pants,代码行数:7,代码来源:markdown_to_html.py


示例8: highlight_

def highlight_(data, lang):
    """A helper function for highlighting data with pygments."""
    try:
        from pygments import highlight
        from pygments.util import ClassNotFound
        from pygments.styles import get_all_styles
        from pygments.lexers import get_lexer_by_name
        from pygments.formatters import Terminal256Formatter
    except ImportError:
        echo_error('Pygments is missing')
        click.echo('Syntax highlighting is provided by pygments.')
        click.echo('Please install pygments (http://pygments.org)!')
        exit(1)

    try:
        lexer = get_lexer_by_name(lang)
    except ClassNotFound:
        echo_error('Lexer not found!')
        exit(1)

    try:
        formatter = Terminal256Formatter(style=config.PYGMENTS_THEME)
    except ClassNotFound:
        styles = get_all_styles()
        error_msg = 'Pygments theme {} not found!'.format(config.PYGMENTS_THEME)
        echo_error(error_msg)
        click.echo("Please correct pygments_theme in your '~/.noterc'!")
        click.echo('Supported themes are:')
        click.echo()
        click.echo('\n'.join(styles))
        exit(1)

    return highlight(data, lexer, formatter)
开发者ID:Jorick,项目名称:pynote,代码行数:33,代码来源:formatting.py


示例9: load_settings

    def load_settings(self):
        '''This function loads project settings
        '''
        self.config_parser = ConfigParser(name='DesignerSettings')
        DESIGNER_CONFIG = os.path.join(get_config_dir(),
                                       constants.DESIGNER_CONFIG_FILE_NAME)

        DEFAULT_CONFIG = os.path.join(get_kd_dir(),
                                      constants.DESIGNER_CONFIG_FILE_NAME)
        if not os.path.exists(DESIGNER_CONFIG):
            shutil.copyfile(DEFAULT_CONFIG,
                            DESIGNER_CONFIG)

        self.config_parser.read(DESIGNER_CONFIG)
        self.config_parser.upgrade(DEFAULT_CONFIG)

        # creates a panel before insert it to update code input theme list
        panel = self.create_json_panel('Kivy Designer Settings',
                                        self.config_parser,
                            os.path.join(get_kd_data_dir(),
                                         'settings', 'designer_settings.json'))
        uid = panel.uid
        if self.interface is not None:
            self.interface.add_panel(panel, 'Kivy Designer Settings', uid)

        # loads available themes
        for child in panel.children:
            if child.id == 'code_input_theme_options':
                child.items = styles.get_all_styles()

        # tries to find python and buildozer path if it's not defined
        path = self.config_parser.getdefault(
            'global', 'python_shell_path', '')

        if path.strip() == '':
            self.config_parser.set('global', 'python_shell_path',
                                   sys.executable)
            self.config_parser.write()

        buildozer_path = self.config_parser.getdefault('buildozer',
                                                       'buildozer_path', '')

        if buildozer_path.strip() == '':
            buildozer_path = find_executable('buildozer')
            if buildozer_path:
                self.config_parser.set('buildozer',
                                       'buildozer_path',
                                        buildozer_path)
                self.config_parser.write()

        self.add_json_panel('Buildozer', self.config_parser,
                            os.path.join(get_kd_data_dir(), 'settings',
                                         'buildozer_settings.json'))
        self.add_json_panel('Hanga', self.config_parser,
                            os.path.join(get_kd_data_dir(), 'settings',
                                         'hanga_settings.json'))
        self.add_json_panel('Keyboard Shortcuts', self.config_parser,
                            os.path.join(get_kd_data_dir(), 'settings',
                                         'shortcuts.json'))
开发者ID:kivy,项目名称:kivy-designer,代码行数:59,代码来源:settings.py


示例10: handle

 def handle(self, *args, **options):
     styles = list(get_all_styles())
     path = os.path.join(settings.MEDIA_ROOT, "css", "highlighting", "%s.css")
     for style in styles:
         f = file(path % style, "w+")
         f.write(HtmlFormatter(style=style).get_style_defs('.highlight'))
         f.close()
     print "generated stylesheets for %i pygments styles" % len(styles)
开发者ID:gdos,项目名称:pygame,代码行数:8,代码来源:generatecss.py


示例11: pref_style

def pref_style():
	styles = list(get_all_styles())
	print "Choose from one of the styles"
	count=1
	for i in styles:
		print count,":",i
		count+=1
	k=input()
	return styles[k-1]
开发者ID:sid1607,项目名称:AlphaPy,代码行数:9,代码来源:syntaxhighlighter.py


示例12: register_options

 def register_options(cls, register):
   register('--code-style', choices=list(get_all_styles()), default='friendly',
            help='Use this stylesheet for code highlights.')
   register('--open', action='store_true',
            help='Open the generated documents in a browser.')
   register('--fragment', action='store_true',
            help='Generate a fragment of html to embed in a page.')
   register('--extension', action='append', default=['.md', '.markdown'],
            help='Process files with these extensions (as well as the standard extensions).')
开发者ID:digideskio,项目名称:pants,代码行数:9,代码来源:markdown_to_html.py


示例13: register_options

 def register_options(cls, register):
   register('--code-style', choices=list(get_all_styles()), default='friendly',
            help='Use this stylesheet for code highlights.')
   register('--open', action='store_true',
            help='Open the generated documents in a browser.')
   register('--fragment', action='store_true',
            help='Generate a fragment of html to embed in a page.')
   register('--ignore-failure', default=False, action='store_true',
            help='Do not consider rendering errors to be build errors.')
开发者ID:pcurry,项目名称:pants,代码行数:9,代码来源:markdown_to_html.py


示例14: configure_codehighlight_options

 def configure_codehighlight_options(option_group, mkflag):
     all_styles = list(get_all_styles())
     option_group.add_option(
         mkflag("code-style"),
         dest="markdown_to_html_code_style",
         type="choice",
         choices=all_styles,
         help="Selects the stylesheet to use for code highlights, one of: " "%s." % " ".join(all_styles),
     )
开发者ID:UrbanCompass,项目名称:commons,代码行数:9,代码来源:markdown_to_html.py


示例15: pygments_css

def pygments_css(schema='colorful'):
    if schema=='list':
        from pygments.styles import get_all_styles
        _message_ok('Avalible styles: {}'.format(', '.join(list(get_all_styles()))))
    else:
        local("pygmentize -f html -S {schema} -a .codehilite > {static_root}/css/pygments.css".format(
            static_root=django_settings.STATIC_ROOT,
            schema=schema,
        ))
开发者ID:mitrofun,项目名称:intopython,代码行数:9,代码来源:fabfile.py


示例16: register_options

 def register_options(cls, register):
   register('--code-style',
            choices=list(get_all_styles()),
            help=('Selects the stylesheet to use for code highlights, '
                  'one of {0}'.format(' '.join(get_all_styles()))),
            legacy='markdown_to_html_code_style')
   register('--open',
            action='store_true',
            help='Open the generated documents in a browser.',
            legacy='markdown_to_html_open')
   register('--fragment',
            action='store_true',
            help='Generate a fragment of html to embed in a page.',
            legacy='markdown_to_html_fragment')
   register('--extension',
            action='append',
            help=('Override the default markdown extensions and process pages '
                  'whose source have these extensions instead.'),
            legacy='markdown_to_html_extensions')
开发者ID:Yasumoto,项目名称:pants,代码行数:19,代码来源:markdown_to_html.py


示例17: load_settings

    def load_settings(self):
        """This function loads project settings
        """
        self.config_parser = ConfigParser(name="DesignerSettings")
        DESIGNER_CONFIG = os.path.join(get_kivy_designer_dir(), DESIGNER_CONFIG_FILE_NAME)

        _dir = os.path.dirname(designer.__file__)
        _dir = os.path.split(_dir)[0]

        DEFAULT_CONFIG = os.path.join(_dir, DESIGNER_CONFIG_FILE_NAME)
        if not os.path.exists(DESIGNER_CONFIG):
            shutil.copyfile(DEFAULT_CONFIG, DESIGNER_CONFIG)

        self.config_parser.read(DESIGNER_CONFIG)
        self.config_parser.upgrade(DEFAULT_CONFIG)

        # creates a panel before insert it to update code input theme list
        panel = self.create_json_panel(
            "Kivy Designer Settings",
            self.config_parser,
            os.path.join(_dir, "designer", "settings", "designer_settings.json"),
        )
        uid = panel.uid
        if self.interface is not None:
            self.interface.add_panel(panel, "Kivy Designer Settings", uid)

        # loads available themes
        for child in panel.children:
            if child.id == "code_input_theme_options":
                child.items = styles.get_all_styles()

        # tries to find python and buildozer path if it's not defined
        path = self.config_parser.getdefault("global", "python_shell_path", "")

        if path.strip() == "":
            self.config_parser.set("global", "python_shell_path", sys.executable)
            self.config_parser.write()

        buildozer_path = self.config_parser.getdefault("buildozer", "buildozer_path", "")

        if buildozer_path.strip() == "":
            buildozer_path = find_executable("buildozer")
            if buildozer_path:
                self.config_parser.set("buildozer", "buildozer_path", buildozer_path)
                self.config_parser.write()

        self.add_json_panel(
            "Buildozer", self.config_parser, os.path.join(_dir, "designer", "settings", "buildozer_settings.json")
        )
        self.add_json_panel(
            "Hanga", self.config_parser, os.path.join(_dir, "designer", "settings", "hanga_settings.json")
        )
        self.add_json_panel(
            "Keyboard Shortcuts", self.config_parser, os.path.join(_dir, "designer", "settings", "shortcuts.json")
        )
开发者ID:Lh4cKg,项目名称:kivy-designer,代码行数:55,代码来源:designer_settings.py


示例18: rtf_out

def rtf_out(name,k):
	"""Rich text format"""
	styles = list(get_all_styles())
	m=styles[k-1]
	new=""
	for i in name:
		if i==".":
			break
		new+=i
	stri="pygmentize -O full,style="+m+" -o "+new+".rtf "+name
	os.system(stri)
开发者ID:sid1607,项目名称:AlphaPy,代码行数:11,代码来源:syntaxhighlighter.py


示例19: add_code_styles_combobox

def add_code_styles_combobox(self, func, previous_style):
  
  combo = QComboBox()
  combo.addItem(previous_style)
  
  for style in sorted(list(get_all_styles())):
    combo.addItem(style)

  combo.activated[str].connect(func)
  self.addWidget(combo)

  return combo
开发者ID:JDHankle,项目名称:SyntaxHighlight,代码行数:12,代码来源:code_highlight_addon.py


示例20: html_out

def html_out(name,k):
	"""HTML printed"""
	styles = list(get_all_styles())
	m=styles[k-1]
	print m
	new=""
	for i in name:
		if i==".":
			break
		new+=i
	stri="pygmentize -O full,style="+m+" -o "+new+".html "+name
	print stri
	os.system(stri)
开发者ID:sid1607,项目名称:AlphaPy,代码行数:13,代码来源:syntaxhighlighter.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python styles.get_style_by_name函数代码示例发布时间:2022-05-25
下一篇:
Python plugin.find_plugin_lexers函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap