renderer

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinimumContentGuessLength is the minimum length of the content to use AI guessing, smaller content will use the fallback lexer.
	MinimumContentGuessLength = 64
)
View Source
const TermFormatter = "terminal256"

Variables

View Source
var BinaryHTMLPlaceholder = template.HTML(`
<div style="margin:2rem;text-align:center;">
		<span role="img" aria-label="warning">⚠️</span>
		The file is not displayed because it has been detected as binary data.
</div>
`)
View Source
var FallbackLexer chroma.Lexer = chroma.MustNewLexer(&chroma.Config{
	Name:      "plaintext",
	Filenames: []string{"*"},
	Priority:  -1,
}, lexers.PlaintextRules)

Functions

func Analyze

func Analyze(content string) chroma.Lexer

func DetectFileType

func DetectFileType(content []byte, hint string, useGuesser bool) string

DetectFileType returns the type of the file based on the content and the hint. If useGuesser is true, it will try to guess the type of the file using AI guessing. If the content's mimetype is not detected as text/plain, it returns "binary"

func GetLexer

func GetLexer(name string) chroma.Lexer

GetLexer returns the lexer for the given name, or the fallback lexer if the lexer is not found.

func GetStyle added in v0.7.0

func GetStyle() *chroma.Style

func GetSyntaxCSS added in v0.7.0

func GetSyntaxCSS() template.CSS

func Guess added in v0.2.0

func Guess(content string) string

func ToMarkdown

func ToMarkdown(fileContent []byte) (template.HTML, error)

func ToSyntaxHighlightedHTML

func ToSyntaxHighlightedHTML(fileType string, fileContent []byte) (template.HTML, error)

ToSyntaxHighlightedHTML returns HTML of the syntax highlighted code via Chroma

func ToSyntaxHighlightedTerm

func ToSyntaxHighlightedTerm(fileType string, fileContent []byte) (string, error)

ToSyntaxHighlightedTerm returns ANSI of the syntax highlighted code via Chroma

Types

This section is empty.

Jump to

Keyboard shortcuts

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