Change things
This commit is contained in:
@ -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/#/@.+?:.+?\\)")
|
||||
|
Reference in New Issue
Block a user