wikitext_parser

package module
v0.0.0-...-5c99a0a Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2022 License: BSD-2-Clause Imports: 4 Imported by: 2

README

wikitext-parser

Utilities to parse and handle wikitext template-based pages.

Might not be useful for recursive matching.

See other projects using this for usage examples.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetWikiStringValue

func GetWikiStringValue(v []interface{}, opts *WikiStringValueOptions) (r []string)

func NormalizeWikiTitle

func NormalizeWikiTitle(title string) string

func ParseWikiText

func ParseWikiText(text string) (result []interface{})

ParseWikiText small WikiText parser that extracts text, Templates, and its arguments/parameters

Types

type DescriptionList

type DescriptionList struct {
	Name    []interface{}
	Entries []interface{}
}

func ParseDescriptionList

func ParseDescriptionList(text string, index int, depth int) (i int, list *DescriptionList)

type HTML

type HTML struct {
	Tag *HTMLTag
}

func ParseHTML

func ParseHTML(text string, index int, depth int) (i int, html *HTML)

type HTMLTag

type HTMLTag struct {
	Parent     *HTMLTag
	Name       []byte
	Parameters []byte
	Content    []*HTMLTag
}

func (*HTMLTag) String

func (t *HTMLTag) String() (r string)
type Link struct {
	URL        string
	IsExternal bool
	Name       []interface{}
}
func ParseLink(text string, index int, depth int, startCharacter byte) (i int, link *Link)

type NewLineToken

type NewLineToken struct {
}

type Template

type Template struct {
	Name         string
	IsLink       bool
	Parameters   map[string][]interface{}
	UnkeyedIndex int
}

func NewTemplate

func NewTemplate(name string, isLink bool) *Template

func ParseTemplate

func ParseTemplate(text string, index int, depth int, startCharacter byte) (i int, template *Template)

func (*Template) AddParameter

func (t *Template) AddParameter(key string, value interface{})

func (*Template) AddParameterUnkeyed

func (t *Template) AddParameterUnkeyed(value interface{})

type UnorderedList

type UnorderedList struct {
	Entries []interface{}
}

func ParseUnorderedList

func ParseUnorderedList(text string, index int, depth int, indent int, startCharacter byte) (i int, list *UnorderedList)

type WikiStringValueOptions

type WikiStringValueOptions struct {
	PageName               string
	Trim                   bool
	StringHandler          func(value string, opt *WikiStringValueOptions) []string
	HTMLHandler            func(value *HTML, opt *WikiStringValueOptions) []string
	LinkHandler            func(value *Link, opt *WikiStringValueOptions) []string
	TemplateLinkHandler    func(value *Template, opt *WikiStringValueOptions) []string
	TemplateHandler        func(value *Template, opt *WikiStringValueOptions) []string
	UnorderedListHandler   func(value *UnorderedList, opt *WikiStringValueOptions) []string
	DescriptionListHandler func(value *DescriptionList, opt *WikiStringValueOptions) []string
	NewLineHandler         func(opt *WikiStringValueOptions) []string
}

func (*WikiStringValueOptions) Default

func (o *WikiStringValueOptions) Default()

Jump to

Keyboard shortcuts

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