Skip to content

Commit dfed263

Browse files
Added example to PygmentsLexer docstring.
1 parent f69bc44 commit dfed263

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

prompt_toolkit/layout/lexers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@ class PygmentsLexer(Lexer):
150150
"""
151151
Lexer that calls a pygments lexer.
152152
153+
Example::
154+
155+
from pygments.lexers import HtmlLexer
156+
lexer = PygmentsLexer(HtmlLexer)
157+
158+
Note: Don't forget to also load a Pygments compatible style. E.g.::
159+
160+
from prompt_toolkit.styles.from_pygments import style_from_pygments
161+
from pygments.styles import get_style_by_name
162+
style = style_from_pygments(get_style_by_name('monokai'))
163+
153164
:param pygments_lexer_cls: A `Lexer` from Pygments.
154165
:param sync_from_start: Start lexing at the start of the document. This
155166
will always give the best results, but it will be slow for bigger

0 commit comments

Comments
 (0)