discordo/ui/markdown.go
ayntgl c5be3b3c86
refactor: switch to Arikawa (#178)
* Basic

* nav

* remove discord pkg

* fix guild delete handler

* misc

* remove ioutil

* remove astatine, press f to pay respect

* panic bad, log.Fatal good

* add preview
2022-08-19 02:31:39 +05:30

20 lines
583 B
Go

package ui
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
}