Documentation
¶
Index ¶
- Constants
- Variables
- func GetValidParentsFor(n string) (parents []string)
- func InStrList(str string, list []string) bool
- func IsValidNode(n string) bool
- func IsValidParent(parent, child string) bool
- func PanicIfErr(e error)
- func ToJSON(n *Node) ([]byte, error)
- func ToXML(n *Node) ([]byte, error)
- type ChildContainer
- type Children
- type Element
- type Link
- type Node
- func (n *Node) AppendChild(child ...*Node) error
- func (n Node) FirstChild() *Node
- func (n *Node) GetElement() Element
- func (n Node) HasParent() bool
- func (n *Node) IsLeaf() bool
- func (n Node) IsRoot() bool
- func (n Node) LastChild() *Node
- func (n *Node) MarshalJSON() ([]byte, error)
- func (n *Node) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (n Node) NumChild() int
- func (n Node) Parent() *Node
- func (n *Node) UnmarshalJSON(data []byte) error
- func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (n *Node) WithChild(child *Node) (this *Node)
- type NodeInfo
- type Page
- type Paragraph
- type Text
- type TextValuer
- type Title
Constants ¶
View Source
const ( TypeNone = "" TypePage = "page" TypePara = "p" TypeText = "text" TypeLink = "link" TypeBlockquote = "blockquote" TypeTitle = "title" TypeH1 = "h1" TypeH2 = "h2" TypeH3 = "h3" TypeList = "list" TypeImage = "image" TypePanel = "panel" )
Variables ¶
View Source
var ( MaxIteration = 1000 MaxRecursionDepth = 1000 SkipLevel = errors.New("skip level") StopWalk = errors.New("stop walk") ErrMaxIter = errors.New("max iteration reached") ErrMaxRecursion = errors.New("max recursion depth reached") ErrInconsistentTree = errors.New("inconsistent tree") ErrInvalidNode = errors.New("invalid node") ErrNodeAlreadyAttached = errors.New("node already attached") ErrNodeNotFound = errors.New("node not found") ErrParentNodeNotFound = errors.New("parent node not found") ErrChildNotAllowed = errors.New("child not allowed") )
View Source
var AllNodes = []string{TypeNone, TypePage, TypePara, TypeText, TypeLink, TypeBlockquote, TypeTitle, TypeH1, TypeH2, TypeH3, TypeList}
View Source
var (
ErrInvalidElementType = errors.New("invalid element type")
)
Functions ¶
func GetValidParentsFor ¶
GetValidParentsFor returns slice of parents which can contain `n` as child
func IsValidNode ¶
func IsValidParent ¶
IsValidParent returns true if parent is valid node to contain given child
func PanicIfErr ¶
func PanicIfErr(e error)
Types ¶
type ChildContainer ¶
type Element ¶
func NewElementForType ¶
type Link ¶
type Link struct {
Href string `json:"href,omitempty" xml:"href,attr,omitempty"`
Title string `json:"title,omitempty" xml:"title,attr,omitempty"`
Children `json:"children" xml:",any"`
}
func (*Link) CanContain ¶
type Node ¶
type Node struct {
Element
// contains filtered or unexported fields
}
func NewElementNode ¶
func (*Node) AppendChild ¶
func (Node) FirstChild ¶
func (*Node) GetElement ¶
func (*Node) MarshalJSON ¶
func (*Node) MarshalXML ¶
func (*Node) UnmarshalJSON ¶
func (*Node) UnmarshalXML ¶
type Page ¶
type Page struct {
Version int `json:"version,string" xml:"version,attr"`
Lang string `json:"lang" xml:"lang,attr"`
Children `json:"children" xml:",any"`
}
Page node
func (*Page) CanContain ¶
func (*Page) WithVersion ¶
type Paragraph ¶
type Paragraph struct {
Children `json:"children" xml:",any"`
}
Paragraph node
func NewParagraph ¶
func NewParagraph() *Paragraph
func (*Paragraph) CanContain ¶
type Text ¶
type Text struct {
Text string `json:"text" xml:",chardata"`
Code bool `json:"code,omitempty" xml:"code,attr,omitempty"`
Bold bool `json:"bold,omitempty" xml:"bold,attr,omitempty"`
Italics bool `json:"italics,omitempty" xml:"italics,attr,omitempty"`
Underline bool `json:"underline,omitempty" xml:"underline,attr,omitempty"`
Strikethrough bool `json:"strikethrough,omitempty" xml:"strikethrough,attr,omitempty"`
}
func (*Text) CanContain ¶
type TextValuer ¶
type TextValuer interface {
GetText() string
}
type Title ¶
type Title struct {
Children `json:"children" xml:",any"`
}
Title node
func (*Title) CanContain ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.