commonmarkext

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

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

Go to latest
Published: Apr 1, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

README

Commonmark Ext

Extension to go-commonmark package to allow for plug-able output generators.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CMarkHTMLEscapeString

func CMarkHTMLEscapeString(s string) string

CMarkHTMLEscapeString escapes the supplied string using the commonmark HTML escaping rules.

func CMarkStripHTMLForAltTag

func CMarkStripHTMLForAltTag(s string) string

CMarkStripHTMLForAltTag stripts HTML from text, making it suitable for use in an alt tag. Not very pretty code at all.

func CMarkURLEncodeString

func CMarkURLEncodeString(str string) string

CMarkURLEncodeString escapes the supplied string using the commonmark HTML escaping rules. HACK HACK Commonmark encoding is weird. This code is dumb and not complete. Placeholder until we can get something better

func GenerateFromBytes

func GenerateFromBytes(commonmarkBytes []byte, generator CommonmarkGenerator) []byte

GenerateFromBytes generates output for the supplied byte array (containing commonmark text), using the supplied generator.

func GenerateFromNode

func GenerateFromNode(node *commonmark.CMarkNode, generator CommonmarkGenerator) string

GenerateFromNode generates output for the supplied commonmark node using the supplied generator.

func GenerateFromString

func GenerateFromString(commonmarkString string, generator CommonmarkGenerator) string

GenerateFromString generates output for the supplied string (containing commonmark text), using the supplied generator.

Types

type CommonmarkGenerator

type CommonmarkGenerator interface {
	// blocks
	GenBlockQuote(content string) string
	GenList(numberedList bool, listStartNumber int, content string) string
	GenItem(content string) string
	GenCodeBlock(fenceInfo string, content string) string
	GenHTML(content string) string
	GenParagraph(inTightList bool, content string) string
	GenHeader(level int, content string) string
	GenHrule() string

	// inlines
	GenText(content string) string
	GenSoftbreak() string
	GenLinebreak() string
	GenCode(content string) string
	GenInlineHTML(content string) string
	GenEmph(content string) string
	GenStrong(content string) string
	GenLink(linkURL, title, content string) string
	GenImage(imgURL, alt, title string) string

	// helpers
	GenDocument(content string) string
}

CommonmarkGenerator is the interface needs to be implemented by every output generator. Each of these methods will be called as the particular commonmark element is found in the input document.

type HtmlGenerator

type HtmlGenerator struct {
}

HtmlGenerator is an example generator that generates commonmark compliant HTML.

func NewHtmlGenerator

func NewHtmlGenerator() *HtmlGenerator

func (*HtmlGenerator) GenBlockQuote

func (h *HtmlGenerator) GenBlockQuote(content string) string

func (*HtmlGenerator) GenCode

func (h *HtmlGenerator) GenCode(content string) string

func (*HtmlGenerator) GenCodeBlock

func (h *HtmlGenerator) GenCodeBlock(fenceInfo string, content string) string

func (*HtmlGenerator) GenDocument

func (h *HtmlGenerator) GenDocument(content string) string

func (*HtmlGenerator) GenEmph

func (h *HtmlGenerator) GenEmph(content string) string

func (*HtmlGenerator) GenHTML

func (h *HtmlGenerator) GenHTML(content string) string

func (*HtmlGenerator) GenHeader

func (h *HtmlGenerator) GenHeader(level int, content string) string

func (*HtmlGenerator) GenHrule

func (h *HtmlGenerator) GenHrule() string

func (*HtmlGenerator) GenImage

func (h *HtmlGenerator) GenImage(imgUrl, alt, title string) string

func (*HtmlGenerator) GenInlineHTML

func (h *HtmlGenerator) GenInlineHTML(content string) string

func (*HtmlGenerator) GenItem

func (h *HtmlGenerator) GenItem(content string) string

func (*HtmlGenerator) GenLinebreak

func (h *HtmlGenerator) GenLinebreak() string
func (h *HtmlGenerator) GenLink(linkUrl, title, content string) string

func (*HtmlGenerator) GenList

func (h *HtmlGenerator) GenList(numberedList bool, listStartNumber int, content string) string

func (*HtmlGenerator) GenParagraph

func (h *HtmlGenerator) GenParagraph(inTightList bool, content string) string

func (*HtmlGenerator) GenSoftbreak

func (h *HtmlGenerator) GenSoftbreak() string

func (*HtmlGenerator) GenStrong

func (h *HtmlGenerator) GenStrong(content string) string

func (*HtmlGenerator) GenText

func (h *HtmlGenerator) GenText(content string) string

Jump to

Keyboard shortcuts

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