def style_from_pygments(pygments_style_cls=None):
"""
Shortcut to create a :class:`.Style` instance from a Pygments style class
and a style dictionary.
Example::
from prompt_toolkit.styles.from_pygments import style_from_pygments
from pygments.styles import get_style_by_name
style = style_from_pygments(get_style_by_name('monokai'))
:param pygments_style_cls: Pygments style class to start from.
"""
# Import inline.
from pygments.style import Style as pygments_Style
assert issubclass(pygments_style_cls, pygments_Style)
pygments_style = []
if pygments_style_cls is not None:
for token, style in pygments_style_cls.styles.items():
pygments_style.append((_pygments_token_to_classname(token), style))
return Style(pygments_style)
评论列表
文章目录