python

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package python is the Python tokenizer. lang/python registers it. Options (the switch for the intended differences from Chroma) exists only for the comparison in compat/ and is not exposed.

The token types and token boundaries reproduce the rules of Chroma 2.27.0's python.xml without using regular expressions. The string states, which in Chroma are combined (a state that chains the rules of two states), are represented by a combination of the quote type and the escape rules (frame).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lex

func Lex(src string, end int, o Options) []fh.Token

Lex splits src into tokens (the same contract as Lex of fasthighlight.Language). compat/ uses it to compare with Chroma while switching o.

func Prepare

func Prepare()

Prepare builds the word tables and so on (Prepare of fasthighlight.Language).

Types

type Options

type Options struct {
	// If ChromaDocstring is true, the docstring rule is made the same as Chroma's. In regexp2, the
	// {,2} in Chroma's rule ^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""") is not a repetition but "one
	// character followed by the literal characters "{,2}"", so an ordinary docstring gets the string
	// color. If false, {,2} is read as a repetition of 0 to 2 times (as in Pygments), and a
	// """…""" at the start of a line gets the docstring color.
	ChromaDocstring bool
}

Options is the switch for the intended differences from Chroma. The zero value is the production setting (the one lang/python registers).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL