Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClassSet ¶
ClassSet is a set type with string elements. It has the following methods: Insert(string), Remove(string), Has(string)->bool, Slice()->[]string
func MakeClassSet ¶
MakeClassSet turns a slice of strings into a non-repeating set containing each element from the slice
func (ClassSet) Insert ¶
Insert puts the string class into the set. If the class is already there, there will be no effect.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document stores the contents of an html page in order, and all of the top level elements
func ParseHTMLFile ¶
ParseHTMLFile takes a filepath and parses the html inside
func (*Document) QuerySelector ¶
func (doc *Document) QuerySelector(pattern string) (*HTMLElement, error)
QuerySelector returns a pointer to the first element satisfying the criteria in the input string found in the html document. The function uses CSS selectors like in JavaScript. For reference, follow the link to https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors
type EmptyStackError ¶
type EmptyStackError struct { }
EmptyStackError is an error type that is thrown when an element from a HTMLStack is attempted to be accessed from an empty stack
func (EmptyStackError) Error ¶
func (e EmptyStackError) Error() string
type HTMLElement ¶
type HTMLElement struct { Raw html.Token Tag, ID string ClassList ClassSet Attributes map[string]string Children []*HTMLElement IsSingleTag bool TokenType html.TokenType // contains filtered or unexported fields }
HTMLElement holds the data for the html tags parsed from the file
func (*HTMLElement) QuerySelector ¶
func (elem *HTMLElement) QuerySelector(pattern string) (*HTMLElement, error)
QuerySelector returns a pointer to the first element satisfying the criteria in the input string. The function uses CSS selectors like in JavaScript. For reference, follow the link to https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors
func (*HTMLElement) String ¶
func (elem *HTMLElement) String() string
func (*HTMLElement) Text ¶
func (elem *HTMLElement) Text() string
Text formats the stored text objects into a proper string
type HTMLStack ¶
type HTMLStack struct {
// contains filtered or unexported fields
}
HTMLStack is a stack data structure that can hold HTMLElement objects
func MakeStack ¶
func MakeStack() HTMLStack
MakeStack returns a default HTMLStack object with a nil root and 0 length
func (*HTMLStack) Pop ¶
func (stack *HTMLStack) Pop() (*HTMLElement, error)
Pop removes the top element and returns it
func (*HTMLStack) Push ¶
func (stack *HTMLStack) Push(element *HTMLElement)
Push adds onto the top of the stack
func (*HTMLStack) Top ¶
func (stack *HTMLStack) Top() (*HTMLElement, error)
Top returns the top element if it, or gives an error if stack is empty
type HTMLStackNode ¶
type HTMLStackNode struct {
// contains filtered or unexported fields
}
HTMLStackNode is a linked list node that is used in HTMLStack
type ParsingError ¶
type ParsingError struct{}
ParsingError occurs when an parsing fails or an html.ErrorToken appears
func (ParsingError) Error ¶
func (ParsingError) Error() string
type PatternError ¶
type PatternError struct {
// contains filtered or unexported fields
}
PatternError is thrown when a parsed querySelector pattern's syntax is unrecognized
func (PatternError) Error ¶
func (e PatternError) Error() string