renderer

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TermFormatter = "terminal256"
	TermStyle     = "base16-snazzy"
)
View Source
const (
	// MinimumContentGuessLength is the minimum length of the content to use guesslang, smaller content will use the fallback lexer.
	MinimumContentGuessLength = 64
)

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 = lexers.Fallback
)

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 guesslang. 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 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