2016-12-13 02:14:14 +00:00
|
|
|
package main
|
|
|
|
import "regexp"
|
|
|
|
|
2017-01-05 14:41:14 +00:00
|
|
|
var markdown_bold_italic *regexp.Regexp
|
|
|
|
var markdown_bold *regexp.Regexp
|
|
|
|
var markdown_italic *regexp.Regexp
|
2016-12-13 02:14:14 +00:00
|
|
|
|
|
|
|
func init() {
|
2017-01-05 14:41:14 +00:00
|
|
|
plugins["markdown"] = NewPlugin("markdown","Markdown","Azareal","http://github.com/Azareal","","","",init_markdown,nil,deactivate_markdown)
|
2016-12-13 02:14:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init_markdown() {
|
2017-01-05 14:41:14 +00:00
|
|
|
plugins["markdown"].AddHook("parse_assign", markdown_parse)
|
|
|
|
markdown_bold_italic = regexp.MustCompile(`\*\*\*(.*)\*\*\*`)
|
|
|
|
markdown_bold = regexp.MustCompile(`\*\*(.*)\*\*`)
|
|
|
|
markdown_italic = regexp.MustCompile(`\*(.*)\*`)
|
2016-12-13 02:14:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func deactivate_markdown() {
|
2017-01-05 14:41:14 +00:00
|
|
|
plugins["markdown"].RemoveHook("parse_assign", markdown_parse)
|
2016-12-13 02:14:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func markdown_parse(data interface{}) interface{} {
|
|
|
|
msg := data.(string)
|
2017-01-05 14:41:14 +00:00
|
|
|
msg = markdown_bold_italic.ReplaceAllString(msg,"<i><b>$1</b></i>")
|
|
|
|
msg = markdown_bold.ReplaceAllString(msg,"<b>$1</b>")
|
|
|
|
msg = markdown_italic.ReplaceAllString(msg,"<i>$1</i>")
|
2016-12-13 02:14:14 +00:00
|
|
|
return msg
|
|
|
|
}
|