Classes
SyntaxRole
0
▼
Semantic roles for syntax highlighting.
Each role represents the **purpose** of a code element, no…
SyntaxRole
0
▼
Semantic roles for syntax highlighting.
Each role represents the purpose of a code element, not its syntactic category. This enables consistent theming across languages: a function definition in Python and JavaScript get the same color.
The value of each role is a short CSS-friendly identifier used in
class names like.syntax-functionor CSS variables like--syntax-function.
Categories:
- Control & Structure: Program flow and declarations
- Data & Literals: Values embedded in code
- Identifiers: Named elements (functions, variables, types)
- Documentation: Comments and docstrings
- Feedback: Errors, warnings, diff markers
Example:
>>> SyntaxRole.FUNCTION
<SyntaxRole.FUNCTION: 'function'>
>>> f".syntax-{SyntaxRole.FUNCTION}"
'.syntax-function'