types

package
v0.0.0-...-a18fae3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedFormats = make(Types)

Functions

This section is empty.

Types

type Type

type Type interface {
	// Returns either "inline" or "embed", depending on whether the file
	// should be displayed inline (e.g. code) or embedded (e.g. images)
	Type() string

	// Returns a CSS string used to format the corresponding page
	CSS() string

	// Returns an HTML <title> element for the specified file
	Title(rootUrl, fileUri, filePath, fileName, prefix, mime string) (string, error)

	// Returns an HTML <body> element used to display the specified file
	Body(rootUrl, fileUri, filePath, fileName, prefix, mime string) (string, error)

	// Returns a map of file extensions to MIME type strings.
	Extensions() map[string]string

	// Given a file extension, returns the corresponding media type,
	// if one exists. Otherwise, returns an empty string.
	MediaType(extension string) string

	// Optional function used to validate whether a given file matches this format.
	// If no validation checks are needed, this function should always return true.
	Validate(filePath string) bool
}

type Types

type Types map[string]Type

func (Types) Add

func (t Types) Add(format Type)

func (Types) FileType

func (t Types) FileType(path string) Type

func (Types) GetExtensions

func (t Types) GetExtensions() string

func (Types) GetMediaTypes

func (t Types) GetMediaTypes() string

func (Types) Register

func (t Types) Register(format Type)

func (Types) Validate

func (t Types) Validate(path string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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