markdown

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

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

Go to latest
Published: Nov 14, 2017 License: CC0-1.0 Imports: 8 Imported by: 0

README

Simple Markdown for Golang

Build Status codecov

This is an EXPERIMENTAL implementation of markdown processor.

Are you looking for https://github.com/russross/blackfriday ?

License (current version)

These codes are licensed under CC0.

CC0

Documentation

Index

Constants

View Source
const CODE_Comment = 9
View Source
const CODE_EOF = -1
View Source
const CODE_Ident = 4
View Source
const CODE_Keyword = 0
View Source
const CODE_Number = 1
View Source
const CODE_String = 2
View Source
const CODE_UNKNOWN = 100

Variables

View Source
var CKeywords = strings.Split("void,int,char,float,double,long,short,signed,unsigned,volatile,"+
	"static,const,auto,for,if,else,do,while,continue,break,return,switch,case,default,typedef,enum,struct", ",")
View Source
var CppKeywords = strings.Split("class,public,private,protected,namespace,using,bool,new,delete", ",")
View Source
var DUMMY_DEPTH = 999999
View Source
var GoKeywords = strings.Split("package,import,var,type,for,if,else,continue,break,return,func,switch,case,default,int,string,map,float", ",")
View Source
var Keywords = map[string][]string{
	"go":   GoKeywords,
	"ruby": RubyKeywords,
	"rb":   RubyKeywords,
	"rust": RustKeywords,
	"php":  PhpKeywords,
	"perl": PerlKeywords,
	"pl":   PerlKeywords,
	"c":    CKeywords,
	"cpp":  append(CKeywords, CppKeywords...),
	"js":   append(CKeywords, strings.Split("var,function,new", ",")...),
}
View Source
var PerlKeywords = strings.Split("for,foreach,if,else,elsif,do,while,next,last,return,sub,my,qw,local,require,use", ",")
View Source
var PhpKeywords = strings.Split("for,foreach,if,else,elseif,do,while,continue,break,new,class,return,catch,try,global,public,private,function,switch,case", ",")
View Source
var RubyKeywords = strings.Split("class,def,if,else,unless,do,next,begin,end,ensure,new,attr_accessor,return,require,require_relative", ",")
View Source
var RustKeywords = strings.Split("fn,let,enum,mod,struct,trait,type,use,impl,box,crate,where,true,false,self,super,"+
	"if,else,match,for,loop,while,break,continue,return,as,in,const,static,pub,mut,move,ref,unsafe,extern", ",")

Functions

func Convert

func Convert(scanner0 *bufio.Scanner, writer DocWriter) error

Convert md to html.

Types

type DocWriter

type DocWriter interface {
	Heading(text string, level int) int
	Link(url string, title string, options int) int
	Image(url string, title, alt string, options int) int
	Hr() int
	Strike() int
	Emphasis() int
	Strong() int
	Code() int
	Paragraph() int
	List(mode int) int
	ListItem() int
	Table() int
	TableRow() int
	TableCell(flags int) int
	CheckBox(checked bool) int
	QuoteBlock() int
	CodeBlock(lang string, title string) int
	End(lv int)
	Write(text string)
	WriteStyle(text string, className string, color string, flags int)
	Close()
}

type HTMLWriter

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

HTMLWriter : impl for DocWriter

func NewHTMLWriter

func NewHTMLWriter(writer io.Writer) *HTMLWriter

func (*HTMLWriter) CheckBox

func (w *HTMLWriter) CheckBox(checked bool) int

func (*HTMLWriter) Close

func (w *HTMLWriter) Close()

func (*HTMLWriter) Code

func (w *HTMLWriter) Code() int

func (*HTMLWriter) CodeBlock

func (w *HTMLWriter) CodeBlock(lang string, title string) int

func (*HTMLWriter) Emphasis

func (w *HTMLWriter) Emphasis() int

func (*HTMLWriter) End

func (w *HTMLWriter) End(lv int)

func (*HTMLWriter) Heading

func (w *HTMLWriter) Heading(text string, level int) int

func (*HTMLWriter) Hr

func (w *HTMLWriter) Hr() int

func (*HTMLWriter) Image

func (w *HTMLWriter) Image(url string, title, alt string, opt int) int
func (w *HTMLWriter) Link(url string, title string, opt int) int

func (*HTMLWriter) List

func (w *HTMLWriter) List(mode int) int

func (*HTMLWriter) ListItem

func (w *HTMLWriter) ListItem() int

func (*HTMLWriter) Paragraph

func (w *HTMLWriter) Paragraph() int

func (*HTMLWriter) QuoteBlock

func (w *HTMLWriter) QuoteBlock() int

func (*HTMLWriter) Strike

func (w *HTMLWriter) Strike() int

func (*HTMLWriter) Strong

func (w *HTMLWriter) Strong() int

func (*HTMLWriter) Table

func (w *HTMLWriter) Table() int

func (*HTMLWriter) TableCell

func (w *HTMLWriter) TableCell(flags int) int

func (*HTMLWriter) TableRow

func (w *HTMLWriter) TableRow() int

func (*HTMLWriter) Write

func (w *HTMLWriter) Write(text string)

func (*HTMLWriter) WriteStyle

func (w *HTMLWriter) WriteStyle(text string, className string, color string, flags int)

type LimitedReader

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

func (*LimitedReader) Read

func (r *LimitedReader) Read(p []byte) (n int, err error)

type LinkInlineMatcher

type LinkInlineMatcher struct {
	Start string
}

func (*LinkInlineMatcher) Prefix

func (m *LinkInlineMatcher) Prefix() string

func (*LinkInlineMatcher) Render

func (m *LinkInlineMatcher) Render(params []string, md *state)

func (*LinkInlineMatcher) TryMatch

func (m *LinkInlineMatcher) TryMatch(line string) (int, []string)

type Markdown

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

Markdown config.

func NewMarkdown

func NewMarkdown() *Markdown

NewMarkdown returns *Markdown

type Matcher

type Matcher interface {
	Prefix() string
	TryMatch(line string) (int, []string)
	Render(params []string, s *state)
}

type PlainWriter

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

PlainWriter : impl for DocWriter

func NewPlainWriter

func NewPlainWriter(writer io.Writer) *PlainWriter

func (*PlainWriter) CheckBox

func (w *PlainWriter) CheckBox(checked bool) int

func (*PlainWriter) Close

func (w *PlainWriter) Close()

func (*PlainWriter) Code

func (w *PlainWriter) Code() int

func (*PlainWriter) CodeBlock

func (w *PlainWriter) CodeBlock(lang string, title string) int

func (*PlainWriter) Emphasis

func (w *PlainWriter) Emphasis() int

func (*PlainWriter) End

func (w *PlainWriter) End(lv int)

func (*PlainWriter) Heading

func (w *PlainWriter) Heading(text string, level int) int

func (*PlainWriter) Hr

func (w *PlainWriter) Hr() int

func (*PlainWriter) Image

func (w *PlainWriter) Image(url string, title, alt string, opt int) int
func (w *PlainWriter) Link(url string, title string, opt int) int

func (*PlainWriter) List

func (w *PlainWriter) List(mode int) int

func (*PlainWriter) ListItem

func (w *PlainWriter) ListItem() int

func (*PlainWriter) Paragraph

func (w *PlainWriter) Paragraph() int

func (*PlainWriter) QuoteBlock

func (w *PlainWriter) QuoteBlock() int

func (*PlainWriter) Strike

func (w *PlainWriter) Strike() int

func (*PlainWriter) Strong

func (w *PlainWriter) Strong() int

func (*PlainWriter) Table

func (w *PlainWriter) Table() int

func (*PlainWriter) TableCell

func (w *PlainWriter) TableCell(flags int) int

func (*PlainWriter) TableRow

func (w *PlainWriter) TableRow() int

func (*PlainWriter) Write

func (w *PlainWriter) Write(text string)

func (*PlainWriter) WriteStyle

func (w *PlainWriter) WriteStyle(text string, className string, color string, flags int)

type RegexMatcher

type RegexMatcher struct {
	PrefixStr  string
	Re         *regexp.Regexp
	RenderFunc func(matches []string, s *state, matcher *RegexMatcher)
}

func (*RegexMatcher) Prefix

func (m *RegexMatcher) Prefix() string

func (*RegexMatcher) Render

func (m *RegexMatcher) Render(params []string, s *state)

func (*RegexMatcher) TryMatch

func (m *RegexMatcher) TryMatch(text string) (int, []string)

type SimpleInlineMatcher

type SimpleInlineMatcher struct {
	Start      string
	End        string
	RenderFunc func(content string, s *state, matcher *SimpleInlineMatcher)
}

func (*SimpleInlineMatcher) Prefix

func (m *SimpleInlineMatcher) Prefix() string

func (*SimpleInlineMatcher) Render

func (m *SimpleInlineMatcher) Render(params []string, s *state)

func (*SimpleInlineMatcher) TryMatch

func (m *SimpleInlineMatcher) TryMatch(line string) (int, []string)

type Tokenizer

type Tokenizer struct {
	Lang      string
	Supported bool
	// contains filtered or unexported fields
}

func NewTokenizer

func NewTokenizer(lang string) *Tokenizer

func (*Tokenizer) Code

func (t *Tokenizer) Code(reader io.Reader)

func (*Tokenizer) Read

func (t *Tokenizer) Read() (int, string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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