Skip to content
Prev Previous commit
Next Next commit
feat(lexers.python): Update cdef context of cython lexer to different…
…iate function, class, and variable name tokens. #2932
  • Loading branch information
Spill-Tea committed Jul 15, 2025
commit e85a73890a9384a51b4282d346ee3885e231cfe5
12 changes: 6 additions & 6 deletions pygments/lexers/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,12 +938,12 @@ class CythonLexer(RegexLexer):
(r'[a-zA-Z_]\w*', Name.Function, '#pop')
],
'cdef': [
(r'(public|readonly|extern|api|inline)\b', Keyword.Reserved),
(r'(struct|enum|union|class)\b', Keyword),
(r'([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)',
bygroups(Name.Function, Whitespace), '#pop'),
(r'([a-zA-Z_]\w*)(\s*)(,)',
bygroups(Name.Function, Whitespace, Punctuation)),
(r"(public|readonly|extern|api|inline|packed)\b", Keyword.Reserved),
(r"(struct|enum|union|class|cppclass)\b(\s+)([a-zA-Z_]\w*)",
bygroups(Keyword, Whitespace, Name.Class), "#pop",),
(r"([a-zA-Z_]\w*)(\s*)(?=\()", bygroups(Name.Function, Whitespace), "#pop"),
(r"([a-zA-Z_]\w*)(\s*)(?=[:,=#\n]|$)", bygroups(Name.Variable, Whitespace), "#pop"),
(r"([a-zA-Z_]\w*)(\s*)(,)", bygroups(Name.Variable, Whitespace, Punctuation)),
(r'from\b', Keyword, '#pop'),
(r'as\b', Keyword),
(r':', Punctuation, '#pop'),
Expand Down