parser

package module
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: 4 Imported by: 0

README

MoeChat Parser

An XSS-secured parser for BBCode and chat-style markdown used in MoeChat, written in GoLang.

The parser uses Go's html/template package to inject all user input. Remember that this code has not been checked by any professionals, and comes with NO WARRANTY.

This is designed for use inside HTML - DO NOT use it inside <script> tags or <style> tags!

This code is licensed under the FreeBSD license, described in the LICENSE file.

Documentation

Overview

* This package implements a parser for any markup-style tags, including BBCode tags.

Index

Constants

This section is empty.

Variables

View Source
var Lexer *lexer.Lexer

Functions

This section is empty.

Types

type HtmlTokenBuilder

type HtmlTokenBuilder struct {
	HtmlElements []string
}

func (*HtmlTokenBuilder) Build

func (htb *HtmlTokenBuilder) Build(args *token.TokenArgs) token.Token

type Matcher

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

A Matcher is an extremely general lexer.Matcher. This will not match tags that are in the middle of a word unless AllowInWord is set.

func NewMatcher

func NewMatcher(args MatcherArgs, exprs ...string) *Matcher

func (*Matcher) BuildTokens

func (m *Matcher) BuildTokens(args *token.TokenArgs) []token.Token

func (*Matcher) Exprs

func (m *Matcher) Exprs() []string

func (*Matcher) IsValid

func (m *Matcher) IsValid(args *token.TokenArgs) bool

func (*Matcher) ModifyArgs

func (m *Matcher) ModifyArgs(args []string, idByName map[string]int) ([]string, map[string]int)

func (*Matcher) Name

func (m *Matcher) Name() string

func (*Matcher) Options

func (m *Matcher) Options() int

func (*Matcher) Type

func (m *Matcher) Type() int

type MatcherArgs

type MatcherArgs struct {
	Name          string
	Options       int
	Type          int
	ArgModFunc    func(args []string, namesById map[string]int) ([]string, map[string]int)
	IsValid       func(args *token.TokenArgs) bool
	TokenBuilders []token.TokenBuilder
	NotRe         bool
}

type Parser

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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