Construct a Syntax object to render syntax highlighted code.
code (str) – Code to highlight.
lexer (Lexer | str) – Lexer to use (see https://pygments.org/docs/lexers/)
theme (str, optional) – Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to “monokai”.
dedent (bool, optional) – Enable stripping of initial whitespace. Defaults to False.
line_numbers (bool, optional) – Enable rendering of line numbers. Defaults to False.
start_line (int, optional) – Starting number for line numbers. Defaults to 1.
line_range (Tuple[int | None, int | None], optional) – If given should be a tuple of the start and end line to render. A value of None in the tuple indicates the range is open in that direction.
highlight_lines (Set[int]) – A set of line numbers to highlight.
code_width (int | None) – Width of code to render (not including line numbers), or None
to use all available width.
tab_size (int, optional) – Size of tabs. Defaults to 4.
word_wrap (bool, optional) – Enable word wrapping.
background_color (str, optional) – Optional background color, or None to use theme color. Defaults to None.
indent_guides (bool, optional) – Show indent guides. Defaults to False.
padding (PaddingDimensions) – Padding to apply around the syntax. Defaults to 0 (no padding).
A Pygments Lexer to use if one is not specified or invalid.
Construct a Syntax object from a file.
path (str) – Path to file to highlight.
encoding (str) – Encoding of file.
lexer (str | Lexer, optional) – Lexer to use. If None, lexer will be auto-detected from path/file content.
theme (str, optional) – Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to “emacs”.
dedent (bool, optional) – Enable stripping of initial whitespace. Defaults to True.
line_numbers (bool, optional) – Enable rendering of line numbers. Defaults to False.
start_line (int, optional) – Starting number for line numbers. Defaults to 1.
line_range (Tuple[int, int], optional) – If given should be a tuple of the start and end line to render.
highlight_lines (Set[int]) – A set of line numbers to highlight.
code_width (int | None) – Width of code to render (not including line numbers), or None
to use all available width.
tab_size (int, optional) – Size of tabs. Defaults to 4.
word_wrap (bool, optional) – Enable word wrapping of code.
background_color (str, optional) – Optional background color, or None to use theme color. Defaults to None.
indent_guides (bool, optional) – Show indent guides. Defaults to False.
padding (PaddingDimensions) – Padding to apply around the syntax. Defaults to 0 (no padding).
A Syntax object that may be printed to the console
[Syntax]
Get a syntax theme instance.
name (str | SyntaxTheme)
SyntaxTheme
Guess the alias of the Pygments lexer to use based on a path and an optional string of code. If code is supplied, it will use a combination of the code and the filename to determine the best lexer to use. For example, if the file is index.html
and the file contains Django templating syntax, then “html+django” will be returned. If the file is index.html
, and no templating language is used, the “html” lexer will be used. If no string of code is supplied, the lexer will be chosen based on the file extension..
path (AnyStr) – The path to the file containing the code you wish to know the lexer for.
code (str, optional) – Optional string of code that will be used as a fallback if no lexer is found for the supplied path.
The name of the Pygments lexer that best matches the supplied path/code.
Highlight code and return a Text instance.
The lexer for this syntax, or None if no lexer was found.
Tries to find the lexer by name if a string was passed to the constructor.
Adds a custom style on a part of the code, that will be applied to the syntax display when it’s rendered. Line numbers are 1-based, while column indexes are 0-based.
None
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4