gowiki

package module
v0.0.0-...-93aa751 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2018 License: Apache-2.0 Imports: 12 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gowiki

Gowiki is a golang library to parse mediawiki markup as found in Wikipedia pages.

Documentation

Index

Constants

View Source
const (
	QS_none int = iota
	QS_i
	QS_b
	QS_ib
	QS_bi
)
View Source
const (
	TClosed int = 1 << iota
)

Variables

View Source
var DebugLevel int = 0

var Debug bool = false

View Source
var MagicMap map[string]TemplateRenderer = map[string]TemplateRenderer{
	"DISPLAYTITLE": nil,
}

Functions

This section is empty.

Types

type Article

type Article struct {
	MediaWiki    string
	Title        string
	Links        []WikiLink
	ExtLinks     []string
	Type         string
	AbstractText string
	Media        []WikiLink
	Tokens       []*Token
	//	OldTokens    []*Token
	Root      *ParseNode
	Parsed    bool
	Text      string
	TextLinks []FullWikiLink
	Templates []*Template
	// contains filtered or unexported fields
}

func NewArticle

func NewArticle(title, text string) (*Article, error)

func ParseArticle

func ParseArticle(title, text string, g PageGetter) (*Article, error)

func (*Article) CheckDisambiguation

func (a *Article) CheckDisambiguation() bool

func (*Article) CheckRedirect

func (a *Article) CheckRedirect() (bool, *WikiLink)

func (*Article) GenText

func (a *Article) GenText() error

func (*Article) GetAbstract

func (a *Article) GetAbstract() string
func (a *Article) GetExternalLinks() []string
func (a *Article) GetLinks() []WikiLink

func (*Article) GetMedia

func (a *Article) GetMedia() []WikiLink

func (*Article) GetText

func (a *Article) GetText() string
func (a *Article) GetTextLinks() []FullWikiLink

func (*Article) ParseSimple

func (a *Article) ParseSimple() error

func (*Article) PrintParseTree

func (a *Article) PrintParseTree()

func (*Article) Tokenize

func (a *Article) Tokenize(mw string, g PageGetter) ([]*Token, error)

func (*Article) TranscludeTemplatesRecursive

func (a *Article) TranscludeTemplatesRecursive(mw string, params map[string]string, g PageGetter, depth int) string

type DummyPageGetter

type DummyPageGetter struct{}

func (*DummyPageGetter) Get

func (g *DummyPageGetter) Get(wl WikiLink) (string, error)
type FullWikiLink struct {
	Link  WikiLink
	Text  string
	Start int // rune offset of beginning
	End   int // rune offset of end (index of the char after the last)
}

type Namespaces

type Namespaces map[string]string
var StandardNamespaces Namespaces = map[string]string{
	"media":                  "Media",
	"special":                "Special",
	"talk":                   "Talk",
	"user":                   "User",
	"user talk":              "User talk",
	"wikipedia":              "Wikipedia",
	"wikipedia talk":         "Wikipedia talk",
	"file":                   "File",
	"file talk":              "File talk",
	"mediawiki":              "MediaWiki",
	"mediawiki talk":         "MediaWiki talk",
	"template":               "Template",
	"template talk":          "Template talk",
	"help":                   "Help",
	"help talk":              "Help talk",
	"category":               "Category",
	"category talk":          "Category talk",
	"portal":                 "Portal",
	"portal talk":            "Portal talk",
	"book":                   "Book",
	"book talk":              "Book talk",
	"draft":                  "Draft",
	"draft talk":             "Draft talk",
	"education program":      "Education Program",
	"education program talk": "Education Program talk",
	"timedtext":              "TimedText",
	"timedtext talk":         "TimedText talk",
	"module":                 "Module",
	"module talk":            "Module talk",
	"topic":                  "Topic",
}

func (Namespaces) WikiCanonicalFormNamespaceEsc

func (namespaces Namespaces) WikiCanonicalFormNamespaceEsc(l string, defaultNamespace string, unescape bool) WikiLink

type PageGetter

type PageGetter interface {
	Get(page WikiLink) (string, error)
}

type ParseNode

type ParseNode struct {
	NType    string
	NSubType string
	Link     WikiLink
	Contents string
	Flags    int
	Nodes    []*ParseNode
}

type Template

type Template struct {
	Typ        string            `json:"type"` //magic,normal,ext,param
	Name       string            `json:"name"`
	Attr       string            `json:"attr"` //text after the ':' in magic templates
	Parameters map[string]string `json:"parameters"`
}

type TemplateRenderer

type TemplateRenderer func(name, mw string, params map[string]string) string

type Token

type Token struct {
	TText   string   `json:"tText,omitempty"`
	TType   string   `json:"tType,omitempty"`
	TAttr   string   `json:"tAttr,omitempty"`
	TLink   WikiLink `json:"tLink,omitempty"`
	TClosed bool     `json:"tClosed,omitempty"`
	TPipes  []string `json:"tPipes,omitempty"`
}
type WikiLink struct {
	Namespace string
	PageName  string
	Anchor    string
}

func WikiCanonicalForm

func WikiCanonicalForm(l string) WikiLink

func WikiCanonicalFormEsc

func WikiCanonicalFormEsc(l string, unescape bool) WikiLink

func WikiCanonicalFormNamespace

func WikiCanonicalFormNamespace(l string, defaultNamespace string) WikiLink

func (*WikiLink) FullPagename

func (wl *WikiLink) FullPagename() string

func (*WikiLink) FullPagenameAnchor

func (wl *WikiLink) FullPagenameAnchor() string

func (*WikiLink) GetAnchor

func (wl *WikiLink) GetAnchor() string

func (*WikiLink) HasAnchor

func (wl *WikiLink) HasAnchor() bool
func (wl *WikiLink) IsImplicitSelfLink() bool

Jump to

Keyboard shortcuts

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