highlight¶
Generated by tools/pygments_styles from pygments-2.19.2’s style modules and sphinx-9.1.0’s pygments_styles.py; do not edit.
Types
- highlight.Color :: struct¶
-
Color is a CSS colour as Pygments normalizes it: six hex digits, case kept.
- hex: [6]u8¶
- set: bool¶
- highlight.Html_Lines :: struct¶
-
Html_Lines numbers and emphasizes lines as Pygments does for Sphinx’s :linenos: and :emphasize-lines: (linenos=”inline”, hl_lines): each line starts with <span class=”linenos”> 7</span>, and an emphasized line, number included, is wrapped in <span class=”hll”>…\n</span>.
- first: int¶
-
the first line’s number; 0 leaves lines unnumbered.
- emphasized: proc(user: rawptr, line: int) -> bool¶
-
by 1-based line; nil for none.
- user: rawptr¶
- highlight.Lexer :: enum u8¶
-
Lexer names a language. .Default and .Guess are Sphinx’s pseudo languages: tokenize resolves them against the code (see resolve).
- Text¶
- Python¶
- Pycon¶
- Pytb¶
- C¶
- Cpp¶
- Rust¶
- Go¶
- Java¶
- Kotlin¶
- Csharp¶
- Swift¶
- Zig¶
- Odin¶
- Javascript¶
- Typescript¶
- Json¶
- Yaml¶
- Toml¶
- Ini¶
- Xml¶
- Html¶
- Css¶
- Bash¶
- Console¶
- Powershell¶
- Sql¶
- Diff¶
- Makefile¶
- Dockerfile¶
- Rst¶
- Markdown¶
- Latex¶
- Typst¶
- Dot¶
- Default¶
- Guess¶
- highlight.Lexer_Info :: struct¶
-
- name: string¶
-
Pygments’ lexer name, e.g. “Python”.
- aliases: []string¶
-
the names code blocks use; the first is the canonical one.
- filenames: []string¶
-
glob patterns: “*.py”, “Makefile”.
- mimetypes: []string¶
- step: Step¶
- spec: ^Code_Spec¶
-
the rule tables of lexers built on the code engine.
- highlight.Look :: struct¶
-
Look is a token kind’s resolved style.
- bold: bool¶
- italic: bool¶
- underline: bool¶
- highlight.Output :: struct¶
-
Output is caller storage for the writers. They never allocate: bytes that fit go into buf, and written counts every byte the output needs, so a nil buf measures the output and a second call with a buffer of that size writes it. The same input always gives the same bytes.
- buf: []u8¶
- written: int¶
- highlight.Problem :: struct¶
-
- kind: Problem_Kind¶
- name: string¶
-
the language or style as written.
- suggestion: string¶
-
a close name, for “Did you mean”.
- line: int¶
-
Lexing_Error: 1-based line and column (in characters) of
- column: int¶
-
the first Error token,
- excerpt: string¶
-
the line it is on,
- near: string¶
-
and its text.
- highlight.Problem_Kind :: enum u8¶
-
- None¶
- Unknown_Language¶
-
Sphinx: “Pygments lexer name ‘x’ is not known”.
- Unknown_Style¶
-
pygments_style names no style.
- Lexing_Error¶
-
Sphinx: “Lexing literal_block … resulted in an error”.
- highlight.Scanner :: struct¶
-
Scanner tokenizes one input. Create it with scanner_init and read tokens with next_token, or let tokenize and highlight_html drive it.
- code: string¶
- pos: int¶
- limit: int¶
-
steps see code[:limit]; an inner lexer sees its region only.
- state: State¶
- inner: State¶
-
a nested lexer: Python after a pycon prompt, CSS in <style>.
- region: int¶
-
the inner lexer runs while pos < region.
- region_start: int¶
- nested: bool¶
- head: int¶
- count: int¶
- highlight.Style :: enum u8¶
-
Style is a pygments_style: every style Pygments ships, and Sphinx’s sphinx and none.
- Abap¶
- Algol¶
- Algol_Nu¶
- Arduino¶
- Autumn¶
- Borland¶
- Bw¶
- Coffee¶
- Colorful¶
- Default¶
- Dracula¶
- Emacs¶
- Friendly¶
- Friendly_Grayscale¶
- Fruity¶
- Github_Dark¶
- Gruvbox_Dark¶
- Gruvbox_Light¶
- Igor¶
- Inkpot¶
- Lightbulb¶
- Lilypond¶
- Lovelace¶
- Manni¶
- Material¶
- Monokai¶
- Murphy¶
- Native¶
- None¶
- Nord¶
- Nord_Darker¶
- One_Dark¶
- Paraiso_Dark¶
- Paraiso_Light¶
- Pastie¶
- Perldoc¶
- Rainbow_Dash¶
- Rrt¶
- Sas¶
- Solarized_Dark¶
- Solarized_Light¶
- Sphinx¶
- Staroffice¶
- Stata_Dark¶
- Stata_Light¶
- Tango¶
- Trac¶
- Vim¶
- Vs¶
- Xcode¶
- Zenburn¶
- highlight.Style_Info :: struct¶
-
- name: string¶
- dark: bool¶
-
the background is dark.
- background: string¶
-
the .highlight background.
- highlight: string¶
-
emphasized lines (.hll).
- line_number: string¶
- line_number_background: string¶
- special_line_number: string¶
- special_background: string¶
- base: string¶
-
the root token’s definition, inherited by all.
- rules: []Style_Rule¶
- highlight.Style_Rule :: struct¶
-
Style_Rule is one entry of a style’s dict; a style has at most one per kind.
- kind: Token_Kind¶
- definition: string¶
- highlight.Token :: struct¶
-
Token is a run of the input: code[start:end] has kind. The tokens tokenize returns are contiguous, cover every byte exactly once, and never hold two neighbours of one kind.
- start: u32¶
- end: u32¶
- kind: Token_Kind¶
- highlight.Token_Kind :: enum u8¶
-
Token_Kind mirrors Pygments’ token hierarchy. Each kind has Pygments’ dotted name (kind_name), its short CSS class (kind_class) and its parent (kind_parent), so the stylesheets Sphinx themes already ship style Guidedog’s output unchanged.
- Text¶
- Whitespace¶
- Escape¶
- Error¶
- Other¶
- Keyword¶
- Keyword_Constant¶
- Keyword_Declaration¶
- Keyword_Namespace¶
- Keyword_Pseudo¶
- Keyword_Reserved¶
- Keyword_Type¶
- Name¶
- Name_Attribute¶
- Name_Builtin¶
- Name_Builtin_Pseudo¶
- Name_Class¶
- Name_Constant¶
- Name_Decorator¶
- Name_Entity¶
- Name_Exception¶
- Name_Function¶
- Name_Function_Magic¶
- Name_Property¶
- Name_Label¶
- Name_Namespace¶
- Name_Other¶
- Name_Tag¶
- Name_Variable¶
- Name_Variable_Class¶
- Name_Variable_Global¶
- Name_Variable_Instance¶
- Name_Variable_Magic¶
- Literal¶
- Literal_Date¶
- String¶
- String_Affix¶
- String_Backtick¶
- String_Char¶
- String_Delimiter¶
- String_Doc¶
- String_Double¶
- String_Escape¶
- String_Heredoc¶
- String_Interpol¶
- String_Other¶
- String_Regex¶
- String_Single¶
- String_Symbol¶
- Number¶
- Number_Bin¶
- Number_Float¶
- Number_Hex¶
- Number_Integer¶
- Number_Integer_Long¶
- Number_Oct¶
- Operator¶
- Operator_Word¶
- Punctuation¶
- Punctuation_Marker¶
- Comment¶
- Comment_Hashbang¶
- Comment_Multiline¶
- Comment_Preproc¶
- Comment_Preproc_File¶
- Comment_Single¶
- Comment_Special¶
- Generic¶
- Generic_Deleted¶
- Generic_Emph¶
- Generic_Emph_Strong¶
- Generic_Error¶
- Generic_Heading¶
- Generic_Inserted¶
- Generic_Output¶
- Generic_Prompt¶
- Generic_Strong¶
- Generic_Subheading¶
- Generic_Traceback¶
- Punctuation_Indicator¶
-
Pygments’ YAML lexer uses two types outside its standard set; HTML gives them the classes of their ancestors too, as Pygments does.
- Literal_Scalar_Plain¶
- Generic_Underline¶
-
Types only Pygments’ styles name: github-dark’s Generic.Underline, gruvbox’s Comment.PreProc (not Comment.Preproc), and the LilyPond lexer’s, which lilypond styles. Token.String and Token.Number are not Literal.String and Literal.Number.
- Comment_PreProc¶
- Name_Lvalue¶
- Name_Backslash_Reference¶
- Name_Builtin_Articulation¶
- Name_Builtin_Clef¶
- Name_Builtin_Context¶
- Name_Builtin_Context_Property¶
- Name_Builtin_Dynamic¶
- Name_Builtin_Grob¶
- Name_Builtin_Grob_Property¶
- Name_Builtin_Header_Variable¶
- Name_Builtin_Markup_Command¶
- Name_Builtin_Music_Command¶
- Name_Builtin_Music_Function¶
- Name_Builtin_Paper_Variable¶
- Name_Builtin_Repeat_Type¶
- Name_Builtin_Scale¶
- Name_Builtin_Scheme_Builtin¶
- Name_Builtin_Scheme_Function¶
- Name_Builtin_Translator¶
- Token_String¶
- Token_String_Escape¶
- Token_String_Symbol¶
- Token_Number¶
- Pitch¶
- Chord_Modifier¶
Procedures
- highlight.check_code :: proc(language, code: string) -> Problem¶
-
check_code finds what Sphinx would warn about when it highlights code as language: an unknown language, or code that does not lex as the language it is marked as. Blocks in the “default” language never warn; they fall back to plain text.
- highlight.check_style :: proc(name: string) -> Problem¶
-
check_style reports a pygments_style that names no style.
- highlight.count_tokens :: proc(lexer: Lexer, code: string) -> int¶
-
count_tokens is how many tokens tokenize needs for code.
- highlight.find_lexer :: proc(name: string) -> (Lexer, bool)¶
-
find_lexer finds a lexer by alias (“py”, “c++”), as Pygments’ get_lexer_by_name does, ignoring case; failing that by file name (“setup.py”, “Makefile”) or MIME type.
- highlight.find_lexer_for_filename :: proc(path: string) -> (Lexer, bool)¶
-
find_lexer_for_filename matches the base name of a path against the lexers’ patterns.
- highlight.find_style :: proc(name: string) -> (Style, bool)¶
-
find_style finds a style by its Pygments name, ignoring case.
- highlight.guess_lexer :: proc(code: string) -> Lexer¶
-
guess_lexer picks a lexer from the code alone, as Sphinx’s “guess” language does. JSON that parses cleanly is JSON; otherwise the rule table decides.
- highlight.has_errors :: proc(lexer: Lexer, code: string) -> bool¶
-
has_errors reports whether lexing code produces an Error token, which is when Sphinx warns that a block does not lex as its language.
- highlight.highlight_html :: proc(lexer: Lexer, code: string, out: ^Output)¶
-
highlight_html lexes code and writes its HTML without a token buffer.
- highlight.highlight_html_lines :: proc(lexer: Lexer, code: string, lines: Html_Lines, out: ^Output)¶
-
highlight_html_lines lexes code and writes it as write_html_lines does.
- highlight.highlight_typst :: proc(lexer: Lexer, code: string, out: ^Output)¶
-
highlight_typst lexes code and writes its Typst array without a token buffer.
- highlight.kind_class :: proc(kind: Token_Kind) -> string¶
-
kind_class is the CSS class Pygments’ HtmlFormatter writes: “k”, “s2”, “c1”; “” for Text, which HTML writes without a span.
- highlight.kind_is :: proc(kind, ancestor: Token_Kind) -> bool¶
-
kind_is reports whether kind is ancestor or one of its descendants, as Pygments’
ttype in Token.Stringdoes.
- highlight.kind_name :: proc(kind: Token_Kind) -> string¶
-
kind_name is Pygments’ dotted name without the “Token.” root: “Literal.String.Double”.
- highlight.kind_parent :: proc(kind: Token_Kind) -> (Token_Kind, bool)¶
-
kind_parent is the kind’s parent; false for kinds directly below the root.
- highlight.lexer_alias :: proc(lexer: Lexer) -> string¶
-
lexer_alias is the lexer’s canonical alias: “python”, “cpp”.
- highlight.lexer_info :: proc(lexer: Lexer) -> Lexer_Info¶
-
lexer_info is the lexer’s static description: name, aliases, file patterns, and MIME types.
- highlight.lexer_name :: proc(lexer: Lexer) -> string¶
-
lexer_name is Pygments’ name for the lexer: “Python”, “C++”.
- highlight.next_token :: proc(s: ^Scanner) -> (Token, bool)¶
-
next_token returns the next token; adjacent tokens of one kind come back merged.
- highlight.output_fits :: proc(out: ^Output) -> bool¶
-
output_fits reports whether everything written so far is in the buffer.
- highlight.output_string :: proc(out: ^Output) -> string¶
-
output_string is what fits in the buffer; it is the whole output when output_fits.
- highlight.put :: proc(out: ^Output, s: string)¶
-
put writes s to out: what fits into the buffer, and counts all of it.
- highlight.put_html :: proc(out: ^Output, text: string)¶
-
put_html writes text escaped as Pygments escapes it: & < > “ and ‘.
- highlight.resolve :: proc(lexer: Lexer, code: string) -> Lexer¶
-
resolve makes Sphinx’s choices for a code block. .Default is Python, or a Python console session when the code starts with “>>>”, and falls back to .Text when that does not lex cleanly. Python blocks that start with “>>>” are console sessions too. .Guess guesses from the code. Every other lexer is itself.
- highlight.resolve_style :: proc(style: Style) -> (looks: [Token_Kind]Look, base: Look)¶
-
resolve_style resolves every kind’s look: its parent’s, changed by its own rules.
- highlight.scanner_init :: proc(s: ^Scanner, lexer: Lexer, code: string)¶
-
scanner_init prepares s to tokenize code. The pseudo lexers .Default and .Guess are resolved against the code first. Inputs are limited to 4 GiB.
- highlight.style_name :: proc(style: Style) -> string¶
-
style_name is the style’s pygments_style name, as find_style takes it: “github-dark”.
- highlight.suggest_lexer :: proc(name: string) -> string¶
-
suggest_lexer is the alias closest to a name that find_lexer does not know, for “Did you mean” hints; “” when nothing is close.
- highlight.token_text :: proc(t: Token, code: string) -> string¶
-
token_text is the input a token covers.
- highlight.tokenize :: proc(lexer: Lexer, code: string, buffer: []Token) -> (tokens: []Token, need: int)¶
-
tokenize fills buffer with the tokens of code and returns them. need is how many the whole input has; when it exceeds len(buffer), tokens holds only the first ones, and a buffer of need tokens holds them all. tokenize never allocates.
- highlight.write_css :: proc(style: Style, selector: string, out: ^Output)¶
-
write_css writes the stylesheet Pygments writes for the style with the selector, as Sphinx writes _static/pygments.css with “.highlight”. It ends without a newline.
- highlight.write_html :: proc(tokens: []Token, code: string, out: ^Output)¶
-
write_html writes tokens of code as Pygments’ HTML.
- highlight.write_html_lines :: proc(tokens: []Token, code: string, lines: Html_Lines, out: ^Output)¶
-
write_html_lines writes tokens of code as Pygments’ HTML with numbered or emphasized lines. The whole block is lexed at once, so a string or comment across lines keeps its colour on every line.
- highlight.write_problem :: proc(p: Problem, location: string, out: ^Output)¶
-
write_problem writes an Elm-style report; location, such as “index.rst:12”, heads it.
-- UNKNOWN LANGUAGE ------------------------------------------- index.rst:12 I do not know how to highlight "pyhton", so this block is shown as plain text. Hint: Did you mean "python"?
- highlight.write_typst :: proc(tokens: []Token, code: string, out: ^Output)¶
-
write_typst writes tokens of code as a Typst array of lines. A final newline does not start another line.
- highlight.write_typst_theme :: proc(style: Style, out: ^Output)¶
-
write_typst_theme writes a style as a Typst dictionary: “background” is the block’s fill, “text” the default text settings, and each class maps to its text settings (fill, weight, style), with “underline”, “background” and “border” where set.
Variables
- highlight.STYLES¶