wit

package module
v0.0.0-...-61d06f5 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Body = S("body")

Body matches the body element

View Source
var Head = S("head")

Head matches the head element

Functions

This section is empty.

Types

type AddClasses

type AddClasses struct {
	Classes string
}

AddClasses adds provided classes to matching elements

func (AddClasses) Apply

func (a AddClasses) Apply(d Document)

Apply applies the delta to the provided elements

func (AddClasses) MarshalJSON

func (a AddClasses) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type All

type All struct {
	Selector
	Delta
}

All applies given delta to all matching elements

func (All) Apply

func (a All) Apply(d Document)

Apply applies the delta to the provided elements

func (All) MarshalJSON

func (a All) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type Append

type Append struct {
	HTMLSource
}

Append appends the provided HTML to matching elements

func (Append) Apply

func (a Append) Apply(d Document)

Apply applies the delta to the provided elements

func (Append) MarshalJSON

func (a Append) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type Clear

type Clear struct{}

Clear empties matching elements

func (Clear) Apply

func (c Clear) Apply(d Document)

Apply applies the delta to the provided elements

func (Clear) MarshalJSON

func (c Clear) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type Delta

type Delta interface {
	Apply(document Document)
	MarshalJSON() ([]byte, error)
}

Delta represents a page change

type Document

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

func NewDocument

func NewDocument() Document

func (Document) Render

func (d Document) Render(w io.Writer)

type First

type First struct {
	Selector
	Delta
}

First applies given delta to the first matching element

func (First) Apply

func (f First) Apply(d Document)

Apply applies the delta to the provided elements

func (First) MarshalJSON

func (f First) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type FirstChild

type FirstChild struct {
	Delta
}

FirstChild applies given delta to the first child element

func (FirstChild) Apply

func (fc FirstChild) Apply(d Document)

Apply applies the delta to the provided elements

func (FirstChild) MarshalJSON

func (fc FirstChild) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type HTML

type HTML struct {
	HTMLSource
}

HTML sets the inner HTML of matching elements

func (HTML) Apply

func (h HTML) Apply(d Document)

Apply applies the delta to the provided elements

func (HTML) MarshalJSON

func (h HTML) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type HTMLSource

type HTMLSource interface {
	String() string
	Nodes(context *html.Node) []*html.Node
}

HTMLSource represents an HTML source

func HTMLFromString

func HTMLFromString(html string) HTMLSource

HTMLFromString builds an HTMLSource from a string

func HTMLFromStringFunc

func HTMLFromStringFunc(reader func() string) HTMLSource

HTMLFromStringFunc builds an HTMLSource from a string function

type InsertAfter

type InsertAfter struct {
	HTMLSource
}

InsertAfter inserts the provided HTML after matching elements

func (InsertAfter) Apply

func (i InsertAfter) Apply(d Document)

Apply applies the delta to the provided elements

func (InsertAfter) MarshalJSON

func (i InsertAfter) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type InsertBefore

type InsertBefore struct {
	HTMLSource
}

InsertBefore inserts the provided HTML before matching elements

func (InsertBefore) Apply

func (i InsertBefore) Apply(d Document)

Apply applies the delta to the provided elements

func (InsertBefore) MarshalJSON

func (i InsertBefore) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type LastChild

type LastChild struct {
	Delta
}

LastChild applies given delta to the last child element

func (LastChild) Apply

func (lc LastChild) Apply(d Document)

Apply applies the delta to the provided elements

func (LastChild) MarshalJSON

func (lc LastChild) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type List

type List struct {
	Deltas []Delta
}

List holds a list of deltas

func (List) Apply

func (l List) Apply(d Document)

Apply applies the delta to the provided elements

func (List) MarshalJSON

func (l List) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

func (*List) UnmarshalJSON

func (l *List) UnmarshalJSON(payload []byte) error

UnmarshalJSON sets *l to the unmarshalled list of deltas

type NextSibling

type NextSibling struct {
	Delta
}

NextSibling applies given delta to the next sibling

func (NextSibling) Apply

func (ns NextSibling) Apply(d Document)

Apply applies the delta to the provided elements

func (NextSibling) MarshalJSON

func (ns NextSibling) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type Parent

type Parent struct {
	Delta
}

Parent applies given delta to the parent element

func (Parent) Apply

func (p Parent) Apply(d Document)

Apply applies the delta to the provided elements

func (Parent) MarshalJSON

func (p Parent) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type Prepend

type Prepend struct {
	HTMLSource
}

Prepend prepends the provided HTML to matching elements

func (Prepend) Apply

func (p Prepend) Apply(d Document)

Apply applies the delta to the provided elements

func (Prepend) MarshalJSON

func (p Prepend) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type PrevSibling

type PrevSibling struct {
	Delta
}

PrevSibling applies given delta to the previous sibling

func (PrevSibling) Apply

func (ps PrevSibling) Apply(d Document)

Apply applies the delta to the provided elements

func (PrevSibling) MarshalJSON

func (ps PrevSibling) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type Remove

type Remove struct{}

Remove removes matching elements

func (Remove) Apply

func (r Remove) Apply(d Document)

Apply applies the delta to the provided elements

func (Remove) MarshalJSON

func (r Remove) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type Replace

type Replace struct {
	HTMLSource
}

Replace replaces matching elements with the provided content

func (Replace) Apply

func (r Replace) Apply(d Document)

Apply applies the delta to the provided elements

func (Replace) MarshalJSON

func (r Replace) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type ReplaceAttr

type ReplaceAttr struct {
	Attributes map[string]string
}

ReplaceAttr replaces the attributes of matching elements

func (ReplaceAttr) Apply

func (r ReplaceAttr) Apply(d Document)

Apply applies the delta to the provided elements

func (ReplaceAttr) MarshalJSON

func (r ReplaceAttr) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type RmAttr

type RmAttr struct {
	Attributes []string
}

RmAttr removes provided attributes

func (RmAttr) Apply

func (r RmAttr) Apply(d Document)

Apply applies the delta to the provided elements

func (RmAttr) MarshalJSON

func (r RmAttr) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type RmClasses

type RmClasses struct {
	Classes string
}

RmClasses removes provided classes from matching elements

func (RmClasses) Apply

func (r RmClasses) Apply(d Document)

Apply applies the delta to the provided elements

func (RmClasses) MarshalJSON

func (r RmClasses) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type RmStyles

type RmStyles struct {
	Styles []string
}

RmStyles removes provided CSS properties from matching elements

func (RmStyles) Apply

func (r RmStyles) Apply(d Document)

Apply applies the delta to the provided elements

func (RmStyles) MarshalJSON

func (r RmStyles) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type Root

type Root struct {
	Delta
}

Root applies given delta to the root of the document

func (Root) Apply

func (r Root) Apply(d Document)

Apply applies the delta to the provided elements

func (Root) MarshalJSON

func (r Root) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type Selector

type Selector interface {
	String() string
	cascadia.Matcher
}

Selector wraps a CSS selector

func S

func S(s string) Selector

S wraps a CSS selector in a Selector object

type SetAttr

type SetAttr struct {
	Attributes map[string]string
}

SetAttr sets provided attributes to provided values

func (SetAttr) Apply

func (s SetAttr) Apply(d Document)

Apply applies the delta to the provided elements

func (SetAttr) MarshalJSON

func (s SetAttr) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

type SetStyles

type SetStyles struct {
	Styles map[string]string
}

SetStyles sets provided attributes to provided values

func (SetStyles) Apply

func (s SetStyles) Apply(d Document)

Apply applies the delta to the provided elements

func (SetStyles) MarshalJSON

func (s SetStyles) MarshalJSON() ([]byte, error)

MarshalJSON marshals the delta to JSON format

Jump to

Keyboard shortcuts

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