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 |
---|---|---|---|
|
str
|
The code to guess from. |
required |
|
str | None
|
A path to the code. |
required |
Returns:
Type | Description |
---|---|
str
|
The language, suitable for use with Pygments. |
highlight
¶
highlight(
code,
*,
language=None,
path=None,
theme=HighlightTheme,
tab_size=8
)
Apply syntax highlighting to a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
A string to highlight. |
required |
|
str | None
|
The language to highlight. |
None
|
|
type[HighlightTheme]
|
A HighlightTheme class (type not instance). |
HighlightTheme
|
|
int
|
Number of spaces in a tab. |
8
|
Returns:
Type | Description |
---|---|
Content
|
A Content instance which may be used in a widget. |