token

package
v0.0.0-...-94da09f Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2014 License: BSD-2-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TODO: Interpret as single if there is no closing tag
	PossibleSingle int = 1 << iota
	// TODO: This makes MoeParser ignore any tags inside this tags body. It will be ignored if the Single bit is set.
	NoParseInner
	// TODO: This makes the text inside of tag and passes it as an arg for the output. The text inside will not be parsed.
	TokenBodyAsArg
	// TODO: This makes the tag body become the first arg if there is no first argument (makes [name]arg0[/name] the same as [name=arg0][/name])
	AllowTokenBodyAsFirstArg
	// TODO: remove Converts a number to the number + "px" (ie 12 -> 12px)
	NumberArgToPx
	// TODO: This makes MoeParser match the tags that don't either start with whitespace or the beginning of a line. This is only useful if the token is of the type OpenCloseClass.
	AllowMidWord
	// TODO: This makes MoeParser stop matching:
	// - OpenClass type tokens without leading whitespace/beginning of body
	// - CloseClass type tokens without trailing whitespace/end of body
	// - Single type tokens without leading and trailing whitespace
	DisallowMidWord
	// For compatibility with the bbcode module until it's folded into the moeparsing routines
	HtmlSingle
)

Options for Tokens - return these bits in GetOptions() to implement this behavior

View Source
const (
	// A single token with no opening or closing token
	SingleToken int = iota
	// A token class that starts a section
	OpenToken
	// A token class that ends a section
	CloseToken
	// A token class that can both begin and end a section
	SymmetricToken
)

Token class types - return these in GetType()

Variables

This section is empty.

Functions

This section is empty.

Types

type TextToken

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

A special case of Token used to represent text that isn't matched by any other tokens i.e. "hi" in <p>hi</p>

func NewTextToken

func NewTextToken(body string) *TextToken

func (*TextToken) Output

func (tt *TextToken) Output() (string, error)

Returns the TextToken's body

func (*TextToken) SetArgs

func (tt *TextToken) SetArgs(args *TokenArgs)

func (*TextToken) Type

func (tt *TextToken) Type() string

type Token

type Token interface {
	Type() string
}

The Token interface represents an instance of a token class

type TokenArgs

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

The arguments for a token - these are the regexp capture groups

func NewTokenArgs

func NewTokenArgs(args []string, idByName map[string]int) *TokenArgs

func (*TokenArgs) ById

func (ta *TokenArgs) ById(id int) string

func (*TokenArgs) ByName

func (ta *TokenArgs) ByName(name string) string

func (*TokenArgs) Size

func (ta *TokenArgs) Size() int

type TokenBuilder

type TokenBuilder interface {
	Build(args *TokenArgs) Token
}

Jump to

Keyboard shortcuts

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