richcontent

package
v0.0.0-...-b34ddb9 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAllUrls

func FindAllUrls(input []byte) [][]byte

func FindAllUrlsIndex

func FindAllUrlsIndex(input []byte) [][]int

[[start, end], [start, end], ...]

func RegisterFinder

func RegisterFinder(finder Finder)

Types

type Component

type Component interface {
	HTML() string
}

func MakeComponent

func MakeComponent(html string) Component

type Finder

type Finder func(ctx context.Context, input []byte) ([]RichContent, error)

type MatchIndices

type MatchIndices []int

func (MatchIndices) At

func (m MatchIndices) At(i int) (int, int)

func (MatchIndices) ByteSliceOf

func (m MatchIndices) ByteSliceOf(b []byte, i int) []byte

func (MatchIndices) Len

func (m MatchIndices) Len() int

type RichContent

type RichContent interface {
	Pos() (int, int)
	URLString() string
	Components() []Component
}

func Find

func Find(ctx context.Context, input []byte) ([]RichContent, error)

func FindUrl

func FindUrl(ctx context.Context, input []byte) ([]RichContent, error)

func MakeRichContent

func MakeRichContent(begin, end int, urlString string, components []Component) RichContent

type RichContentByBeginThenLongest

type RichContentByBeginThenLongest []RichContent

func (RichContentByBeginThenLongest) Len

func (RichContentByBeginThenLongest) Less

func (c RichContentByBeginThenLongest) Less(i, j int) bool

func (RichContentByBeginThenLongest) Swap

func (c RichContentByBeginThenLongest) Swap(i, j int)

type UrlPattern

type UrlPattern struct {
	Pattern *regexp.Regexp
	Handler UrlPatternHandler
}

type UrlPatternHandler

type UrlPatternHandler func(ctx context.Context, urlBytes []byte, match MatchIndices) ([]Component, error)

Jump to

Keyboard shortcuts

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