h5

package
v0.0.0-...-3f75658 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2014 License: Artistic-2.0 Imports: 6 Imported by: 2

Documentation

Overview

Package h5 implements a wrapper and DSL for code.google.com/p/go/src/code.google.com/p/go.net/html.

tree, err := h5.New(rdr)

tree.Walk(func(n *Node) {
   // do something with the node
})

tree2 := tree.Clone()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Anchor

func Anchor(url, content string) *exphtml.Node

Anchor constructs an Anchor Node

func Children

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

func CloneNode

func CloneNode(n *exphtml.Node) *exphtml.Node

CloneNode makes a copy of a Node with all descendants.

func Data

func Data(n *exphtml.Node) string

String form of an html nodes data. (eg: The Tagname for ElementNodes or text for TextNodes)

func Div

func Div(id string, class []string, children ...*exphtml.Node) *exphtml.Node

func Element

func Element(name string, attrs []exphtml.Attribute, children ...*exphtml.Node) *exphtml.Node

func Partial

func Partial(r io.Reader) ([]*html.Node, error)

func PartialFromString

func PartialFromString(s string) ([]*html.Node, error)

func RenderNodes

func RenderNodes(w io.Writer, ns []*html.Node) error

func RenderNodesToString

func RenderNodesToString(ns []*html.Node) string

func Text

func Text(str string) *exphtml.Node

Text constructs a TextNode

func WalkNodes

func WalkNodes(n *exphtml.Node, f func(*exphtml.Node))

Walk walks a Node with all descendants applying a given function to each one.

Types

type Tree

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

Tree represents an html5 Node tree.

func New

func New(r io.Reader) (*Tree, error)

Construct a new h5 parser from a io.Reader

func NewFromString

func NewFromString(s string) (*Tree, error)

Construct a new h5 parser from a string

func NewTree

func NewTree(n *exphtml.Node) Tree

func (Tree) Clone

func (t Tree) Clone() Tree

Clone clones an html5 nodetree to get a detached copy the parent of the node we are cloning will not be copied.

func (Tree) Render

func (t Tree) Render(w io.Writer) error

func (Tree) String

func (t Tree) String() string

func (Tree) Top

func (t Tree) Top() *exphtml.Node

func (Tree) Walk

func (t Tree) Walk(f func(*exphtml.Node))

Walk a Tree applying a given function to each Node.

Jump to

Keyboard shortcuts

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