htmlutil

package module
v0.0.0-...-9c4df57 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2014 License: MIT Imports: 8 Imported by: 0

README

htmlutil

A collection of helper methods for go.net/html. The document is available at godoc.

This work was mainly done while I was employed by Hohoyi.com and was part of the Sight app.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Codes      = NewAtomSetFromString("style script link")
	Blocks     = NewAtomSetFromString("address article aside audio blockquote canvas dd div dl fieldset figcaption figure figcaption footer form h1 h2 h3 h4 h5 h6 header hgroup hr noscript ol output p pre section table tfoot ul video")
	Containers = NewAtomSetFromString("article aside div footer header hgroup section")
	Headers    = NewAtomSetFromString("h1 h2 h3 h4 h5 h6 h7")
	Voids      = NewAtomSetFromString("area base br col embed hr img input keygen link meta param source track wbr")
)
View Source
var BodyContext *html.Node

BodyContext can be used as the context when parsing fragments.

Functions

func Children

func Children(n *html.Node) (ns []*html.Node)

func Create

func Create(tag string) *html.Node

func DelAttr

func DelAttr(n *html.Node, name string)

func Drop

func Drop(n *html.Node) *html.Node

func FindAllFunc

func FindAllFunc(n *html.Node, f func(*html.Node) bool) (nodes []*html.Node)

func FindId

func FindId(n *html.Node, id string) *html.Node

func FindOne

func FindOne(n *html.Node, a atom.Atom) *html.Node

func FindOneFunc

func FindOneFunc(n *html.Node, f func(*html.Node) bool) *html.Node

func FindTags

func FindTags(n *html.Node, f func(*html.Node), atoms ...atom.Atom)

func GetAttr

func GetAttr(n *html.Node, name string) string

func GetText

func GetText(n *html.Node) string

func GetValue

func GetValue(n *html.Node) string

func Lift

func Lift(n *html.Node)

func ParseClean

func ParseClean(r io.Reader) (*html.Node, error)

Clean and parse the HTML, so that: 0. Encoding converted to UTF8 if not already. 1. Comment and DOCTYPE removed. 2. Code blocks (script, style, link) removed.

func Replace

func Replace(original, repl *html.Node)

func SetAttr

func SetAttr(n *html.Node, name, val string)

func Walk

func Walk(n *html.Node, before, after func(*html.Node))

Types

type AtomSet

type AtomSet map[atom.Atom]struct{}

func NewAtomSet

func NewAtomSet(atoms []atom.Atom) AtomSet

func NewAtomSetFromString

func NewAtomSetFromString(s string) AtomSet

func (AtomSet) Has

func (s AtomSet) Has(a atom.Atom) bool

func (AtomSet) HasName

func (s AtomSet) HasName(name []byte) bool

Jump to

Keyboard shortcuts

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