aboutsummaryrefslogtreecommitdiff
path: root/matrix/matrix.go
diff options
context:
space:
mode:
Diffstat (limited to 'matrix/matrix.go')
-rw-r--r--matrix/matrix.go33
1 files changed, 11 insertions, 22 deletions
diff --git a/matrix/matrix.go b/matrix/matrix.go
index cb986ee..6d94e2e 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -40,7 +40,6 @@ import (
"maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/debug"
"maunium.net/go/gomuks/interface"
- "maunium.net/go/gomuks/lib/bfhtml"
"maunium.net/go/gomuks/matrix/pushrules"
"maunium.net/go/gomuks/matrix/rooms"
)
@@ -474,28 +473,18 @@ func (c *Container) SendMessage(roomID string, msgtype mautrix.MessageType, text
}
func (c *Container) renderMarkdown(text string) string {
- parser := blackfriday.New(
- blackfriday.WithExtensions(blackfriday.NoIntraEmphasis |
- blackfriday.Tables |
- blackfriday.FencedCode |
- blackfriday.Strikethrough |
- blackfriday.SpaceHeadings |
- blackfriday.DefinitionLists))
- ast := parser.Parse([]byte(text))
-
- renderer := bfhtml.HTMLRenderer{
- HTMLRenderer: blackfriday.NewHTMLRenderer(blackfriday.HTMLRendererParameters{
- Flags: blackfriday.UseXHTML,
- }),
- }
-
- var buf strings.Builder
- renderer.RenderHeader(&buf, ast)
- ast.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
- return renderer.RenderNode(&buf, node, entering)
+ renderer := blackfriday.NewHTMLRenderer(blackfriday.HTMLRendererParameters{
+ Flags: blackfriday.UseXHTML,
})
- renderer.RenderFooter(&buf, ast)
- return buf.String()
+
+ return strings.ReplaceAll(string(blackfriday.Run([]byte(text),
+ blackfriday.WithExtensions(blackfriday.NoIntraEmphasis|
+ blackfriday.Tables|
+ blackfriday.FencedCode|
+ blackfriday.Strikethrough|
+ blackfriday.SpaceHeadings|
+ blackfriday.DefinitionLists),
+ blackfriday.WithRenderer(renderer))), "\n", "")
}
var mentionRegex = regexp.MustCompile("\\[(.+?)]\\(https://matrix.to/#/@.+?:.+?\\)")