filters

package
v0.0.0-...-44e12ef Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package filters implements text filtering.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, maker Maker)

Register registers a new filter maker.

Types

type CSSMin

type CSSMin int

func (CSSMin) Apply

func (f CSSMin) Apply(in []byte) (out []byte, err error)

func (CSSMin) Name

func (f CSSMin) Name() string

type Collection

type Collection struct {
	// contains filtered or unexported fields
}

Collection is a collection of filters addressed by some key.

func NewCollection

func NewCollection() *Collection

NewCollection returns a new collection.

func (*Collection) Add

func (c *Collection) Add(key string, filterName string, args []string) error

Add adds the filter to collection to be addressable by key.

func (*Collection) AddFromYAML

func (c *Collection) AddFromYAML(key string, line interface{}) error

AddFromYAML parses a `filters` value (line) and adds corresponding filters.

func (*Collection) ApplyFilter

func (c *Collection) ApplyFilter(key string, in []byte) (out []byte, err error)

ApplyFilter applies a filter found by key to the given string. If the filter wasn't found, returns the original string.

func (*Collection) Get

func (c *Collection) Get(key string) Filter

Get returns a filter for key. It returns nil if the filter wasn't found.

func (*Collection) SetEnabled

func (c *Collection) SetEnabled(enabled bool)

SetEnabled sets enabled state of the collection.

type Exec

type Exec struct {
	// contains filtered or unexported fields
}

func (*Exec) Apply

func (f *Exec) Apply(in []byte) (out []byte, err error)

func (*Exec) Name

func (f *Exec) Name() string

type Filter

type Filter interface {
	Name() string
	Apply([]byte) ([]byte, error)
}

Filter is an interface declaring a filter.

func Make

func Make(name string, args []string) Filter

Make creates a new filter by name with the given arguments. It returns nil if it can't find a filter maker with such name.

type HTMLMin

type HTMLMin struct {
	// contains filtered or unexported fields
}

func (*HTMLMin) Apply

func (f *HTMLMin) Apply(in []byte) (out []byte, err error)

func (*HTMLMin) Name

func (f *HTMLMin) Name() string

type JSMin

type JSMin int

func (JSMin) Apply

func (f JSMin) Apply(in []byte) (out []byte, err error)

func (JSMin) Name

func (f JSMin) Name() string

type Maker

type Maker func([]string) Filter

Maker is a type of function which accepts arguments for filter and returns a new instance of the filter.

Jump to

Keyboard shortcuts

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