package html
Import Path
github.com/alecthomas/chroma/v2/formatters/html (on go.dev)
Dependency Relation
imports 8 packages, and imported by 2 packages
Involved Source Files
html.go
Package-Level Type Names (total 3)
Formatter that generates HTML.
// Exported field to detect when classes are being used
(*Formatter) Format(w io.Writer, style *chroma.Style, iterator chroma.Iterator) (err error)
WriteCSS writes CSS style definitions (without any surrounding HTML).
*Formatter : github.com/alecthomas/chroma/v2.Formatter
func New(options ...Option) *Formatter
Option sets an option of the HTML formatter.
func BaseLineNumber(n int) Option
func ClassPrefix(prefix string) Option
func HighlightLines(ranges [][2]int) Option
func InlineCode(b bool) Option
func LineNumbersInTable(b bool) Option
func PreventSurroundingPre(b bool) Option
func Standalone(b bool) Option
func TabWidth(width int) Option
func WithAllClasses(b bool) Option
func WithClasses(b bool) Option
func WithCustomCSS(css map[chroma.TokenType]string) Option
func WithLineNumbers(b bool) Option
func WithLinkableLineNumbers(b bool, prefix string) Option
func WithPreWrapper(wrapper PreWrapper) Option
func WrapLongLines(b bool) Option
func New(options ...Option) *Formatter
PreWrapper defines the operations supported in WithPreWrapper.
End is called to write the end </pre> element.
Start is called to write a start <pre> element.
The code flag tells whether this block surrounds
highlighted code. This will be false when surrounding
line numbers.
func WithPreWrapper(wrapper PreWrapper) Option
Package-Level Functions (total 17)
BaseLineNumber sets the initial number to start line numbering at. Defaults to 1.
ClassPrefix sets the CSS class prefix.
HighlightLines higlights the given line ranges with the Highlight style.
A range is the beginning and ending of a range as 1-based line numbers, inclusive.
InlineCode creates inline code wrapped in a code tag.
LineNumbersInTable will, when combined with WithLineNumbers, separate the line numbers
and code in table td's, which make them copy-and-paste friendly.
New HTML formatter.
PreventSurroundingPre prevents the surrounding pre tags around the generated code.
Standalone configures the HTML formatter for generating a standalone HTML document.
StyleEntryToCSS converts a chroma.StyleEntry to CSS attributes.
TabWidth sets the number of characters for a tab. Defaults to 8.
WithAllClasses disables an optimisation that omits redundant CSS classes.
WithClasses emits HTML using CSS classes, rather than inline styles.
WithCustomCSS sets user's custom CSS styles.
WithLineNumbers formats output with line numbers.
WithLinkableLineNumbers decorates the line numbers HTML elements with an "id"
attribute so they can be linked.
WithPreWrapper allows control of the surrounding pre tags.
WrapLongLines wraps long lines.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |