mwfmt

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollegiateResultFormatter

type CollegiateResultFormatter types.CollegiateResult

CollegiateResultFormatter formats CollegiateResult

func (CollegiateResultFormatter) ANSI

ANSI fills the Formatter interface to create ANSI CLI output

func (CollegiateResultFormatter) HTML

HTML fills the Formatter interface to create HTML output

func (CollegiateResultFormatter) JSON

JSON fills the Formatter interface to create JSON output

func (CollegiateResultFormatter) Plain

Plain fills the Formatter interface to create plaintext output

type CollegiateResultsFormatter

type CollegiateResultsFormatter []types.CollegiateResult

CollegiateResultsFormatter formats []CollegiateResult

func (CollegiateResultsFormatter) ANSI

ANSI fills the Formatter interface to create ANSI CLI output

func (CollegiateResultsFormatter) HTML

HTML fills the Formatter interface to create HTML output

func (CollegiateResultsFormatter) JSON

JSON fills the Formatter interface to create JSON output

func (CollegiateResultsFormatter) Plain

Plain fills the Formatter interface to create plaintext output

type DefiningTextFormatter

type DefiningTextFormatter types.DefiningText

DefiningTextFormatter formats DefiningText

func (DefiningTextFormatter) ANSI

ANSI fills the Formatter interface to create ANSI CLI output

func (DefiningTextFormatter) HTML

HTML fills the Formatter interface to create HTML output

func (DefiningTextFormatter) JSON

JSON fills the Formatter interface to create JSON output

func (DefiningTextFormatter) Plain

Plain fills the Formatter interface to create plaintext output

type DefinitionsFormatter

type DefinitionsFormatter []types.Definition

DefinitionsFormatter formats []Definition

func (DefinitionsFormatter) ANSI

ANSI fills the Formatter interface to create ANSI CLI output

func (DefinitionsFormatter) HTML

func (f DefinitionsFormatter) HTML(opts FormatterOptions) ([]byte, error)

HTML fills the Formatter interface to create HTML output

func (DefinitionsFormatter) JSON

func (f DefinitionsFormatter) JSON(opts FormatterOptions) ([]byte, error)

JSON fills the Formatter interface to create JSON output

func (DefinitionsFormatter) Plain

Plain fills the Formatter interface to create plaintext output

type Formatter

type Formatter interface {
	ANSI(FormatterOptions) (string, error)
	Plain(FormatterOptions) (string, error)
	JSON(FormatterOptions) ([]byte, error)
	HTML(FormatterOptions) ([]byte, error)
}

Formatter is an interface for abstracting fromatting for different elements

func Format

func Format(item interface{}) Formatter

Format picks the appropriate formatter for the given item. Item must be of a type defined in mwtypes.

type FormatterOptions

type FormatterOptions struct {
	A          aurora.Aurora
	Prefix     string
	Homographs int
}

FormatterOptions stores and transfers state between formatters

func (FormatterOptions) WithAurora

func (fo FormatterOptions) WithAurora(a aurora.Aurora) FormatterOptions

WithAurora copies the FormatterOptions but with the appropriate value

func (FormatterOptions) WithHomographs

func (fo FormatterOptions) WithHomographs(h int) FormatterOptions

WithHomographs the FormatterOptions but with the appropriate value

func (FormatterOptions) WithPrefix

func (fo FormatterOptions) WithPrefix(p string) FormatterOptions

WithPrefix copies the FormatterOptions but with the appropriate value

type MWXMLChild

type MWXMLChild struct {
	Text string
	Node *MWXMLNode
}

MWXMLChild contains either plain text or a child node in a MW text XML tree

type MWXMLNode

type MWXMLNode struct {
	XMLName  xml.Name
	Attrs    []xml.Attr `xml:",attr"`
	Children []MWXMLChild
}

MWXMLNode is a node of the XML tree of a parsed MW text

func (MWXMLNode) GetArgs

func (p MWXMLNode) GetArgs() ([]string, error)

GetArgs returns the list of pipe-separated args in the original tag

func (MWXMLNode) GetAttr

func (p MWXMLNode) GetAttr(attr string) (string, bool)

GetAttr retrieves an attr from a node. Returns (value, ok)

func (*MWXMLNode) UnmarshalXML

func (p *MWXMLNode) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML is used to integrate with `encoding/xml`

type MerriamWebsterTagTextFormatter

type MerriamWebsterTagTextFormatter string

MerriamWebsterTagTextFormatter formats text that contains MW tokens https://dictionaryapi.com/products/json#sec-2.tokens

func (MerriamWebsterTagTextFormatter) ANSI

ANSI fills the Formatter interface to create ANSI CLI output

func (MerriamWebsterTagTextFormatter) HTML

HTML fills the Formatter interface to create HTML output

func (MerriamWebsterTagTextFormatter) JSON

JSON fills the Formatter interface to create JSON output

func (MerriamWebsterTagTextFormatter) Plain

Plain fills the Formatter interface to create plaintext output

type PronounciationsFormatter

type PronounciationsFormatter []types.Pronounciation

PronounciationsFormatter formats []Pronounciation

func (PronounciationsFormatter) ANSI

ANSI fills the Formatter interface to create ANSI CLI output

func (PronounciationsFormatter) HTML

HTML fills the Formatter interface to create HTML output

func (PronounciationsFormatter) JSON

JSON fills the Formatter interface to create JSON output

func (PronounciationsFormatter) Plain

Plain fills the Formatter interface to create plaintext output

type SenseFormatter

type SenseFormatter types.Sense

SenseFormatter formats a sense

func (SenseFormatter) ANSI

func (f SenseFormatter) ANSI(opts FormatterOptions) (string, error)

ANSI fills the Formatter interface to create ANSI CLI output

func (SenseFormatter) HTML

func (f SenseFormatter) HTML(opts FormatterOptions) ([]byte, error)

HTML fills the Formatter interface to create HTML output

func (SenseFormatter) JSON

func (f SenseFormatter) JSON(opts FormatterOptions) ([]byte, error)

JSON fills the Formatter interface to create JSON output

func (SenseFormatter) Plain

func (f SenseFormatter) Plain(opts FormatterOptions) (string, error)

Plain fills the Formatter interface to create plaintext output

type SenseSequenceFormatter

type SenseSequenceFormatter types.SenseSequence

SenseSequenceFormatter formats a SenseSequence

func (SenseSequenceFormatter) ANSI

ANSI fills the Formatter interface to create ANSI CLI output

func (SenseSequenceFormatter) HTML

HTML fills the Formatter interface to create HTML output

func (SenseSequenceFormatter) JSON

JSON fills the Formatter interface to create JSON output

func (SenseSequenceFormatter) Plain

Plain fills the Formatter interface to create plaintext output

Jump to

Keyboard shortcuts

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