blob: 56bb989f1307467135292bd0f39f7dc88e3880e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package markdown
import "html/template"
type Option struct {
ImageSource func(string) string
}
func Parse(s string, opt *Option) (template.HTML, *ParseError) {
lxs := lex(s)
tree, err := ast(lxs)
if err != nil {
return "", err
}
if opt == nil {
opt = new(Option)
}
if opt.ImageSource == nil {
opt.ImageSource = func(s string) string { return s }
}
return tree.Eval(opt)
}
func ParseBytes(b []byte, opt *Option) (template.HTML, *ParseError) {
return Parse(string(b), opt)
}
|