We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f06c9c commit 7c1b0c5Copy full SHA for 7c1b0c5
format/markdown.go
@@ -8,6 +8,7 @@ package format
8
9
import (
10
"fmt"
11
+ "regexp"
12
"strings"
13
14
"github.com/yuin/goldmark"
@@ -39,6 +40,15 @@ func UnwrapSingleParagraph(html string) string {
39
40
return html
41
}
42
43
+var mdEscapeRegex = regexp.MustCompile("([\\\\`*_[\\]])")
44
+
45
+func EscapeMarkdown(text string) string {
46
+ text = mdEscapeRegex.ReplaceAllString(text, "\\$1")
47
+ text = strings.ReplaceAll(text, ">", ">")
48
+ text = strings.ReplaceAll(text, "<", "<")
49
+ return text
50
+}
51
52
func RenderMarkdownCustom(text string, renderer goldmark.Markdown) event.MessageEventContent {
53
var buf strings.Builder
54
err := renderer.Convert([]byte(text), &buf)
0 commit comments