css

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmbedDeclaration

func EmbedDeclaration(fsys fs.FS, decl *css.Declaration) error

func EmbedFont

func EmbedFont(fsys fs.FS, decl *css.Declaration) error

EmbedFont parses a @font-face src and embeds the woff font variant, preserving links to the other variants. It will always make the woff embed the first item in the list of fonts so that browsers that pick the first match will use that one.

func ParseFontSrc

func ParseFontSrc(tokens []Token) (map[string]string, error)

ParseFontSrc takes a list of Token tokens and parses them into a map indexed by the font format.

func ParseWriteSheet

func ParseWriteSheet(fsys fs.FS, f string, o io.Writer) error

func StringRule

func StringRule(fsys fs.FS, out io.Writer, rule *css.Rule) error

Types

type Token

type Token struct {
	Type  TokenType
	Value string
}

func Tokenize

func Tokenize(v string) []Token

Tokenize will tokenize a @font-face src string that contains one or more comma separated values containing url and format functions (the values of these functions must be quoted). It returns a slice of tokens

type TokenType

type TokenType int
const (
	QuotedString TokenType = iota
	FunctionStart
	Comma
	Semicolon
)

Jump to

Keyboard shortcuts

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