testutil

package
v0.0.0-...-25b8d04 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAnchor

func CreateAnchor(href, text string) *html.Node

func CreateDiv

func CreateDiv(id int) *html.Node

CreateDiv creates a div with the integer id as its id.

func CreateDivTree

func CreateDivTree() []*html.Node

func CreateHTML

func CreateHTML() *html.Node

CreateHTML returns an <html> that consist of empty <head> and <body>. This is an additional method and doesn't exist in original Java code.

func CreateHeading

func CreateHeading(n int, value string) *html.Node

func CreateListItem

func CreateListItem(text string) *html.Node

func CreateMetaName

func CreateMetaName(name string, content string) *html.Node

func CreateMetaProperty

func CreateMetaProperty(property string, content string) *html.Node

func CreateParagraph

func CreateParagraph(text string) *html.Node

func CreateSpan

func CreateSpan(text string) *html.Node

func CreateTitle

func CreateTitle(value string) *html.Node

func GetContentFromTextDocument

func GetContentFromTextDocument(doc *webdoc.TextDocument) string

func GetPrettyHTML

func GetPrettyHTML(node *html.Node) string

GetPrettyHTML returns formatted outer HTML of the node.

func NewTextDocumentFromPage

func NewTextDocumentFromPage(doc *html.Node, wc stringutil.WordCounter, pageURL *url.URL) *webdoc.TextDocument

func RemoveAllDirAttributes

func RemoveAllDirAttributes(str string) string

Types

type FakeWebDocumentBuilder

type FakeWebDocumentBuilder struct {
	// contains filtered or unexported fields
}

FakeWebDocumentBuilder is a simple builder that just creates an html-like string from the calls. Only used for dom-converter test.

func NewFakeWebDocumentBuilder

func NewFakeWebDocumentBuilder() *FakeWebDocumentBuilder

func (*FakeWebDocumentBuilder) AddDataTable

func (db *FakeWebDocumentBuilder) AddDataTable(e *html.Node)

func (*FakeWebDocumentBuilder) AddEmbed

func (db *FakeWebDocumentBuilder) AddEmbed(embed webdoc.Element)

func (*FakeWebDocumentBuilder) AddLineBreak

func (db *FakeWebDocumentBuilder) AddLineBreak(node *html.Node)

func (*FakeWebDocumentBuilder) AddTag

func (db *FakeWebDocumentBuilder) AddTag(tag *webdoc.Tag)

func (*FakeWebDocumentBuilder) AddTextNode

func (db *FakeWebDocumentBuilder) AddTextNode(textNode *html.Node)

func (*FakeWebDocumentBuilder) Build

func (db *FakeWebDocumentBuilder) Build() string

func (*FakeWebDocumentBuilder) EndNode

func (db *FakeWebDocumentBuilder) EndNode()

func (*FakeWebDocumentBuilder) SkipNode

func (db *FakeWebDocumentBuilder) SkipNode(e *html.Node)

func (*FakeWebDocumentBuilder) StartNode

func (db *FakeWebDocumentBuilder) StartNode(e *html.Node)

type PageParamContentInfo

type PageParamContentInfo struct {
	Type      PageParamContentType
	TargetURL string
	Number    int
}

func PPCINumberInPlainText

func PPCINumberInPlainText(number int) *PageParamContentInfo
func PPCINumericOutlink(targetURL string, number int) *PageParamContentInfo

func PPCIUnrelatedTerms

func PPCIUnrelatedTerms() *PageParamContentInfo

type PageParamContentType

type PageParamContentType uint
const (
	UnrelatedTerms PageParamContentType = iota
	NumberInPlainText
	NumericOutlink
)

type TextBlockBuilder

type TextBlockBuilder struct {
	// contains filtered or unexported fields
}

func NewTextBlockBuilder

func NewTextBlockBuilder(wc stringutil.WordCounter) *TextBlockBuilder

func (*TextBlockBuilder) CreateForAnchorText

func (tbb *TextBlockBuilder) CreateForAnchorText(text string) *webdoc.TextBlock

func (*TextBlockBuilder) CreateForText

func (tbb *TextBlockBuilder) CreateForText(text string) *webdoc.TextBlock

type TextBuilder

type TextBuilder struct {
	// contains filtered or unexported fields
}

func NewTextBuilder

func NewTextBuilder(wc stringutil.WordCounter) *TextBuilder

func (*TextBuilder) CreateForAnchorText

func (tb *TextBuilder) CreateForAnchorText(str string) *webdoc.Text

func (*TextBuilder) CreateForText

func (tb *TextBuilder) CreateForText(str string) *webdoc.Text

func (*TextBuilder) CreateNestedText

func (tb *TextBuilder) CreateNestedText(str string, levels int) *webdoc.Text

type TextDocumentBuilder

type TextDocumentBuilder struct {
	// contains filtered or unexported fields
}

func NewTextDocumentBuilder

func NewTextDocumentBuilder(wc stringutil.WordCounter) *TextDocumentBuilder

func (*TextDocumentBuilder) AddContentBlock

func (tdb *TextDocumentBuilder) AddContentBlock(str string, labels ...string) *webdoc.TextBlock

func (*TextDocumentBuilder) AddNonContentBlock

func (tdb *TextDocumentBuilder) AddNonContentBlock(str string, labels ...string) *webdoc.TextBlock

func (*TextDocumentBuilder) Build

func (tdb *TextDocumentBuilder) Build() *webdoc.TextDocument

type WebDocumentBuilder

type WebDocumentBuilder struct {
	// contains filtered or unexported fields
}

WebDocumentBuilder is a simple builder for testing.

func NewWebDocumentBuilder

func NewWebDocumentBuilder() *WebDocumentBuilder

func (*WebDocumentBuilder) AddAnchorText

func (db *WebDocumentBuilder) AddAnchorText(text string) *webdoc.Text

func (*WebDocumentBuilder) AddImage

func (db *WebDocumentBuilder) AddImage() *webdoc.Image

func (*WebDocumentBuilder) AddLeadImage

func (db *WebDocumentBuilder) AddLeadImage() *webdoc.Image

func (*WebDocumentBuilder) AddNestedText

func (db *WebDocumentBuilder) AddNestedText(text string) *webdoc.Text

func (*WebDocumentBuilder) AddTable

func (db *WebDocumentBuilder) AddTable(innerHTML string) *webdoc.Table

func (*WebDocumentBuilder) AddTagEnd

func (db *WebDocumentBuilder) AddTagEnd(tagName string) *webdoc.Tag

func (*WebDocumentBuilder) AddTagStart

func (db *WebDocumentBuilder) AddTagStart(tagName string) *webdoc.Tag

func (*WebDocumentBuilder) AddText

func (db *WebDocumentBuilder) AddText(text string) *webdoc.Text

func (*WebDocumentBuilder) Build

func (db *WebDocumentBuilder) Build() *webdoc.Document

Jump to

Keyboard shortcuts

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