Documentation ¶
Overview ¶
Package gq the goquery parser
Index ¶
- Constants
- func Attr(_ *plugin.Context, content any, args ...string) (any, error)
- func Child(_ *plugin.Context, content any, args ...string) (any, error)
- func Get(ctx *plugin.Context, _ any, args ...string) (any, error)
- func Href(ctx *plugin.Context, content any, _ ...string) (any, error)
- func Html(_ *plugin.Context, content any, args ...string) (any, error)
- func Join(ctx *plugin.Context, content any, args ...string) (any, error)
- func NewGoQueryParser(funcs FuncMap) parser.Parser
- func Next(_ *plugin.Context, content any, args ...string) (any, error)
- func Parent(_ *plugin.Context, content any, args ...string) (any, error)
- func Parents(_ *plugin.Context, content any, args ...string) (any, error)
- func Prefix(_ *plugin.Context, content any, args ...string) (ret any, err error)
- func Prev(_ *plugin.Context, content any, args ...string) (any, error)
- func Set(ctx *plugin.Context, content any, args ...string) (any, error)
- func Slice(_ *plugin.Context, content any, args ...string) (any, error)
- func Suffix(_ *plugin.Context, content any, args ...string) (ret any, err error)
- func Text(_ *plugin.Context, content any, _ ...string) (any, error)
- type FuncMap
- type GFunc
- type Parser
- func (p *Parser) GetElement(ctx *plugin.Context, content any, arg string) (ret string, err error)
- func (p *Parser) GetElements(ctx *plugin.Context, content any, arg string) (ret []string, err error)
- func (p *Parser) GetString(ctx *plugin.Context, content any, arg string) (ret string, err error)
- func (p *Parser) GetStrings(ctx *plugin.Context, content any, arg string) (ret []string, err error)
Constants ¶
const Key string = "gq"
Key the gq parser register key.
Variables ¶
This section is empty.
Functions ¶
func Attr ¶ added in v0.3.0
Attr gets the specified attribute's value for the first element in the Selection. The first argument is the name of the attribute, the second is the default value
func Child ¶ added in v0.3.0
Child gets the child elements of each element in the Selection. If present the selector will return filtered by the specified selector.
func Get ¶ added in v0.3.0
Get returns the value associated with this context for key, or nil if no value is associated with key.
func Href ¶ added in v0.3.0
Href gets the href attribute's value, if URL is not absolute returns the absolute URL.
func Html ¶ added in v0.3.0
Html the first argument is outer. If true returns the outer HTML rendering of the first item in the selection - that is, the HTML including the first element's tag and attributes, or gets the HTML contents of the first element in the set of matched elements. It includes text and comment nodes;
func Join ¶ added in v0.3.0
Join the text with the separator, if not present separator uses the default separator ", ".
func NewGoQueryParser ¶ added in v0.3.0
NewGoQueryParser creates a new goquery Parser with the given FuncMap.
func Next ¶ added in v0.3.0
Next gets the immediately following sibling of each element in the Selection. If present selector gets all following siblings of each element up to but not including the element matched by the selector.
func Parent ¶ added in v0.3.0
Parent gets the parent of each element in the Selection. if present the selector will return filtered by a selector.
func Parents ¶ added in v0.3.0
Parents gets the ancestors of each element in the current Selection. if present the selector will return filtered by a selector.
func Prev ¶ added in v0.3.0
Prev gets the immediately preceding sibling of each element in the Selection. If present selector gets all preceding siblings of each element up to but not including the element matched by the selector.
func Set ¶ added in v0.3.0
Set value associated with key is val. The first argument is the key, and the second argument is value. if the value is present will store the content.
func Slice ¶ added in v0.3.0
Slice reduces the set of matched elements to a subset specified by a range of indices. The start index is 0-based and indicates the index of the first element to select. The end index is 0-based and indicates the index at which the elements stop being selected (the end index is not selected).
If the end index is not specified reduces the set of matched elements to the one at the specified start index.
The indices may be negative, in which case they represent an offset from the end of the selection.
Types ¶
type FuncMap ¶ added in v0.3.0
FuncMap is the type of the map defining the mapping from names to functions.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser the goquery parser
func (*Parser) GetElement ¶
GetElement gets the element of the content with the given arguments.
content := `<ul><li>1</li><li>2</li></ul>` GetElement(ctx, content, "ul li") returns "<li>1</li>\n<li>2</li>"
func (*Parser) GetElements ¶
func (p *Parser) GetElements(ctx *plugin.Context, content any, arg string) (ret []string, err error)
GetElements gets the elements of the content with the given arguments.
content := `<ul><li>1</li><li>2</li></ul>` GetElements(ctx, content, "ul li") returns []string{"<li>1</li>", "<li>2</li>"}
func (*Parser) GetString ¶
GetString gets the string of the content with the given arguments.
content := `<ul><li>1</li><li>2</li></ul>` GetString(ctx, content, "ul li") returns "1\n2"
func (*Parser) GetStrings ¶
GetStrings gets the strings of the content with the given arguments.
content := `<ul><li>1</li><li>2</li></ul>` GetStrings(ctx, content, "ul li") returns []string{"1", "2"}