Skip to content

Commit 42559aa

Browse files
Little simplification in pygments_token_to_classname and PygmentsLexer code.
1 parent 8490296 commit 42559aa

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

prompt_toolkit/lexers/pygments.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from prompt_toolkit.filters import to_filter
1414
from prompt_toolkit.formatted_text.utils import split_lines
15+
from prompt_toolkit.styles.pygments import pygments_token_to_classname
1516
from .base import Lexer, SimpleLexer
1617

1718
__all__ = [
@@ -116,9 +117,7 @@ class _TokenCache(dict):
116117
``class:pygments,pygments.A,pygments.A.B,pygments.A.B.C``
117118
"""
118119
def __missing__(self, key):
119-
parts = ('pygments',) + key
120-
121-
result = ('class:' + '.'.join(parts)).lower()
120+
result = 'class:' + pygments_token_to_classname(key)
122121
self[key] = result
123122
return result
124123

prompt_toolkit/styles/pygments.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,5 @@ def pygments_token_to_classname(token):
5757
(Our Pygments lexer will also turn the tokens that pygments produces in a
5858
prompt_toolkit list of fragments that match these styling rules.)
5959
"""
60-
if token:
61-
return 'pygments.' + '.'.join(token).lower()
62-
else:
63-
return 'pygments'
60+
parts = ('pygments', ) + token
61+
return '.'.join(parts).lower()

0 commit comments

Comments
 (0)