Move interfaces to maubot package and other stuff to app/

This commit is contained in:
Tulir Asokan 2018-06-14 11:11:24 +03:00
parent ef8fffaff8
commit 3a27831112
14 changed files with 329 additions and 198 deletions

View file

@ -19,9 +19,10 @@ package matrix
import (
"strings"
"gopkg.in/russross/blackfriday.v2"
"maubot.xyz"
)
func RenderMarkdown(text string) map[string]interface{} {
func RenderMarkdown(text string) maubot.Content {
parser := blackfriday.New(
blackfriday.WithExtensions(blackfriday.NoIntraEmphasis |
blackfriday.Tables |
@ -43,10 +44,10 @@ func RenderMarkdown(text string) map[string]interface{} {
renderer.RenderFooter(&buf, ast)
htmlBody := buf.String()
return map[string]interface{}{
"formatted_body": htmlBody,
"format": "org.matrix.custom.html",
"msgtype": "m.text",
"body": HTMLToText(htmlBody),
return maubot.Content{
FormattedBody: htmlBody,
Format: maubot.FormatHTML,
MsgType: maubot.MsgText,
Body: HTMLToText(htmlBody),
}
}