textual.highlight
HighlightTheme ¶
Contains the style definition for user with the highlight method.
guess_language ¶
Guess the language based on the code and path. The result may be used in the highlight function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code |
str
|
The code to guess from. |
required |
path |
str | None
|
A path to the code. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The language, suitable for use with Pygments. |
highlight ¶
Apply syntax highlighting to a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code |
str
|
A string to highlight. |
required |
language |
str | None
|
The language to highlight. |
None
|
theme |
type[HighlightTheme]
|
A HighlightTheme class (type not instance). |
HighlightTheme
|
tab_size |
int
|
Number of spaces in a tab. |
8
|
Returns:
| Type | Description |
|---|---|
Content
|
A Content instance which may be used in a widget. |