summaryrefslogtreecommitdiffstats
path: root/bridge/slack/helpers.go
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/slack/helpers.go')
-rw-r--r--bridge/slack/helpers.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go
index 7c012a4b..b95ae878 100644
--- a/bridge/slack/helpers.go
+++ b/bridge/slack/helpers.go
@@ -188,6 +188,36 @@ func (b *Bslack) replaceURL(text string) string {
return text
}
+func (b *Bslack) replaceb0rkedMarkDown(text string) string {
+ // taken from https://github.com/mattermost/mattermost-server/blob/master/app/slackimport.go
+ //
+ regexReplaceAllString := []struct {
+ regex *regexp.Regexp
+ rpl string
+ }{
+ // bold
+ {
+ regexp.MustCompile(`(^|[\s.;,])\*(\S[^*\n]+)\*`),
+ "$1**$2**",
+ },
+ // strikethrough
+ {
+ regexp.MustCompile(`(^|[\s.;,])\~(\S[^~\n]+)\~`),
+ "$1~~$2~~",
+ },
+ // single paragraph blockquote
+ // Slack converts > character to >
+ {
+ regexp.MustCompile(`(?sm)^>`),
+ ">",
+ },
+ }
+ for _, rule := range regexReplaceAllString {
+ text = rule.regex.ReplaceAllString(text, rule.rpl)
+ }
+ return text
+}
+
func (b *Bslack) replaceCodeFence(text string) string {
return codeFenceRE.ReplaceAllString(text, "```")
}