20 lines
588 B
Go
20 lines
588 B
Go
package discord
|
|
|
|
import "regexp"
|
|
|
|
var (
|
|
boldRegex = regexp.MustCompile(`(?ms)\*\*(.*?)\*\*`)
|
|
italicRegex = regexp.MustCompile(`(?ms)\*(.*?)\*`)
|
|
underlineRegex = regexp.MustCompile(`(?ms)__(.*?)__`)
|
|
strikeThroughRegex = regexp.MustCompile(`(?ms)~~(.*?)~~`)
|
|
)
|
|
|
|
func ParseMarkdown(md string) string {
|
|
var res string
|
|
res = boldRegex.ReplaceAllString(md, "[::b]$1[::-]")
|
|
res = italicRegex.ReplaceAllString(res, "[::i]$1[::-]")
|
|
res = underlineRegex.ReplaceAllString(res, "[::u]$1[::-]")
|
|
res = strikeThroughRegex.ReplaceAllString(res, "[::s]$1[::-]")
|
|
|
|
return res
|
|
}
|