parser

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: AGPL-3.0 Imports: 2 Imported by: 7

Documentation

Overview

Package parser the schema parser

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllParsers

func AllParsers() map[string]*ext.Extension

func Register

func Register(key string, parser Parser)

Register registers the Parser with the given key Parser

Types

type Parser

type Parser interface {
	// GetString gets the string of the content with the given arguments.
	// e.g.:
	//
	// content := `<ul><li>1</li><li>2</li></ul>`
	// GetString(ctx, content, "ul li") returns "1\n2"
	//
	GetString(*plugin.Context, any, string) (string, error)
	// GetStrings gets the strings of the content with the given arguments.
	// e.g.:
	//
	// content := `<ul><li>1</li><li>2</li></ul>`
	// GetStrings(ctx, content, "ul li") returns []string{"1", "2"}
	//
	GetStrings(*plugin.Context, any, string) ([]string, error)
	// GetElement gets the element of the content with the given arguments.
	// e.g.:
	//
	// content := `<ul><li>1</li><li>2</li></ul>`
	// GetElement(ctx, content, "ul li") returns "<li>1</li>\n<li>2</li>"
	//
	GetElement(*plugin.Context, any, string) (string, error)
	// GetElements gets the elements of the content with the given arguments.
	// e.g.:
	//
	// content := `<ul><li>1</li><li>2</li></ul>`
	// GetElements(ctx, content, "ul li") returns []string{"<li>1</li>", "<li>2</li>"}
	//
	GetElements(*plugin.Context, any, string) ([]string, error)
}

Parser the content schema

func GetParser

func GetParser(key string) (Parser, bool)

GetParser returns a Parser with the given key

Jump to

Keyboard shortcuts

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