lispy

package module
v0.0.0-...-d14e85b Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2013 License: MIT Imports: 7 Imported by: 0

README

Lispy Syntax System

Simple, Elegant yet Extendible Syntax System.

Syntax

(tagname:content|attr1:value1|attr2:value2|etc:etc)
Escapers
\| \: \( \)

Note: Usually Brackets '()' do not need escaping, just don't match the syntax! If you planning on using emoticon always escape ;-)

Installation

go get github.com/CJ-Jackson/lispy

Example

(video:(source:forrest_gump.mp4|type:video/mp4)
	(source:forrest_gump.ogg|type:video/ogg)
	(track:subtitles_en.vtt|kind:subtitles|srclang:en|label:English)
	(track:subtitles_no.vtt|kind:subtitles|srclang:no|label:Norwegian)
|width:320|height:240|controls:)

Output:

<video width="320" height="240" controls><source src="forrest_gump.mp4" type="video/mp4" />
	<source src="forrest_gump.ogg" type="video/ogg" />
	<track kind="subtitles" label="English" src="subtitles_en.vtt" srclang="en" />
	<track kind="subtitles" label="Norwegian" src="subtitles_no.vtt" srclang="no" />
</video>

Usage

package main

import (
	"github.com/CJ-Jackson/lispy"
	"fmt"
)

func main() {
	parser := lispy.New()
	fmt.Print(parser.Render("(p:Hello World!)"))
	// Output: <p>Hello World!</p>
}

Documentation

Documentation are avaliable at

http://gowalker.org/github.com/CJ-Jackson/lispy

Note

Like HTML it's is suspectible to leakage when forgetting to close tag, unlike HTML it is sandboxed to a variable, while HTML is sandboxed to a page.

Documentation

Overview

Simple, Elegant yet Extendible Syntax System. (p:Hello World in Paragraph!)

Index

Constants

This section is empty.

Variables

View Source
var DefaultMap = struct {
	sync.RWMutex
	Map LispyHandlerMap
}{
	Map: LispyHandlerMap{
		"--":         LispyFunc(Blanks),
		"_":          LispyFunc(Escape),
		"_html":      LispyFunc(EscapedHtml),
		"a":          LispyFunc(A),
		"abbr":       LispyFunc(CommonTitle),
		"address":    LispyFunc(Common),
		"area":       LispyFunc(Area),
		"article":    LispyFunc(Common),
		"aside":      LispyFunc(Common),
		"audio":      LispyFunc(Audio),
		"b":          LispyFunc(Common),
		"bdi":        LispyFunc(Common),
		"bdo":        LispyFunc(CommonDir),
		"blockquote": LispyFunc(CommonCite),
		"br":         LispyFunc(Br),
		"button":     LispyFunc(Button),
		"c":          LispyFunc(HtmlAmp),
		"canvas":     LispyFunc(Canvas),
		"caption":    LispyFunc(Common),
		"cite":       LispyFunc(Common),
		"code":       LispyFunc(Common),
		"col":        LispyFunc(CommonSpan),
		"colgroup":   LispyFunc(CommonSpan),
		"css":        LispyFunc(CSS),
		"datalist":   LispyFunc(Common),
		"dd":         LispyFunc(Common),
		"del":        LispyFunc(CommonCiteDateTime),
		"details":    LispyFunc(Details),
		"dfn":        LispyFunc(Common),
		"div":        LispyFunc(Common),
		"dl":         LispyFunc(Common),
		"dt":         LispyFunc(Common),
		"em":         LispyFunc(Common),
		"embed":      LispyFunc(Embed),
		"fieldset":   LispyFunc(FieldSet),
		"figcaption": LispyFunc(Common),
		"figure":     LispyFunc(Common),
		"footer":     LispyFunc(Common),
		"form":       LispyFunc(Form),
		"h1":         LispyFunc(Header),
		"h2":         LispyFunc(Header),
		"h3":         LispyFunc(Header),
		"h4":         LispyFunc(Header),
		"h5":         LispyFunc(Header),
		"h6":         LispyFunc(Header),
		"header":     LispyFunc(Common),
		"hgroup":     LispyFunc(Common),
		"hr":         LispyFunc(Common),
		"i":          LispyFunc(Common),
		"iframe":     LispyFunc(CommonSrc),
		"img":        LispyFunc(Img),
		"input":      LispyFunc(Input),
		"ins":        LispyFunc(CommonCiteDateTime),
		"javascript": LispyFunc(JavaScript),
		"kbd":        LispyFunc(Common),
		"keygen":     LispyFunc(Keygen),
		"label":      LispyFunc(Label),
		"legend":     LispyFunc(Common),
		"li":         LispyFunc(CommonValue),
		"map":        LispyFunc(CommonName),
		"mark":       LispyFunc(Common),
		"nav":        LispyFunc(Common),
		"object":     LispyFunc(Object),
		"ol":         LispyFunc(Ol),
		"option":     LispyFunc(Option),
		"output":     LispyFunc(Output),
		"p":          LispyFunc(Common),
		"param":      LispyFunc(Param),
		"pre":        LispyFunc(Common),
		"q":          LispyFunc(CommonCite),
		"raw":        LispyFunc(Raw),
		"rp":         LispyFunc(Common),
		"rt":         LispyFunc(Common),
		"ruby":       LispyFunc(Common),
		"s":          LispyFunc(Common),
		"samp":       LispyFunc(Common),
		"scriptfile": LispyFunc(ScriptFile),
		"section":    LispyFunc(Common),
		"select":     LispyFunc(Select),
		"small":      LispyFunc(Common),
		"source":     LispyFunc(Source),
		"span":       LispyFunc(Common),
		"strong":     LispyFunc(Common),
		"style":      LispyFunc(CSS),
		"sub":        LispyFunc(Common),
		"sup":        LispyFunc(Common),
		"table":      LispyFunc(Table),
		"tbody":      LispyFunc(Common),
		"td":         LispyFunc(TableTd),
		"textarea":   LispyFunc(Textarea),
		"tfood":      LispyFunc(Common),
		"th":         LispyFunc(TableTd),
		"thead":      LispyFunc(Common),
		"time":       LispyFunc(Time),
		"tr":         LispyFunc(Common),
		"track":      LispyFunc(Track),
		"u":          LispyFunc(Common),
		"ul":         LispyFunc(Common),
		"var":        LispyFunc(Common),
		"video":      LispyFunc(Video),
		"wbr":        LispyFunc(Wbr),
	},
}

Functions

func A

func A(li *Lispy) string

func ANoFollow

func ANoFollow(li *Lispy) string

func Area

func Area(li *Lispy) string

func AreaNoFollow

func AreaNoFollow(li *Lispy) string

func Audio

func Audio(li *Lispy) string

func Blanks

func Blanks(li *Lispy) string

func Br

func Br(li *Lispy) string

func Button

func Button(li *Lispy) string

func CSS

func CSS(li *Lispy) string

func Canvas

func Canvas(li *Lispy) string

func Common

func Common(li *Lispy) string

func CommonCite

func CommonCite(li *Lispy) string

func CommonCiteDateTime

func CommonCiteDateTime(li *Lispy) string

func CommonDir

func CommonDir(li *Lispy) string

func CommonName

func CommonName(li *Lispy) string

func CommonSpan

func CommonSpan(li *Lispy) string

func CommonSrc

func CommonSrc(li *Lispy) string

func CommonTitle

func CommonTitle(li *Lispy) string

func CommonValue

func CommonValue(li *Lispy) string

func Details

func Details(li *Lispy) string

func Embed

func Embed(li *Lispy) string

func Escape

func Escape(li *Lispy) string

func EscapedHtml

func EscapedHtml(li *Lispy) string

func FieldSet

func FieldSet(li *Lispy) string

func Form

func Form(li *Lispy) string
func Header(li *Lispy) string

func HtmlAmp

func HtmlAmp(li *Lispy) string

func Img

func Img(li *Lispy) string

func Input

func Input(li *Lispy) string

func JavaScript

func JavaScript(li *Lispy) string

func Keygen

func Keygen(li *Lispy) string

func Label

func Label(li *Lispy) string

func Object

func Object(li *Lispy) string

func Ol

func Ol(li *Lispy) string

func Option

func Option(li *Lispy) string

func Output

func Output(li *Lispy) string

func Param

func Param(li *Lispy) string

func Raw

func Raw(li *Lispy) string

func ScriptFile

func ScriptFile(li *Lispy) string

func Select

func Select(li *Lispy) string

func Source

func Source(li *Lispy) string

func Table

func Table(li *Lispy) string

func TableTd

func TableTd(li *Lispy) string

func Textarea

func Textarea(li *Lispy) string

func Time

func Time(li *Lispy) string

func Track

func Track(li *Lispy) string

func Video

func Video(li *Lispy) string

func Wbr

func Wbr(li *Lispy) string

Types

type Lispy

type Lispy struct {
	sync.RWMutex
	Name      string
	Content   string
	CacheName string
	// contains filtered or unexported fields
}

Lispy Structure

func New

func New() *Lispy

Construct with Default Map

func (*Lispy) AddFuncMap

func (li *Lispy) AddFuncMap(lispymap LispyMap) *Lispy

Add Function Map

func (*Lispy) AddHandlerMap

func (li *Lispy) AddHandlerMap(lispyhandlermap LispyHandlerMap) *Lispy

Add Handler Map

func (*Lispy) AllowTags

func (li *Lispy) AllowTags(names ...string)

Specify Allowed Tags, useful for comment system.

Note: All tags are enabled by default.

func (*Lispy) ContentAsInt64

func (li *Lispy) ContentAsInt64() int64

Get Content as Int64, return 0 on fail!

func (*Lispy) Copy

func (li *Lispy) Copy() *Lispy

Copy

func (*Lispy) Delete

func (li *Lispy) Delete(name string)

Delete Parameter/Attribute

func (*Lispy) Exist

func (li *Lispy) Exist(name string) bool

Check for existant of Parameter/Attribute

func (*Lispy) ExistDel

func (li *Lispy) ExistDel(name string) bool

func (*Lispy) ExistRes

func (li *Lispy) ExistRes(name string) bool

func (*Lispy) Get

func (li *Lispy) Get(name string) string

Get Parameter/Attribute

func (*Lispy) GetDel

func (li *Lispy) GetDel(name string) string

func (*Lispy) GetInt

func (li *Lispy) GetInt(name string) int

Get Parameter/Attribute as Int, return 0 on fail!

func (*Lispy) GetInt64

func (li *Lispy) GetInt64(name string) int64

Get Parameter/Attribute as Int64, return 0 on fail!

func (*Lispy) GetInt64Del

func (li *Lispy) GetInt64Del(name string) int64

func (*Lispy) GetIntDel

func (li *Lispy) GetIntDel(name string) int

func (*Lispy) GetNames

func (li *Lispy) GetNames() []string

Get Names of Parameter/Attribute.

Note: Does not operate while Parameter/Attribute has been Restricted.

func (*Lispy) GetParam

func (li *Lispy) GetParam() string

func (*Lispy) GetRaw

func (li *Lispy) GetRaw(name string) string

Get Raw Parameter/Attribute (Unescaped)

func (*Lispy) GetRawDel

func (li *Lispy) GetRawDel(name string) string

func (*Lispy) ParseParam

func (li *Lispy) ParseParam()

func (*Lispy) RawContent

func (li *Lispy) RawContent() string

Unescaped Content

func (*Lispy) RawContentExt

func (li *Lispy) RawContentExt() string

Unescaped Content Extended, includes | : ( )

func (*Lispy) Render

func (li *Lispy) Render(str string) string

Render Syntax from String, returns rendered String

func (*Lispy) RenderSafe

func (li *Lispy) RenderSafe(str string) html.HTML

Alais of Render, but marks the string as safe!

func (*Lispy) RenderedContent

func (li *Lispy) RenderedContent() html.HTML

func (*Lispy) RestrictAttribute

func (li *Lispy) RestrictAttribute()

Restrict Attribute, useful for comment system.

Note: Alias of RestrictParam

func (*Lispy) RestrictParam

func (li *Lispy) RestrictParam()

Restrict Parameter, useful for comment system.

func (*Lispy) Safe

func (li *Lispy) Safe(str string) html.HTML

Make string as safe!

func (*Lispy) Set

func (li *Lispy) Set(name, value string)

Set Parameter/Attribute

func (*Lispy) SetFunc

func (li *Lispy) SetFunc(name string, function LispyFunc) *Lispy

Set Function

func (*Lispy) SetHandler

func (li *Lispy) SetHandler(name string, lispyhandler LispyHandler) *Lispy

Set Handler

type LispyFunc

type LispyFunc func(*Lispy) string

func (LispyFunc) Lispy

func (li LispyFunc) Lispy(lii *Lispy) string

type LispyHandler

type LispyHandler interface {
	Lispy(*Lispy) string
}

Lispy Handler Interface

type LispyHandlerMap

type LispyHandlerMap map[string]LispyHandler

Lispy Handler Map

func (LispyHandlerMap) Set

func (li LispyHandlerMap) Set(name string, handle LispyHandler)

Setter

type LispyMap

type LispyMap map[string]LispyFunc

Lispy Map

func (LispyMap) Set

func (li LispyMap) Set(name string, function func(li *Lispy) string)

Setter

Jump to

Keyboard shortcuts

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