htmldown

package module
v0.0.0-...-0adfe49 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2016 License: MIT Imports: 4 Imported by: 0

README

htmldown

html to markdown

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockquoteNode

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

BlockquoteNode is used to <blockquote>

func (*BlockquoteNode) Attr

func (bn *BlockquoteNode) Attr() map[string]string

func (*BlockquoteNode) Children

func (bn *BlockquoteNode) Children(nodes ...Node) []Node

func (*BlockquoteNode) Markdown

func (bn *BlockquoteNode) Markdown() string

Markdown renders BlockquoteNode as \n```\n text \n```\n

func (*BlockquoteNode) New

func (bn *BlockquoteNode) New(t html.Token, parent Node) Node

New returns new BlockquoteNode

func (*BlockquoteNode) Parent

func (bn *BlockquoteNode) Parent() Node

func (*BlockquoteNode) Tag

func (bn *BlockquoteNode) Tag() string

func (*BlockquoteNode) Text

func (bn *BlockquoteNode) Text(str ...string) string

type BreakNode

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

BreakNode is used to <br/>

func (*BreakNode) Attr

func (bn *BreakNode) Attr() map[string]string

func (*BreakNode) Children

func (bn *BreakNode) Children(nodes ...Node) []Node

func (*BreakNode) Markdown

func (bn *BreakNode) Markdown() string

Markdown renders BreakNode as "\n\n"

func (*BreakNode) New

func (bn *BreakNode) New(t html.Token, parent Node) Node

New returns new BreakNode

func (*BreakNode) Parent

func (bn *BreakNode) Parent() Node

func (*BreakNode) Tag

func (bn *BreakNode) Tag() string

func (*BreakNode) Text

func (bn *BreakNode) Text(str ...string) string

type CodeNode

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

CodeNode is used to <code>

func (*CodeNode) Attr

func (bn *CodeNode) Attr() map[string]string

func (*CodeNode) Children

func (bn *CodeNode) Children(nodes ...Node) []Node

func (*CodeNode) Markdown

func (cn *CodeNode) Markdown() string

Markdown renders CodeNode as <code>text</code> if element class exist, render as <code class="class">text</code>

func (*CodeNode) New

func (cn *CodeNode) New(t html.Token, parent Node) Node

New returns new CodeNode

func (*CodeNode) Parent

func (bn *CodeNode) Parent() Node

func (*CodeNode) Tag

func (bn *CodeNode) Tag() string

func (*CodeNode) Text

func (bn *CodeNode) Text(str ...string) string

type CommonNode

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

CommonNode is a node that print as normal html, not markdown

func (*CommonNode) Attr

func (bn *CommonNode) Attr() map[string]string

func (*CommonNode) Children

func (bn *CommonNode) Children(nodes ...Node) []Node

func (*CommonNode) Markdown

func (cn *CommonNode) Markdown() string

Markdown renders CommonNode as html tag string ,<tag>text</tag>

func (*CommonNode) New

func (cn *CommonNode) New(t html.Token, parent Node) Node

New returns new CommonNode

func (*CommonNode) Parent

func (bn *CommonNode) Parent() Node

func (*CommonNode) Tag

func (bn *CommonNode) Tag() string

func (*CommonNode) Text

func (bn *CommonNode) Text(str ...string) string

type Document

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

Document maintains nodes of html content

func NewDocument

func NewDocument(r io.Reader) *Document

NewDocument returns new document with io.Reader

func (*Document) Markdown

func (doc *Document) Markdown() (string, error)

Markdown renders this document to markdown content

func (*Document) Root

func (doc *Document) Root() Node

Root returns root node of the document

func (*Document) SetNode

func (doc *Document) SetNode(tag string, n Node)

SetNode sets node by tag name. so it parses element by this node

type HeaderNode

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

HeaderNode is used to <h1-6>

func (*HeaderNode) Attr

func (bn *HeaderNode) Attr() map[string]string

func (*HeaderNode) Children

func (bn *HeaderNode) Children(nodes ...Node) []Node

func (*HeaderNode) Markdown

func (hn *HeaderNode) Markdown() string

func (*HeaderNode) New

func (hn *HeaderNode) New(t html.Token, parent Node) Node

func (*HeaderNode) Parent

func (bn *HeaderNode) Parent() Node

func (*HeaderNode) Tag

func (bn *HeaderNode) Tag() string

func (*HeaderNode) Text

func (bn *HeaderNode) Text(str ...string) string

type HorizontalNode

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

HorizontalNode is used to <hr/>

func (*HorizontalNode) Attr

func (bn *HorizontalNode) Attr() map[string]string

func (*HorizontalNode) Children

func (bn *HorizontalNode) Children(nodes ...Node) []Node

func (*HorizontalNode) Markdown

func (hn *HorizontalNode) Markdown() string

Markdown renders HorizontalNode as `---\n`

func (*HorizontalNode) New

func (hn *HorizontalNode) New(t html.Token, parent Node) Node

New returns HorizontalNode

func (*HorizontalNode) Parent

func (bn *HorizontalNode) Parent() Node

func (*HorizontalNode) Tag

func (bn *HorizontalNode) Tag() string

func (*HorizontalNode) Text

func (bn *HorizontalNode) Text(str ...string) string

type HrefNode

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

HrefNode is used to <a>

func (*HrefNode) Attr

func (bn *HrefNode) Attr() map[string]string

func (*HrefNode) Children

func (bn *HrefNode) Children(nodes ...Node) []Node

func (*HrefNode) Markdown

func (hn *HrefNode) Markdown() string

Markdown renders HrefNode as [text](href)

func (*HrefNode) New

func (hn *HrefNode) New(t html.Token, parent Node) Node

New returns new HrefNode

func (*HrefNode) Parent

func (bn *HrefNode) Parent() Node

func (*HrefNode) Tag

func (bn *HrefNode) Tag() string

func (*HrefNode) Text

func (bn *HrefNode) Text(str ...string) string

type ImageNode

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

ImageNode is used to <img>

func (*ImageNode) Attr

func (bn *ImageNode) Attr() map[string]string

func (*ImageNode) Children

func (bn *ImageNode) Children(nodes ...Node) []Node

func (*ImageNode) Markdown

func (in *ImageNode) Markdown() string

Markdown renders ImageNode as ![alt](src)

func (*ImageNode) New

func (in *ImageNode) New(t html.Token, parent Node) Node

New returns new ImageNode

func (*ImageNode) Parent

func (bn *ImageNode) Parent() Node

func (*ImageNode) Tag

func (bn *ImageNode) Tag() string

func (*ImageNode) Text

func (bn *ImageNode) Text(str ...string) string

type Node

type Node interface {
	New(t html.Token, parent Node) Node
	Tag() string                   // node's tag name
	Text(str ...string) string     // get or append node's text
	Attr() map[string]string       // node's attributes
	Parent() Node                  // node's parent
	Children(nodes ...Node) []Node // append or get node's children nodes
	Markdown() string              // render nodes to markdown
}

Node defines a simple description iof html node

type ParagraphNode

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

ParagraphNode is used to <p>

func (*ParagraphNode) Attr

func (bn *ParagraphNode) Attr() map[string]string

func (*ParagraphNode) Children

func (bn *ParagraphNode) Children(nodes ...Node) []Node

func (*ParagraphNode) Markdown

func (pn *ParagraphNode) Markdown() string

Markdown renders ParagraphNode with \n

func (*ParagraphNode) New

func (pn *ParagraphNode) New(t html.Token, parent Node) Node

New returns new ParagraphNode

func (*ParagraphNode) Parent

func (bn *ParagraphNode) Parent() Node

func (*ParagraphNode) Tag

func (bn *ParagraphNode) Tag() string

func (*ParagraphNode) Text

func (bn *ParagraphNode) Text(str ...string) string

type PreNode

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

PreNode is used to <pre>

func (*PreNode) Attr

func (bn *PreNode) Attr() map[string]string

func (*PreNode) Children

func (bn *PreNode) Children(nodes ...Node) []Node

func (*PreNode) Markdown

func (pn *PreNode) Markdown() string

func (*PreNode) New

func (pn *PreNode) New(t html.Token, parent Node) Node

func (*PreNode) Parent

func (bn *PreNode) Parent() Node

func (*PreNode) Tag

func (bn *PreNode) Tag() string

func (*PreNode) Text

func (bn *PreNode) Text(str ...string) string

type RootNode

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

RootNode is root node of html document

func (*RootNode) Attr

func (bn *RootNode) Attr() map[string]string

func (*RootNode) Children

func (bn *RootNode) Children(nodes ...Node) []Node

func (*RootNode) Markdown

func (bn *RootNode) Markdown() string

func (*RootNode) New

func (bn *RootNode) New(t html.Token, parent Node) Node

New returns new baseNode

func (*RootNode) Parent

func (bn *RootNode) Parent() Node

func (*RootNode) Tag

func (rt *RootNode) Tag() string

Tag returns RootNode's tag ,"root"

func (*RootNode) Text

func (bn *RootNode) Text(str ...string) string

type StrongNode

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

StrongNode is used to <strong> and <em>

func (*StrongNode) Attr

func (bn *StrongNode) Attr() map[string]string

func (*StrongNode) Children

func (bn *StrongNode) Children(nodes ...Node) []Node

func (*StrongNode) Markdown

func (sn *StrongNode) Markdown() string

func (*StrongNode) New

func (sn *StrongNode) New(t html.Token, parent Node) Node

func (*StrongNode) Parent

func (bn *StrongNode) Parent() Node

func (*StrongNode) Tag

func (bn *StrongNode) Tag() string

func (*StrongNode) Text

func (bn *StrongNode) Text(str ...string) string

Jump to

Keyboard shortcuts

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