wiki

package
v0.30.10 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: AGPL-3.0, AGPL-3.0-only Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWikiSyntax         = errors.New("invalid wiki syntax")
	ErrGlobalPrefix       = fmt.Errorf("%w: missing prefix '{{Infobox' at the start", ErrWikiSyntax)
	ErrGlobalSuffix       = fmt.Errorf("%w: missing '}}' at the end", ErrWikiSyntax)
	ErrArrayNoClose       = fmt.Errorf("%w: array should be closed by '}'", ErrWikiSyntax)
	ErrArrayItemWrapped   = fmt.Errorf("%w: array item should be wrapped by '[]'", ErrWikiSyntax)
	ErrExpectingNewField  = fmt.Errorf("%w: missing '|' to start a new field", ErrWikiSyntax)
	ErrExpectingSignEqual = fmt.Errorf("%w: missing '=' to separate field name and value", ErrWikiSyntax)
)

Functions

This section is empty.

Types

type Field

type Field struct {
	Key    string `json:"key"`
	Value  string `json:"value"`
	Values []Item `json:"values"`
	Array  bool   `json:"array"`
	Null   bool   `json:"null,omitempty"`
}

type Item

type Item struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type SyntaxError added in v0.20.13

type SyntaxError struct {
	Err  error
	Line string
	Lino int
}

func (*SyntaxError) Error added in v0.20.13

func (p *SyntaxError) Error() string

func (*SyntaxError) Unwrap added in v0.20.13

func (p *SyntaxError) Unwrap() error

type Wiki

type Wiki struct {
	Type   string  `json:"type"`
	Fields []Field `json:"fields"`
}

func Parse

func Parse(s string) (Wiki, error)

func ParseOmitError

func ParseOmitError(s string) Wiki

ParseOmitError try to parse a string as wiki, omitting error.

func (Wiki) NonZero

func (w Wiki) NonZero() Wiki

NonZero return a wiki without empty fields and items.

Jump to

Keyboard shortcuts

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